Skip to content

Commit

Permalink
nitty gritty
Browse files Browse the repository at this point in the history
  • Loading branch information
bjerrep committed Jun 7, 2019
1 parent 3afadd2 commit 10a416e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 17 deletions.
3 changes: 2 additions & 1 deletion src/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ def server_connector(self):
try:
self.multicast.send({'command': 'get_server_socket',
'to': 'server',
'from': self.id})
'from': self.id,
'version': util.LUDIT_VERSION})
except OSError:
log.warning('got a multicast send exception. Bummer.')

Expand Down
9 changes: 5 additions & 4 deletions src/client/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Channel(Enum):
RIGHT = 1
STEREO = 2


LOG_FIRST_AUDIO_COUNT = 5


Expand Down Expand Up @@ -143,14 +144,14 @@ def construct_pipeline(self, realtime=False):

pipeline += (
'd.src_%s ! tee name=t%s '

'interleave name=i%s ! capssetter caps = audio/x-raw,channels=2,channel-mask=0x3 ! '
'audioconvert ! audioresample ! queue name=lastqueue%s max-size-time=20000000000 ! '
'volume name=vol%s volume=%f ! alsasink sync=true %s buffer-time=%d '

't%s.src_0 ! queue ! audiocheblimit poles=%i name=lowpass%s mode=low-pass cutoff=%f ! '
'%s ! volume name=lowvol%s volume=%f ! i%s.sink_0 '

't%s.src_1 ! queue ! audiocheblimit poles=%i name=highpass%s mode=high-pass cutoff=%f ! '
'volume name=highvol%s volume=%f ! i%s.sink_1 ' %
(channel, channel,
Expand Down Expand Up @@ -193,9 +194,9 @@ def construct_and_start_local_pipeline(self):

def stop_pipeline(self):
if self.pipeline:
self.pipeline.set_state(Gst.State.NULL)
# log.warning('writing pipeline dot file')
# Gst.debug_bin_to_dot_file(self.pipeline, Gst.DebugGraphDetails.ALL, 'ludit_client')
self.pipeline.set_state(Gst.State.NULL)
self.pipeline = None

def has_pipeline(self):
Expand Down
8 changes: 3 additions & 5 deletions src/client/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def process_runtime_message(self, runtime):
gst_setup_elapsed_us = (time.time() - gst_setup_start) * 1000000

if (gst_setup_elapsed_us > target_time_us - i * target_window_us and
gst_setup_elapsed_us < target_time_us + i * target_window_us):
gst_setup_elapsed_us < target_time_us + i * target_window_us):
break

setup_message = 'time setup took %.3f us in %i tries' % (gst_setup_elapsed_us, i)
Expand Down Expand Up @@ -139,7 +139,6 @@ def process_runtime_message(self, runtime):
self.buffer_state = BufferState.MONITOR_STARTING
self.last_status_time = None


def process_server_message(self, message):
"""
A message example (originating from webpage):
Expand Down Expand Up @@ -242,9 +241,8 @@ def run(self):
if self.server_audio_state != ServerAudioState.STOPPED:
self.pipeline_monitor()

if (self.is_playing() and
self.last_status_time and
(time.time() - self.last_status_time > 2)):
if (self.is_playing() and self.last_status_time and
(time.time() - self.last_status_time > 2)):
self.last_status_time = time.time()
self.print_stats()

Expand Down
1 change: 1 addition & 0 deletions src/common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

NS_IN_SEC = 1000000000

LUDIT_VERSION = "0.1"
CONFIG_VERSION = "0.3"

multicast_ip = '225.168.1.102'
Expand Down
2 changes: 1 addition & 1 deletion src/server/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def set_param(self, message):
self.send(message)

except Exception as e:
log.exception('unable to parse parameter')
log.exception('unable to parse parameter %s' % str(e))

def set_param_array(self, name, key, value):
self.jsn[name][key] = float(value)
Expand Down
5 changes: 4 additions & 1 deletion src/server/server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/python
#!/usr/bin/env python3

from common import util
from common.log import logger as log
Expand Down Expand Up @@ -92,6 +92,9 @@ def multicast_rx(self, message):
try:
command = message['command']
if command == 'get_server_socket':
if message['version'] != util.LUDIT_VERSION:
raise Exception('server version is %s but client version is %s' %
(util.LUDIT_VERSION, message['version']))
device = message['from']
groupname, devicename = device.split(':')
endpoint = self.play_sequencer.get_group(groupname).get_device(devicename).get_endpoint()
Expand Down
10 changes: 5 additions & 5 deletions src/server/sourcealsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ def construct_pipeline(self):
else:
device = ''

pipeline = 'alsasrc %s ! '\
'cutter name=cutter leaky=false run-length=%i threshold-dB=%f ! '\
pipeline = 'alsasrc %s ! ' \
'cutter name=cutter leaky=false run-length=%i threshold-dB=%f ! ' \
'faac ! aacparse ! avmux_adts ! appsink name=appsink' % \
(device,
int(float(self.config['timeout']) * util.NS_IN_SEC),
float(self.config['threshold_dB']))
(device,
int(float(self.config['timeout']) * util.NS_IN_SEC),
float(self.config['threshold_dB']))

log.info('launching pipeline listening to alsa %s' % device)
self.pipeline = Gst.parse_launch(pipeline)
Expand Down

0 comments on commit 10a416e

Please sign in to comment.