• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

sound_handler_mkit.h

Go to the documentation of this file.
00001 // sound_handler_haiku.h: Sound handling using Mkit media kit
00002 //
00003 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
00004 //   Foundation, Inc
00005 //
00006 // This program is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 3 of the License, or
00009 // (at your option) any later version.
00010 
00011 // This program is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 // 
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020 #ifndef SOUND_HANDLER_MKIT_H
00021 #define SOUND_HANDLER_MKIT_H
00022 
00023 #include "sound_handler.h" // for inheritance
00024 
00025 #include <string>
00026 #include <set> // for composition (InputStreams)
00027 #include <fstream> // for composition (file_stream)
00028 #include <boost/thread/mutex.hpp>
00029 #include <boost/scoped_ptr.hpp>
00030 
00031 #include <SoundPlayer.h>
00032 
00033 // Forward declarations
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     // write a .WAV file header
00072     void write_wave_header(std::ofstream& outfile);
00073 
00074     // See dox in sound_handler.h
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     // See dox in sound_handler.h
00088     virtual int create_sound(std::auto_ptr<SimpleBuffer> data, std::auto_ptr<media::SoundInfo> sinfo);
00089 
00090     // See dox in sound_handler.h
00091     // overridden to serialize access to the data buffer slot
00092     virtual StreamBlockId addSoundBlock(unsigned char* data,
00093                                        unsigned int data_bytes,
00094                                        unsigned int sample_count,
00095                                        int streamId);
00096 
00097     // See dox in sound_handler.h
00098     virtual void    stop_sound(int sound_handle);
00099 
00100     // See dox in sound_handler.h
00101     virtual void    delete_sound(int sound_handle);
00102 
00103     // See dox in sound_handler.h
00104     virtual void reset();
00105 
00106     // See dox in sound_handler.h
00107     virtual void    stop_all_sounds();
00108 
00109     // See dox in sound_handler.h
00110     virtual int get_volume(int sound_handle);
00111 
00112     // See dox in sound_handler.h
00113     virtual void    set_volume(int sound_handle, int volume);
00114 
00115     // See dox in sound_handler.h
00116     virtual media::SoundInfo* get_sound_info(int soundHandle);
00117 
00118     // See dox in sound_handler.h
00119     // overridden to serialize access to the _muted member
00120     virtual void mute();
00121 
00122     // See dox in sound_handler.h
00123     // overridden to serialize access to the _muted member
00124     virtual void unmute();
00125 
00126     // See dox in sound_handler.h
00127     // overridden to serialize access to the _muted member
00128     virtual bool is_muted() const;
00129 
00130     // See dox in sound_handler.h
00131     // overridden to close audio card
00132     virtual void pause();
00133 
00134     // See dox in sound_handler.h
00135     // overridden to open audio card
00136     virtual void unpause();
00137 
00138     // See dox in sound_handler.h
00139     virtual unsigned int get_duration(int sound_handle);
00140 
00141     // See dox in sound_handler.h
00142     virtual unsigned int tell(int sound_handle);
00143 
00144     // See dox in sound_handler.h
00145     // Overridden to unpause SDL audio
00146     void plugInputStream(std::auto_ptr<InputStream> in);
00147 
00148     // See dox in sound_handler.h
00149     void fetchSamples(boost::int16_t* to, unsigned int nSamples);
00150 };
00151 
00152 } // gnash.sound namespace 
00153 } // namespace gnash
00154 
00155 #endif // SOUND_HANDLER_MKIT_H

Generated on Thu Sep 30 2010 14:35:03 for Gnash by  doxygen 1.7.1