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
00021 #ifndef SOUND_HANDLER_SDL_H
00022 #define SOUND_HANDLER_SDL_H
00023
00024
00025 #include "sound_handler.h"
00026
00027 #include <set>
00028 #include <SDL_audio.h>
00029 #include <boost/thread/mutex.hpp>
00030
00031
00032 namespace gnash {
00033 class SimpleBuffer;
00034 namespace sound {
00035 class EmbedSound;
00036 class InputStream;
00037 }
00038 }
00039
00040 namespace gnash {
00041 namespace sound {
00042
00044 class SDL_sound_handler : public sound_handler
00045 {
00046 private:
00047
00049 SDL_AudioSpec audioSpec;
00050
00052 void initAudio();
00053
00054 void openAudio();
00055
00056 void closeAudio();
00057
00058 bool _audioOpened;
00059
00061 mutable boost::mutex _mutex;
00062
00064 mutable boost::mutex _mutedMutex;
00065
00066
00067 void mix(boost::int16_t* outSamples, boost::int16_t* inSamples,
00068 unsigned int nSamples, float volume);
00069
00070
00072
00087 static void sdl_audio_callback (void *udata, Uint8 *stream, int buffer_length_in);
00088
00089 public:
00090
00091 SDL_sound_handler(media::MediaHandler* m);
00092
00093 ~SDL_sound_handler();
00094
00095 virtual int createStreamingSound(const media::SoundInfo& sinfo);
00096
00097
00098 virtual int create_sound(std::auto_ptr<SimpleBuffer> data,
00099 const media::SoundInfo& sinfo);
00100
00101
00102
00103 virtual StreamBlockId addSoundBlock(std::auto_ptr<SimpleBuffer> buf,
00104 size_t sample_count, int seekSamples, int streamId);
00105
00106
00107 virtual void stopEventSound(int sound_handle);
00108
00109
00110 virtual void stopAllEventSounds();
00111
00112 virtual void stopStreamingSound(int sound_handle);
00113
00114
00115 virtual void delete_sound(int sound_handle);
00116
00117
00118 virtual void reset();
00119
00120
00121 virtual void stop_all_sounds();
00122
00123
00124 virtual int get_volume(int sound_handle) const;
00125
00126
00127 virtual void set_volume(int sound_handle, int volume);
00128
00129
00130 virtual media::SoundInfo* get_sound_info(int soundHandle) const;
00131
00132
00133
00134 virtual void mute();
00135
00136
00137
00138 virtual void unmute();
00139
00140
00141
00142 virtual bool is_muted() const;
00143
00144
00145
00146 virtual void pause();
00147
00148
00149
00150 virtual void unpause();
00151
00152
00153 virtual unsigned int get_duration(int sound_handle) const;
00154
00155
00156 virtual unsigned int tell(int sound_handle) const;
00157
00158
00159
00160 void plugInputStream(std::auto_ptr<InputStream> in);
00161
00162
00163 void unplugInputStream(InputStream* id);
00164
00165
00166 void fetchSamples(boost::int16_t* to, unsigned int nSamples);
00167 };
00168
00169 }
00170 }
00171
00172 #endif // SOUND_HANDLER_SDL_H