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_MKIT_H
00021 #define SOUND_HANDLER_MKIT_H
00022
00023 #include "sound_handler.h"
00024
00025 #include <string>
00026 #include <set>
00027 #include <fstream>
00028 #include <boost/thread/mutex.hpp>
00029 #include <boost/scoped_ptr.hpp>
00030
00031 #include <SoundPlayer.h>
00032
00033
00034 namespace gnash {
00035 class SimpleBuffer;
00036 namespace sound {
00037 class EmbedSound;
00038 class InputStream;
00039 }
00040 }
00041
00042 namespace gnash {
00043 namespace sound {
00044
00046 class Mkit_sound_handler : public sound_handler
00047 {
00048 boost::scoped_ptr<BSoundPlayer> _soundplayer;
00049
00051 static void FillNextBuffer(void *cookie, void *buffer, size_t size,
00052 const media_raw_audio_format &format);
00053
00055 void openAudio();
00056
00057 bool _audioopen;
00058
00060 boost::mutex _mutex;
00061
00063 mutable boost::mutex _mutedMutex;
00064
00066
00069 std::ofstream file_stream;
00070
00071
00072 void write_wave_header(std::ofstream& outfile);
00073
00074
00075 void mix(boost::int16_t* outSamples, boost::int16_t* inSamples,
00076 unsigned int nSamples, float volume);
00077
00078 void MixAudio (boost::uint8_t *dst, const boost::uint8_t *src, boost::uint32_t len, int volume);
00079
00080 public:
00081 Mkit_sound_handler(media::MediaHandler* m);
00082
00083 Mkit_sound_handler(media::MediaHandler* m, const std::string& wave_file);
00084
00085 ~Mkit_sound_handler();
00086
00087
00088 virtual int create_sound(std::auto_ptr<SimpleBuffer> data, std::auto_ptr<media::SoundInfo> sinfo);
00089
00090
00091
00092 virtual StreamBlockId addSoundBlock(unsigned char* data,
00093 unsigned int data_bytes,
00094 unsigned int sample_count,
00095 int streamId);
00096
00097
00098 virtual void stop_sound(int sound_handle);
00099
00100
00101 virtual void delete_sound(int sound_handle);
00102
00103
00104 virtual void reset();
00105
00106
00107 virtual void stop_all_sounds();
00108
00109
00110 virtual int get_volume(int sound_handle);
00111
00112
00113 virtual void set_volume(int sound_handle, int volume);
00114
00115
00116 virtual media::SoundInfo* get_sound_info(int soundHandle);
00117
00118
00119
00120 virtual void mute();
00121
00122
00123
00124 virtual void unmute();
00125
00126
00127
00128 virtual bool is_muted() const;
00129
00130
00131
00132 virtual void pause();
00133
00134
00135
00136 virtual void unpause();
00137
00138
00139 virtual unsigned int get_duration(int sound_handle);
00140
00141
00142 virtual unsigned int tell(int sound_handle);
00143
00144
00145
00146 void plugInputStream(std::auto_ptr<InputStream> in);
00147
00148
00149 void fetchSamples(boost::int16_t* to, unsigned int nSamples);
00150 };
00151
00152 }
00153 }
00154
00155 #endif // SOUND_HANDLER_MKIT_H