Gnash
0.8.10
|
SDL-based sound_handler. More...
#include <sound_handler_sdl.h>
Public Member Functions | |
SDL_sound_handler (media::MediaHandler *m) | |
~SDL_sound_handler () | |
virtual int | createStreamingSound (const media::SoundInfo &sinfo) |
virtual int | create_sound (std::auto_ptr< SimpleBuffer > data, const media::SoundInfo &sinfo) |
Create a sound buffer slot, for on-demand playback. | |
virtual StreamBlockId | addSoundBlock (std::auto_ptr< SimpleBuffer > buf, size_t sample_count, int seekSamples, int streamId) |
virtual void | stopEventSound (int sound_handle) |
Remove scheduled requests to play the specified sound buffer slot. | |
virtual void | stopAllEventSounds () |
Stop all instances of all playing event sounds. | |
virtual void | stopStreamingSound (int sound_handle) |
Remove scheduled requests to play the specified sound buffer slot. | |
virtual void | delete_sound (int sound_handle) |
Discard the sound data for an embedded event sound. | |
virtual void | reset () |
Discard all sound inputs (slots and aux streamers) and clear scheduling. | |
virtual void | stop_all_sounds () |
Remove all scheduled request for playback of sound buffer slots. | |
virtual int | get_volume (int sound_handle) const |
Gets the volume for a given sound buffer slot. | |
virtual void | set_volume (int sound_handle, int volume) |
Sets the volume for a given event sound. | |
virtual media::SoundInfo * | get_sound_info (int soundHandle) const |
Returns a SoundInfo object for the sound with the given id. | |
virtual void | mute () |
Call this to mute audio. | |
virtual void | unmute () |
Call this to unmute audio. | |
virtual bool | is_muted () const |
Returns whether or not sound is muted. | |
virtual void | pause () |
gnash calls this to pause audio | |
virtual void | unpause () |
gnash calls this to unpause audio | |
virtual unsigned int | get_duration (int sound_handle) const |
Gets the duration in milliseconds of an event sound. | |
virtual unsigned int | tell (int sound_handle) const |
Gets the playhead position in milliseconds of an event sound. | |
void | plugInputStream (std::auto_ptr< InputStream > in) |
Plug an InputStream to the mixer. | |
void | unplugInputStream (InputStream *id) |
Unplug an external InputStream from the mixer. | |
void | fetchSamples (boost::int16_t *to, unsigned int nSamples) |
Fetch mixed samples. |
SDL-based sound_handler.
gnash::sound::SDL_sound_handler::SDL_sound_handler | ( | media::MediaHandler * | m | ) |
gnash::sound::SDL_sound_handler::~SDL_sound_handler | ( | ) |
sound_handler::StreamBlockId gnash::sound::SDL_sound_handler::addSoundBlock | ( | std::auto_ptr< SimpleBuffer > | data, |
size_t | sampleCount, | ||
int | seekSamples, | ||
int | streamId | ||
) | [virtual] |
Append data for a streaming sound.
Gnash's parser calls this to fill up soundstreams data.
data | The sound data to be stored. May not be null. This should be appropriately padded ( |
sampleCount | Number of samples in the data |
seekSamples | Offset of sound to frame data |
streamId | The soundhandlers id of the sound we want to add data to |
SoundException | on error |
Reimplemented from gnash::sound::sound_handler.
int gnash::sound::SDL_sound_handler::create_sound | ( | std::auto_ptr< SimpleBuffer > | data, |
const media::SoundInfo & | sinfo | ||
) | [virtual] |
Create a sound buffer slot, for on-demand playback.
Event sound functions:
data | The sound data to be stored. May not be null. This should be appropriately padded ( |
sinfo | A SoundInfo object containing info about samplerate, samplecount, stereo etc. |
Reimplemented from gnash::sound::sound_handler.
int gnash::sound::SDL_sound_handler::createStreamingSound | ( | const media::SoundInfo & | sinfo | ) | [virtual] |
Streaming sound functions:
Reimplemented from gnash::sound::sound_handler.
void gnash::sound::SDL_sound_handler::delete_sound | ( | int | sound_handle | ) | [virtual] |
Discard the sound data for an embedded event sound.
Only embedded event sounds are deleted; this happens when the associated sound_sample is deleted.
sound_handle | The id for the event sound to be deleted |
Reimplemented from gnash::sound::sound_handler.
void gnash::sound::SDL_sound_handler::fetchSamples | ( | boost::int16_t * | to, |
unsigned int | nSamples | ||
) | [virtual] |
Fetch mixed samples.
We run through all the plugged InputStreams fetching decoded audio blocks and mixing them into the given output stream.
to | The buffer to write mixed samples to. Buffer must be big enough to hold nSamples samples. |
nSamples | The amount of samples to fetch. NOTE: this number currently refers to "mono" samples due to some bad design decision. It is so expected that the user fetches 44100 * 2 samples which has to be interpreted as series of left,right channel couples. TODO: use actual number of samples so that it's expected to fetch 44100 per second and let expose a function to give interpretation of what comes back (how many bytes per channel, which format). |
Reimplemented from gnash::sound::sound_handler.
References gnash::sound::sound_handler::hasInputStreams().
unsigned int gnash::sound::SDL_sound_handler::get_duration | ( | int | sound_handle | ) | const [virtual] |
Gets the duration in milliseconds of an event sound.
sound_handle | The id of the event sound |
Reimplemented from gnash::sound::sound_handler.
media::SoundInfo * gnash::sound::SDL_sound_handler::get_sound_info | ( | int | handle | ) | const [virtual] |
Returns a SoundInfo object for the sound with the given id.
Note: This should only be used for streaming sounds. The SoundInfo object is still owned by the soundhandler.
soundHandle | The soundhandlers id of the sound we want some info about. |
Reimplemented from gnash::sound::sound_handler.
int gnash::sound::SDL_sound_handler::get_volume | ( | int | sound_handle | ) | const [virtual] |
Gets the volume for a given sound buffer slot.
Only use for event sounds!
sound_handle | The sound to get the volume for. |
Reimplemented from gnash::sound::sound_handler.
bool gnash::sound::SDL_sound_handler::is_muted | ( | ) | const [virtual] |
Returns whether or not sound is muted.
Reimplemented from gnash::sound::sound_handler.
void gnash::sound::SDL_sound_handler::mute | ( | ) | [virtual] |
Call this to mute audio.
Reimplemented from gnash::sound::sound_handler.
void gnash::sound::SDL_sound_handler::pause | ( | ) | [virtual] |
gnash calls this to pause audio
Reimplemented from gnash::sound::sound_handler.
void gnash::sound::SDL_sound_handler::plugInputStream | ( | std::auto_ptr< InputStream > | in | ) | [virtual] |
Plug an InputStream to the mixer.
in | The InputStream to plug, ownership transferred |
Reimplemented from gnash::sound::sound_handler.
void gnash::sound::SDL_sound_handler::reset | ( | ) | [virtual] |
Discard all sound inputs (slots and aux streamers) and clear scheduling.
Gnash calls this on movie restart.
The function should stop all sounds and get ready for a "parse from scratch" operation.
Reimplemented from gnash::sound::sound_handler.
References stop_all_sounds().
void gnash::sound::SDL_sound_handler::set_volume | ( | int | sound_handle, |
int | volume | ||
) | [virtual] |
Sets the volume for a given event sound.
Only used by the AS Sound class
sound_handle | The handle of the event sound to set volume for. |
volume | A number from 0 to 100 representing a volume level. 100 is full volume and 0 is no volume. The default setting is 100. |
Reimplemented from gnash::sound::sound_handler.
void gnash::sound::SDL_sound_handler::stop_all_sounds | ( | ) | [virtual] |
Remove all scheduled request for playback of sound buffer slots.
Mixed functions: This applies both to streaming and event sounds.
Reimplemented from gnash::sound::sound_handler.
Referenced by reset().
void gnash::sound::SDL_sound_handler::stopAllEventSounds | ( | ) | [virtual] |
Stop all instances of all playing event sounds.
Reimplemented from gnash::sound::sound_handler.
void gnash::sound::SDL_sound_handler::stopEventSound | ( | int | sound_handle | ) | [virtual] |
Remove scheduled requests to play the specified sound buffer slot.
Stop all instances of the specified event sound if it's playing. (Normally a full-featured sound API would take a handle specifying the *instance* of a playing sample, but SWF is not expressive that way.)
sound_handle | id for the sound to be stopped |
Reimplemented from gnash::sound::sound_handler.
void gnash::sound::SDL_sound_handler::stopStreamingSound | ( | int | handle | ) | [virtual] |
Remove scheduled requests to play the specified sound buffer slot.
sound_handle | The sound_handlers id for the sound to be stopped. |
Reimplemented from gnash::sound::sound_handler.
unsigned int gnash::sound::SDL_sound_handler::tell | ( | int | sound_handle | ) | const [virtual] |
Gets the playhead position in milliseconds of an event sound.
sound_handle | The id of the event sound |
Reimplemented from gnash::sound::sound_handler.
void gnash::sound::SDL_sound_handler::unmute | ( | ) | [virtual] |
Call this to unmute audio.
Reimplemented from gnash::sound::sound_handler.
void gnash::sound::SDL_sound_handler::unpause | ( | ) | [virtual] |
gnash calls this to unpause audio
Reimplemented from gnash::sound::sound_handler.
References gnash::sound::sound_handler::hasInputStreams().
void gnash::sound::SDL_sound_handler::unplugInputStream | ( | InputStream * | id | ) | [virtual] |
Unplug an external InputStream from the mixer.
This is called by AS classes NetStream or Sound to dettach callback, so that audio from the classes no longer will be played through the soundhandler.
id | The key identifying the auxiliary streamer, as returned by attach_aux_streamer. |
Reimplemented from gnash::sound::sound_handler.