[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11011: Close audio card on gnash pa
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11011: Close audio card on gnash pause, and resume on unpause. Drops audio card interrupts while paused. |
Date: |
Sat, 06 Jun 2009 01:55:37 +0200 |
User-agent: |
Bazaar (1.13.1) |
------------------------------------------------------------
revno: 11011
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Sat 2009-06-06 01:55:37 +0200
message:
Close audio card on gnash pause, and resume on unpause. Drops audio card
interrupts while paused.
modified:
libsound/sdl/sound_handler_sdl.cpp
libsound/sdl/sound_handler_sdl.h
=== modified file 'libsound/sdl/sound_handler_sdl.cpp'
--- a/libsound/sdl/sound_handler_sdl.cpp 2009-02-25 22:33:03 +0000
+++ b/libsound/sdl/sound_handler_sdl.cpp 2009-06-05 23:55:37 +0000
@@ -95,16 +95,36 @@
//512 - not enough for videostream
audioSpec.samples = 2048;
+ openAudio();
+
+}
+
+void
+SDL_sound_handler::openAudio()
+{
+ if ( _audioOpened ) return; // nothing to do
+
if (SDL_OpenAudio(&audioSpec, NULL) < 0 ) {
boost::format fmt = boost::format(
_("Unable to open SDL audio: %s"))
% SDL_GetError();
throw SoundException(fmt.str());
}
+
+ _audioOpened = true;
+}
+
+void
+SDL_sound_handler::closeAudio()
+{
+ SDL_CloseAudio();
+ _audioOpened = false;
}
SDL_sound_handler::SDL_sound_handler(const std::string& wavefile)
+ :
+ _audioOpened(false)
{
initAudio();
@@ -124,6 +144,8 @@
}
SDL_sound_handler::SDL_sound_handler()
+ :
+ _audioOpened(false)
{
initAudio();
}
@@ -416,6 +438,24 @@
return sound_handler::is_muted();
}
+void
+SDL_sound_handler::pause()
+{
+ closeAudio();
+
+ sound_handler::pause();
+}
+
+void
+SDL_sound_handler::unpause()
+{
+ openAudio();
+
+ if ( hasInputStreams() ) SDL_PauseAudio(0);
+
+ sound_handler::unpause();
+}
+
} // gnash.sound namespace
} // namespace gnash
=== modified file 'libsound/sdl/sound_handler_sdl.h'
--- a/libsound/sdl/sound_handler_sdl.h 2009-02-25 22:33:03 +0000
+++ b/libsound/sdl/sound_handler_sdl.h 2009-06-05 23:55:37 +0000
@@ -51,6 +51,12 @@
/// Initialize audio card
void initAudio();
+
+ void openAudio();
+
+ void closeAudio();
+
+ bool _audioOpened;
/// Mutex for making sure threads doesn't mess things up
boost::mutex _mutex;
@@ -144,6 +150,14 @@
virtual bool is_muted() const;
// See dox in sound_handler.h
+ // overridden to close audio card
+ virtual void pause();
+
+ // See dox in sound_handler.h
+ // overridden to open audio card
+ virtual void unpause();
+
+ // See dox in sound_handler.h
virtual unsigned int get_duration(int sound_handle);
// See dox in sound_handler.h
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11011: Close audio card on gnash pause, and resume on unpause. Drops audio card interrupts while paused.,
Sandro Santilli <=