Gnash  0.8.11dev
sound_handler_mkit.h
Go to the documentation of this file.
1 // sound_handler_haiku.h: Sound handling using Mkit media kit
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 #ifndef SOUND_HANDLER_MKIT_H
21 #define SOUND_HANDLER_MKIT_H
22 
23 #include "sound_handler.h" // for inheritance
24 
25 #include <set> // for composition (InputStreams)
26 #include <boost/thread/mutex.hpp>
27 #include <boost/scoped_ptr.hpp>
28 
29 #include <SoundPlayer.h>
30 
31 // Forward declarations
32 namespace gnash {
33  class SimpleBuffer;
34  namespace sound {
35  class EmbedSound;
36  class InputStream;
37  }
38 }
39 
40 namespace gnash {
41 namespace sound {
42 
45 {
46  boost::scoped_ptr<BSoundPlayer> _soundplayer;
47 
49  static void FillNextBuffer(void *cookie, void *buffer, size_t size,
50  const media_raw_audio_format &format);
51 
53  void openAudio();
54 
55  bool _audioopen;
56 
58  boost::mutex _mutex;
59 
61  mutable boost::mutex _mutedMutex;
62 
63  // See dox in sound_handler.h
64  void mix(boost::int16_t* outSamples, boost::int16_t* inSamples,
65  unsigned int nSamples, float volume);
66 
67  void MixAudio (boost::uint8_t *dst, const boost::uint8_t *src, boost::uint32_t len, int volume);
68 
69 public:
71 
73 
74  // See dox in sound_handler.h
75  virtual int create_sound(std::auto_ptr<SimpleBuffer> data, std::auto_ptr<media::SoundInfo> sinfo);
76 
77  // See dox in sound_handler.h
78  // overridden to serialize access to the data buffer slot
79  virtual StreamBlockId addSoundBlock(unsigned char* data,
80  unsigned int data_bytes,
81  unsigned int sample_count,
82  int streamId);
83 
84  // See dox in sound_handler.h
85  virtual void stop_sound(int sound_handle);
86 
87  // See dox in sound_handler.h
88  virtual void delete_sound(int sound_handle);
89 
90  // See dox in sound_handler.h
91  virtual void reset();
92 
93  // See dox in sound_handler.h
94  virtual void stop_all_sounds();
95 
96  // See dox in sound_handler.h
97  virtual int get_volume(int sound_handle);
98 
99  // See dox in sound_handler.h
100  virtual void set_volume(int sound_handle, int volume);
101 
102  // See dox in sound_handler.h
103  virtual media::SoundInfo* get_sound_info(int soundHandle);
104 
105  // See dox in sound_handler.h
106  // overridden to serialize access to the _muted member
107  virtual void mute();
108 
109  // See dox in sound_handler.h
110  // overridden to serialize access to the _muted member
111  virtual void unmute();
112 
113  // See dox in sound_handler.h
114  // overridden to serialize access to the _muted member
115  virtual bool is_muted() const;
116 
117  // See dox in sound_handler.h
118  // overridden to close audio card
119  virtual void pause();
120 
121  // See dox in sound_handler.h
122  // overridden to open audio card
123  virtual void unpause();
124 
125  // See dox in sound_handler.h
126  virtual unsigned int get_duration(int sound_handle);
127 
128  // See dox in sound_handler.h
129  virtual unsigned int tell(int sound_handle);
130 
131  // See dox in sound_handler.h
132  // Overridden to unpause SDL audio
133  void plugInputStream(std::auto_ptr<InputStream> in);
134 
135  // See dox in sound_handler.h
136  void fetchSamples(boost::int16_t* to, unsigned int nSamples);
137 };
138 
139 } // gnash.sound namespace
140 } // namespace gnash
141 
142 #endif // SOUND_HANDLER_MKIT_H
Definition: klash_part.cpp:331
Class containing information about an embedded sound definition.
Definition: SoundInfo.h:34
virtual void delete_sound(int sound_handle)
Discard the sound data for an embedded event sound.
Definition: sound_handler_mkit.cpp:182
virtual void set_volume(int sound_handle, int volume)
Sets the volume for a given event sound.
Definition: sound_handler_mkit.cpp:205
virtual void pause()
gnash calls this to pause audio
Definition: sound_handler_mkit.cpp:337
virtual void unmute()
Call this to unmute audio.
Definition: sound_handler_mkit.cpp:323
Sound mixer.
Definition: sound_handler.h:87
SimpleBuffer data
Definition: LocalConnection_as.cpp:153
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
virtual void unpause()
gnash calls this to unpause audio
Definition: sound_handler_mkit.cpp:347
virtual unsigned int tell(int sound_handle)
Definition: sound_handler_mkit.cpp:226
Mkit_sound_handler(media::MediaHandler *m)
Definition: sound_handler_mkit.cpp:50
Mkit media kit based sound_handler.
Definition: sound_handler_mkit.h:44
void fetchSamples(boost::int16_t *to, unsigned int nSamples)
Fetch mixed samples.
Definition: sound_handler_mkit.cpp:120
The MediaHandler class acts as a factory to provide parser and decoders.
Definition: MediaHandler.h:68
virtual void stop_all_sounds()
Mixed functions:
Definition: sound_handler_mkit.cpp:189
virtual void mute()
Call this to mute audio.
Definition: sound_handler_mkit.cpp:316
virtual StreamBlockId addSoundBlock(unsigned char *data, unsigned int data_bytes, unsigned int sample_count, int streamId)
Definition: sound_handler_mkit.cpp:164
unsigned long StreamBlockId
Identifier of a streaming sound block.
Definition: sound_handler.h:97
virtual int get_volume(int sound_handle)
Definition: sound_handler_mkit.cpp:197
virtual void reset()
Discard all sound inputs (slots and aux streamers) and clear scheduling.
Definition: sound_handler_mkit.cpp:148
Definition: GnashKey.h:159
void plugInputStream(std::auto_ptr< InputStream > in)
Plug an InputStream to the mixer.
Definition: sound_handler_mkit.cpp:297
virtual bool is_muted() const
Returns whether or not sound is muted.
Definition: sound_handler_mkit.cpp:330
virtual void stop_sound(int sound_handle)
Definition: sound_handler_mkit.cpp:174
virtual media::SoundInfo * get_sound_info(int soundHandle)
Definition: sound_handler_mkit.cpp:212
virtual unsigned int get_duration(int sound_handle)
Definition: sound_handler_mkit.cpp:219
~Mkit_sound_handler()
Definition: sound_handler_mkit.cpp:79
virtual int create_sound(std::auto_ptr< SimpleBuffer > data, std::auto_ptr< media::SoundInfo > sinfo)
Definition: sound_handler_mkit.cpp:156