gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-


From: Sandro Santilli
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-269-g6b47871
Date: Fri, 15 Apr 2011 08:03:18 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  6b478714a7264187cce8bd6d24c458ed94441843 (commit)
      from  01751cbf0cb298150d37d436412143b58b108f73 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=6b478714a7264187cce8bd6d24c458ed94441843


commit 6b478714a7264187cce8bd6d24c458ed94441843
Author: Sandro Santilli <address@hidden>
Date:   Fri Apr 15 10:02:39 2011 +0200

    Implement onLoad callback for AS Sound object. Fixes #31314.

diff --git a/libcore/asobj/Sound_as.cpp b/libcore/asobj/Sound_as.cpp
index a70f62f..2af3c99 100644
--- a/libcore/asobj/Sound_as.cpp
+++ b/libcore/asobj/Sound_as.cpp
@@ -43,6 +43,7 @@
 #include "ObjectURI.h"
 #include "Relay.h"
 
+//#define GNASH_DEBUG_SOUND_AS 1
 
 namespace gnash {
 
@@ -234,7 +235,9 @@ private:
 
     /// Thread-safe setter for _soundCompleted
     void markSoundCompleted(bool completed);
-    
+
+    bool _soundLoaded;
+
     // Does this sound have a live input stream?
     bool isAttached() const {
         return (_inputStream);
@@ -257,7 +260,8 @@ Sound_as::Sound_as(as_object* owner)
     _leftOverSize(0),
     _inputStream(0),
     remainingLoops(0),
-    _soundCompleted(false)
+    _soundCompleted(false),
+    _soundLoaded(false)
 {
 }
 
@@ -345,6 +349,29 @@ void
 Sound_as::probeAudio()
 {
 
+    if (!_mediaParser) {
+        log_debug("Sound_as::probeAudio: no parser, nothing to probe for");
+        stopProbeTimer();
+        return;
+    }
+
+    if ( ! _soundLoaded ) {
+#ifdef GNASH_DEBUG_SOUND_AS
+        log_debug("Probing audio for load");
+#endif
+        if ( _mediaParser->parsingCompleted() )
+        {
+            _soundLoaded = true;
+            if ( ! isStreaming )
+            {
+                stopProbeTimer(); // will be re-started on Sound.start()
+            }
+            bool success = _mediaParser->getAudioInfo() != 0;
+            callMethod(&owner(), NSV::PROP_ON_LOAD, success);
+        }
+        return; 
+    }
+
     if (isAttached()) {
 #ifdef GNASH_DEBUG_SOUND_AS
         log_debug("Probing audio for end");
@@ -352,9 +379,12 @@ Sound_as::probeAudio()
 
         boost::mutex::scoped_lock lock(_soundCompletedMutex);
         if (_soundCompleted) {
-            // when _soundCompleted is true we're
-            // NOT attached !
-            _mediaParser.reset(); // no use for this anymore...
+            // when _soundCompleted is true we're NOT attached !
+            // MediaParser may be still needed,
+            // if this is a non-streaming sound
+            if ( isStreaming ) {
+                _mediaParser.reset(); // no use for this anymore...
+            }
             _inputStream = 0;
             _soundCompleted = false;
             stopProbeTimer();
@@ -363,13 +393,14 @@ Sound_as::probeAudio()
             callMethod(&owner(), NSV::PROP_ON_SOUND_COMPLETE);
         }
     }
-    else if (_mediaParser) {
+    else {
 #ifdef GNASH_DEBUG_SOUND_AS
         log_debug("Probing audio for start");
 #endif
 
         bool parsingCompleted = _mediaParser->parsingCompleted();
         try {
+            log_debug("Attaching aux streamer");
             _inputStream = attachAuxStreamerIfNeeded();
         } 
         catch (const MediaException& e) {
@@ -516,6 +547,11 @@ Sound_as::loadSound(const std::string& file, bool 
streaming)
         _inputStream = 0;
     }
 
+    
+    /// Mark sound as not being loaded
+    // TODO: should we check for _soundLoaded == true?
+    _soundLoaded = false;
+
     /// Delete any media parser being used (make sure we have detached!)
     _mediaParser.reset();
 
@@ -533,6 +569,8 @@ Sound_as::loadSound(const std::string& file, bool streaming)
                 rcfile.saveStreamingMedia()));
     if ( ! inputStream.get() ) {
         log_error( _("Gnash could not open this url: %s"), url );
+        // dispatch onLoad (false)
+        callMethod(&owner(), NSV::PROP_ON_LOAD, false);
         return;
     }
 
@@ -543,20 +581,15 @@ Sound_as::loadSound(const std::string& file, bool 
streaming)
     if ( ! _mediaParser ) {
         log_error(_("Unable to create parser for Sound at %s"), url);
         // not necessarely correct, the stream might have been found...
+        // dispatch onLoad (false)
+        callMethod(&owner(), NSV::PROP_ON_LOAD, false);
         return;
     }
 
     // TODO: use global _soundbuftime
     _mediaParser->setBufferTime(60000); // one minute buffer... should be fine
 
-    if (isStreaming) {
-        startProbeTimer();
-    } 
-    else {
-        LOG_ONCE(log_unimpl("Non-streaming Sound.loadSound: will behave "
-                    "as a streaming one"));
-        // if not streaming, we'll probe on .start()
-    }
+    startProbeTimer();
 
     VM& vm = getVM(owner());
     owner().set_member(getURI(vm, "duration"), getDuration());
@@ -641,13 +674,6 @@ Sound_as::start(double secOff, int loops)
             return;
         }
 
-        if (secOff > 0) {
-            _startTime = secOff * 1000;
-            boost::uint32_t seekms = boost::uint32_t(secOff * 1000);
-            // TODO: boost::mutex::scoped_lock parserLock(_parserMutex);
-            _mediaParser->seek(seekms); // well, we try...
-        }
-
         if (isStreaming) {
             IF_VERBOSE_ASCODING_ERRORS(
             log_aserror(_("Sound.start() has no effect on a streaming Sound"));
@@ -655,13 +681,21 @@ Sound_as::start(double secOff, int loops)
             return;
         }
 
+        // Always seek as we might be called during or after some playing...
+        {
+            _startTime = secOff * 1000;
+            boost::uint32_t seekms = boost::uint32_t(secOff * 1000);
+            // TODO: boost::mutex::scoped_lock parserLock(_parserMutex);
+            bool seeked = _mediaParser->seek(seekms); // well, we try...
+            log_debug("Seeked MediaParser to %d, returned: %d", seekms, 
seeked);
+        }
+
+
         // Save how many loops to do (not when streaming)
         if (loops > 0) {
             remainingLoops = loops;
         }
 
-        // TODO: we should really be waiting for the sound to be fully
-        //       loaded before starting to play it (!isStreaming case)
         startProbeTimer();
 
     } else {
diff --git a/testsuite/actionscript.all/Sound.as 
b/testsuite/actionscript.all/Sound.as
index 76efe10..1af1658 100644
--- a/testsuite/actionscript.all/Sound.as
+++ b/testsuite/actionscript.all/Sound.as
@@ -27,8 +27,6 @@ rcsid="$Id: Sound.as,v 1.1 2008/06/17 12:42:22 strk Exp $";
 
 endOfTest = function()
 {
-    // TODO: test non-streaming sound too !
-
 #if OUTPUT_VERSION > 5
     check_totals(108);
 #else
@@ -254,9 +252,12 @@ s.onSoundComplete = function()
 
     // fixing this might fix google dict
     // See https://savannah.gnu.org/bugs/index.php?31314
-    xcheck(s.onLoadCalled);
-    xcheck_equals(typeof(s.onLoadArg), 'boolean');
-    xcheck_equals(s.onLoadArg, true);
+    check(s.onLoadCalled);
+    check_equals(typeof(s.onLoadArg), 'boolean');
+    check_equals(s.onLoadArg, true);
+
+    // TODO: test non-streaming sound 
+    // TODO: test loadSound on unexistent sound 
 
     endOfTest();
 };

-----------------------------------------------------------------------

Summary of changes:
 libcore/asobj/Sound_as.cpp          |   80 +++++++++++++++++++++++++----------
 testsuite/actionscript.all/Sound.as |   11 +++--
 2 files changed, 63 insertions(+), 28 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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