[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog backend/sound_handler_sdl.cpp b... [relea
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog backend/sound_handler_sdl.cpp b... [release_0_7_2] |
Date: |
Wed, 01 Nov 2006 16:23:59 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Branch: release_0_7_2
Changes by: Sandro Santilli <strk> 06/11/01 16:23:59
Modified files:
. : ChangeLog
backend : sound_handler_sdl.cpp sound_handler_sdl.h
Log message:
* backend/sound_handler_sdl.{h,cpp}:
use more unsigned types (remove compiler warnings);
properly check sdl_audio_callback 'length' argument;
minor style nits.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.1412.2.38&r2=1.1412.2.39
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_sdl.cpp?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.29.2.1&r2=1.29.2.2
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_sdl.h?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.7&r2=1.7.2.1
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1412.2.38
retrieving revision 1.1412.2.39
diff -u -b -r1.1412.2.38 -r1.1412.2.39
--- ChangeLog 1 Nov 2006 16:20:22 -0000 1.1412.2.38
+++ ChangeLog 1 Nov 2006 16:23:59 -0000 1.1412.2.39
@@ -1,3 +1,10 @@
+2006-11-01 Sandro Santilli <address@hidden>
+
+ * backend/sound_handler_sdl.{h,cpp}:
+ use more unsigned types (remove compiler warnings);
+ properly check sdl_audio_callback 'length' argument;
+ minor style nits.
+
2006-11-01 Hiroyuki Ikezoe <address@hidden>
* backend/sound_handler_gst.cpp:
Index: backend/sound_handler_sdl.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_sdl.cpp,v
retrieving revision 1.29.2.1
retrieving revision 1.29.2.2
diff -u -b -r1.29.2.1 -r1.29.2.2
--- backend/sound_handler_sdl.cpp 30 Oct 2006 20:54:46 -0000 1.29.2.1
+++ backend/sound_handler_sdl.cpp 1 Nov 2006 16:23:59 -0000 1.29.2.2
@@ -33,7 +33,7 @@
#include <SDL.h>
-void sdl_audio_callback(void *udata, Uint8 *stream, int len); // SDL C audio
handler
+static void sdl_audio_callback(void *udata, Uint8 *stream, int len); // SDL C
audio handler
@@ -56,7 +56,8 @@
SDL_sound_handler::~SDL_sound_handler()
{
- for (size_t i= m_sound_data.size(); i > 0; i--) {
+ for (size_t i=0, e=m_sound_data.size(); i < e; ++i)
+ {
stop_sound(i);
delete_sound(i);
}
@@ -576,14 +577,18 @@
}
// envelope-volume adjustment
-void use_envelopes(active_sound* sound, int length)
+static void
+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->operator[](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->operator[](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++;
}
@@ -591,26 +596,26 @@
int32_t cur_env_pos =
sound->envelopes->operator[](sound->current_env).m_mark44;
// Next envelope position
- int32_t next_env_pos = 0;
+ uint32_t next_env_pos = 0;
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->operator[](sound->current_env+1).m_mark44;
+ next_env_pos =
(*sound->envelopes)[sound->current_env+1].m_mark44;
}
int startpos = 0;
// Make sure we start adjusting at the right sample
- if (sound->current_env == 0 &&
sound->envelopes->operator[](sound->current_env).m_mark44 >
sound->samples_played) {
- startpos = sound->raw_position +
(sound->envelopes->operator[](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;
}
int16_t* data = (int16_t*) (sound->raw_data + startpos);
- for (int i=0; i < length/2; i+=2) {
- float left =
(float)sound->envelopes->operator[](sound->current_env).m_level0 / 32768.0;
- float right =
(float)sound->envelopes->operator[](sound->current_env).m_level1 / 32768.0;
+ for (unsigned int i=0; i < length/2; i+=2) {
+ float left =
(float)(*sound->envelopes)[sound->current_env].m_level0 / 32768.0;
+ float right =
(float)(*sound->envelopes)[sound->current_env].m_level1 / 32768.0;
data[i] = (int16_t)(data[i] * left); // Left
data[i+1] = (int16_t)(data[i+1] * right); // Right
@@ -630,8 +635,18 @@
// The callback function which refills the buffer with data
-void sdl_audio_callback (void *udata, Uint8 *stream, int buffer_length)
+static void
+sdl_audio_callback (void *udata, Uint8 *stream, int buffer_length_in)
{
+
+ if ( buffer_length_in < 0 )
+ {
+ gnash::log_error("Negative buffer length in sdl_audio_callback
(%d)", buffer_length_in);
+ return;
+ }
+
+ unsigned int buffer_length = static_cast<unsigned
int>(buffer_length_in);
+
// We run through all of the sounds, and mix all of the active sounds
// into the stream given by the callback.
// If a sound is looping it will be decoded from the beginning again.
@@ -665,7 +680,7 @@
&& (sound->position < sound->data_size ||
sound->loop_count != 0)) {
// First we mix what is decoded
- int index = 0;
+ unsigned int index = 0;
if (sound->raw_data_size - sound->raw_position
> 0) {
// If the volume needs adjustments we
call a function to do that
if (handler->m_sound_data[i]->volume !=
100) {
@@ -673,6 +688,7 @@
sound->raw_data_size -
sound->raw_position,
handler->m_sound_data[i]->volume);
} else if (sound->envelopes != NULL) {
+ assert(sound->raw_data_size >=
sound->raw_position);
use_envelopes(sound,
sound->raw_data_size - sound->raw_position);
}
SDL_MixAudio(stream, (const
Uint8*)(sound->raw_data + sound->raw_position),
@@ -816,6 +832,7 @@
sound->raw_data_size -
sound->raw_position,
handler->m_sound_data[i]->volume);
} else if (sound->envelopes != NULL) {
+ assert(buffer_length >= index);
use_envelopes(sound, buffer_length -
index);
}
Index: backend/sound_handler_sdl.h
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_sdl.h,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -b -r1.7 -r1.7.2.1
--- backend/sound_handler_sdl.h 21 Oct 2006 09:54:44 -0000 1.7
+++ backend/sound_handler_sdl.h 1 Nov 2006 16:23:59 -0000 1.7.2.1
@@ -46,28 +46,28 @@
#endif
// data size
- long data_size;
+ unsigned long data_size;
// position in the stream
- long position;
+ unsigned long position;
// The compressed data
uint8_t* data;
// data size
- long raw_data_size;
+ unsigned long raw_data_size;
// position in the raw stream
- long raw_position;
+ unsigned long raw_position;
// The decompressed data
uint8_t* raw_data;
- // Numbers of loops
+ /// Numbers of loops: -1 means loop forever, 0 means play once
long loop_count;
// Offset, only used with mp3 streams
- int offset;
+ unsigned int offset;
// Envelopes
std::vector<gnash::sound_handler::sound_envelope>* envelopes;
@@ -76,7 +76,7 @@
uint32_t current_env;
// Number if samples played
- long samples_played;
+ unsigned long samples_played;
} active_sound;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog backend/sound_handler_sdl.cpp b... [release_0_7_2],
Sandro Santilli <=