Gnash  0.8.11dev
EmbedSoundInst.h
Go to the documentation of this file.
1 // EmbedSoundInst.h - instance of an embedded sound, for gnash
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 #ifndef SOUND_EMBEDSOUNDINST_H
21 #define SOUND_EMBEDSOUNDINST_H
22 
23 #include <cassert>
24 #include <cstdint> // For C99 int types
25 #include <limits>
26 
27 #include "EmbedSound.h"
28 #include "LiveSound.h"
29 #include "SoundEnvelope.h"
30 
31 // Forward declarations
32 namespace gnash {
33  namespace sound {
34  class EmbedSound;
35  }
36  namespace media {
37  class MediaHandler;
38  }
39 }
40 
41 namespace gnash {
42 namespace sound {
43 
45 class EmbedSoundInst : public LiveSound
46 {
47 public:
48 
50  //
66  unsigned int inPoint, unsigned int outPoint,
67  const SoundEnvelopes* envelopes, int loopCount);
68 
69  // See dox in sound_handler.h (InputStream)
70  virtual bool eof() const;
71 
73  //
75  virtual ~EmbedSoundInst();
76 
77 private:
78 
79  virtual size_t checkEarlierEnd(size_t bytesAhead, size_t pos) const {
80  if (_outPoint < std::numeric_limits<unsigned long>::max()) {
81  const size_t toCustomEnd = _outPoint - pos;
82  return std::min(toCustomEnd, bytesAhead);
83  }
84  return bytesAhead;
85  }
86 
87  virtual bool moreData();
88 
90  //
107  void applyEnvelopes(std::int16_t* samples, unsigned int nSamples,
108  unsigned int firstSampleNum, const SoundEnvelopes& env);
109 
110  bool reachedCustomEnd() const;
111 
113  virtual bool decodingCompleted() const {
114  return (decodingPosition >= _soundDef.size());
115  }
116 
118  //
120  virtual void decodeNextBlock();
121 
123  unsigned long decodingPosition;
124 
127  long loopCount;
128 
131  const unsigned long _outPoint;
132 
135  const SoundEnvelopes* envelopes;
136 
138  std::uint32_t current_env;
139 
141  //
145  EmbedSound& _soundDef;
146 
147 };
148 
149 
150 } // gnash.sound namespace
151 } // namespace gnash
152 
153 #endif // SOUND_EMBEDSOUNDINST_H
Definition of an embedded sound.
Definition: EmbedSound.h:49
Instance of a defined sound (LiveSoundData)
Definition: LiveSound.h:46
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
The MediaHandler class acts as a factory to provide parser and decoders.
Definition: MediaHandler.h:69
std::vector< SoundEnvelope > SoundEnvelopes
A vector of SoundEnvelope objects.
Definition: SoundEnvelope.h:60
Instance of a defined sound (EmbedSound)
Definition: EmbedSoundInst.h:45