Gnash
0.8.10
|
Buffered AudioStreamer. More...
#include <NetStream_as.h>
Classes | |
class | CursoredBuffer |
A buffer with a cursor state. More... | |
Public Types | |
typedef boost::ptr_deque < CursoredBuffer > | AudioQueue |
Public Member Functions | |
BufferedAudioStreamer (sound::sound_handler *handler) | |
void | cleanAudioQueue () |
void | attachAuxStreamer () |
Attach the aux streamer. | |
void | detachAuxStreamer () |
Detach the aux streamer. | |
unsigned int | fetch (boost::int16_t *samples, unsigned int nSamples, bool &eof) |
Fetch samples from the audio queue. | |
void | push (CursoredBuffer *audio) |
Push a buffer to the audio queue. | |
Static Public Member Functions | |
static unsigned int | fetchWrapper (void *owner, boost::int16_t *samples, unsigned int nSamples, bool &eof) |
Fetch samples from the audio queue. | |
Public Attributes | |
sound::sound_handler * | _soundHandler |
AudioQueue | _audioQueue |
size_t | _audioQueueSize |
Number of bytes in the audio queue, protected by _audioQueueMutex. | |
boost::mutex | _audioQueueMutex |
sound::InputStream * | _auxStreamer |
Buffered AudioStreamer.
This class you create passing a sound handler, which will be used to implement attach/detach and eventually throw away buffers of sound when no sound handler is given.
Then you push samples to a buffer of it and can request attach/detach operations. When attached, the sound handler will fetch samples from the buffer, in a thread-safe way.
typedef boost::ptr_deque<CursoredBuffer> gnash::BufferedAudioStreamer::AudioQueue |
gnash::BufferedAudioStreamer::BufferedAudioStreamer | ( | sound::sound_handler * | handler | ) |
handler | Sound handler to use for attach/detach |
void gnash::BufferedAudioStreamer::attachAuxStreamer | ( | ) |
Attach the aux streamer.
On success, _auxStreamerAttached will be set to true. Won't attach again if already attached.
References _soundHandler, _auxStreamer, _, gnash::sound::sound_handler::unplugInputStream(), gnash::sound::sound_handler::attach_aux_streamer(), and fetchWrapper().
Referenced by gnash::NetStream_as::play().
void gnash::BufferedAudioStreamer::cleanAudioQueue | ( | ) |
References _audioQueueMutex, and _audioQueue.
Referenced by gnash::NetStream_as::~NetStream_as(), gnash::NetStream_as::close(), and gnash::NetStream_as::seek().
void gnash::BufferedAudioStreamer::detachAuxStreamer | ( | ) |
Detach the aux streamer.
_auxStreamerAttached will be set to true. Won't detach if not attached.
References _soundHandler, _auxStreamer, and gnash::sound::sound_handler::unplugInputStream().
Referenced by gnash::NetStream_as::~NetStream_as(), and gnash::NetStream_as::close().
unsigned int gnash::BufferedAudioStreamer::fetch | ( | boost::int16_t * | samples, |
unsigned int | nSamples, | ||
bool & | eof | ||
) |
Fetch samples from the audio queue.
References _audioQueueMutex, _audioQueue, assert, gnash::BufferedAudioStreamer::CursoredBuffer::m_size, gnash::key::n, gnash::BufferedAudioStreamer::CursoredBuffer::m_ptr, and _audioQueueSize.
Referenced by fetchWrapper().
unsigned int gnash::BufferedAudioStreamer::fetchWrapper | ( | void * | owner, |
boost::int16_t * | samples, | ||
unsigned int | nSamples, | ||
bool & | eof | ||
) | [static] |
void gnash::BufferedAudioStreamer::push | ( | CursoredBuffer * | audio | ) |
Push a buffer to the audio queue.
audio | Samples buffer, ownership transferred. |
References _audioQueueMutex, _auxStreamer, _audioQueue, _audioQueueSize, and gnash::BufferedAudioStreamer::CursoredBuffer::m_size.
This is where audio frames are pushed by ::advance and consumed by sound_handler callback (audio_streamer)
Referenced by gnash::NetStream_as::update(), fetch(), push(), and cleanAudioQueue().
boost::mutex gnash::BufferedAudioStreamer::_audioQueueMutex |
The queue needs to be protected as sound_handler callback is invoked by a separate thread (dunno if it makes sense actually)
Referenced by gnash::NetStream_as::update(), fetch(), push(), and cleanAudioQueue().
Referenced by attachAuxStreamer(), detachAuxStreamer(), and push().
Referenced by attachAuxStreamer(), and detachAuxStreamer().