gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/swf/StartSoundTag.cpp se...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/swf/StartSoundTag.cpp se...
Date: Fri, 23 Nov 2007 23:37:04 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/11/23 23:37:04

Modified files:
        .              : ChangeLog 
        server/swf     : StartSoundTag.cpp StartSoundTag.h 

Log message:
        some more cleanup (attempt).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4947&r2=1.4948
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/StartSoundTag.cpp?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/StartSoundTag.h?cvsroot=gnash&r1=1.1&r2=1.2

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4947
retrieving revision 1.4948
diff -u -b -r1.4947 -r1.4948
--- ChangeLog   23 Nov 2007 22:55:16 -0000      1.4947
+++ ChangeLog   23 Nov 2007 23:37:03 -0000      1.4948
@@ -1,3 +1,7 @@
+2007-11-23 Sandro Santilli <address@hidden>
+
+       * server/swf/StartSoundTag.{cpp,h}: some more cleanup (attempt).
+
 2007-11-23 Bastiaan Jacques <address@hidden>
 
        * backend/render_handler_ogl.cpp: Implement nested masks. Also take

Index: server/swf/StartSoundTag.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/StartSoundTag.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- server/swf/StartSoundTag.cpp        23 Nov 2007 22:23:25 -0000      1.1
+++ server/swf/StartSoundTag.cpp        23 Nov 2007 23:37:04 -0000      1.2
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: StartSoundTag.cpp,v 1.1 2007/11/23 22:23:25 strk Exp $ */
+/* $Id: StartSoundTag.cpp,v 1.2 2007/11/23 23:37:04 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -32,43 +32,51 @@
 namespace gnash {
 namespace SWF {
 
+/* public static */
 void
 StartSoundTag::loader(stream* in, tag_type tag, movie_definition* m)
 {
+       assert(tag == SWF::STARTSOUND); // 15 
+
+       // Make static ?
     sound_handler* handler = get_sound_handler();
 
-    assert(tag == SWF::STARTSOUND); // 15 
+       in->ensureBytes(2); // sound_id
 
-    uint16_t   sound_id = in->read_u16();
+       int sound_id = in->read_u16();
 
     sound_sample* sam = m->get_sound_sample(sound_id);
-    if (sam)
-    {
-       StartSoundTag*  sst = new StartSoundTag();
-       sst->read(in, tag, m, sam);
-
-       IF_VERBOSE_PARSE
-       (
-           log_parse(_("start_sound tag: id=%d, stop = %d, loop ct = %d"),
-                     sound_id, int(sst->m_stop_playback), sst->m_loop_count);
-       );
-    }
-    else
+       if ( ! sam ) // invalid id... nothing to do
     {
+               IF_VERBOSE_MALFORMED_SWF(
+               // if there's no sound_handler we might have simply skipped
+               // the definition of sound sample...
        if (handler)
        {
-           IF_VERBOSE_MALFORMED_SWF(
                log_swferror(_("start_sound_loader: sound_id %d is not 
defined"), sound_id);
-           );
        }
+               );
+
+               return;
     }
+
+       // NOTE: sound_id != sam->m_sound_handler_id
+       StartSoundTag*  sst = new StartSoundTag(sam->m_sound_handler_id);
+       sst->read(in, tag, m);
+
+       IF_VERBOSE_PARSE (
+       log_parse(_("StartSound: id=%d, stop = %d, loop ct = %d"),
+               sound_id, int(sst->m_stop_playback), sst->m_loop_count);
+       );
+
+       m->addControlTag(sst); // takes ownership
 }
 
+/* private */
 void
-StartSoundTag::read(stream* in, int /* tag_type */, movie_definition* m,
-               const sound_sample* sam)
+StartSoundTag::read(stream* in, int /* tag_type */, movie_definition* m)
 {
-       assert(sam);
+       in->ensureBytes(1); // header
 
        in->read_uint(2);       // skip reserved bits.
        m_stop_playback = in->read_bit(); 
@@ -83,14 +91,20 @@
        
        uint32_t        in_point = 0;
        uint32_t        out_point = 0;
+
+       in->ensureBytes(has_in_point*4 + has_out_point*4 + has_loops*2);
+
        if (has_in_point) { in_point = in->read_u32(); }
        if (has_out_point) { out_point = in->read_u32(); }
        if (has_loops) { m_loop_count = in->read_u16(); }
 
        if (has_envelope)
        {
+               in->ensureBytes(1);
                int nPoints = in->read_u8();
+
                m_envelopes.resize(nPoints);
+               in->ensureBytes(8*nPoints);
                for (int i=0; i < nPoints; i++)
                {
                        m_envelopes[i].m_mark44 = in->read_u32();
@@ -98,13 +112,7 @@
                        m_envelopes[i].m_level1 = in->read_u16();
                }
        }
-       else
-       {
-               m_envelopes.resize(0);
-       }
 
-       m_handler_id = sam->m_sound_handler_id;
-       m->addControlTag(this);
 }
 
 
@@ -124,7 +132,7 @@
                }
                else
                {
-                       handler->play_sound(m_handler_id, m_loop_count, 0,0, 
(m_envelopes.size() == 0 ? NULL : &m_envelopes));
+                       handler->play_sound(m_handler_id, m_loop_count, 0, 0, 
(m_envelopes.empty() ? NULL : &m_envelopes));
                }
        }
 }

Index: server/swf/StartSoundTag.h
===================================================================
RCS file: /sources/gnash/gnash/server/swf/StartSoundTag.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- server/swf/StartSoundTag.h  23 Nov 2007 22:23:25 -0000      1.1
+++ server/swf/StartSoundTag.h  23 Nov 2007 23:37:04 -0000      1.2
@@ -59,18 +59,22 @@
        uint32_t* envelopes;
 
        /// \brief
-       /// Initialize this StartSoundTag from
-       /// the stream  & given sample.
+       /// Initialize this StartSoundTag from the stream  
        //
-       /// Insert ourself into the movie.
+       /// The stream is assumed to be positioned right after the
+       /// sound_id field of the tag structure.
        ///
-       void read(stream* in, int tag_type,
-               movie_definition* m, const sound_sample* sam);
+       void read(stream* in, int tag_type, movie_definition* m);
 
 
-       StartSoundTag()
+       /// Create a StartSoundTag for starting the given sound sample
+       //
+       /// @param sound_handler_id
+       /// Sound sample identifier as provided by sound_handler (sic!)
+       ///
+       StartSoundTag(int sound_id)
                :
-               m_handler_id(0),
+               m_handler_id(sound_id),
                m_loop_count(0),
                m_stop_playback(false)
        {




reply via email to

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