Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SOUND_HANDLER_AHI_H
00021 #define SOUND_HANDLER_AHI_H
00022
00023 #include "sound_handler.h"
00024
00025 #include <string>
00026 #include <set>
00027 #include <fstream>
00028 #include <boost/thread/mutex.hpp>
00029
00030 #include <proto/dos.h>
00031 #include <proto/exec.h>
00032 #include <proto/ahi.h>
00033
00034 #include <devices/ahi.h>
00035 #include <exec/memory.h>
00036
00037 #include <sys/types.h>
00038
00039 namespace gnash {
00040 class SimpleBuffer;
00041 namespace sound {
00042 class EmbedSound;
00043 class InputStream;
00044 }
00045 }
00046
00047 namespace gnash {
00048 namespace sound {
00049
00051 class AOS4_sound_handler : public sound_handler
00052 {
00053 private:
00054 struct MsgPort *_port;
00055 uint32 _timerSig;
00056 struct TimeRequest *_timerio;
00057 struct TimerIFace *ITimer;
00058
00059 struct AHIIFace *IAHI;
00060 struct Library *AHIBase;
00061 struct MsgPort *AHImp;
00062 struct AHIRequest *AHIio;
00063 BYTE AHIDevice;
00064 struct AHIRequest *AHIios[2];
00065 APTR AHIiocopy;
00066 ULONG AHICurBuf;
00067 bool AHIReqSent[2];
00068 UBYTE *PlayBuffer[2];
00069 ULONG BufferFill;
00070 UBYTE *BufferPointer;
00071 ULONG Buffer;
00072
00073 struct Process *AudioPump;
00074
00075 bool TimerInit(void);
00076 void TimerExit(void);
00077 void TimerReset(uint32 microDelay);
00078
00080 void initAudio();
00081 void openAudio();
00082 void closeAudio();
00083
00084 bool _audioOpened;
00085 bool _closing;
00086
00087 struct DeathMessage *_dmsg;
00088 struct MsgPort *_DMreplyport;
00089
00091 boost::mutex _mutex;
00092
00094 mutable boost::mutex _mutedMutex;
00095
00097
00100 std::ofstream file_stream;
00101
00102
00103 void write_wave_header(std::ofstream& outfile);
00104
00105
00106 void mix(boost::int16_t* outSamples, boost::int16_t* inSamples,
00107 unsigned int nSamples, float volume);
00108
00109 void MixAudio (boost::uint8_t *dst, const boost::uint8_t *src, boost::uint32_t len, int volume);
00110
00111 public:
00112
00113 AOS4_sound_handler(media::MediaHandler* m);
00114
00115 AOS4_sound_handler(media::MediaHandler* m, const std::string& wave_file);
00116
00117 ~AOS4_sound_handler();
00118
00119
00120 virtual int create_sound(std::auto_ptr<SimpleBuffer> data, std::auto_ptr<media::SoundInfo> sinfo);
00121
00122
00123
00124 virtual StreamBlockId addSoundBlock(unsigned char* data,
00125 unsigned int data_bytes,
00126 unsigned int sample_count,
00127 int streamId);
00128
00129
00130 virtual void stop_sound(int sound_handle);
00131
00132
00133 virtual void delete_sound(int sound_handle);
00134
00135
00136 virtual void reset();
00137
00138
00139 virtual void stop_all_sounds();
00140
00141
00142 virtual int get_volume(int sound_handle);
00143
00144
00145 virtual void set_volume(int sound_handle, int volume);
00146
00147
00148 virtual media::SoundInfo* get_sound_info(int soundHandle);
00149
00150
00151
00152 virtual void mute();
00153
00154
00155
00156 virtual void unmute();
00157
00158
00159
00160 virtual bool is_muted() const;
00161
00162
00163
00164 virtual void pause();
00165
00166
00167
00168 virtual void unpause();
00169
00170
00171 virtual unsigned int get_duration(int sound_handle);
00172
00173
00174 virtual unsigned int tell(int sound_handle);
00175
00176
00177
00178 void plugInputStream(std::auto_ptr<InputStream> in);
00179
00180
00181 void fetchSamples(boost::int16_t* to, unsigned int nSamples);
00182
00183 int audioTask();
00184 };
00185
00186
00187
00188 }
00189 }
00190
00191 #endif // SOUND_HANDLER_AHI_H