From aafdd144d2e108e9a601603cc0d8ccbf532242e7 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Fri, 1 Dec 2006 16:27:30 +0000 Subject: [PATCH] fixed #2067 --- .../src/products/gLiveSupport/src/GLiveSupport.cxx | 14 +++++++++++++- .../src/products/gLiveSupport/src/GLiveSupport.h | 7 ++++++- .../products/gLiveSupport/src/OptionsWindow.cxx | 7 +++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/campcaster/src/products/gLiveSupport/src/GLiveSupport.cxx b/campcaster/src/products/gLiveSupport/src/GLiveSupport.cxx index 6e8b46895..4b252c832 100644 --- a/campcaster/src/products/gLiveSupport/src/GLiveSupport.cxx +++ b/campcaster/src/products/gLiveSupport/src/GLiveSupport.cxx @@ -1622,13 +1622,22 @@ GLiveSupport :: setCueAudioDevice(Ptr::Ref deviceName) *----------------------------------------------------------------------------*/ void LiveSupport :: GLiveSupport :: -GLiveSupport :: playTestSoundOnCue(void) throw () +GLiveSupport :: playTestSoundOnCue(Ptr::Ref oldDevice, + Ptr::Ref newDevice) + throw () { if (cueItemPlayingNow) { stopCueAudio(); // stop the audio player and } // release old resources try { + if (cuePlayer->isOpen()) { + if (cuePlayer->isPlaying()) { + cuePlayer->stop(); + } + cuePlayer->close(); + } + cuePlayer->setAudioDevice(*newDevice); cuePlayer->open(*testAudioUrl); cuePlayer->start(); Ptr::Ref sleepT(new time_duration(microseconds(10))); @@ -1638,8 +1647,11 @@ GLiveSupport :: playTestSoundOnCue(void) throw () } } catch (std::runtime_error &e) { // "invalid device" error from open(); do nothing + } catch (std::logic_error &e) { + // some other error; do nothing } cuePlayer->close(); + cuePlayer->setAudioDevice(*oldDevice); } diff --git a/campcaster/src/products/gLiveSupport/src/GLiveSupport.h b/campcaster/src/products/gLiveSupport/src/GLiveSupport.h index 9ba2ae03e..daa581e4e 100644 --- a/campcaster/src/products/gLiveSupport/src/GLiveSupport.h +++ b/campcaster/src/products/gLiveSupport/src/GLiveSupport.h @@ -988,9 +988,14 @@ class GLiveSupport : public LocalizedConfigurable, /** * Play a test sound on the cue audio player. + * + * @param oldDevice the name of the current audio device. + * @param oldDevice the name of the audio device to be tested. */ void - playTestSoundOnCue(void) throw (); + playTestSoundOnCue(Ptr::Ref oldDevice, + Ptr::Ref newDevice) + throw (); /** * Search in the local storage. diff --git a/campcaster/src/products/gLiveSupport/src/OptionsWindow.cxx b/campcaster/src/products/gLiveSupport/src/OptionsWindow.cxx index d39ebe378..86be1c58d 100644 --- a/campcaster/src/products/gLiveSupport/src/OptionsWindow.cxx +++ b/campcaster/src/products/gLiveSupport/src/OptionsWindow.cxx @@ -349,13 +349,12 @@ OptionsWindow :: onTestButtonClicked(const EntryBin * entry) Ptr::Ref oldDevice = optionsContainer->getOptionItem(OptionsContainer:: - outputPlayerDeviceName); + cuePlayerDeviceName); Ptr::Ref newDevice(new Glib::ustring(entry->get_text())); - gLiveSupport->setCueAudioDevice(newDevice); // NOTE: we can't use the - gLiveSupport->playTestSoundOnCue(); // output player b/c that - gLiveSupport->setCueAudioDevice(oldDevice); // would trigger onStop() + // NOTE: we can't use the output player b/c that would trigger onStop() + gLiveSupport->playTestSoundOnCue(oldDevice, newDevice); }