Skip to content

Commit

Permalink
move large_packets to the utility superclass so we don't need to over…
Browse files Browse the repository at this point in the history
…ride the make_protocol method to customize the list

git-svn-id: https://xpra.org/svn/Xpra/trunk@8953 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 7, 2015
1 parent b5c37f6 commit da55d29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
4 changes: 4 additions & 0 deletions src/xpra/net/subprocess_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def __init__(self, input_filename="-", output_filename="-", wrapped_object=None,
self.input_filename = input_filename
self.output_filename = output_filename
self.method_whitelist = None
self.large_packets = []
#the gobject instance which is wrapped:
self.wrapped_object = wrapped_object
self.send_queue = Queue()
Expand Down Expand Up @@ -136,6 +137,7 @@ def make_protocol(self):
except Exception as e:
log.warn("failed to enable rencode: %s", e)
protocol.enable_compressor("none")
protocol.large_packets = self.large_packets
return protocol


Expand Down Expand Up @@ -228,6 +230,7 @@ def __init__(self, description="wrapper"):
self.description = description
self.send_queue = Queue()
self.signal_callbacks = {}
self.large_packets = []
#hook a default packet handlers:
self.connect(Protocol.CONNECTION_LOST, self.connection_lost)

Expand Down Expand Up @@ -255,6 +258,7 @@ def make_protocol(self):
protocol.enable_encoder("rencode")
#we assume this is local, so no compression:
protocol.enable_compressor("none")
protocol.large_packets = self.large_packets
return protocol


Expand Down
21 changes: 4 additions & 17 deletions src/xpra/sound/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class sound_subprocess(subprocess_callee):
"""
def __init__(self, wrapped_object, method_whitelist, exports_list):
#add bits common to both record and play:
methods = method_whitelist+["set_volume", "stop"]
methods = method_whitelist+["set_volume", "stop", "cleanup"]
exports = ["state-changed", "bitrate-changed", "error"] + exports_list
subprocess_callee.__init__(self, wrapped_object=wrapped_object, method_whitelist=methods)
for x in exports:
Expand Down Expand Up @@ -77,12 +77,7 @@ def __init__(self, *pipeline_args):
from xpra.sound.src import SoundSource
sound_pipeline = SoundSource(*pipeline_args)
sound_subprocess.__init__(self, sound_pipeline, [], ["new-stream", "new-buffer"])

def make_protocol(self):
#overriden so we can tell that "new-buffer" is a large packet:
p = subprocess_callee.make_protocol(self)
p.large_packets = ["new-buffer"]
return p
self.large_packets = ["new-buffer"]

class sound_play(sound_subprocess):
""" wraps SoundSink as a subprocess """
Expand Down Expand Up @@ -187,14 +182,10 @@ class source_subprocess_wrapper(sound_subprocess_wrapper):

def __init__(self, plugin, options, codecs, volume, element_options):
sound_subprocess_wrapper.__init__(self, "sound-source")
self.large_packets = ["new-buffer"]
self.command = [get_sound_executable(), "_sound_record", "-", "-", plugin or "", "", ",".join(codecs), "", str(volume)]
self._add_debug_args()

def make_protocol(self):
protocol = subprocess_caller.make_protocol(self)
protocol.large_packets = ["new-buffer"]
return protocol

def __repr__(self):
return "source_subprocess_wrapper(%s)" % self.process

Expand All @@ -203,15 +194,11 @@ class sink_subprocess_wrapper(sound_subprocess_wrapper):

def __init__(self, plugin, options, codec, volume, element_options):
sound_subprocess_wrapper.__init__(self, "sound-sink")
self.large_packets = ["add_data"]
self.codec = codec
self.command = [get_sound_executable(), "_sound_play", "-", "-", plugin or "", "", codec, "", str(volume)]
self._add_debug_args()

def make_protocol(self):
protocol = subprocess_caller.make_protocol(self)
protocol.large_packets = ["add_data"]
return protocol

def add_data(self, data, metadata):
if DEBUG_SOUND:
log("add_data(%s bytes, %s) forwarding to %s", len(data), metadata, self.protocol)
Expand Down

0 comments on commit da55d29

Please sign in to comment.