Gnash  0.8.11dev
sound_handler_ahi.h
Go to the documentation of this file.
1 // sound_handler_ahi.h: Sound handling using standard AHI
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_AHI_H
21 #define SOUND_HANDLER_AHI_H
22 
23 #include "sound_handler.h" // for inheritance
24 
25 #include <set> // for composition (InputStreams)
26 #include <mutex>
27 
28 #include <proto/dos.h>
29 #include <proto/exec.h>
30 #include <proto/ahi.h>
31 
32 #include <devices/ahi.h>
33 #include <exec/memory.h>
34 
35 #include <sys/types.h>
36 // Forward declarations
37 namespace gnash {
38  class SimpleBuffer;
39  namespace sound {
40  class EmbedSound;
41  class InputStream;
42  }
43 }
44 
45 namespace gnash {
46 namespace sound {
47 
50 {
51 private:
52  struct MsgPort *_port;
53  uint32 _timerSig;
54  struct TimeRequest *_timerio;
55  struct TimerIFace *ITimer;
56 
57  struct AHIIFace *IAHI;
58  struct Library *AHIBase;
59  struct MsgPort *AHImp; //AHI Message Port
60  struct AHIRequest *AHIio;
61  BYTE AHIDevice;
62  struct AHIRequest *AHIios[2];
63  APTR AHIiocopy;
64  ULONG AHICurBuf;
65  bool AHIReqSent[2];
66  UBYTE *PlayBuffer[2];
67  ULONG BufferFill;
68  UBYTE *BufferPointer;
69  ULONG Buffer;
70 
71  struct Process *AudioPump;
72 
73  bool TimerInit(void);
74  void TimerExit(void);
75  void TimerReset(uint32 microDelay);
76 
78  void initAudio();
79  void openAudio();
80  void closeAudio();
81 
82  bool _audioOpened;
83  bool _closing;
84 
85  struct DeathMessage *_dmsg; // the child Death Message
86  struct MsgPort *_DMreplyport; // and its port
87 
89  std::mutex _mutex;
90 
91  // See dox in sound_handler.h
92  void mix(std::int16_t* outSamples, std::int16_t* inSamples,
93  unsigned int nSamples, float volume);
94 
95 public:
96 
98 
100 
101  // See dox in sound_handler.h
102  virtual int create_sound(std::unique_ptr<SimpleBuffer> data, std::unique_ptr<media::SoundInfo> sinfo);
103 
104  // See dox in sound_handler.h
105  // overridden to serialize access to the data buffer slot
106  virtual StreamBlockId addSoundBlock(unsigned char* data,
107  unsigned int data_bytes,
108  unsigned int sample_count,
109  int streamId);
110 
111  // See dox in sound_handler.h
112  virtual void stop_sound(int sound_handle);
113 
114  // See dox in sound_handler.h
115  virtual void delete_sound(int sound_handle);
116 
117  // See dox in sound_handler.h
118  virtual void reset();
119 
120  // See dox in sound_handler.h
121  virtual void stop_all_sounds();
122 
123  // See dox in sound_handler.h
124  virtual int get_volume(int sound_handle);
125 
126  // See dox in sound_handler.h
127  virtual void set_volume(int sound_handle, int volume);
128 
129  // See dox in sound_handler.h
130  virtual media::SoundInfo* get_sound_info(int soundHandle);
131 
132  // See dox in sound_handler.h
133  // overridden to close audio card
134  virtual void pause();
135 
136  // See dox in sound_handler.h
137  // overridden to open audio card
138  virtual void unpause();
139 
140  // See dox in sound_handler.h
141  virtual unsigned int get_duration(int sound_handle);
142 
143  // See dox in sound_handler.h
144  virtual unsigned int tell(int sound_handle);
145 
146  // See dox in sound_handler.h
147  // Overridden to unpause SDL audio
148  void plugInputStream(std::unique_ptr<InputStream> in);
149 
150  // See dox in sound_handler.h
151  void fetchSamples(std::int16_t* to, unsigned int nSamples);
152 
153  int audioTask();
154 };
155 
156 
157 
158 } // gnash.sound namespace
159 } // namespace gnash
160 
161 #endif // SOUND_HANDLER_AHI_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
AHI-based sound_handler.
Definition: sound_handler_ahi.h:49
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