1
// sound_handler_ahi.h: Sound handling using standard AHI
3
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
5
// This program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 3 of the License, or
8
// (at your option) any later version.
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program; if not, write to the Free Software
17
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef SOUND_HANDLER_AOS4_H
21
#define SOUND_HANDLER_AOS4_H
24
#include "sound_handler.h" // for inheritance
26
#include <vector> // for composition (Sounds)
27
#include <set> // for composition (InputStreams)
28
#include <fstream> // for composition (file_stream)
29
#include <boost/thread/mutex.hpp>
31
#include <proto/dos.h>
32
#include <proto/exec.h>
33
#include <proto/ahi.h>
35
#include <devices/ahi.h>
36
#include <exec/memory.h>
38
#include <sys/types.h>
39
// Forward declarations
51
/// AHI-based sound_handler
52
class AOS4_sound_handler : public sound_handler
55
struct MsgPort *_port;
57
struct TimeRequest *_timerio;
58
struct TimerIFace *ITimer;
60
struct AHIIFace *IAHI;
61
struct Library *AHIBase;
62
struct MsgPort *AHImp; //AHI Message Port
63
struct AHIRequest *AHIio;
65
struct AHIRequest *AHIios[2];
74
struct Process *AudioPump;
78
void TimerReset(uint32 microDelay);
80
/// Initialize audio card
88
struct DeathMessage *_dmsg; // the child Death Message
89
struct MsgPort *_DMreplyport; // and its port
91
/// Mutex for making sure threads doesn't mess things up
94
/// Mutex protecting _muted (defined in base class)
95
mutable boost::mutex _mutedMutex;
97
/// File stream for dump file
99
/// TODO: move to base class ?
101
std::ofstream file_stream;
103
// write a .WAV file header
104
void write_wave_header(std::ofstream& outfile);
106
// See dox in sound_handler.h
107
void mix(boost::int16_t* outSamples, boost::int16_t* inSamples,
108
unsigned int nSamples, float volume);
110
void MixAudio (boost::uint8_t *dst, const boost::uint8_t *src, boost::uint32_t len, int volume);
114
AOS4_sound_handler();
116
AOS4_sound_handler(const std::string& wave_file);
118
~AOS4_sound_handler();
120
// See dox in sound_handler.h
121
virtual int create_sound(std::auto_ptr<SimpleBuffer> data, std::auto_ptr<media::SoundInfo> sinfo);
123
// See dox in sound_handler.h
124
// overridden to serialize access to the data buffer slot
125
virtual StreamBlockId addSoundBlock(unsigned char* data,
126
unsigned int data_bytes,
127
unsigned int sample_count,
130
// See dox in sound_handler.h
131
virtual void stop_sound(int sound_handle);
133
// See dox in sound_handler.h
134
virtual void delete_sound(int sound_handle);
136
// See dox in sound_handler.h
137
virtual void reset();
139
// See dox in sound_handler.h
140
virtual void stop_all_sounds();
142
// See dox in sound_handler.h
143
virtual int get_volume(int sound_handle);
145
// See dox in sound_handler.h
146
virtual void set_volume(int sound_handle, int volume);
148
// See dox in sound_handler.h
149
virtual media::SoundInfo* get_sound_info(int soundHandle);
151
// See dox in sound_handler.h
152
// overridden to serialize access to the _muted member
155
// See dox in sound_handler.h
156
// overridden to serialize access to the _muted member
157
virtual void unmute();
159
// See dox in sound_handler.h
160
// overridden to serialize access to the _muted member
161
virtual bool is_muted() const;
163
// See dox in sound_handler.h
164
// overridden to close audio card
165
virtual void pause();
167
// See dox in sound_handler.h
168
// overridden to open audio card
169
virtual void unpause();
171
// See dox in sound_handler.h
172
virtual unsigned int get_duration(int sound_handle);
174
// See dox in sound_handler.h
175
virtual unsigned int tell(int sound_handle);
177
// See dox in sound_handler.h
178
// Overridden to unpause SDL audio
179
void plugInputStream(std::auto_ptr<InputStream> in);
181
// See dox in sound_handler.h
182
void fetchSamples(boost::int16_t* to, unsigned int nSamples);
189
} // gnash.sound namespace
192
#endif // SOUND_HANDLER_SDL_H