[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog libmedia/sound_handler.h libmed...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog libmedia/sound_handler.h libmed... |
Date: |
Wed, 11 Jun 2008 14:40:28 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 08/06/11 14:40:27
Modified files:
. : ChangeLog
libmedia : sound_handler.h
libmedia/ffmpeg: AudioDecoderFfmpeg.cpp sound_handler_sdl.cpp
sound_handler_sdl.h
Log message:
* libmedia/sound_handler.h: drop the Buffer here, use the one in
libbase.
* libmedia/ffmpeg/sound_handler_sdl.{cpp,h}: updated to use the
Buffer in libbase, split body of the SDL callbacks in subfunction
(still too big the lower one).
* libmedia/ffmpeg/AudioDecoderFfmpeg.cpp: try at reintroducing the
parsing feature (isn't really working).
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6899&r2=1.6900
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/sound_handler.h?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/ffmpeg/AudioDecoderFfmpeg.cpp?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/ffmpeg/sound_handler_sdl.cpp?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/ffmpeg/sound_handler_sdl.h?cvsroot=gnash&r1=1.12&r2=1.13
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6899
retrieving revision 1.6900
diff -u -b -r1.6899 -r1.6900
--- ChangeLog 11 Jun 2008 13:58:16 -0000 1.6899
+++ ChangeLog 11 Jun 2008 14:40:26 -0000 1.6900
@@ -1,5 +1,15 @@
2008-06-11 Sandro Santilli <address@hidden>
+ * libmedia/sound_handler.h: drop the Buffer here, use the one in
+ libbase.
+ * libmedia/ffmpeg/sound_handler_sdl.{cpp,h}: updated to use the
+ Buffer in libbase, split body of the SDL callbacks in subfunction
+ (still too big the lower one).
+ * libmedia/ffmpeg/AudioDecoderFfmpeg.cpp: try at reintroducing the
+ parsing feature (isn't really working).
+
+2008-06-11 Sandro Santilli <address@hidden>
+
* libbase/: Buffer.h, Makefile.am: add a generic Buffer class aimed
at unifying buffer types among the whole gnash lib.
Index: libmedia/sound_handler.h
===================================================================
RCS file: /sources/gnash/gnash/libmedia/sound_handler.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- libmedia/sound_handler.h 9 Jun 2008 18:12:55 -0000 1.20
+++ libmedia/sound_handler.h 11 Jun 2008 14:40:27 -0000 1.21
@@ -48,149 +48,6 @@
///
namespace media {
-/// A buffer of bytes
-class Buffer {
-public:
- Buffer()
- :
- _capacity(0),
- _data(0),
- _size(0)
- {}
-
- /// Create a Buffer with the given initial content
- //
- /// @param newData data to assign to this buffer.
- /// Allocated with new[]. Ownership transferred.
- ///
- /// @param size number of bytes in the new data
- ///
- Buffer(boost::uint8_t* newData, size_t size)
- :
- _capacity(size),
- _data(newData),
- _size(size)
- {}
-
- /// Append data to this buffer
- //
- /// @param newData data to append to this buffer.
- /// Allocated with new[]. Ownership transferred.
- ///
- /// @param size number of bytes in the new data
- ///
- void append(boost::uint8_t* newData, size_t size)
- {
- if ( ! _capacity )
- {
- _data = newData;
- _size = size;
- _capacity = _size;
- return;
- }
-
- reserve(_size+size);
-
- assert(_capacity >= _size+size);
- memcpy(_data+_size, newData, size);
- _size += size;
- delete [] newData;
- }
-
- /// Assign data to this buffer
- //
- /// @param newData data to assign to this buffer.
- /// Allocated with new[]. Ownership transferred.
- ///
- /// @param size number of bytes in the new data
- ///
- void assign(boost::uint8_t* newData, size_t size)
- {
- if ( ! _capacity )
- {
- _data = newData;
- _size = size;
- _capacity = _size;
- return;
- }
-
- _size=0; // so reserve won't memcpy...
- reserve(size);
-
- assert(_capacity >= size);
-
- memcpy(_data, newData, size);
- _size = size;
-
- delete [] newData;
- }
-
- const boost::uint8_t* data() const
- {
- return _data;
- }
-
- boost::uint8_t* data()
- {
- return _data;
- }
-
- const boost::uint8_t* data(size_t pos) const
- {
- assert(pos < _capacity);
- return _data+pos;
- }
-
- boost::uint8_t* data(size_t pos)
- {
- assert(pos < _capacity);
- return _data+pos;
- }
-
- void resize(size_t newSize)
- {
- // we won't change capacity here
- // (should we?)
- _size = newSize;
- }
-
- void reserve(size_t newCapacity)
- {
- if ( _capacity > newCapacity ) return;
-
- // TODO: use smalles power of 2 bigger then newCapacity
- _capacity = std::max(newCapacity, _capacity*2);
-
- boost::uint8_t* tmp = _data;
- _data = new boost::uint8_t[_capacity];
- if ( tmp )
- {
- if ( _size ) memcpy(_data, tmp, _size);
- delete [] tmp;
- }
- }
-
- size_t size() const
- {
- return _size;
- }
-
- ~Buffer()
- {
- delete [] _data;
- }
-
-private:
-
- size_t _capacity;
-
- boost::uint8_t* _data;
-
- size_t _size;
-
-};
-
-
/// Sound handler.
//
/// Stores the audio found by the parser and plays on demand.
Index: libmedia/ffmpeg/AudioDecoderFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/libmedia/ffmpeg/AudioDecoderFfmpeg.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- libmedia/ffmpeg/AudioDecoderFfmpeg.cpp 9 Jun 2008 14:31:53 -0000
1.9
+++ libmedia/ffmpeg/AudioDecoderFfmpeg.cpp 11 Jun 2008 14:40:27 -0000
1.10
@@ -192,6 +192,15 @@
return ret;
}
+ if (!_parser)
+ {
+ log_error(_("AudioDecoderFfmpeg: libavcodec can't parse the
current audio format"));
+ decodedBytes=inputSize;
+ outputSize=0;
+ return 0;
+ }
+
+#if 0
LOG_ONCE( log_unimpl("Parsing inside FFMPEG AudioDecoder (shouldn't be
needed, core lib should be fixed to not even try)") );
// TODO: for each parsed frame, call decodeFrame and
// grow the buffer to return...
@@ -199,6 +208,44 @@
decodedBytes=inputSize; // pretend we decoded everything
outputSize=0; // and that resulting output is empty
return 0;
+
+#else
+
+ long bytes_decoded = 0;
+ int bufsize = (AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2;
+ boost::uint8_t* output = new boost::uint8_t[bufsize];
+ boost::uint32_t orgbufsize = bufsize;
+ decodedBytes = 0;
+
+ bufsize = 0;
+ while (bufsize == 0 && decodedBytes < inputSize)
+ {
+ boost::uint8_t* frame;
+ int framesize;
+
+ bytes_decoded = av_parser_parse(_parser, _audioCodecCtx,
&frame, &framesize, input+decodedBytes, inputSize-decodedBytes, 0, 0); //the
last 2 is pts & dts
+
+ int tmp = 0;
+#ifdef FFMPEG_AUDIO2
+ bufsize = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+ tmp = avcodec_decode_audio2(_audioCodecCtx,
reinterpret_cast<boost::int16_t*>(output), &bufsize, frame, framesize);
+#else
+ tmp = avcodec_decode_audio(_audioCodecCtx,
reinterpret_cast<boost::int16_t*>(output), &bufsize, frame, framesize);
+#endif
+
+ if (bytes_decoded < 0 || tmp < 0 || bufsize < 0) {
+ log_error(_("Error while decoding audio data. Upgrading
ffmpeg/libavcodec might fix this issue."));
+ // Setting data position to data size will get the
sound removed
+ // from the active sound list later on.
+ decodedBytes = inputSize;
+ break;
+ }
+
+ decodedBytes += bytes_decoded;
+ }
+
+#endif
+
}
boost::uint8_t*
Index: libmedia/ffmpeg/sound_handler_sdl.cpp
===================================================================
RCS file: /sources/gnash/gnash/libmedia/ffmpeg/sound_handler_sdl.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- libmedia/ffmpeg/sound_handler_sdl.cpp 9 Jun 2008 18:12:56 -0000
1.12
+++ libmedia/ffmpeg/sound_handler_sdl.cpp 11 Jun 2008 14:40:27 -0000
1.13
@@ -540,7 +540,7 @@
sound_data* sounddata = m_sound_data[sound_handle];
// If there is no active sounds, return 0
- if (sounddata->m_active_sounds.size() == 0) return 0;
+ if (sounddata->m_active_sounds.empty()) return 0;
// We use the first active sound of this.
active_sound* asound = sounddata->m_active_sounds[0];
@@ -572,7 +572,8 @@
{
if ( _decodedData.get() )
{
- return _decodedData->data(pos);
+ assert(pos < _decodedData->size());
+ return _decodedData->data()+pos;
}
else return 0;
}
@@ -604,57 +605,57 @@
// envelope-volume adjustment
static void
-use_envelopes(active_sound* sound, unsigned int length)
+use_envelopes(active_sound& sound, unsigned int length)
{
// Check if this is the time to use envelopes yet
- if (sound->current_env == 0 && (*sound->envelopes)[0].m_mark44 >
sound->samples_played+length/2)
+ if (sound.current_env == 0 && (*sound.envelopes)[0].m_mark44 >
sound.samples_played+length/2)
{
return;
}
// switch to the next envelope if needed and possible
- else if (sound->current_env < sound->envelopes->size()-1 &&
(*sound->envelopes)[sound->current_env+1].m_mark44 >= sound->samples_played)
+ else if (sound.current_env < sound.envelopes->size()-1 &&
(*sound.envelopes)[sound.current_env+1].m_mark44 >= sound.samples_played)
{
- sound->current_env++;
+ sound.current_env++;
}
// Current envelope position
- boost::int32_t cur_env_pos =
sound->envelopes->operator[](sound->current_env).m_mark44;
+ boost::int32_t cur_env_pos =
sound.envelopes->operator[](sound.current_env).m_mark44;
// Next envelope position
boost::uint32_t next_env_pos = 0;
- if (sound->current_env == (sound->envelopes->size()-1)) {
+ if (sound.current_env == (sound.envelopes->size()-1)) {
// If there is no "next envelope" then set the next envelope
start point to be unreachable
next_env_pos = cur_env_pos + length;
} else {
- next_env_pos =
(*sound->envelopes)[sound->current_env+1].m_mark44;
+ next_env_pos = (*sound.envelopes)[sound.current_env+1].m_mark44;
}
unsigned int startpos = 0;
// Make sure we start adjusting at the right sample
- if (sound->current_env == 0 &&
(*sound->envelopes)[sound->current_env].m_mark44 > sound->samples_played) {
- startpos = sound->raw_position +
((*sound->envelopes)[sound->current_env].m_mark44 - sound->samples_played)*2;
+ if (sound.current_env == 0 &&
(*sound.envelopes)[sound.current_env].m_mark44 > sound.samples_played) {
+ startpos = sound.raw_position +
((*sound.envelopes)[sound.current_env].m_mark44 - sound.samples_played)*2;
} else {
- startpos = sound->raw_position;
+ startpos = sound.raw_position;
}
- boost::int16_t* data =
reinterpret_cast<boost::int16_t*>(sound->get_raw_data_ptr(startpos));
+ boost::int16_t* data =
reinterpret_cast<boost::int16_t*>(sound.get_raw_data_ptr(startpos));
for (unsigned int i=0; i < length/2; i+=2) {
- float left =
static_cast<float>((*sound->envelopes)[sound->current_env].m_level0 / 32768.0);
- float right =
static_cast<float>((*sound->envelopes)[sound->current_env].m_level1 / 32768.0);
+ float left =
static_cast<float>((*sound.envelopes)[sound.current_env].m_level0 / 32768.0);
+ float right =
static_cast<float>((*sound.envelopes)[sound.current_env].m_level1 / 32768.0);
data[i] = static_cast<boost::int16_t>(data[i] * left); // Left
data[i+1] = static_cast<boost::int16_t>(data[i+1] * right); //
Right
- if ((sound->samples_played+(length/2-i)) >= next_env_pos &&
sound->current_env != (sound->envelopes->size()-1)) {
- sound->current_env++;
+ if ((sound.samples_played+(length/2-i)) >= next_env_pos &&
sound.current_env != (sound.envelopes->size()-1)) {
+ sound.current_env++;
// Next envelope position
- if (sound->current_env == (sound->envelopes->size()-1))
{
+ if (sound.current_env == (sound.envelopes->size()-1)) {
// If there is no "next envelope" then set the
next envelope start point to be unreachable
next_env_pos = cur_env_pos + length;
} else {
- next_env_pos =
(*sound->envelopes)[sound->current_env+1].m_mark44;
+ next_env_pos =
(*sound.envelopes)[sound.current_env+1].m_mark44;
}
}
}
@@ -663,11 +664,12 @@
// Prepare for mixing/adding (volume adjustments) and mix/add.
static void
-do_mixing(Uint8* stream, active_sound* sound, Uint8* data, unsigned int
mix_length, unsigned int volume) {
+do_mixing(Uint8* stream, active_sound& sound, Uint8* data, unsigned int
mix_length, unsigned int volume)
+{
// If the volume needs adjustments we call a function to do that
if (volume != 100) {
adjust_volume(reinterpret_cast<boost::int16_t*>(data),
mix_length, volume);
- } else if (sound->envelopes != NULL) {
+ } else if (sound.envelopes != NULL) {
use_envelopes(sound, mix_length);
}
@@ -675,10 +677,10 @@
SDL_MixAudio(static_cast<Uint8*>(stream),static_cast<const
Uint8*>(data), mix_length, SDL_MIX_MAXVOLUME);
// Update sound info
- sound->raw_position += mix_length;
+ sound.raw_position += mix_length;
// Sample size is always 2
- sound->samples_played += mix_length / 2;
+ sound.samples_played += mix_length / 2;
}
@@ -793,30 +795,58 @@
}
// Run through all the sounds. TODO: don't call .size() at every
iteration !
- for(boost::uint32_t i=0; i < handler->m_sound_data.size(); i++) {
+ for(boost::uint32_t i=0; i < handler->m_sound_data.size(); i++)
+ {
sound_data* sounddata = handler->m_sound_data[i];
- for(boost::uint32_t j = 0; j <
sounddata->m_active_sounds.size(); j++) {
+ handler->mixSoundData(*sounddata, buffer, buffer_length);
+ }
- // Temp variables to make the code simpler and easier
to read
- active_sound* sound = sounddata->m_active_sounds[j];
+ //
+ // WRITE CONTENTS OF stream TO FILE
+ //
+ if (handler->file_stream) {
+ handler->file_stream.write((char*) stream, buffer_length_in);
+ // now, mute all audio
+ memset ((void*) stream, 0, buffer_length_in);
+ }
+
+
+
+}
+
+void
+sound_data::clearActiveSounds()
+{
+ for (ActiveSounds::iterator i=m_active_sounds.begin(),
e=m_active_sounds.end(); i!=e; ++i)
+ {
+ delete *i;
+ }
+ m_active_sounds.clear();
+}
+/*private*/
+void
+SDL_sound_handler::mixActiveSound(active_sound& sound, sound_data& sounddata,
Uint8* buffer, unsigned int buffer_length)
+{
// If there exist no decoder, then we can't decode!
- if (sound->decoder == NULL) continue;
+ if (sound.decoder == NULL) return;
- // When the current sound dont have enough decoded data
to fill the buffer,
+ // When the current sound don't have enough decoded data to fill the
buffer,
// we first mix what is already decoded, then decode
some more data, and
// mix some more until the buffer is full. If a sound
loops the magic
// happens here ;)
- if (sound->rawDataSize() - sound->raw_position <
buffer_length
- && (sound->position < sound->dataSize() ||
sound->loop_count != 0)) {
+ //
+ if (sound.rawDataSize() - sound.raw_position < buffer_length
+ && (sound.position < sound.dataSize() || sound.loop_count != 0))
+ {
// First we mix what is decoded
unsigned int index = 0;
- if (sound->rawDataSize() - sound->raw_position
> 0)
+ if (sound.rawDataSize() - sound.raw_position > 0)
{
- index = sound->rawDataSize() -
sound->raw_position;
+ index = sound.rawDataSize() - sound.raw_position;
- do_mixing(stream, sound,
sound->get_raw_data_ptr(sound->raw_position),
- index, sounddata->volume);
+ do_mixing(buffer, sound,
sound.get_raw_data_ptr(sound.raw_position),
+ index, sounddata.volume);
}
@@ -826,20 +856,20 @@
unsigned int decoded_size = 0;
// Delete any previous raw_data
- sound->deleteDecodedData();
+ sound.deleteDecodedData();
while(decoded_size < buffer_length)
{
// If we need to loop, we reset the
data pointer
- if (sound->dataSize() ==
sound->position && sound->loop_count != 0) {
- sound->loop_count--;
- sound->position = 0;
- sound->samples_played = 0;
+ if (sound.dataSize() == sound.position &&
sound.loop_count != 0) {
+ sound.loop_count--;
+ sound.position = 0;
+ sound.samples_played = 0;
}
// Test if we will get problems...
Should not happen...
- assert(sound->dataSize() >
sound->position);
+ assert(sound.dataSize() > sound.position);
// temp raw buffer
Uint8* tmp_raw_buffer;
@@ -848,32 +878,32 @@
boost::uint32_t inputSize = 0;
bool parse = true;
- if (sounddata->soundinfo->getFormat()
== AUDIO_CODEC_ADPCM) {
+ if (sounddata.soundinfo->getFormat() ==
AUDIO_CODEC_ADPCM) {
parse = false;
- if
(sounddata->m_frames_size.size() > 0) inputSize =
sounddata->m_frames_size[sound->position];
- else inputSize =
sound->dataSize() - sound->position;
+ if (sounddata.m_frames_size.size() > 0)
inputSize = sounddata.m_frames_size[sound.position];
+ else inputSize = sound.dataSize() -
sound.position;
} else {
- inputSize = sound->dataSize() -
sound->position;
+ inputSize = sound.dataSize() - sound.position;
}
- tmp_raw_buffer =
sound->decoder->decode(sound->get_data_ptr(sound->position),
+ tmp_raw_buffer =
sound.decoder->decode(sound.get_data_ptr(sound.position),
inputSize, tmp_raw_buffer_size, decodedBytes, parse);
- sound->position += decodedBytes;
+ sound.position += decodedBytes;
-
sound->appendDecodedData(tmp_raw_buffer, tmp_raw_buffer_size);
+ sound.appendDecodedData(tmp_raw_buffer,
tmp_raw_buffer_size);
decoded_size += tmp_raw_buffer_size;
// no more to decode from this sound,
so we break the loop
- if (sound->dataSize() <=
sound->position && sound->loop_count == 0 || tmp_raw_buffer_size == 0 &&
decodedBytes == 0) {
- sound->position =
sound->dataSize();
+ if (sound.dataSize() <= sound.position &&
sound.loop_count == 0 || tmp_raw_buffer_size == 0 && decodedBytes == 0) {
+ sound.position = sound.dataSize();
break;
}
} // end of "decode min. bufferlength data"
while loop
- sound->raw_position = 0;
+ sound.raw_position = 0;
// Determine how much should be mixed
unsigned int mix_length = 0;
@@ -882,62 +912,63 @@
} else {
mix_length = decoded_size;
}
- if (sound->rawDataSize() < 2) continue; //
something went terrible wrong
- do_mixing(stream+index, sound,
sound->get_raw_data_ptr(0), mix_length, sounddata->volume);
+ if (sound.rawDataSize() < 2)
+ {
+ log_error("Something went terribly wrong during mixing
of an active sound");
+ return; // something went terrible wrong
+ }
+ do_mixing(buffer+index, sound, sound.get_raw_data_ptr(0),
mix_length, sounddata.volume);
+
+ }
// When the current sound has enough decoded data to
fill
// the buffer, we do just that.
- } else if (sound->rawDataSize() > sound->raw_position
&& sound->rawDataSize() - sound->raw_position > buffer_length ) {
+ else if (sound.rawDataSize() > sound.raw_position &&
sound.rawDataSize() - sound.raw_position > buffer_length )
+ {
+
+ do_mixing(buffer, sound,
sound.get_raw_data_ptr(sound.raw_position),
+ buffer_length, sounddata.volume);
- do_mixing(stream, sound,
sound->get_raw_data_ptr(sound->raw_position),
- buffer_length, sounddata->volume);
+ }
// When the current sound doesn't have anymore data to
decode,
// and doesn't loop (anymore), but still got unplayed
data,
// we put the last data on the stream
- } else if (sound->rawDataSize() - sound->raw_position
<= buffer_length && sound->rawDataSize() > sound->raw_position+1) {
-
-
- do_mixing(stream, sound,
sound->get_raw_data_ptr(sound->raw_position),
- sound->rawDataSize() -
sound->raw_position, sounddata->volume);
+ else if (sound.rawDataSize() - sound.raw_position <= buffer_length &&
sound.rawDataSize() > sound.raw_position+1)
+ {
- sound->raw_position = sound->rawDataSize();
- }
- // Sound is done, remove it from the active list
- if (sound->position == sound->dataSize() &&
sound->raw_position == sound->rawDataSize() && sound->loop_count == 0) {
-
sounddata->m_active_sounds.erase(sounddata->m_active_sounds.begin() + j);
- handler->soundsPlaying--;
- handler->_soundsStopped++;
+ do_mixing(buffer, sound,
sound.get_raw_data_ptr(sound.raw_position),
+ sound.rawDataSize() - sound.raw_position,
sounddata.volume);
+ sound.raw_position = sound.rawDataSize();
}
- } // active sounds loop
- } // existing sounds loop
-
- //
- // WRITE CONTENTS OF stream TO FILE
- //
- if (handler->file_stream) {
- handler->file_stream.write((char*) stream, buffer_length_in);
- // now, mute all audio
- memset ((void*) stream, 0, buffer_length_in);
- }
-
-
-
}
+/*private*/
void
-sound_data::clearActiveSounds()
+SDL_sound_handler::mixSoundData(sound_data& sounddata, Uint8* buffer, unsigned
int buffer_length)
{
- for (ActiveSounds::iterator i=m_active_sounds.begin(),
e=m_active_sounds.end(); i!=e; ++i)
+ // TODO: don't call size() on every iteration
+ for(boost::uint32_t i = 0; i<sounddata.m_active_sounds.size(); i++)
{
- delete *i;
+
+ // Temp variables to make the code simpler and easier to read
+ active_sound* sound = sounddata.m_active_sounds[i];
+
+ mixActiveSound(*sound, sounddata, buffer, buffer_length);
+
+ // Sound is done, remove it from the active list
+ if (sound->position == sound->dataSize() && sound->raw_position
== sound->rawDataSize() && sound->loop_count == 0)
+ {
+ sounddata.eraseActiveSound(i);
+ soundsPlaying--;
+ _soundsStopped++;
+
+ }
}
- m_active_sounds.clear();
}
-
} // gnash.media namespace
} // namespace gnash
Index: libmedia/ffmpeg/sound_handler_sdl.h
===================================================================
RCS file: /sources/gnash/gnash/libmedia/ffmpeg/sound_handler_sdl.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- libmedia/ffmpeg/sound_handler_sdl.h 9 Jun 2008 18:12:56 -0000 1.12
+++ libmedia/ffmpeg/sound_handler_sdl.h 11 Jun 2008 14:40:27 -0000 1.13
@@ -23,6 +23,7 @@
#include "sound_handler.h" // for inheritance
#include "AudioDecoder.h"
+#include "Buffer.h"
#include "log.h"
@@ -86,6 +87,7 @@
void append(boost::uint8_t* data, unsigned int size)
{
_buf.append(data, size);
+ delete [] data; // since ownership was transferred...
}
/// Return size of the data buffer
@@ -110,7 +112,8 @@
/// An assertion will fail if pos > size()
///
const boost::uint8_t* data(size_t pos) const {
- return _buf.data(pos);
+ assert(pos < _buf.size());
+ return _buf.data()+pos;
}
/// Return a pointer to an offset in the underlying buffer
@@ -119,7 +122,8 @@
/// An assertion will fail if pos > size()
///
boost::uint8_t* data(size_t pos) {
- return _buf.data(pos);
+ assert(pos < _buf.size());
+ return _buf.data()+pos;
}
/// Volume for AS-sounds, range: 0-100.
@@ -136,6 +140,12 @@
/// Drop all active sounds
void clearActiveSounds();
+
+ /// Drop an active sound
+ void eraseActiveSound(size_t i)
+ {
+ m_active_sounds.erase(m_active_sounds.begin() + i);
+ }
};
/// Used to hold the info about active sounds
@@ -247,12 +257,12 @@
{
if ( ! _decodedData.get() )
{
- _decodedData.reset( new Buffer(data, size) );
- }
- else
- {
- _decodedData->assign(data, size);
+ _decodedData.reset( new Buffer() );
}
+
+ _decodedData->resize(0); // shouldn't release memory
+ _decodedData->append(data, size);
+ delete [] data; // ownership transferred...
}
size_t rawDataSize() const
@@ -328,6 +338,10 @@
// write a .WAV file header
void write_wave_header(std::ofstream& outfile);
+ void mixSoundData(sound_data& sounddata, Uint8* stream, unsigned int
buffer_length);
+
+ void mixActiveSound(active_sound& sound, sound_data& sounddata, Uint8*
stream, unsigned int buffer_length);
+
public:
SDL_sound_handler();
SDL_sound_handler(const std::string& wave_file);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog libmedia/sound_handler.h libmed...,
Sandro Santilli <=