Go to the documentation of this file.
19 #ifndef SOUND_HANDLER_H
20 #define SOUND_HANDLER_H
46 class StreamingSoundData;
106 virtual void stop_all_sounds();
121 virtual int create_sound(std::unique_ptr<SimpleBuffer>
data,
132 virtual void stopEventSound(
int sound_handle);
136 virtual void stopAllEventSounds();
144 virtual void delete_sound(
int sound_handle);
177 bool allowMultiple,
unsigned int inPoint = 0,
178 unsigned int outPoint =
179 std::numeric_limits<unsigned int>::max());
186 bool isSoundPlaying(
int id)
const;
196 virtual void set_volume(
int sound_handle,
int volume);
202 virtual unsigned int get_duration(
int sound_handle)
const;
209 virtual unsigned int tell(
int sound_handle)
const;
219 virtual int get_volume(
int sound_handle)
const;
231 virtual void stopStreamingSound(
int handle);
248 size_t sampleCount,
int seekSamples,
int streamId);
287 int getStreamBlock(
int handle)
const;
313 virtual void reset();
324 bool is_muted()
const;
327 virtual void pause() { _paused=
true; }
416 virtual void fetchSamples(std::int16_t* to,
unsigned int nSamples);
443 virtual void mix(std::int16_t* outSamples, std::int16_t* inSamples,
444 unsigned int nSamples,
float volume);
451 void setAudioDump(
const std::string& wavefile);
456 bool streamingSound()
const;
476 virtual void plugInputStream(std::unique_ptr<InputStream> in);
479 virtual void unplugAllInputStreams();
482 bool hasInputStreams()
const;
487 virtual void delete_all_sounds();
492 size_t _soundsStarted;
495 size_t _soundsStopped;
501 std::atomic<bool> _muted;
506 typedef std::vector<EmbedSound*> Sounds;
513 typedef std::vector<StreamingSoundData*> StreamingSounds;
518 StreamingSounds _streamingSounds;
521 void stopEmbedSoundInstances(
EmbedSound& def);
526 typedef std::set<InputStream*> InputStreams;
531 InputStreams _inputStreams;
536 void unplugCompletedInputStreams();
538 std::unique_ptr<WAVWriter> _wavWriter;
547 #elif defined(SOUND_AHI)
550 #elif defined(SOUND_MKIT)
558 #endif // SOUND_HANDLER_H
WAV writer class.
Definition: WAVWriter.h:32
virtual unsigned int get_duration(int sound_handle) const
Gets the duration in milliseconds of an event sound.
Definition: sound_handler.cpp:421
virtual void stopStreamingSound(int handle)
Remove scheduled requests to play the specified sound buffer slot.
Definition: sound_handler.cpp:268
#define MIX_MAXVOLUME
Definition: sound_handler.cpp:77
void startSound(int id, int loops, const SoundEnvelopes *env, bool allowMultiple, unsigned int inPoint=0, unsigned int outPoint=std::numeric_limits< unsigned int >::max())
Start playback of an event sound.
Definition: sound_handler.cpp:517
void log_swferror(StringType msg, Args... args)
Definition: log.h:325
virtual void unplugAllInputStreams()
Unplug all input streams.
Definition: sound_handler.cpp:636
Definition of an embedded sound.
Definition: EmbedSound.h:50
@ T
Definition: GnashKey.h:132
virtual void unplugInputStream(InputStream *id)
Unplug an external InputStream from the mixer.
Definition: sound_handler.cpp:373
virtual void stopEventSound(int sound_handle)
Remove scheduled requests to play the specified sound buffer slot.
Definition: sound_handler.cpp:283
virtual void fetchSamples(std::int16_t *to, unsigned int nSamples)
Fetch mixed samples.
Definition: sound_handler.cpp:646
media::SoundInfo soundinfo
Object holding information about the sound.
Definition: EmbedSound.h:171
unsigned int(* aux_streamer_ptr)(void *udata, std::int16_t *samples, unsigned int nSamples, bool &eof)
Definition: AuxStream.h:31
void log_debug(StringType msg, Args... args)
Definition: log.h:301
bool streamingSound() const
Check if a streaming sound is playing.
Definition: sound_handler.cpp:719
@ i
Definition: GnashKey.h:155
#define LOG_ONCE(x)
Definition: log.h:49
void clearInstances()
Drop all active sounds.
Definition: StreamingSoundData.cpp:63
virtual void delete_sound(int sound_handle)
Discard the sound data for an embedded event sound.
Definition: sound_handler.cpp:198
void unmute()
Call this to unmute audio.
Definition: sound_handler.cpp:805
#define _(String)
Definition: log.h:44
bool isPlaying() const
Are there known playing instances of this sound ?
Definition: EmbedSound.cpp:97
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
virtual int get_volume(int sound_handle) const
Gets the volume for a given sound buffer slot.
Definition: sound_handler.cpp:241
bool isPaused() const
return true if audio is paused
Definition: sound_handler.h:333
@ m
Definition: GnashKey.h:159
@ s
Definition: GnashKey.h:165
void mute()
Call this to mute audio.
Definition: sound_handler.cpp:798
virtual int createStreamingSound(const media::SoundInfo &sinfo)
Streaming sound functions:
Definition: sound_handler.cpp:442
std::unique_ptr< EmbedSoundInst > createInstance(media::MediaHandler &mh, unsigned int inPoint, unsigned int outPoint, const SoundEnvelopes *envelopes, int loopCount)
Create an instance of this sound.
Definition: EmbedSound.cpp:60
sound_handler(media::MediaHandler *m)
Definition: sound_handler.h:460
void log_error(StringType msg, Args... args)
Definition: log.h:283
@ volume
Definition: klash_part.cpp:331
virtual void stopAllEventSounds()
Stop all instances of all playing event sounds.
Definition: sound_handler.cpp:306
#define IF_VERBOSE_MALFORMED_SWF(x)
Definition: log.h:404
size_t append(SimpleBuffer data, size_t sampleCount, int seekSamples)
Append a sound data block.
Definition: StreamingSoundData.cpp:38
VGPaint fill
Definition: testr_gtk.cpp:86
int getStreamBlock(int handle) const
Get the identifier for the block playing in a specific stream.
Definition: sound_handler.cpp:730
void setFinalVolume(int v)
Set the volume to apply to mixed output.
Definition: sound_handler.h:303
virtual void plugInputStream(std::unique_ptr< InputStream > in)
Plug an InputStream to the mixer.
Definition: sound_handler.cpp:613
virtual InputStream * attach_aux_streamer(aux_streamer_ptr ptr, void *udata)
Plug an external InputStream into the mixer.
Definition: sound_handler.cpp:820
bool hasInputStreams() const
Does the mixer have input streams ?
Definition: sound_handler.cpp:785
virtual int create_sound(std::unique_ptr< SimpleBuffer > data, const media::SoundInfo &sinfo)
Event sound functions:
Definition: sound_handler.cpp:455
virtual void reset()
Discard all sound inputs (slots and aux streamers) and clear scheduling.
Definition: sound_handler.cpp:812
bool is_muted() const
Returns whether or not sound is muted.
Definition: sound_handler.cpp:791
virtual void unpause()
gnash calls this to unpause audio
Definition: sound_handler.h:330
virtual void pause()
gnash calls this to pause audio
Definition: sound_handler.h:327
sound_handler * create_sound_handler_mkit(media::MediaHandler *m)
Definition: sound_handler_mkit.cpp:269
EmbedSoundInst * firstPlayingInstance() const
Return the first created instance of this sound.
Definition: EmbedSound.cpp:111
void getPlayingInstances(std::vector< InputStream * > &to) const
Append to the given vector all playing instances of this sound def.
Definition: StreamingSoundData.cpp:135
size_t swfToOutSamples(const media::SoundInfo &sinfo, size_t swfSamples, const size_t outRate=44100)
Convert SWF-specified number of samples to output number of samples.
Definition: SoundUtils.h:55
int getFinalVolume() const
Sound output functions.
Definition: sound_handler.h:297
virtual void mix(std::int16_t *outSamples, std::int16_t *inSamples, unsigned int nSamples, float volume)
Mix nSamples from inSamples to outSamples, with given volume.
Definition: sound_handler.cpp:841
size_t numSoundsStarted() const
Special test-fuction. Reports how many times a sound has been started.
Definition: sound_handler.h:388
virtual unsigned int tell(int sound_handle) const
Gets the playhead position in milliseconds of an event sound.
Definition: sound_handler.cpp:398
Sound mixer.
Definition: sound_handler.h:88
size_t numSoundsStopped() const
Special test-fuction. Reports how many times a sound has been stopped.
Definition: sound_handler.h:394
void setAudioDump(const std::string &wavefile)
Request to dump audio to the given filename.
Definition: sound_handler.cpp:701
pixel_iterator< T > end(GnashImage &im)
Definition: ImageIterators.h:198
unsigned long StreamBlockId
Identifier of a streaming sound block.
Definition: sound_handler.h:97
std::vector< SoundEnvelope > SoundEnvelopes
A vector of SoundEnvelope objects.
Definition: SoundEnvelope.h:60
@ c
Definition: GnashKey.h:149
sound_handler * create_sound_handler_aos4(media::MediaHandler *m)
Definition: sound_handler_ahi.cpp:259
virtual StreamBlockId addSoundBlock(SimpleBuffer data, size_t sampleCount, int seekSamples, int streamId)
Definition: sound_handler.cpp:147
#define DSOEXPORT
Definition: dsodefs.h:55
sound_handler * create_sound_handler_sdl(media::MediaHandler *m)
Definition: sound_handler_sdl.cpp:234
void playStream(int handle, StreamBlockId blockId)
Start playback of a streaming sound, if not playing already.
Definition: sound_handler.cpp:497
bool isSoundPlaying(int id) const
Check if an event sound is playing.
Definition: sound_handler.cpp:485
virtual media::SoundInfo * get_sound_info(int handle) const
Returns a SoundInfo object for the sound with the given id.
Definition: sound_handler.cpp:258
virtual ~sound_handler()
Definition: sound_handler.cpp:834
virtual void stop_all_sounds()
Mixed functions:
Definition: sound_handler.cpp:225
bool empty() const
Is the data buffer empty ?
Definition: EmbedSound.h:74
void log_unimpl(StringType msg, Args... args)
Definition: log.h:289
Instance of a defined sound (StreamingSoundData)
Definition: StreamingSound.h:49
virtual void set_volume(int sound_handle, int volume)
Sets the volume for a given event sound.
Definition: sound_handler.cpp:250
virtual void delete_all_sounds()
Stop and delete all sounds.
Definition: sound_handler.cpp:169
SimpleBuffer data
Definition: LocalConnection_as.cpp:151
@ e
Definition: GnashKey.h:151
A simple buffer of bytes.
Definition: SimpleBuffer.h:38
Definition: AuxStream.h:34
Definition of an embedded sound.
Definition: StreamingSoundData.h:48
#define ADJUST_VOLUME(s, v)
Definition: sound_handler.cpp:78