Title: [138545] trunk/Source/WebCore
Revision
138545
Author
[email protected]
Date
2012-12-28 13:04:18 -0800 (Fri, 28 Dec 2012)

Log Message

[GStreamer] GstMessage handler in AudioDestination
https://bugs.webkit.org/show_bug.cgi?id=105292

Reviewed by Martin Robinson.

Handle GStreamer warnings and errors coming from the playback
pipeline. For now we only display warnings on the console.

* platform/audio/gstreamer/AudioDestinationGStreamer.cpp:
(WebCore::messageCallback):
(WebCore):
(WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer):
(WebCore::AudioDestinationGStreamer::finishBuildingPipelineAfterWavParserPadReady):
(WebCore::AudioDestinationGStreamer::handleMessage):
* platform/audio/gstreamer/AudioDestinationGStreamer.h:
(AudioDestinationGStreamer):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (138544 => 138545)


--- trunk/Source/WebCore/ChangeLog	2012-12-28 20:32:06 UTC (rev 138544)
+++ trunk/Source/WebCore/ChangeLog	2012-12-28 21:04:18 UTC (rev 138545)
@@ -1,3 +1,22 @@
+2012-12-28  Philippe Normand  <[email protected]>
+
+        [GStreamer] GstMessage handler in AudioDestination
+        https://bugs.webkit.org/show_bug.cgi?id=105292
+
+        Reviewed by Martin Robinson.
+
+        Handle GStreamer warnings and errors coming from the playback
+        pipeline. For now we only display warnings on the console.
+
+        * platform/audio/gstreamer/AudioDestinationGStreamer.cpp:
+        (WebCore::messageCallback):
+        (WebCore):
+        (WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer):
+        (WebCore::AudioDestinationGStreamer::finishBuildingPipelineAfterWavParserPadReady):
+        (WebCore::AudioDestinationGStreamer::handleMessage):
+        * platform/audio/gstreamer/AudioDestinationGStreamer.h:
+        (AudioDestinationGStreamer):
+
 2012-12-28  Martin Robinson  <[email protected]>
 
         [GTK][WK2] Add support for IME Composition

Modified: trunk/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp (138544 => 138545)


--- trunk/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp	2012-12-28 20:32:06 UTC (rev 138544)
+++ trunk/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp	2012-12-28 21:04:18 UTC (rev 138545)
@@ -36,6 +36,11 @@
 // needs to handle this number of frames per cycle as well.
 const unsigned framesToPull = 128;
 
+gboolean messageCallback(GstBus* bus, GstMessage* message, AudioDestinationGStreamer* destination)
+{
+    return destination->handleMessage(message);
+}
+
 PassOwnPtr<AudioDestination> AudioDestination::create(AudioIOCallback& callback, float sampleRate)
 {
     return adoptPtr(new AudioDestinationGStreamer(callback, sampleRate));
@@ -58,6 +63,9 @@
     , m_isPlaying(false)
 {
     m_pipeline = gst_pipeline_new("play");
+    GRefPtr<GstBus> bus = adoptGRef(gst_pipeline_get_bus(GST_PIPELINE(m_pipeline)));
+    gst_bus_add_signal_watch(bus.get());
+    g_signal_connect(bus.get(), "message", G_CALLBACK(messageCallback), this);
 
     GstElement* webkitAudioSrc = reinterpret_cast<GstElement*>(g_object_new(WEBKIT_TYPE_WEB_AUDIO_SRC,
                                                                             "rate", sampleRate,
@@ -79,6 +87,8 @@
 
 AudioDestinationGStreamer::~AudioDestinationGStreamer()
 {
+    GRefPtr<GstBus> bus = adoptGRef(gst_pipeline_get_bus(GST_PIPELINE(m_pipeline)));
+    g_signal_handlers_disconnect_by_func(bus.get(), reinterpret_cast<gpointer>(messageCallback), this);
     gst_element_set_state(m_pipeline, GST_STATE_NULL);
     gst_object_unref(m_pipeline);
 }
@@ -119,6 +129,28 @@
     gst_element_sync_state_with_parent(audioSink.leakRef());
 }
 
+gboolean AudioDestinationGStreamer::handleMessage(GstMessage* message)
+{
+    GOwnPtr<GError> error;
+    GOwnPtr<gchar> debug;
+
+    switch (GST_MESSAGE_TYPE(message)) {
+    case GST_MESSAGE_WARNING:
+        gst_message_parse_warning(message, &error.outPtr(), &debug.outPtr());
+        g_warning("Warning: %d, %s. Debug output: %s", error->code,  error->message, debug.get());
+        break;
+    case GST_MESSAGE_ERROR:
+        gst_message_parse_error(message, &error.outPtr(), &debug.outPtr());
+        g_warning("Error: %d, %s. Debug output: %s", error->code,  error->message, debug.get());
+        gst_element_set_state(m_pipeline, GST_STATE_NULL);
+        m_isPlaying = false;
+        break;
+    default:
+        break;
+    }
+    return TRUE;
+}
+
 void AudioDestinationGStreamer::start()
 {
     ASSERT(m_wavParserAvailable);

Modified: trunk/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.h (138544 => 138545)


--- trunk/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.h	2012-12-28 20:32:06 UTC (rev 138544)
+++ trunk/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.h	2012-12-28 21:04:18 UTC (rev 138545)
@@ -24,6 +24,7 @@
 
 typedef struct _GstElement GstElement;
 typedef struct _GstPad GstPad;
+typedef struct _GstMessage GstMessage;
 
 namespace WebCore {
 
@@ -40,6 +41,7 @@
     AudioIOCallback& callback() const { return m_callback; }
 
     void finishBuildingPipelineAfterWavParserPadReady(GstPad*);
+    gboolean handleMessage(GstMessage*);
 
 private:
     AudioIOCallback& m_callback;

Modified: trunk/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp (138544 => 138545)


--- trunk/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp	2012-12-28 20:32:06 UTC (rev 138544)
+++ trunk/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp	2012-12-28 21:04:18 UTC (rev 138545)
@@ -148,7 +148,7 @@
 AudioFileReader::~AudioFileReader()
 {
     if (m_pipeline) {
-        GRefPtr<GstBus> bus = gst_pipeline_get_bus(GST_PIPELINE(m_pipeline));
+        GRefPtr<GstBus> bus = adoptGRef(gst_pipeline_get_bus(GST_PIPELINE(m_pipeline)));
         g_signal_handlers_disconnect_by_func(bus.get(), reinterpret_cast<gpointer>(messageCallback), this);
         gst_element_set_state(m_pipeline, GST_STATE_NULL);
         gst_object_unref(GST_OBJECT(m_pipeline));
@@ -331,7 +331,7 @@
     // A deinterleave element is added once a src pad becomes available in decodebin.
     m_pipeline = gst_pipeline_new(0);
 
-    GRefPtr<GstBus> bus = gst_pipeline_get_bus(GST_PIPELINE(m_pipeline));
+    GRefPtr<GstBus> bus = adoptGRef(gst_pipeline_get_bus(GST_PIPELINE(m_pipeline)));
     gst_bus_add_signal_watch(bus.get());
     g_signal_connect(bus.get(), "message", G_CALLBACK(messageCallback), this);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to