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

EmbedSound.h

Go to the documentation of this file.
00001 // EmbedSound.h - embedded sound definition, for gnash
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_EMBEDSOUND_H
00021 #define SOUND_EMBEDSOUND_H
00022 
00023 #include "SimpleBuffer.h" // for composition
00024 #include "SoundInfo.h" // for composition
00025 #include "SoundEnvelope.h" // for SoundEnvelopes define
00026 
00027 #include <vector>
00028 #include <map> // for composition (m_frame_size)
00029 #include <memory> // for auto_ptr (composition)
00030 #include <set> // for composition (_soundInstances)
00031 #include <cassert>
00032 #include <boost/thread/mutex.hpp>
00033 
00034 
00035 // Forward declarations
00036 namespace gnash {
00037     namespace sound {
00038         class EmbedSoundInst;
00039         class InputStream;
00040     }
00041     namespace media {
00042         class MediaHandler;
00043     }
00044 }
00045 
00046 namespace gnash {
00047 namespace sound {
00048 
00050 class EmbedSound
00051 {
00053     std::auto_ptr<SimpleBuffer> _buf;
00054 
00055     void ensureBufferPadding();
00056 
00057 public:
00058 
00060     //
00068     EmbedSound(std::auto_ptr<SimpleBuffer> data,
00069             std::auto_ptr<media::SoundInfo> info, int nVolume,
00070             size_t paddingBytes);
00071 
00072     ~EmbedSound();
00073 
00075     std::auto_ptr<media::SoundInfo> soundinfo;
00076 
00077     typedef std::map<boost::uint32_t,boost::uint32_t> FrameSizeMap;
00078 
00080     FrameSizeMap m_frames_size;
00081 
00083     //
00090     void append(boost::uint8_t* data, unsigned int size);
00091 
00093     size_t size() const 
00094     {
00095         return _buf->size();
00096     }
00097 
00099     bool empty() const 
00100     {
00101         return _buf->empty();
00102     }
00103 
00105     const boost::uint8_t* data() const {
00106         return _buf->data();
00107     }
00108 
00110     boost::uint8_t* data() {
00111         return _buf->data();
00112     }
00113 
00115     //
00119     const boost::uint8_t* data(size_t pos) const {
00120         assert(pos < _buf->size());
00121         return _buf->data()+pos;
00122     }
00123 
00125     //
00129     boost::uint8_t* data(size_t pos) {
00130         assert(pos < _buf->size());
00131         return _buf->data()+pos;
00132     }
00133 
00135     //
00138     bool isPlaying() const;
00139 
00141     //
00144     size_t numPlayingInstances() const;
00145 
00147     void getPlayingInstances(std::vector<InputStream*>& to) const;
00148 
00150     //
00153     EmbedSoundInst* firstPlayingInstance() const;
00154 
00156     //
00193     std::auto_ptr<EmbedSoundInst> createInstance( media::MediaHandler& mh,
00194             unsigned long blockOffset,
00195             unsigned int inPoint, unsigned int outPoint,
00196             const SoundEnvelopes* envelopes, unsigned int loopCount);
00197 
00200     int volume;
00201 
00203     //
00206     typedef std::list<EmbedSoundInst*> Instances;
00207 
00209     //
00215     Instances _soundInstances;
00216 
00218     //
00221     mutable boost::mutex _soundInstancesMutex;
00222 
00224     //
00227     void clearInstances();
00228 
00230     //
00235     Instances::iterator eraseActiveSound(Instances::iterator i);
00236 
00238     //
00249     void eraseActiveSound(EmbedSoundInst* inst);
00250 
00251     const size_t _paddingBytes;
00252 };
00253 
00254 } // gnash.sound namespace 
00255 } // namespace gnash
00256 
00257 #endif // SOUND_EMBEDSOUND_H

Generated on Thu Sep 30 2010 14:34:58 for Gnash by  doxygen 1.7.1