gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog backend/sound_handler_sdl.cpp [release_0_


From: Tomas Groth
Subject: [Gnash-commit] gnash ChangeLog backend/sound_handler_sdl.cpp [release_0_7_2]
Date: Mon, 06 Nov 2006 21:03:24 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Branch:         release_0_7_2
Changes by:     Tomas Groth <tgc>       06/11/06 21:03:24

Modified files:
        .              : ChangeLog 
        backend        : sound_handler_sdl.cpp 

Log message:
        Make mp3-decoding with mad work when the stream is not fully loaded 
when playback starts. Fixes bug #18207.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&only_with_tag=release_0_7_2&r1=1.1412.2.100&r2=1.1412.2.101
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.3&r2=1.29.2.4

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1412.2.100
retrieving revision 1.1412.2.101
diff -u -b -r1.1412.2.100 -r1.1412.2.101
--- ChangeLog   6 Nov 2006 19:27:41 -0000       1.1412.2.100
+++ ChangeLog   6 Nov 2006 21:03:23 -0000       1.1412.2.101
@@ -1,3 +1,9 @@
+2006-11-06 Tomas Groth Christensen <tomas@>
+
+       * backend/sound_handler_sdl.cpp: Make mp3-decoding with mad work
+         when the stream is not fully loaded when playback starts. Fixes
+         bug #18207.
+
 2006-11-06  Rob Savoye  <address@hidden>
 
        * plugin/Makefile.am: Put back in the KLASH conditional so klash

Index: backend/sound_handler_sdl.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_sdl.cpp,v
retrieving revision 1.29.2.3
retrieving revision 1.29.2.4
diff -u -b -r1.29.2.3 -r1.29.2.4
--- backend/sound_handler_sdl.cpp       3 Nov 2006 11:14:27 -0000       1.29.2.3
+++ backend/sound_handler_sdl.cpp       6 Nov 2006 21:03:24 -0000       1.29.2.4
@@ -219,13 +219,6 @@
                for(uint32_t i=0; i < 
m_sound_data[handle_id]->m_active_sounds.size(); i++) {
                        m_sound_data[handle_id]->m_active_sounds[i]->data = 
m_sound_data[handle_id]->data;
                        m_sound_data[handle_id]->m_active_sounds[i]->data_size 
= m_sound_data[handle_id]->data_size;
-#ifdef USE_MAD
-                       uint64_t this_frame = (const 
Uint8*)m_sound_data[handle_id]->m_active_sounds[i]->stream.this_frame - 
m_sound_data[handle_id]->m_active_sounds[i]->data;
-                       uint64_t next_frame = (const 
Uint8*)m_sound_data[handle_id]->m_active_sounds[i]->stream.next_frame - 
m_sound_data[handle_id]->m_active_sounds[i]->data;
-                       
mad_stream_buffer(&m_sound_data[handle_id]->m_active_sounds[i]->stream, 
m_sound_data[handle_id]->data, m_sound_data[handle_id]->data_size);
-                       
m_sound_data[handle_id]->m_active_sounds[i]->stream.this_frame += this_frame;
-                       
m_sound_data[handle_id]->m_active_sounds[i]->stream.next_frame += next_frame;
-#endif
                }
 
        } else {
@@ -267,10 +260,12 @@
        sound->data = m_sound_data[sound_handle]->data;
 
        // Set the given options of the sound
-       sound->position = start_position;
        if (start_position < 0) sound->position = 0;
-       sound->offset = (m_sound_data[sound_handle]->stereo ? offset : 
offset*2); // offset is stored as stereo
+       else sound->position = start_position;
+
        if (offset < 0) sound->offset = 0;
+       else sound->offset = (m_sound_data[sound_handle]->stereo ? offset : 
offset*2); // offset is stored as stereo
+
        sound->envelopes = envelopes;
        sound->current_env = 0;
        sound->samples_played = 0;
@@ -306,7 +301,6 @@
                mad_stream_init(&sound->stream);
                mad_frame_init(&sound->frame);
                mad_synth_init(&sound->synth);
-               mad_stream_buffer(&sound->stream, sound->data+sound->position, 
sound->data_size-sound->position);
 
                sound->raw_data = 0;
                sound->raw_data_size = 0;
@@ -738,29 +732,42 @@
                                // If we need to loop, we reset the data 
pointer, and tell mad about it
                                if (sound->data_size == sound->position && 
sound->loop_count != 0) {
                                        sound->position = 0;
-                                       mad_stream_buffer(&sound->stream, 
sound->data, sound->data_size);
                                        sound->loop_count--;
                                }
 
+                               mad_stream_buffer(&sound->stream, 
sound->data+sound->position, sound->data_size-sound->position);
+
                                int ret;
+                               const unsigned char* old_next_frame = 
sound->stream.next_frame;
+                               int loops = 0;
                                while(true) {
+
                                        ret = mad_frame_decode(&sound->frame, 
&sound->stream);
+                                       loops++;
                                        
                                        // There is always some junk in front 
of the data, 
                                        // so we continue until we get past it.
                                        if (ret && sound->stream.error == 
MAD_ERROR_LOSTSYNC) continue;
                                        
+                                       // Error handling is done by relooping 
(max. 8 times) and just hooping that it will work...
+                                       if (loops > 8) break;
+                                       if (ret == -1 && sound->stream.error != 
MAD_ERROR_BUFLEN && MAD_RECOVERABLE(sound->stream.error)) {
+                                               gnash::log_warning("Recoverable 
error while decoding MP3-stream, MAD error: %s", mad_stream_errorstr 
(&sound->stream));
+                                               continue;
+                                       }
+                                       
                                        break;
                                }
 
                                if (ret == -1 && sound->stream.error != 
MAD_ERROR_BUFLEN) {
-                                       gnash::log_error("Error while decoding 
MP3-stream, MAD error: %d", sound->stream.error);
+                                       gnash::log_error("Unrecoverable error 
while decoding MP3-stream, MAD error: %s", mad_stream_errorstr 
(&sound->stream));
+                                       sound->position = sound->data_size;
                                        continue;
                                } else if (ret == -1 && sound->stream.error == 
MAD_ERROR_BUFLEN) {
                                        // the buffer is empty, no more to 
decode!
                                        sound->position = sound->data_size;
                                } else {
-                                       sound->position += 
sound->stream.next_frame - sound->stream.buffer - sound->position;
+                                       sound->position += 
sound->stream.next_frame - old_next_frame;
                                }
 
                                mad_synth_frame (&sound->synth, &sound->frame);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]