added a "Test" button to the "set audio device" section of the options window

at the moment, it doesn't work too well, due to #1613
This commit is contained in:
fgerlits 2006-01-27 13:01:01 +00:00
parent 0ad80a607a
commit 0815136ec6
15 changed files with 247 additions and 17 deletions

View file

@ -139,6 +139,8 @@ install-arch:
$(CURDIR)/debian/livesupport/opt/livesupport/var/LiveSupport/gLiveSupport*.res \
$(CURDIR)/debian/livesupport/opt/livesupport/var/LiveSupport/livesupport.png \
$(CURDIR)/debian/livesupport/opt/livesupport/var/LiveSupport/stationLogo.png \
$(CURDIR)/debian/livesupport/opt/livesupport/var/LiveSupport/testAudio.ogg \
$(CURDIR)/debian/livesupport/opt/livesupport/var/LiveSupport/testAudio.ogg.license \
$(CURDIR)/debian/livesupport-studio/opt/livesupport/var/LiveSupport
mkdir -p $(CURDIR)/debian/livesupport-studio/usr/share/applications
cp -a $(CURDIR)/debian/livesupport-studio.desktop \

View file

@ -104,13 +104,24 @@ class EntryBin : public BlueBin
return entry;
}
/**
* Return the entry held in this container (const version).
*
* @return the entry held in this container.
*/
const Gtk::Entry *
getEntry(void) const throw ()
{
return entry;
}
/**
* Return the text of the entry.
*
* @return the get_text() string of the Gtk::Entry.
*/
Glib::ustring
get_text(void) throw ()
get_text(void) const throw ()
{
return getEntry()->get_text();
}

View file

@ -341,8 +341,10 @@ install: all
${MKDIR} ${USR_ETC_DIR}
${MKDIR} ${USR_VAR_DIR}/LiveSupport
${CP} ${TMP_DIR}/*.res ${USR_VAR_DIR}/LiveSupport
${CP} ${VAR_DIR}/livesupport.png ${VAR_DIR}/stationLogo.png \
${USR_VAR_DIR}/LiveSupport
${CP} ${VAR_DIR}/livesupport.png \
${VAR_DIR}/stationLogo.png \
${VAR_DIR}/testAudio.ogg \
${VAR_DIR}/testAudio.ogg.license ${USR_VAR_DIR}/LiveSupport
${CP} ${BIN_DIR}/gLiveSupport.sh ${USR_BIN_DIR}
${CP} ${G_LIVESUPPORT_EXE} ${USR_BIN_DIR}
${CP} ${ETC_DIR}/gLiveSupport.xml.template ${USR_ETC_DIR}

View file

@ -89,6 +89,9 @@
<!ELEMENT stationLogo EMPTY >
<!ATTLIST stationLogo path CDATA #REQUIRED >
<!ELEMENT testAudioUrl EMPTY >
<!ATTLIST testAudioUrl path CDATA #REQUIRED >
<!ELEMENT metadataType EMPTY >
<!ATTLIST metadataType dcName NMTOKEN #REQUIRED >
<!ATTLIST metadataType id3Tag CDATA #IMPLIED >
@ -155,6 +158,8 @@
<stationLogo path = "var/stationLogo.png" />
<testAudioUrl path = "file://var/testAudio.ogg" />
<metadataTypeContainer>
<metadataType dcName = "dc:title"
id3Tag = "TIT2"

View file

@ -89,6 +89,9 @@
<!ELEMENT stationLogo EMPTY >
<!ATTLIST stationLogo path CDATA #REQUIRED >
<!ELEMENT testAudioUrl EMPTY >
<!ATTLIST testAudioUrl path CDATA #REQUIRED >
<!ELEMENT metadataType EMPTY >
<!ATTLIST metadataType dcName NMTOKEN #REQUIRED >
<!ATTLIST metadataType id3Tag CDATA #IMPLIED >
@ -153,7 +156,9 @@
</audioPlayer>
</cuePlayer>
<stationLogo path="ls_var_dir/LiveSupport/stationLogo.png" />
<stationLogo path = "ls_var_dir/LiveSupport/stationLogo.png" />
<testAudioUrl path = "file://ls_var_dir/LiveSupport/testAudio.ogg" />
<metadataTypeContainer>
<metadataType dcName = "dc:title"

View file

@ -89,6 +89,9 @@
<!ELEMENT stationLogo EMPTY >
<!ATTLIST stationLogo path CDATA #REQUIRED >
<!ELEMENT testAudioUrl EMPTY >
<!ATTLIST testAudioUrl path CDATA #REQUIRED >
<!ELEMENT metadataType EMPTY >
<!ATTLIST metadataType dcName NMTOKEN #REQUIRED >
<!ATTLIST metadataType id3Tag CDATA #IMPLIED >
@ -153,7 +156,9 @@
</audioPlayer>
</cuePlayer>
<stationLogo path="var/stationLogo.png" />
<stationLogo path = "var/stationLogo.png" />
<testAudioUrl path = "file:var/testAudio.ogg" />
<metadataTypeContainer>
<metadataType dcName = "dc:title"

View file

@ -301,3 +301,41 @@ AudioPlayerTest :: playPlaylistTest(void)
audioPlayer->close();
}
/*------------------------------------------------------------------------------
* Test if we can switch back and forth between devices.
*----------------------------------------------------------------------------*/
void
AudioPlayerTest :: switchDevicesTest(void)
throw (CPPUNIT_NS::Exception)
{
Ptr<AudioPlayerFactory>::Ref audioPlayerFactory;
audioPlayerFactory = AudioPlayerFactory::getInstance();
CPPUNIT_ASSERT(audioPlayerFactory.get());
Ptr<AudioPlayerInterface>::Ref audioPlayer;
audioPlayer = audioPlayerFactory->getAudioPlayer();
CPPUNIT_ASSERT(audioPlayer.get());
audioPlayer->setAudioDevice("/dev/dsp");
CPPUNIT_ASSERT_NO_THROW(
audioPlayer->open("file:var/testAudio.ogg")
);
audioPlayer->start();
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
while (audioPlayer->isPlaying()) {
TimeConversion::sleep(sleepT);
}
audioPlayer->close();
audioPlayer->setAudioDevice("plughw:0,0");
CPPUNIT_ASSERT_NO_THROW(
audioPlayer->open("file:var/testAudio.ogg")
);
audioPlayer->start();
while (audioPlayer->isPlaying()) {
TimeConversion::sleep(sleepT);
}
audioPlayer->close();
}

View file

@ -73,6 +73,7 @@ class AudioPlayerTest : public BaseTestMethod
CPPUNIT_TEST(firstTest);
CPPUNIT_TEST(playAudioClipTest);
CPPUNIT_TEST(playPlaylistTest);
CPPUNIT_TEST(switchDevicesTest);
CPPUNIT_TEST_SUITE_END();
private:
@ -108,6 +109,14 @@ class AudioPlayerTest : public BaseTestMethod
void
playPlaylistTest(void) throw (CPPUNIT_NS::Exception);
/**
* Test if we can switch back and forth between devices.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
switchDevicesTest(void) throw (CPPUNIT_NS::Exception);
public:
/**

View file

@ -127,6 +127,11 @@ static const std::string cuePlayerElementName = "cuePlayer";
*----------------------------------------------------------------------------*/
static const std::string stationLogoConfigElementName = "stationLogo";
/*------------------------------------------------------------------------------
* The name of the config element for the test audio file location
*----------------------------------------------------------------------------*/
static const std::string testAudioUrlConfigElementName = "testAudioUrl";
/*------------------------------------------------------------------------------
* The name of the user preference for storing Scratchpad contents
*----------------------------------------------------------------------------*/
@ -333,6 +338,17 @@ GLiveSupport :: configure(const xmlpp::Element & element)
mkdir(configFileName->c_str(), 0700); // create dir if does not exist
configFileName->append(configFileNameStr);
optionsContainer.reset(new OptionsContainer(element, configFileName));
// read the test audio file location
nodes = element.get_children(testAudioUrlConfigElementName);
if (nodes.size() < 1) {
throw std::invalid_argument("no test audio url element");
}
const xmlpp::Element* testAudioUrlElement
= dynamic_cast<const xmlpp::Element*>(nodes.front());
testAudioUrl.reset(new Glib::ustring(
testAudioUrlElement->get_attribute("path")
->get_value() ));
}
@ -1487,3 +1503,40 @@ GLiveSupport :: loadWindowPositions(void) throw ()
}
}
/*------------------------------------------------------------------------------
* Set the device for the cue audio player.
*----------------------------------------------------------------------------*/
void
LiveSupport :: GLiveSupport ::
GLiveSupport :: setCueAudioDevice(Ptr<const Glib::ustring>::Ref deviceName)
throw ()
{
cuePlayer->setAudioDevice(*deviceName);
}
/*------------------------------------------------------------------------------
* Play a test sound on the cue audio player.
*----------------------------------------------------------------------------*/
void
LiveSupport :: GLiveSupport ::
GLiveSupport :: playTestSoundOnCue(void) throw ()
{
if (cueItemPlayingNow) {
stopCueAudio(); // stop the audio player and
} // release old resources
try {
cuePlayer->open(*testAudioUrl);
cuePlayer->start();
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
while (cuePlayer->isPlaying()) {
TimeConversion::sleep(sleepT);
}
} catch (std::runtime_error &e) {
// "invalid device" error from open(); do nothing
}
cuePlayer->close();
}

View file

@ -254,6 +254,11 @@ class GLiveSupport : public LocalizedConfigurable,
*/
Glib::RefPtr<Gdk::Pixbuf> stationLogoPixbuf;
/**
* The location of the test audio file.
*/
Ptr<Glib::ustring>::Ref testAudioUrl;
/**
* Read a supportedLanguages configuration element,
* and fill the supportedLanguages map with its contents.
@ -907,6 +912,21 @@ class GLiveSupport : public LocalizedConfigurable,
detachCueAudioListener(AudioPlayerEventListener * listener)
throw (std::invalid_argument);
/**
* Set the device for the cue audio player.
*
* @param deviceName the name of the new device
*/
void
setCueAudioDevice(Ptr<const Glib::ustring>::Ref deviceName)
throw ();
/**
* Play a test sound on the cue audio player.
*/
void
playTestSoundOnCue(void) throw ();
/**
* Search in the local storage.
*

View file

@ -219,6 +219,28 @@ OptionsWindow :: onCloseButtonClicked(bool needConfirm) throw ()
}
/*------------------------------------------------------------------------------
* Event handler for the test button
*----------------------------------------------------------------------------*/
void
OptionsWindow :: onTestButtonClicked(const EntryBin * entry)
throw ()
{
Ptr<OptionsContainer>::Ref optionsContainer
= gLiveSupport->getOptionsContainer();
Ptr<const Glib::ustring>::Ref
oldDevice = optionsContainer->getOptionItem(OptionsContainer::
outputPlayerDeviceName);
Ptr<const Glib::ustring>::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()
}
/*------------------------------------------------------------------------------
* Create a new user entry field item.
*----------------------------------------------------------------------------*/
@ -279,6 +301,20 @@ OptionsWindow :: constructSoundSection(void) throw ()
OptionsContainer::cuePlayerDeviceName);
audioDeviceTable->attach(*cuePlayerEntry, 1, 2, 0, 1);
Button * cueTestButton;
try {
cueTestButton = Gtk::manage(wf->createButton(
*getResourceUstring("testButtonLabel") ));
} catch (std::invalid_argument &e) {
// TODO: signal error
std::cerr << e.what() << std::endl;
std::exit(1);
}
cueTestButton->signal_clicked().connect(sigc::bind<EntryBin*>(
sigc::mem_fun(*this,&OptionsWindow::onTestButtonClicked),
cuePlayerEntry));
audioDeviceTable->attach(*cueTestButton, 2, 3, 0, 1);
// display the settings for the output player device
Glib::ustring outputPlayerLabelContents;
try {
@ -298,6 +334,20 @@ OptionsWindow :: constructSoundSection(void) throw ()
OptionsContainer::outputPlayerDeviceName);
audioDeviceTable->attach(*outputPlayerEntry, 1, 2, 1, 2);
Button * outputTestButton;
try {
outputTestButton = Gtk::manage(wf->createButton(
*getResourceUstring("testButtonLabel") ));
} catch (std::invalid_argument &e) {
// TODO: signal error
std::cerr << e.what() << std::endl;
std::exit(1);
}
outputTestButton->signal_clicked().connect(sigc::bind<EntryBin*>(
sigc::mem_fun(*this, &OptionsWindow::onTestButtonClicked),
outputPlayerEntry));
audioDeviceTable->attach(*outputTestButton, 2, 3, 1, 2);
// make a new box and pack the components into it
Gtk::VBox * section = Gtk::manage(new Gtk::VBox);
section->pack_start(*audioDeviceTable, Gtk::PACK_SHRINK, 5);

View file

@ -152,7 +152,7 @@ class OptionsWindow : public WhiteWindow, public LocalizedObject
*/
EntryBin *
createEntry(OptionsContainer::OptionItemString optionItem)
throw ();
throw ();
/**
* Construct the "Sound" section.
@ -160,7 +160,7 @@ class OptionsWindow : public WhiteWindow, public LocalizedObject
* @return a pointer to the new box (already Gtk::manage()'ed)
*/
Gtk::VBox*
constructSoundSection(void) throw ();
constructSoundSection(void) throw ();
/**
* Construct the "Servers" section.
@ -168,7 +168,7 @@ class OptionsWindow : public WhiteWindow, public LocalizedObject
* @return a pointer to the new box (already Gtk::manage()'ed)
*/
Gtk::VBox*
constructServersSection(void) throw ();
constructServersSection(void) throw ();
/**
* Construct the "About" section.
@ -176,7 +176,7 @@ class OptionsWindow : public WhiteWindow, public LocalizedObject
* @return a pointer to the new box (already Gtk::manage()'ed)
*/
Gtk::VBox*
constructAboutSection(void) throw ();
constructAboutSection(void) throw ();
protected:
@ -184,19 +184,19 @@ class OptionsWindow : public WhiteWindow, public LocalizedObject
* Event handler for the Cancel button.
*/
virtual void
onCancelButtonClicked(void) throw ();
onCancelButtonClicked(void) throw ();
/**
* Event handler for the Apply button.
*/
virtual void
onApplyButtonClicked(void) throw ();
onApplyButtonClicked(void) throw ();
/**
* Event handler for the OK button.
*/
virtual void
onOkButtonClicked(void) throw ();
onOkButtonClicked(void) throw ();
/**
* Event handler for the Close button.
@ -207,9 +207,19 @@ class OptionsWindow : public WhiteWindow, public LocalizedObject
* @see WhiteWindow::onCloseButtonClicked()
*/
virtual void
onCloseButtonClicked(bool needConfirm = true) throw ();
onCloseButtonClicked(bool needConfirm = true) throw ();
/**
* Event handler for the test button
*
* @param entry the text entry field containing the new device name
* @see GLiveSupport::setCueAudioDevice()
* @see GLiveSupport::playTestSoundOnCue()
*/
virtual void
onTestButtonClicked(const EntryBin * entry) throw ();
public:
/**
* Constructor.
@ -219,14 +229,13 @@ class OptionsWindow : public WhiteWindow, public LocalizedObject
* @param bundle the resource bundle holding localized resources
*/
OptionsWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle)
throw ();
Ptr<ResourceBundle>::Ref bundle) throw ();
/**
* Virtual destructor.
*/
virtual
~OptionsWindow(void) throw ()
~OptionsWindow(void) throw ()
{
}

View file

@ -231,6 +231,7 @@ root:table
cueDeviceLabel:string { "Cue audio device:" }
outputDeviceLabel:string { "Live Mode audio device:" }
testButtonLabel:string { "Test" }
authenticationLabel:string { "Authentication server" }
storageLabel:string { "Storage server" }

View file

@ -0,0 +1,20 @@
This is a shortened and reencoded version of the following sound file
File:
Name: "cowbell.aif"
Url: http://freesound.iua.upf.edu/samplesViewSingle.php?id=14782
Date of upload: 2006-01-24 20:28:02
Designer / Creator / Uploader:
Name: "ignotus"
Url: http://freesound.iua.upf.edu/usersViewSingle.php?id=13366
Description:
By "ignotus" : A cow in the high pastures of the Picos de Europa,
northwest Spain. Recorded with a mini-DV camcorder built-in stereo mic.
Tags:
animal bell field-recording nature
It was released under the Creative Commons Sampling Plus 1.0 license
http://creativecommons.org/licenses/by-nd/2.0/