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. ecb10a6abe06fc90ea44


From: Sandro Santilli
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. ecb10a6abe06fc90ea44bf288874ec2a3d1852ef
Date: Fri, 22 Oct 2010 19:29:36 +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  ecb10a6abe06fc90ea44bf288874ec2a3d1852ef (commit)
       via  1e4cafce392b710b76b218b79f50c21cb203201d (commit)
      from  47a20a77980ca65fe3dccab1565d346b3eae8569 (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=ecb10a6abe06fc90ea44bf288874ec2a3d1852ef


commit ecb10a6abe06fc90ea44bf288874ec2a3d1852ef
Author: Sandro Santilli <address@hidden>
Date:   Fri Oct 22 21:27:49 2010 +0200

    Have dump-gui use NullSoundHandler to manually fetch samples at a 
predictable rate to improve sync between streaming and event sound (and video). 
Use the configured sound handler as a pure mixer (worth cleaning things up here 
to allow _only_ using a mixer from a factory)

diff --git a/gui/dump.cpp b/gui/dump.cpp
index 6a534f9..99b6f20 100644
--- a/gui/dump.cpp
+++ b/gui/dump.cpp
@@ -37,6 +37,7 @@
 #include "VM.h"
 #include "GnashSleep.h"
 #include "RunResources.h"
+#include "NullSoundHandler.h"
 
 #include <iostream>
 #include <string>
@@ -138,6 +139,11 @@ DumpGui::init(int argc, char **argv[])
     _renderer.reset(create_Renderer_agg(_pixelformat.c_str()));
     _runResources.setRenderer(_renderer);
 
+    sound_handler* mixer = _runResources.soundHandler();
+    MediaHandler* mh = _runResources.mediaHandler();
+    _soundHandler.reset(new NullSoundHandler(mh, mixer));
+    _runResources.setSoundHandler(_soundHandler);
+
     // We know what type of renderer it is.
     _agg_renderer = static_cast<Renderer_agg_base*>(_renderer.get());
     
@@ -152,10 +158,9 @@ DumpGui::run()
 
     size_t usecs_interval = _interval*1000;
 
-    WallClockTimer timer;
+    VirtualClock& timer = getClock();
 
     _terminate_request = false;
-
     while (!_terminate_request) {
 
         // advance movie now
@@ -163,13 +168,16 @@ DumpGui::run()
             ++_framecount;
             writeFrame();
         }
-  
-        gnashSleep(usecs_interval);
+
+        writeSamples();
 
         // check if we've reached a timeout
         if (_timeout && timer.elapsed() > _timeout ) {
-            _terminate_request = true;
+            break;
         }
+
+        gnashSleep(usecs_interval);
+
     }
 
     boost::uint32_t total_time = timer.elapsed();
@@ -219,6 +227,44 @@ DumpGui::writeFrame()
 }
 
 void
+DumpGui::writeSamples()
+{
+    VirtualClock& timer = getClock();
+    sound::sound_handler* sh = _runResources.soundHandler();
+
+    unsigned int ms = timer.elapsed();
+
+    // We need to fetch as many samples
+    // as needed for a theoretical 44100hz loop.
+    // That is 44100 samples each second.
+    // 44100/1000 = x/ms
+    //  x = (44100*ms) / 1000
+    unsigned int nSamples = (441*ms) / 10;
+
+    // We double because sound_handler interface takes
+    // "mono" samples... (eh.. would be wise to change)
+    unsigned int toFetch = nSamples*2;
+
+    // Now substract what we fetched already
+    toFetch -= _samplesFetched;
+
+    // And update _samplesFetched..
+    _samplesFetched += toFetch;
+
+    //log_debug("DumpGui::writeSamples(%d) fetching %d samples", ms, toFetch);
+
+    boost::int16_t samples[1024];
+    while (toFetch) {
+        unsigned int n = std::min(toFetch, 1024u);
+        // Fetching samples should trigger writing to file
+        sh->fetchSamples(samples, n);
+        toFetch -= n;
+    }
+
+}
+
+
+void
 DumpGui::init_dumpfile()
 {
     // May be empty if only screenshots are required.
diff --git a/gui/dump.h b/gui/dump.h
index e60d9bb..ccb15f6 100644
--- a/gui/dump.h
+++ b/gui/dump.h
@@ -25,9 +25,11 @@
 
 #include "dsodefs.h" // for DSOEXPORT
 #include "gui.h" // for inheritance
+
 #include <string>
 #include <fstream>
 #include <boost/scoped_array.hpp>
+#include <boost/shared_ptr.hpp>
 
 namespace gnash
 {
@@ -67,6 +69,7 @@ class DSOEXPORT DumpGui : public Gui
     bool want_multiple_regions() { return true; }
     bool want_redraw() { return false; }
     void writeFrame();
+    void writeSamples();
 
 private:
     
@@ -82,6 +85,7 @@ private:
 
     unsigned int _timeout;              /* maximum length of movie */
     unsigned int _framecount;           /* number of frames rendered */
+    unsigned int _samplesFetched;       /* number of samples fetched */
 
     unsigned int _bpp;                  /* bits per pixel */
     std::string _pixelformat;              /* colorspace name (eg, "RGB24") */
@@ -90,6 +94,8 @@ private:
     std::ofstream _fileStream;        /* stream for output file */
     void init_dumpfile();               /* convenience method to create dump 
file */
 
+    boost::shared_ptr<sound::sound_handler> _soundHandler;
+
 
 
 };

http://git.savannah.gnu.org/cgit//commit/?id=1e4cafce392b710b76b218b79f50c21cb203201d


commit 1e4cafce392b710b76b218b79f50c21cb203201d
Author: Sandro Santilli <address@hidden>
Date:   Fri Oct 22 21:26:31 2010 +0200

    Take the mixer by raw pointer... since there's no way to get a shared_ptr 
from RunResource...

diff --git a/libsound/NullSoundHandler.h b/libsound/NullSoundHandler.h
index 6874110..3f9d697 100644
--- a/libsound/NullSoundHandler.h
+++ b/libsound/NullSoundHandler.h
@@ -23,7 +23,6 @@
 
 #include "sound_handler.h" // for inheritance
 #include "dsodefs.h" // for DSOEXPORT
-#include <boost/shared_ptr.hpp> 
 
 namespace gnash {
 
@@ -38,9 +37,9 @@ class DSOEXPORT NullSoundHandler : public sound_handler
 {
 public:
 
-    boost::shared_ptr<sound_handler> _mixer;
+    sound_handler* _mixer;
 
-    NullSoundHandler(media::MediaHandler* m, boost::shared_ptr<sound_handler> 
mixer=boost::shared_ptr<sound_handler>((sound_handler*)0))
+    NullSoundHandler(media::MediaHandler* m, sound_handler* mixer=0)
         :
         sound_handler(m),
         _mixer(mixer)

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

Summary of changes:
 gui/dump.cpp                |   56 +++++++++++++++++++++++++++++++++++++++----
 gui/dump.h                  |    6 ++++
 libsound/NullSoundHandler.h |    5 +--
 3 files changed, 59 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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