From f458399000333d524a944af969ee233977e576d6 Mon Sep 17 00:00:00 2001 From: mark Date: Thu, 8 Feb 2007 14:48:48 +0000 Subject: [PATCH] Send audio player error message as an argument to onStop(), as discussed with fgerlits. Refert to #2165 --- .../playlistExecutor/src/GstreamerPlayer.cxx | 19 +++++++++++++------ .../playlistExecutor/src/GstreamerPlayer.h | 5 +++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.cxx b/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.cxx index a07c1ca52..849da22e2 100644 --- a/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.cxx +++ b/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.cxx @@ -143,14 +143,14 @@ GstreamerPlayer :: errorHandler(GstElement * pipeline, gpointer self) throw () { + GstreamerPlayer* const player = (GstreamerPlayer*) self; + player->m_errorMessage = error->message; + + std::cerr << "gstreamer error: " << error->message << std::endl; + // Important: We *must* use an idle function call here, so that the signal handler returns // before fireOnStopEvent() is executed. g_idle_add(fireOnStopEvent, self); - - std::string str( "Audio Player Error: "); - str += error->message; - - throw std::runtime_error(str); } @@ -223,11 +223,16 @@ GstreamerPlayer :: fireOnStopEvent(gpointer self) throw ( GstreamerPlayer* const player = (GstreamerPlayer*) self; + Ptr::Ref msg; + if (!player->m_errorMessage.empty()) { + msg.reset(new const std::string(player->m_errorMessage)); + } + ListenerVector::iterator it = player->m_listeners.begin(); ListenerVector::iterator end = player->m_listeners.end(); while (it != end) { - (*it)->onStop(); + (*it)->onStop(msg); ++it; } @@ -325,6 +330,8 @@ GstreamerPlayer :: open(const std::string fileUrl) debug() << "Opening URL: " << fileUrl << endl; debug() << "Timestamp: " << *TimeConversion::now() << endl; + m_errorMessage.clear(); + std::string filePath; if (fileUrl.find("file://") == 0) { diff --git a/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.h b/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.h index 28ebeb618..dcc649d75 100644 --- a/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.h +++ b/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.h @@ -150,6 +150,11 @@ class GstreamerPlayer : virtual public Configurable, */ std::string m_audioDevice; + /** + * Contains runtime error messages from GStreamer. + */ + std::string m_errorMessage; + /** * The URL of the preloaded file. Empty if nothing is preloaded. */