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:
fgerlits 2007-02-08 16:11:39 +00:00
parent 781827b505
commit fb6e1b709a
14 changed files with 40 additions and 33 deletions

View File

@ -87,7 +87,8 @@ class AudioPlayerEventListener
* @param errorMessage is a 0 pointer if the player stopped normally
*/
virtual void
onStop(Ptr<const std::string>::Ref errorMessage) throw () = 0;
onStop(Ptr<const Glib::ustring>::Ref errorMessage)
throw () = 0;
};

View File

@ -144,7 +144,7 @@ GstreamerPlayer :: errorHandler(GstElement * pipeline,
throw ()
{
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;
@ -223,20 +223,16 @@ GstreamerPlayer :: fireOnStopEvent(gpointer self) throw (
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 end = player->m_listeners.end();
while (it != end) {
(*it)->onStop(msg);
(*it)->onStop(player->m_errorMessage);
++it;
}
player->m_errorMessage.reset();
// false == Don't call this idle function again
return false;
}
@ -331,7 +327,7 @@ GstreamerPlayer :: open(const std::string fileUrl)
debug() << "Opening URL: " << fileUrl << endl;
debug() << "Timestamp: " << *TimeConversion::now() << endl;
m_errorMessage.clear();
m_errorMessage.reset();
std::string filePath;

View File

@ -153,7 +153,7 @@ class GstreamerPlayer : virtual public Configurable,
/**
* 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.

View File

@ -622,7 +622,7 @@ GstreamerPlayerTest :: eventListenerOnStopTest(void)
* Another, more realistic test of the event listener mechanism.
*----------------------------------------------------------------------------*/
void
GstreamerPlayerTest :: onStop(Ptr<const std::string>::Ref errorMessage)
GstreamerPlayerTest :: onStop(Ptr<const Glib::ustring>::Ref errorMessage)
throw ()
{
if (!startNewClipFlag) {

View File

@ -248,7 +248,7 @@ class GstreamerPlayerTest : public CPPUNIT_NS::TestFixture,
* @param errorMessage is a 0 pointer if the player stopped normally
*/
virtual void
onStop(Ptr<const std::string>::Ref errorMessage)
onStop(Ptr<const Glib::ustring>::Ref errorMessage)
throw ();
};

View File

@ -96,7 +96,8 @@ class TestEventListener : public AudioPlayerEventListener
* @param errorMessage is a 0 pointer if the player stopped normally
*/
virtual void
onStop(Ptr<const std::string>::Ref errorMessage) throw ()
onStop(Ptr<const Glib::ustring>::Ref errorMessage)
throw ()
{
stopFlag = true;
}

View File

@ -135,9 +135,10 @@ class DialogWindow : public WhiteWindow,
* @param bundle a resource bundle containing the localized
* button labels
*/
DialogWindow(Ptr<Glib::ustring>::Ref message,
int buttonTypes,
Ptr<ResourceBundle>::Ref bundle) throw ();
DialogWindow(Ptr<const Glib::ustring>::Ref message,
int buttonTypes,
Ptr<ResourceBundle>::Ref bundle)
throw ();
/**
* Virtual destructor.

View File

@ -414,8 +414,8 @@ class WidgetFactory :
* @return the DialogWindow object.
*/
DialogWindow *
createDialogWindow(Ptr<Glib::ustring>::Ref message,
Ptr<ResourceBundle>::Ref bundle,
createDialogWindow(Ptr<const Glib::ustring>::Ref message,
Ptr<ResourceBundle>::Ref bundle,
int buttons = DialogWindow::okButton)
throw ();

View File

@ -58,9 +58,9 @@ using namespace LiveSupport::Widgets;
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
DialogWindow :: DialogWindow (Ptr<Glib::ustring>::Ref message,
int buttonTypes,
Ptr<ResourceBundle>::Ref bundle)
DialogWindow :: DialogWindow (Ptr<const Glib::ustring>::Ref message,
int buttonTypes,
Ptr<ResourceBundle>::Ref bundle)
throw ()
: WhiteWindow(Colors::White,
WidgetFactory::getInstance()->getWhiteWindowCorners(),

View File

@ -684,9 +684,9 @@ WidgetFactory :: createTreeView(Glib::RefPtr<Gtk::TreeModel> treeModel)
* Create a dialog window.
*----------------------------------------------------------------------------*/
DialogWindow *
WidgetFactory :: createDialogWindow(Ptr<Glib::ustring>::Ref message,
Ptr<ResourceBundle>::Ref bundle,
int buttons)
WidgetFactory :: createDialogWindow(Ptr<const Glib::ustring>::Ref message,
Ptr<ResourceBundle>::Ref bundle,
int buttons)
throw ()
{
return new DialogWindow(message, buttons, bundle);

View File

@ -205,9 +205,13 @@ CuePlayer :: onStopButtonClicked(void) throw ()
* Event handler for the "cue audio player has stopped" event.
*----------------------------------------------------------------------------*/
void
CuePlayer :: onStop(Ptr<const std::string>::Ref errorMessage) throw ()
CuePlayer :: onStop(Ptr<const Glib::ustring>::Ref errorMessage) throw ()
{
setAudioState(waitingState);
if (errorMessage) {
gLiveSupport->displayMessageWindow(errorMessage);
}
}

View File

@ -184,8 +184,8 @@ class CuePlayer : public Gtk::HBox,
* @param errorMessage is a 0 pointer if the player stopped normally
*/
virtual void
onStop(Ptr<const std::string>::Ref errorMessage
= Ptr<const std::string>::Ref())
onStop(Ptr<const Glib::ustring>::Ref errorMessage
= Ptr<const Glib::ustring>::Ref())
throw ();
};

View File

@ -518,7 +518,7 @@ GLiveSupport :: checkConfiguration(void) throw ()
*----------------------------------------------------------------------------*/
void
LiveSupport :: GLiveSupport ::
GLiveSupport :: displayMessageWindow(Ptr<Glib::ustring>::Ref message)
GLiveSupport :: displayMessageWindow(Ptr<const Glib::ustring>::Ref message)
throw ()
{
std::cerr << "gLiveSupport: " << *message << std::endl;
@ -1318,7 +1318,7 @@ GLiveSupport :: stopOutputAudio(void)
*----------------------------------------------------------------------------*/
void
LiveSupport :: GLiveSupport ::
GLiveSupport :: onStop(Ptr<const std::string>::Ref errorMessage)
GLiveSupport :: onStop(Ptr<const Glib::ustring>::Ref errorMessage)
throw ()
{
outputItemPlayingNow.reset();
@ -1334,6 +1334,10 @@ GLiveSupport :: onStop(Ptr<const std::string>::Ref errorMessage)
std::cerr << "logic_error caught in GLiveSupport::onStop()\n";
std::exit(1);
}
if (errorMessage) {
displayMessageWindow(errorMessage);
}
}

View File

@ -486,7 +486,7 @@ class GLiveSupport : public LocalizedConfigurable,
* @param message the message to display
*/
void
displayMessageWindow(Ptr<Glib::ustring>::Ref message)
displayMessageWindow(Ptr<const Glib::ustring>::Ref message)
throw ();
/**
@ -1060,8 +1060,8 @@ class GLiveSupport : public LocalizedConfigurable,
* @param errorMessage is a 0 pointer if the player stopped normally
*/
virtual void
onStop(Ptr<const std::string>::Ref errorMessage
= Ptr<const std::string>::Ref())
onStop(Ptr<const Glib::ustring>::Ref errorMessage
= Ptr<const Glib::ustring>::Ref())
throw ();
/**