Skip to content

Commit

Permalink
#849: handle volume messages with gstreamer 0.x without generating an…
Browse files Browse the repository at this point in the history
… ugly warning

git-svn-id: https://xpra.org/svn/Xpra/trunk@10251 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 11, 2015
1 parent 63774e4 commit 8951396
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions src/xpra/sound/sound_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from xpra.log import Logger
log = Logger("sound")

from xpra.util import csv
from xpra.gtk_common.gobject_compat import import_gobject, import_glib
from xpra.gtk_common.gobject_util import one_arg_signal
gobject = import_gobject()
Expand All @@ -26,6 +27,11 @@ def inject_fault():
_counter += 1
return (_counter % FAULT_RATE)==0

try:
MESSAGE_ELEMENT = gst.MESSAGE_ELEMENT
except:
#gstreamer 1.x:
MESSAGE_ELEMENT = None

class SoundPipeline(gobject.GObject):

Expand Down Expand Up @@ -190,14 +196,19 @@ def on_message(self, bus, message):
log.error(" %s", details)
self.state = "error"
self.idle_emit("error", str(err))
elif t == gst.MESSAGE_TAG:
elif t == gst.MESSAGE_TAG or t == MESSAGE_ELEMENT:
try:
#Gst 0.10:
assert message.structure is not None, "test for pygst / 0.10"
self.parse_message0(message)
#Gst 0.10: can handle both TAG and ELEMENT:
parse = self.parse_message0
except:
#Gst 1.0:
self.parse_message1(message)
#Gst 1.0: can only handle tag messages for now:
parse = self.parse_message1
try:
parse(message)
except Exception as e:
log.warn("Warning: failed to parse gstreamer message:")
log.warn(" %s: %s", type(e), e)
elif t == gst.MESSAGE_STREAM_STATUS:
log("stream status: %s", message)
elif t == gst.MESSAGE_STREAM_START:
Expand Down Expand Up @@ -259,14 +270,22 @@ def parse_message0(self, message):
log("mode: %s", mode)
self.codec_mode = mode
found = True
if structure.has_field("type"):
if structure["type"]=="volume-changed":
log.info("volumes=%s", csv("%i%%" % (v*100/2**16) for v in structure["volumes"]))
found = True
else:
log.info("type=%s", structure["type"])
if not found:
#these, we know about, so we just log them:
for x in ("minimum-bitrate", "maximum-bitrate", "channel-mode", "container-format"):
if structure.has_field(x):
v = structure[x]
log("tag message: %s = %s", x, v)
return #handled
log.info("unknown sound pipeline tag message %s: %s", message, structure)
log.info("unknown sound pipeline message %s: %s", message, structure)
log.info(" %s", structure.keys())


def parse_message1(self, message):
#message parsing code for GStreamer 1.x
Expand Down

0 comments on commit 8951396

Please sign in to comment.