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 <mutex>
27 #include <memory>
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  std::unique_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  std::mutex _mutex;
59 
60  // See dox in sound_handler.h
61  void mix(std::int16_t* outSamples, std::int16_t* inSamples,
62  unsigned int nSamples, float volume);
63 
64  void MixAudio (std::uint8_t *dst, const std::uint8_t *src, std::uint32_t len, int volume);
65 
66 public:
68 
70 
71  // See dox in sound_handler.h
72  virtual int create_sound(std::unique_ptr<SimpleBuffer> data, std::unique_ptr<media::SoundInfo> sinfo);
73 
74  // See dox in sound_handler.h
75  // overridden to serialize access to the data buffer slot
76  virtual StreamBlockId addSoundBlock(unsigned char* data,
77  unsigned int data_bytes,
78  unsigned int sample_count,
79  int streamId);
80 
81  // See dox in sound_handler.h
82  virtual void stop_sound(int sound_handle);
83 
84  // See dox in sound_handler.h
85  virtual void delete_sound(int sound_handle);
86 
87  // See dox in sound_handler.h
88  virtual void reset();
89 
90  // See dox in sound_handler.h
91  virtual void stop_all_sounds();
92 
93  // See dox in sound_handler.h
94  virtual int get_volume(int sound_handle);
95 
96  // See dox in sound_handler.h
97  virtual void set_volume(int sound_handle, int volume);
98 
99  // See dox in sound_handler.h
100  virtual media::SoundInfo* get_sound_info(int soundHandle);
101 
102  // See dox in sound_handler.h
103  // overridden to close audio card
104  virtual void pause();
105 
106  // See dox in sound_handler.h
107  // overridden to open audio card
108  virtual void unpause();
109 
110  // See dox in sound_handler.h
111  virtual unsigned int get_duration(int sound_handle);
112 
113  // See dox in sound_handler.h
114  virtual unsigned int tell(int sound_handle);
115 
116  // See dox in sound_handler.h
117  // Overridden to unpause SDL audio
118  void plugInputStream(std::unique_ptr<InputStream> in);
119 
120  // See dox in sound_handler.h
121  void fetchSamples(std::int16_t* to, unsigned int nSamples);
122 };
123 
124 } // gnash.sound namespace
125 } // namespace gnash
126 
127 #endif // SOUND_HANDLER_MKIT_H
Definition: klash_part.cpp:331
Class containing information about an embedded sound definition.
Definition: SoundInfo.h:34
void plugInputStream(std::unique_ptr< InputStream > in)
Plug an InputStream to the mixer.
Definition: sound_handler_mkit.cpp:296
virtual int create_sound(std::unique_ptr< SimpleBuffer > data, std::unique_ptr< media::SoundInfo > sinfo)
Definition: sound_handler_mkit.cpp:155
virtual void delete_sound(int sound_handle)
Discard the sound data for an embedded event sound.
Definition: sound_handler_mkit.cpp:181
virtual void set_volume(int sound_handle, int volume)
Sets the volume for a given event sound.
Definition: sound_handler_mkit.cpp:204
virtual void pause()
gnash calls this to pause audio
Definition: sound_handler_mkit.cpp:315
Sound mixer.
Definition: sound_handler.h:87
SimpleBuffer data
Definition: LocalConnection_as.cpp:151
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:325
virtual unsigned int tell(int sound_handle)
Definition: sound_handler_mkit.cpp:225
Mkit_sound_handler(media::MediaHandler *m)
Definition: sound_handler_mkit.cpp:49
Mkit media kit based sound_handler.
Definition: sound_handler_mkit.h:44
The MediaHandler class acts as a factory to provide parser and decoders.
Definition: MediaHandler.h:69
virtual void stop_all_sounds()
Mixed functions:
Definition: sound_handler_mkit.cpp:188
void fetchSamples(std::int16_t *to, unsigned int nSamples)
Fetch mixed samples.
Definition: sound_handler_mkit.cpp:119
virtual StreamBlockId addSoundBlock(unsigned char *data, unsigned int data_bytes, unsigned int sample_count, int streamId)
Definition: sound_handler_mkit.cpp:163
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:196
virtual void reset()
Discard all sound inputs (slots and aux streamers) and clear scheduling.
Definition: sound_handler_mkit.cpp:147
Definition: GnashKey.h:159
virtual void stop_sound(int sound_handle)
Definition: sound_handler_mkit.cpp:173
virtual media::SoundInfo * get_sound_info(int soundHandle)
Definition: sound_handler_mkit.cpp:211
virtual unsigned int get_duration(int sound_handle)
Definition: sound_handler_mkit.cpp:218
~Mkit_sound_handler()
Definition: sound_handler_mkit.cpp:78