added error reporting to CuePlayer and GLiveSupport when the audio player fails;
plus minor API changes to make things simpler
This commit is contained in:
parent
781827b505
commit
fb6e1b709a
14 changed files with 40 additions and 33 deletions
|
@ -87,7 +87,8 @@ class AudioPlayerEventListener
|
||||||
* @param errorMessage is a 0 pointer if the player stopped normally
|
* @param errorMessage is a 0 pointer if the player stopped normally
|
||||||
*/
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
onStop(Ptr<const std::string>::Ref errorMessage) throw () = 0;
|
onStop(Ptr<const Glib::ustring>::Ref errorMessage)
|
||||||
|
throw () = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ GstreamerPlayer :: errorHandler(GstElement * pipeline,
|
||||||
throw ()
|
throw ()
|
||||||
{
|
{
|
||||||
GstreamerPlayer* const player = (GstreamerPlayer*) self;
|
GstreamerPlayer* const player = (GstreamerPlayer*) self;
|
||||||
player->m_errorMessage = error->message;
|
player->m_errorMessage.reset(new const Glib::ustring(error->message));
|
||||||
|
|
||||||
std::cerr << "gstreamer error: " << error->message << std::endl;
|
std::cerr << "gstreamer error: " << error->message << std::endl;
|
||||||
|
|
||||||
|
@ -223,20 +223,16 @@ GstreamerPlayer :: fireOnStopEvent(gpointer self) throw (
|
||||||
|
|
||||||
GstreamerPlayer* const player = (GstreamerPlayer*) self;
|
GstreamerPlayer* const player = (GstreamerPlayer*) self;
|
||||||
|
|
||||||
Ptr<const std::string>::Ref msg;
|
|
||||||
if (!player->m_errorMessage.empty()) {
|
|
||||||
msg.reset(new const std::string(player->m_errorMessage));
|
|
||||||
player->m_errorMessage.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
ListenerVector::iterator it = player->m_listeners.begin();
|
ListenerVector::iterator it = player->m_listeners.begin();
|
||||||
ListenerVector::iterator end = player->m_listeners.end();
|
ListenerVector::iterator end = player->m_listeners.end();
|
||||||
|
|
||||||
while (it != end) {
|
while (it != end) {
|
||||||
(*it)->onStop(msg);
|
(*it)->onStop(player->m_errorMessage);
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player->m_errorMessage.reset();
|
||||||
|
|
||||||
// false == Don't call this idle function again
|
// false == Don't call this idle function again
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -331,7 +327,7 @@ GstreamerPlayer :: open(const std::string fileUrl)
|
||||||
debug() << "Opening URL: " << fileUrl << endl;
|
debug() << "Opening URL: " << fileUrl << endl;
|
||||||
debug() << "Timestamp: " << *TimeConversion::now() << endl;
|
debug() << "Timestamp: " << *TimeConversion::now() << endl;
|
||||||
|
|
||||||
m_errorMessage.clear();
|
m_errorMessage.reset();
|
||||||
|
|
||||||
std::string filePath;
|
std::string filePath;
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ class GstreamerPlayer : virtual public Configurable,
|
||||||
/**
|
/**
|
||||||
* Contains runtime error messages from GStreamer.
|
* Contains runtime error messages from GStreamer.
|
||||||
*/
|
*/
|
||||||
std::string m_errorMessage;
|
Ptr<const Glib::ustring>::Ref m_errorMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL of the preloaded file. Empty if nothing is preloaded.
|
* The URL of the preloaded file. Empty if nothing is preloaded.
|
||||||
|
|
|
@ -622,7 +622,7 @@ GstreamerPlayerTest :: eventListenerOnStopTest(void)
|
||||||
* Another, more realistic test of the event listener mechanism.
|
* Another, more realistic test of the event listener mechanism.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
GstreamerPlayerTest :: onStop(Ptr<const std::string>::Ref errorMessage)
|
GstreamerPlayerTest :: onStop(Ptr<const Glib::ustring>::Ref errorMessage)
|
||||||
throw ()
|
throw ()
|
||||||
{
|
{
|
||||||
if (!startNewClipFlag) {
|
if (!startNewClipFlag) {
|
||||||
|
|
|
@ -248,7 +248,7 @@ class GstreamerPlayerTest : public CPPUNIT_NS::TestFixture,
|
||||||
* @param errorMessage is a 0 pointer if the player stopped normally
|
* @param errorMessage is a 0 pointer if the player stopped normally
|
||||||
*/
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
onStop(Ptr<const std::string>::Ref errorMessage)
|
onStop(Ptr<const Glib::ustring>::Ref errorMessage)
|
||||||
throw ();
|
throw ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,8 @@ class TestEventListener : public AudioPlayerEventListener
|
||||||
* @param errorMessage is a 0 pointer if the player stopped normally
|
* @param errorMessage is a 0 pointer if the player stopped normally
|
||||||
*/
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
onStop(Ptr<const std::string>::Ref errorMessage) throw ()
|
onStop(Ptr<const Glib::ustring>::Ref errorMessage)
|
||||||
|
throw ()
|
||||||
{
|
{
|
||||||
stopFlag = true;
|
stopFlag = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,9 +135,10 @@ class DialogWindow : public WhiteWindow,
|
||||||
* @param bundle a resource bundle containing the localized
|
* @param bundle a resource bundle containing the localized
|
||||||
* button labels
|
* button labels
|
||||||
*/
|
*/
|
||||||
DialogWindow(Ptr<Glib::ustring>::Ref message,
|
DialogWindow(Ptr<const Glib::ustring>::Ref message,
|
||||||
int buttonTypes,
|
int buttonTypes,
|
||||||
Ptr<ResourceBundle>::Ref bundle) throw ();
|
Ptr<ResourceBundle>::Ref bundle)
|
||||||
|
throw ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Virtual destructor.
|
* Virtual destructor.
|
||||||
|
|
|
@ -414,8 +414,8 @@ class WidgetFactory :
|
||||||
* @return the DialogWindow object.
|
* @return the DialogWindow object.
|
||||||
*/
|
*/
|
||||||
DialogWindow *
|
DialogWindow *
|
||||||
createDialogWindow(Ptr<Glib::ustring>::Ref message,
|
createDialogWindow(Ptr<const Glib::ustring>::Ref message,
|
||||||
Ptr<ResourceBundle>::Ref bundle,
|
Ptr<ResourceBundle>::Ref bundle,
|
||||||
int buttons = DialogWindow::okButton)
|
int buttons = DialogWindow::okButton)
|
||||||
throw ();
|
throw ();
|
||||||
|
|
||||||
|
|
|
@ -58,9 +58,9 @@ using namespace LiveSupport::Widgets;
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
DialogWindow :: DialogWindow (Ptr<Glib::ustring>::Ref message,
|
DialogWindow :: DialogWindow (Ptr<const Glib::ustring>::Ref message,
|
||||||
int buttonTypes,
|
int buttonTypes,
|
||||||
Ptr<ResourceBundle>::Ref bundle)
|
Ptr<ResourceBundle>::Ref bundle)
|
||||||
throw ()
|
throw ()
|
||||||
: WhiteWindow(Colors::White,
|
: WhiteWindow(Colors::White,
|
||||||
WidgetFactory::getInstance()->getWhiteWindowCorners(),
|
WidgetFactory::getInstance()->getWhiteWindowCorners(),
|
||||||
|
|
|
@ -684,9 +684,9 @@ WidgetFactory :: createTreeView(Glib::RefPtr<Gtk::TreeModel> treeModel)
|
||||||
* Create a dialog window.
|
* Create a dialog window.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
DialogWindow *
|
DialogWindow *
|
||||||
WidgetFactory :: createDialogWindow(Ptr<Glib::ustring>::Ref message,
|
WidgetFactory :: createDialogWindow(Ptr<const Glib::ustring>::Ref message,
|
||||||
Ptr<ResourceBundle>::Ref bundle,
|
Ptr<ResourceBundle>::Ref bundle,
|
||||||
int buttons)
|
int buttons)
|
||||||
throw ()
|
throw ()
|
||||||
{
|
{
|
||||||
return new DialogWindow(message, buttons, bundle);
|
return new DialogWindow(message, buttons, bundle);
|
||||||
|
|
|
@ -205,9 +205,13 @@ CuePlayer :: onStopButtonClicked(void) throw ()
|
||||||
* Event handler for the "cue audio player has stopped" event.
|
* Event handler for the "cue audio player has stopped" event.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
CuePlayer :: onStop(Ptr<const std::string>::Ref errorMessage) throw ()
|
CuePlayer :: onStop(Ptr<const Glib::ustring>::Ref errorMessage) throw ()
|
||||||
{
|
{
|
||||||
setAudioState(waitingState);
|
setAudioState(waitingState);
|
||||||
|
|
||||||
|
if (errorMessage) {
|
||||||
|
gLiveSupport->displayMessageWindow(errorMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -184,8 +184,8 @@ class CuePlayer : public Gtk::HBox,
|
||||||
* @param errorMessage is a 0 pointer if the player stopped normally
|
* @param errorMessage is a 0 pointer if the player stopped normally
|
||||||
*/
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
onStop(Ptr<const std::string>::Ref errorMessage
|
onStop(Ptr<const Glib::ustring>::Ref errorMessage
|
||||||
= Ptr<const std::string>::Ref())
|
= Ptr<const Glib::ustring>::Ref())
|
||||||
throw ();
|
throw ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -518,7 +518,7 @@ GLiveSupport :: checkConfiguration(void) throw ()
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
LiveSupport :: GLiveSupport ::
|
LiveSupport :: GLiveSupport ::
|
||||||
GLiveSupport :: displayMessageWindow(Ptr<Glib::ustring>::Ref message)
|
GLiveSupport :: displayMessageWindow(Ptr<const Glib::ustring>::Ref message)
|
||||||
throw ()
|
throw ()
|
||||||
{
|
{
|
||||||
std::cerr << "gLiveSupport: " << *message << std::endl;
|
std::cerr << "gLiveSupport: " << *message << std::endl;
|
||||||
|
@ -1318,7 +1318,7 @@ GLiveSupport :: stopOutputAudio(void)
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
LiveSupport :: GLiveSupport ::
|
LiveSupport :: GLiveSupport ::
|
||||||
GLiveSupport :: onStop(Ptr<const std::string>::Ref errorMessage)
|
GLiveSupport :: onStop(Ptr<const Glib::ustring>::Ref errorMessage)
|
||||||
throw ()
|
throw ()
|
||||||
{
|
{
|
||||||
outputItemPlayingNow.reset();
|
outputItemPlayingNow.reset();
|
||||||
|
@ -1334,6 +1334,10 @@ GLiveSupport :: onStop(Ptr<const std::string>::Ref errorMessage)
|
||||||
std::cerr << "logic_error caught in GLiveSupport::onStop()\n";
|
std::cerr << "logic_error caught in GLiveSupport::onStop()\n";
|
||||||
std::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (errorMessage) {
|
||||||
|
displayMessageWindow(errorMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -486,7 +486,7 @@ class GLiveSupport : public LocalizedConfigurable,
|
||||||
* @param message the message to display
|
* @param message the message to display
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
displayMessageWindow(Ptr<Glib::ustring>::Ref message)
|
displayMessageWindow(Ptr<const Glib::ustring>::Ref message)
|
||||||
throw ();
|
throw ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1060,8 +1060,8 @@ class GLiveSupport : public LocalizedConfigurable,
|
||||||
* @param errorMessage is a 0 pointer if the player stopped normally
|
* @param errorMessage is a 0 pointer if the player stopped normally
|
||||||
*/
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
onStop(Ptr<const std::string>::Ref errorMessage
|
onStop(Ptr<const Glib::ustring>::Ref errorMessage
|
||||||
= Ptr<const std::string>::Ref())
|
= Ptr<const Glib::ustring>::Ref())
|
||||||
throw ();
|
throw ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue