Gnash  0.8.11dev
Public Types | Public Member Functions | Public Attributes | List of all members
gnash::sound::EmbedSound Class Reference

Definition of an embedded sound. More...

#include <EmbedSound.h>

Public Types

typedef std::list< EmbedSoundInst * > Instances
 Vector containing the active instances of this sounds being played. More...
 

Public Member Functions

 EmbedSound (std::unique_ptr< SimpleBuffer > data, media::SoundInfo info, int volume)
 Construct a sound with given data, info and volume. More...
 
 ~EmbedSound ()
 
size_t size () const
 Return size of the data buffer. More...
 
bool empty () const
 Is the data buffer empty ? More...
 
const std::uint8_t * data () const
 Return a pointer to the underlying buffer. More...
 
const std::uint8_t * data (size_t pos) const
 Return a pointer to an offset in the underlying buffer. More...
 
bool isPlaying () const
 Are there known playing instances of this sound ? More...
 
size_t numPlayingInstances () const
 Return number of playing instances of this sound. More...
 
void getPlayingInstances (std::vector< InputStream *> &to) const
 Append to the given vector all playing instances of this sound def. More...
 
EmbedSoundInstfirstPlayingInstance () const
 Return the first created instance of this sound. More...
 
std::unique_ptr< EmbedSoundInstcreateInstance (media::MediaHandler &mh, unsigned int inPoint, unsigned int outPoint, const SoundEnvelopes *envelopes, int loopCount)
 Create an instance of this sound. More...
 
void clearInstances ()
 Drop all active sounds. More...
 
Instances::iterator eraseActiveSound (Instances::iterator i)
 Drop an active sound (by iterator) More...
 
void eraseActiveSound (EmbedSoundInst *inst)
 Drop an active sound (by pointer) More...
 

Public Attributes

media::SoundInfo soundinfo
 Object holding information about the sound. More...
 
int volume
 

Detailed Description

Definition of an embedded sound.

Member Typedef Documentation

§ Instances

Vector containing the active instances of this sounds being played.

NOTE: This class does NOT own the active sounds

Constructor & Destructor Documentation

§ EmbedSound()

gnash::sound::EmbedSound::EmbedSound ( std::unique_ptr< SimpleBuffer data,
media::SoundInfo  info,
int  volume 
)

Construct a sound with given data, info and volume.

Parameters
dataThe encoded sound data.
infoencoding info
volumeinitial volume (0..100). Optional, defaults to 100.

§ ~EmbedSound()

gnash::sound::EmbedSound::~EmbedSound ( )

References clearInstances().

Member Function Documentation

§ clearInstances()

void gnash::sound::EmbedSound::clearInstances ( )

Drop all active sounds.

Locks _soundInstancesMutex

Referenced by gnash::sound::sound_handler::stopAllEventSounds(), and ~EmbedSound().

§ createInstance()

std::unique_ptr< EmbedSoundInst > gnash::sound::EmbedSound::createInstance ( media::MediaHandler mh,
unsigned int  inPoint,
unsigned int  outPoint,
const SoundEnvelopes envelopes,
int  loopCount 
)

Create an instance of this sound.

The returned instance ownership is transferred

Parameters
mhThe MediaHandler to use for on-demand decoding
inPointOffset in output samples this instance should start playing from. These are post-resampling samples from the start of the specified blockId.
outPointOffset in output samples this instance should stop playing at. These are post-resampling samples from the start of the specified blockId.
envelopesSoundEnvelopes to apply to this sound. May be 0 for none.
loopCountNumber of times this instance should loop over the defined sound.
Todo:
document if every loop starts at secsOffset ! Locks the _soundInstancesMutex when pushing to it

Referenced by gnash::sound::sound_handler::startSound().

§ data() [1/2]

const std::uint8_t* gnash::sound::EmbedSound::data ( ) const
inline

Return a pointer to the underlying buffer.

Referenced by gnash::sound::EmbedSoundInst::EmbedSoundInst().

§ data() [2/2]

const std::uint8_t* gnash::sound::EmbedSound::data ( size_t  pos) const
inline

Return a pointer to an offset in the underlying buffer.

Parameters
posThe offset value. An assertion will fail if pos > size()

§ empty()

bool gnash::sound::EmbedSound::empty ( ) const
inline

Is the data buffer empty ?

Referenced by gnash::sound::sound_handler::startSound().

§ eraseActiveSound() [1/2]

EmbedSound::Instances::iterator gnash::sound::EmbedSound::eraseActiveSound ( Instances::iterator  i)

Drop an active sound (by iterator)

Does NOT lock the _soundInstancesMutex

Returns
iterator after the one being erased

Referenced by eraseActiveSound(), and gnash::sound::EmbedSoundInst::~EmbedSoundInst().

§ eraseActiveSound() [2/2]

void gnash::sound::EmbedSound::eraseActiveSound ( EmbedSoundInst inst)

Drop an active sound (by pointer)

Parameters
instThe active sound instance to unregister

This is intended to be called by EmbedSoundInst destructor, which may be called by a separate thread so MUST be thread-safe

Does lock the _soundInstancesMutex

Todo:
make private and mark EmbedSoundInst as friend ?

References eraseActiveSound(), and gnash::log_error().

§ firstPlayingInstance()

EmbedSoundInst * gnash::sound::EmbedSound::firstPlayingInstance ( ) const

Return the first created instance of this sound.

Locks _soundInstancesMutex

Referenced by gnash::sound::sound_handler::tell().

§ getPlayingInstances()

void gnash::sound::EmbedSound::getPlayingInstances ( std::vector< InputStream *> &  to) const

Append to the given vector all playing instances of this sound def.

Referenced by gnash::sound::sound_handler::stopAllEventSounds().

§ isPlaying()

bool gnash::sound::EmbedSound::isPlaying ( ) const

Are there known playing instances of this sound ?

Locks _soundInstancesMutex

Referenced by gnash::sound::sound_handler::isSoundPlaying(), gnash::sound::sound_handler::startSound(), and gnash::sound::sound_handler::tell().

§ numPlayingInstances()

size_t gnash::sound::EmbedSound::numPlayingInstances ( ) const

Return number of playing instances of this sound.

Locks _soundInstancesMutex

§ size()

size_t gnash::sound::EmbedSound::size ( ) const
inline

Return size of the data buffer.

Referenced by gnash::sound::EmbedSoundInst::EmbedSoundInst().

Member Data Documentation

§ soundinfo

media::SoundInfo gnash::sound::EmbedSound::soundinfo

Object holding information about the sound.

Referenced by gnash::sound::sound_handler::get_duration(), and gnash::sound::sound_handler::startSound().

§ volume

int gnash::sound::EmbedSound::volume

Volume for AS-sounds, range: 0-100. It's the SWF range that is represented here.

Referenced by gnash::sound::EmbedSoundInst::EmbedSoundInst().


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