Public Member Functions

gnash::sound::AOS4_sound_handler Class Reference

AHI-based sound_handler. More...

#include <sound_handler_ahi.h>

Inheritance diagram for gnash::sound::AOS4_sound_handler:
Inheritance graph
[legend]
Collaboration diagram for gnash::sound::AOS4_sound_handler:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 AOS4_sound_handler (media::MediaHandler *m)
 AOS4_sound_handler (media::MediaHandler *m, const std::string &wave_file)
 ~AOS4_sound_handler ()
virtual int create_sound (std::auto_ptr< SimpleBuffer > data, std::auto_ptr< media::SoundInfo > sinfo)
 Create a sound buffer slot, for on-demand playback.
virtual StreamBlockId addSoundBlock (unsigned char *data, unsigned int data_bytes, unsigned int sample_count, int streamId)
 Append data to an existing sound buffer slot.
virtual void stop_sound (int sound_handle)
 Remove scheduled requests to play the specified sound buffer slot.
virtual void delete_sound (int sound_handle)
 Discard a sound buffer slot.
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)
 Gets the volume for a given sound buffer slot.
virtual void set_volume (int sound_handle, int volume)
 Sets the volume for a given sound buffer slot.
virtual media::SoundInfoget_sound_info (int soundHandle)
 Returns a pointer to the 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)
 Gets the duration in milliseconds of an event sound connected to an AS Sound obejct.
virtual unsigned int tell (int sound_handle)
 Gets the playhead position in milliseconds of an event sound connected to an AS Sound obejct.
void plugInputStream (std::auto_ptr< InputStream > in)
 Plug an InputStream to the mixer.
void fetchSamples (boost::int16_t *to, unsigned int nSamples)
 Fetch mixed samples.
int audioTask ()

Detailed Description

AHI-based sound_handler.


Constructor & Destructor Documentation

gnash::sound::AOS4_sound_handler::AOS4_sound_handler ( media::MediaHandler m  ) 
gnash::sound::AOS4_sound_handler::AOS4_sound_handler ( media::MediaHandler m,
const std::string &  wave_file 
)
gnash::sound::AOS4_sound_handler::~AOS4_sound_handler (  ) 

Member Function Documentation

sound_handler::StreamBlockId gnash::sound::AOS4_sound_handler::addSoundBlock ( unsigned char *  data,
unsigned int  dataBytes,
unsigned int  sampleCount,
int  streamId 
) [virtual]

Append data to an existing sound buffer slot.

Gnash's parser calls this to fill up soundstreams data. TODO: the current code uses memory reallocation to grow the sound, which is suboptimal; instead, we should maintain sound sources as a list of buffers, to avoid reallocations.

Parameters:
data The sound data to be saved, allocated by new[]. Ownership is transferred. TODO: use SimpleBuffer ?
dataBytes Size of the data in bytes
sampleCount Number of samples in the data
streamId The soundhandlers id of the sound we want to add data to
Returns:
an identifier for the new block for use in playSound
Exceptions:
SoundException on error

Reimplemented from gnash::sound::sound_handler.

int gnash::sound::AOS4_sound_handler::audioTask (  ) 
int gnash::sound::AOS4_sound_handler::create_sound ( std::auto_ptr< SimpleBuffer data,
std::auto_ptr< media::SoundInfo sinfo 
) [virtual]

Create a sound buffer slot, for on-demand playback.

Parameters:
data The data to be stored. For soundstream this is NULL. The data is in encoded format, with format specified with the sinfo parameter, this is to allow on-demand decoding (if the sound is never played, it's never decoded).
sinfo A SoundInfo object contained in an auto_ptr, which contains info about samplerate, samplecount, stereo and more. The SoundObject must be not-NULL!
Returns:
the id given by the soundhandler for later identification.

Reimplemented from gnash::sound::sound_handler.

void gnash::sound::AOS4_sound_handler::delete_sound ( int  sound_handle  )  [virtual]

Discard a sound buffer slot.

Parameters:
sound_handle The sound_handlers id for the sound to be deleted

Reimplemented from gnash::sound::sound_handler.

void gnash::sound::AOS4_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.

Parameters:
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(), and pause().

Referenced by audioTask().

unsigned int gnash::sound::AOS4_sound_handler::get_duration ( int  sound_handle  )  [virtual]

Gets the duration in milliseconds of an event sound connected to an AS Sound obejct.

Parameters:
sound_handle The id of the event sound
Returns:
the duration of the sound in milliseconds

Reimplemented from gnash::sound::sound_handler.

media::SoundInfo * gnash::sound::AOS4_sound_handler::get_sound_info ( int  soundHandle  )  [virtual]

Returns a pointer to the SoundInfo object for the sound with the given id.

The SoundInfo object is still owned by the soundhandler.

Parameters:
soundHandle The soundhandlers id of the sound we want some info about.
Returns:
a pointer to the SoundInfo object for the sound with the given id.

Reimplemented from gnash::sound::sound_handler.

int gnash::sound::AOS4_sound_handler::get_volume ( int  sound_handle  )  [virtual]

Gets the volume for a given sound buffer slot.

Only used by the AS Sound class

Parameters:
sound_handle The sound_handlers id for the sound to be deleted
Returns:
the sound volume level as an integer from 0 to 100, where 0 is off and 100 is full volume. The default setting is 100.

Reimplemented from gnash::sound::sound_handler.

bool gnash::sound::AOS4_sound_handler::is_muted (  )  const [virtual]

Returns whether or not sound is muted.

Returns:
true if muted, false if not

Reimplemented from gnash::sound::sound_handler.

void gnash::sound::AOS4_sound_handler::mute (  )  [virtual]

Call this to mute audio.

Reimplemented from gnash::sound::sound_handler.

void gnash::sound::AOS4_sound_handler::pause (  )  [virtual]

gnash calls this to pause audio

Reimplemented from gnash::sound::sound_handler.

References _.

Referenced by fetchSamples(), and ~AOS4_sound_handler().

void gnash::sound::AOS4_sound_handler::plugInputStream ( std::auto_ptr< InputStream in  )  [virtual]

Plug an InputStream to the mixer.

Parameters:
in The InputStream to plug, ownership transferred

Reimplemented from gnash::sound::sound_handler.

References unpause().

void gnash::sound::AOS4_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 gnash::sound::sound_handler::delete_all_sounds(), and stop_all_sounds().

void gnash::sound::AOS4_sound_handler::set_volume ( int  sound_handle,
int  volume 
) [virtual]

Sets the volume for a given sound buffer slot.

Only used by the AS Sound class

Parameters:
sound_handle The sound_handlers id for the sound to be deleted
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::AOS4_sound_handler::stop_all_sounds (  )  [virtual]

Remove all scheduled request for playback of sound buffer slots.

Reimplemented from gnash::sound::sound_handler.

Referenced by reset().

void gnash::sound::AOS4_sound_handler::stop_sound ( int  sound_handle  )  [virtual]

Remove scheduled requests to play the specified sound buffer slot.

Stop the specified 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.)

Parameters:
sound_handle The sound_handlers id for the sound to be deleted

Reimplemented from gnash::sound::sound_handler.

unsigned int gnash::sound::AOS4_sound_handler::tell ( int  sound_handle  )  [virtual]

Gets the playhead position in milliseconds of an event sound connected to an AS Sound obejct.

Parameters:
sound_handle The id of the event sound
Returns:
the duration of the sound in milliseconds

Reimplemented from gnash::sound::sound_handler.

void gnash::sound::AOS4_sound_handler::unmute (  )  [virtual]

Call this to unmute audio.

Reimplemented from gnash::sound::sound_handler.

void gnash::sound::AOS4_sound_handler::unpause (  )  [virtual]

gnash calls this to unpause audio

Reimplemented from gnash::sound::sound_handler.

References _, and gnash::sound::sound_handler::hasInputStreams().

Referenced by plugInputStream().


The documentation for this class was generated from the following files: