[orca] Add some sanity checks to prevent crashing due to GStreamer failure
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Add some sanity checks to prevent crashing due to GStreamer failure
- Date: Mon, 31 Aug 2020 11:26:18 +0000 (UTC)
commit fab3115af35cd0c821f5a05d24db8206e2673f0c
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Mon Aug 31 13:21:39 2020 +0200
Add some sanity checks to prevent crashing due to GStreamer failure
GStreamer can be initialized but still fail to create an element.
Add checks for this condition so we don't crash upon launch.
See gitlab issue #161
src/orca/sound.py | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/orca/sound.py b/src/orca/sound.py
index 7c7cbc73e..724db5fac 100644
--- a/src/orca/sound.py
+++ b/src/orca/sound.py
@@ -46,6 +46,8 @@ class Player:
self._initialized = False
self._source = None
self._sink = None
+ self._player = None
+ self._pipeline = None
if not _gstreamerAvailable:
msg = 'SOUND ERROR: Gstreamer is not available'
@@ -108,6 +110,11 @@ class Player:
return
self._player = Gst.ElementFactory.make('playbin', 'player')
+ if self._player is None:
+ msg = 'SOUND ERROR: Gstreamer is available, but player is None'
+ debug.println(debug.LEVEL_INFO, msg, True)
+ return
+
bus = self._player.get_bus()
bus.add_signal_watch()
bus.connect("message", self._onPlayerMessage)
@@ -149,8 +156,11 @@ class Player:
element.set_state(Gst.State.NULL)
return
- self._player.set_state(Gst.State.NULL)
- self._pipeline.set_state(Gst.State.NULL)
+ if self._player:
+ self._player.set_state(Gst.State.NULL)
+
+ if self._pipeline:
+ self._pipeline.set_state(Gst.State.NULL)
def shutdown(self):
"""Shuts down the sound utilities."""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]