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 public:
62 
64 
65  // See dox in sound_handler.h
66  virtual int create_sound(std::unique_ptr<SimpleBuffer> data, std::unique_ptr<media::SoundInfo> sinfo);
67 
68  // See dox in sound_handler.h
69  // overridden to serialize access to the data buffer slot
70  virtual StreamBlockId addSoundBlock(unsigned char* data,
71  unsigned int data_bytes,
72  unsigned int sample_count,
73  int streamId);
74 
75  // See dox in sound_handler.h
76  virtual void stop_sound(int sound_handle);
77 
78  // See dox in sound_handler.h
79  virtual void delete_sound(int sound_handle);
80 
81  // See dox in sound_handler.h
82  virtual void reset();
83 
84  // See dox in sound_handler.h
85  virtual void stop_all_sounds();
86 
87  // See dox in sound_handler.h
88  virtual int get_volume(int sound_handle);
89 
90  // See dox in sound_handler.h
91  virtual void set_volume(int sound_handle, int volume);
92 
93  // See dox in sound_handler.h
94  virtual media::SoundInfo* get_sound_info(int soundHandle);
95 
96  // See dox in sound_handler.h
97  // overridden to close audio card
98  virtual void pause();
99 
100  // See dox in sound_handler.h
101  // overridden to open audio card
102  virtual void unpause();
103 
104  // See dox in sound_handler.h
105  virtual unsigned int get_duration(int sound_handle);
106 
107  // See dox in sound_handler.h
108  virtual unsigned int tell(int sound_handle);
109 
110  // See dox in sound_handler.h
111  // Overridden to unpause SDL audio
112  void plugInputStream(std::unique_ptr<InputStream> in);
113 
114  // See dox in sound_handler.h
115  void fetchSamples(std::int16_t* to, unsigned int nSamples);
116 };
117 
118 } // gnash.sound namespace
119 } // namespace gnash
120 
121 #endif // SOUND_HANDLER_MKIT_H
Definition: klash_part.cpp:331
Class containing information about an embedded sound definition.
Definition: SoundInfo.h:34
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
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
unsigned long StreamBlockId
Identifier of a streaming sound block.
Definition: sound_handler.h:97
Definition: GnashKey.h:159