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_EMBEDSOUND_H
00021 #define SOUND_EMBEDSOUND_H
00022
00023 #include "SimpleBuffer.h"
00024 #include "SoundInfo.h"
00025 #include "SoundEnvelope.h"
00026
00027 #include <vector>
00028 #include <map>
00029 #include <memory>
00030 #include <set>
00031 #include <cassert>
00032 #include <boost/thread/mutex.hpp>
00033
00034
00035
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 }
00255 }
00256
00257 #endif // SOUND_EMBEDSOUND_H