[cheese] Show an error message if the camera state is NULL
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] Show an error message if the camera state is NULL
- Date: Wed, 26 Jun 2013 21:18:20 +0000 (UTC)
commit 202e73abf80ad737658a9e7a20f5502a406eb64b
Author: David King <amigadave amigadave com>
Date: Wed Jun 26 22:01:12 2013 +0100
Show an error message if the camera state is NULL
If there is a GST_MESSAGE_ERROR, stop the stream and emit
::state-flags-changed on the CheeseCamera. Handle the state change in
CheeseWindow by showing a generic error message. This message can easily
occur if the video device is busy, such as when another application is
using the webcam.
Fixes bug 703123.
libcheese/cheese-camera.c | 7 +++++--
src/cheese-main.vala | 7 ++++---
src/cheese-window.vala | 9 +++++++++
3 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
index dbad241..a625359 100644
--- a/libcheese/cheese-camera.c
+++ b/libcheese/cheese-camera.c
@@ -184,7 +184,7 @@ cheese_camera_photo_data (CheeseCamera *camera, GstSample *sample)
* @camera: the #CheeseCamera
*
* Process messages create by the @camera on the @bus. Emit
- * ::state-flags-changes if the state of the camera has changed.
+ * ::state-flags-changed if the state of the camera has changed.
*/
static void
cheese_camera_bus_message_cb (GstBus *bus, GstMessage *message, CheeseCamera *camera)
@@ -216,12 +216,15 @@ cheese_camera_bus_message_cb (GstBus *bus, GstMessage *message, CheeseCamera *ca
gst_message_parse_error (message, &err, &debug);
if (err && err->message) {
- g_warning ("%s\n", err->message);
+ g_warning ("%s: %s\n", err->message, debug);
g_error_free (err);
} else {
g_warning ("Unparsable GST_MESSAGE_ERROR message.\n");
}
+ cheese_camera_stop (camera);
+ g_signal_emit (camera, camera_signals[STATE_FLAGS_CHANGED], 0,
+ GST_STATE_NULL);
g_free (debug);
break;
}
diff --git a/src/cheese-main.vala b/src/cheese-main.vala
index 16ea591..51fba55 100644
--- a/src/cheese-main.vala
+++ b/src/cheese-main.vala
@@ -254,10 +254,8 @@ public class Cheese.Main : Gtk.Application
{
video_preview.hide ();
warning ("Error: %s\n", err.message);
- //error_layer.text = err.message;
- //error_layer.show ();
+ main_window.show_error (err.message);
- //toggle_camera_actions_sensitivities (false);
return;
}
@@ -332,6 +330,9 @@ public class Cheese.Main : Gtk.Application
case Gst.State.PLAYING:
main_window.camera_state_change_playing ();
break;
+ case Gst.State.NULL:
+ main_window.camera_state_change_null ();
+ break;
default:
break;
}
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index 584eb6d..ce4596f 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -1282,6 +1282,15 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
}
}
+ /**
+ * Report an error as the camerabin switched to the NULL state.
+ */
+ public void camera_state_change_null ()
+ {
+ show_error (_("There was an error playing video from the webcam"));
+ toggle_camera_actions_sensitivities (false);
+ }
+
/**
* Set wide mode active when started from the command line (and do not change
* the GSetting).
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]