gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r11019: Open audio card lazily, to


From: Sandro Santilli
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11019: Open audio card lazily, to save lots of wakeups (at least with HDA Intel) when sound is not even needed, or at least until it is...
Date: Sun, 07 Jun 2009 02:17:31 +0200
User-agent: Bazaar (1.13.1)

------------------------------------------------------------
revno: 11019
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Sun 2009-06-07 02:17:31 +0200
message:
  Open audio card lazily, to save lots of wakeups (at least with HDA Intel) 
when sound is not even needed, or at least until it is...
modified:
  libsound/sdl/sound_handler_sdl.cpp
=== modified file 'libsound/sdl/sound_handler_sdl.cpp'
--- a/libsound/sdl/sound_handler_sdl.cpp        2009-06-06 23:29:42 +0000
+++ b/libsound/sdl/sound_handler_sdl.cpp        2009-06-07 00:17:31 +0000
@@ -95,7 +95,13 @@
     //512 - not enough for  videostream
     audioSpec.samples = 2048;   
 
+    // NOTE: we open and close the audio card for the sole purpose
+    //       of throwing an exception on error (unavailable audio
+    //       card). Normally we'd want to open the audio card only
+    //       when needed (it has a cost in number of wakeups).
+    //
     openAudio();
+    closeAudio();
 
 }
 
@@ -383,12 +389,15 @@
 
     sound_handler::plugInputStream(newStreamer);
 
-    lock.unlock(); // we need to unlock before unpausing (right?)
+    { // TODO: this whole block should only be executed when adding
+      // the first stream. 
 
 #ifdef GNASH_DEBUG_SDL_AUDIO_PAUSING
-    log_debug("Unpausing SDL Audio...");
+        log_debug("Unpausing SDL Audio on inpust stream plug...");
 #endif
-    SDL_PauseAudio(0);
+        openAudio(); // lazy sound card initialization
+        SDL_PauseAudio(0); // start polling data from us 
+    }
 }
 
 void
@@ -423,9 +432,11 @@
 void
 SDL_sound_handler::unpause() 
 {
-    openAudio();
-
-    if ( hasInputStreams() ) SDL_PauseAudio(0);
+    if ( hasInputStreams() )
+    {
+        openAudio();
+        SDL_PauseAudio(0);
+    }
 
     sound_handler::unpause();
 }


reply via email to

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