From 0580a4668898ecb7aeb34bbfcf780634114380db Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sat, 13 Feb 2016 23:37:22 +0100 Subject: [PATCH 1/3] audio: Add a config option for queue buffer size It may help to increase this for users that are experiencing buffering before track changes. Workaround for #1409. --- docs/changelog.rst | 4 ++++ docs/config.rst | 10 ++++++++++ mopidy/audio/actor.py | 5 +++++ mopidy/config/__init__.py | 1 + mopidy/config/default.conf | 1 + 5 files changed, 21 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index ea1b5a76..6cdf5365 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -169,6 +169,10 @@ Audio This should be fixed properly together with :issue:`1222`. (Fixes: :issue:`1430`, PR: :issue:`1438`) +- Add a new config option, buffer_time, for setting the buffer time of the + GStreamer queue. If you experience buffering before track changes, it may + help to increase this. Workaround for :issue:`1409`. + Gapless ------- diff --git a/docs/config.rst b/docs/config.rst index efbf5e86..bf131dbe 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -155,6 +155,16 @@ These are the available audio configurations. For specific use cases, see ``gst-inspect-1.0`` to see what output properties can be set on the sink. For example: ``gst-inspect-1.0 shout2send`` +.. confval:: audio/buffer_time + + Buffer size in milliseconds. + + Expects an integer above 0. + + Sets the buffer size of the GStreamer queue. If you experience buffering + before track changes, it may help to increase this. The default is letting + GStreamer decide the size. + Logging configuration ===================== diff --git a/mopidy/audio/actor.py b/mopidy/audio/actor.py index 02ad48ed..f825a768 100644 --- a/mopidy/audio/actor.py +++ b/mopidy/audio/actor.py @@ -470,6 +470,11 @@ class Audio(pykka.ThreadingActor): # systems. So leave the default to play it safe. queue = Gst.ElementFactory.make('queue') + if self._config['audio']['buffer_time'] > 0: + queue.set_property( + 'max-size-time', + self._config['audio']['buffer_time'] * Gst.MSECOND) + audio_sink.add(queue) audio_sink.add(self._outputs) diff --git a/mopidy/config/__init__.py b/mopidy/config/__init__.py index 042c20d9..21a6a00b 100644 --- a/mopidy/config/__init__.py +++ b/mopidy/config/__init__.py @@ -38,6 +38,7 @@ _audio_schema['mixer_track'] = Deprecated() _audio_schema['mixer_volume'] = Integer(optional=True, minimum=0, maximum=100) _audio_schema['output'] = String() _audio_schema['visualizer'] = Deprecated() +_audio_schema['buffer_time'] = Integer(optional=True, minimum=1) _proxy_schema = ConfigSchema('proxy') _proxy_schema['scheme'] = String(optional=True, diff --git a/mopidy/config/default.conf b/mopidy/config/default.conf index 675381d9..c747703b 100644 --- a/mopidy/config/default.conf +++ b/mopidy/config/default.conf @@ -15,6 +15,7 @@ config_file = mixer = software mixer_volume = output = autoaudiosink +buffer_time = [proxy] scheme = From 3e781310f998100eb34d4dcd767d7337d98e67f6 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sun, 14 Feb 2016 00:15:27 +0100 Subject: [PATCH 2/3] tests: Add buffer_time to test config --- tests/audio/test_actor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/audio/test_actor.py b/tests/audio/test_actor.py index 2bcc792a..b6ec6170 100644 --- a/tests/audio/test_actor.py +++ b/tests/audio/test_actor.py @@ -22,6 +22,7 @@ from tests import dummy_audio, path_to_data_dir class BaseTest(unittest.TestCase): config = { 'audio': { + 'buffer_time': None, 'mixer': 'fakemixer track_max_volume=65536', 'mixer_track': None, 'mixer_volume': None, @@ -38,6 +39,7 @@ class BaseTest(unittest.TestCase): def setUp(self): # noqa: N802 config = { 'audio': { + 'buffer_time': None, 'mixer': 'foomixer', 'mixer_volume': None, 'output': 'testoutput', From 59dadc653594941179b86971c797145b1b22cdaf Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sun, 14 Feb 2016 00:21:22 +0100 Subject: [PATCH 3/3] docs: Link to config and clarify buffer size --- docs/changelog.rst | 6 +++--- docs/config.rst | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 6cdf5365..931e1437 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -169,9 +169,9 @@ Audio This should be fixed properly together with :issue:`1222`. (Fixes: :issue:`1430`, PR: :issue:`1438`) -- Add a new config option, buffer_time, for setting the buffer time of the - GStreamer queue. If you experience buffering before track changes, it may - help to increase this. Workaround for :issue:`1409`. +- Add a new config option, :confval:`audio/buffer_time`, for setting the buffer + time of the GStreamer queue. If you experience buffering before track + changes, it may help to increase this. Workaround for :issue:`1409`. Gapless ------- diff --git a/docs/config.rst b/docs/config.rst index bf131dbe..b0d2e52e 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -162,8 +162,9 @@ These are the available audio configurations. For specific use cases, see Expects an integer above 0. Sets the buffer size of the GStreamer queue. If you experience buffering - before track changes, it may help to increase this. The default is letting - GStreamer decide the size. + before track changes, it may help to increase this, possibly by at least a + few seconds. The default is letting GStreamer decide the size, which at the + time of this writing is 1000. Logging configuration