AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
#include <AndroidSLESMediaQueue.h>
Public Types | |
enum | QueueEvent { QueueEvent::ERROR, QueueEvent::FINISHED_READING, QueueEvent::FINISHED_PLAYING } |
Represent the event types that will be sent to the StatusCallback when the queue change state. More... | |
using | Byte = DecoderInterface::Byte |
using | EventCallback = std::function< void(QueueEvent event, const std::string &reason)> |
Public Member Functions | |
void | onBufferFree () |
~AndroidSLESMediaQueue () | |
size_t | getNumBytesBuffered () const |
size_t | getNumBytesPlayed () const |
Static Public Member Functions | |
static std::unique_ptr< AndroidSLESMediaQueue > | create (std::shared_ptr< applicationUtilities::androidUtilities::AndroidSLESObject > queueObject, std::unique_ptr< DecoderInterface > decoder, EventCallback onStatusChanged, const PlaybackConfiguration &playbackConfiguration) |
Static Public Attributes | |
static constexpr size_t | NUMBER_OF_BUFFERS {4u} |
The number of buffers to use. More... | |
static constexpr size_t | BUFFER_SIZE {131072u} |
Buffer size for the decoded data. This has to be big enough to be used with the decoder. More... | |
Class responsible for reading raw audio from a decoder and feeding it to the underlying media player queue.
For that, the AndroidSLESMediaQueue
has a parallel job that: 1- Fill its unused buffers with raw audio by calling the decoder read
function. 2- Enqueue the buffers into the OpenSL ES media player queue. 3- Wait until the media queue finishes playing one of the buffers. 4- Once the media player is done with a buffer, it calls onBufferFree
. 5- The AndroidSLESMediaQueue
mark the buffer as unused and go back to 1.
using alexaClientSDK::mediaPlayer::android::AndroidSLESMediaQueue::EventCallback = std::function<void(QueueEvent event, const std::string& reason)> |
Callback method signature called by the AndroidSLESMediaQueue
when there is a queue event.
event | The event that has occurred. |
reason | A description of what triggered the error. It can be an empty string depending on the event triggered. |
Represent the event types that will be sent to the StatusCallback
when the queue change state.
alexaClientSDK::mediaPlayer::android::AndroidSLESMediaQueue::~AndroidSLESMediaQueue | ( | ) |
Destructor.
|
static |
Creates a new AndroidSLESMediaQueue
object.
queueObject | The AndroidSLESObject that represent the OpenSL ES queue. |
decoder | The decoder object used to get raw audio. |
onStatusChanged | A function object that should point to a valid callback function called whenever the queue state changes. |
playbackConfiguration | The playback configuration parameters. |
nullptr
. size_t alexaClientSDK::mediaPlayer::android::AndroidSLESMediaQueue::getNumBytesBuffered | ( | ) | const |
Get number of bytes that is currently queued.
size_t alexaClientSDK::mediaPlayer::android::AndroidSLESMediaQueue::getNumBytesPlayed | ( | ) | const |
Get number of bytes that has been played so far since this object was created.
void alexaClientSDK::mediaPlayer::android::AndroidSLESMediaQueue::onBufferFree | ( | ) |
The callback function to be called when the media player is no longer reading from a buffer.
|
static |
Buffer size for the decoded data. This has to be big enough to be used with the decoder.
|
static |
The number of buffers to use.
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0