diff --git a/mopidy/backends/gstreamer.py b/mopidy/backends/gstreamer.py index 25c6cca7..ffa72cc8 100644 --- a/mopidy/backends/gstreamer.py +++ b/mopidy/backends/gstreamer.py @@ -17,8 +17,10 @@ logger = logging.getLogger(u'backends.gstreamer') class GStreamerMessages(threading.Thread): def run(self): gobject.MainLoop().run() -GStreamerMessages().start() +message_thread = GStreamerMessages() +message_thread.daemon = True +message_thread.start() class GStreamerBackend(BaseBackend): """ @@ -88,7 +90,8 @@ class GStreamerPlaybackController(BasePlaybackController): def time_position(self): try: return self._bin.query_position(gst.FORMAT_TIME)[0] // gst.MSECOND - except gst.QueryError: + except gst.QueryError, e: + logger.error('time_position failed: %s',e ) return 0 def destroy(self): diff --git a/tests/backends/base.py b/tests/backends/base.py index b0ceef79..0d62554d 100644 --- a/tests/backends/base.py +++ b/tests/backends/base.py @@ -1,5 +1,6 @@ import random import time +import threading from mopidy.mixers.dummy import DummyMixer from mopidy.models import Playlist, Track @@ -546,19 +547,21 @@ class BasePlaybackControllerTest(object): @populate_playlist def test_end_of_track_callback_gets_called(self): end_of_track_callback = self.playback.end_of_track_callback + event = threading.Event() def wrapper(): - wrapper.called = True - return end_of_track_callback() - wrapper.called = False + result = end_of_track_callback() + event.set() + return result self.playback.end_of_track_callback= wrapper self.playback.play() - self.playback.seek(self.tracks[0].length - 1) - time.sleep(0.5) + self.playback.seek(self.tracks[0].length - 10) - self.assert_(wrapper.called) + event.wait(5) + + self.assert_(event.is_set()) @populate_playlist def test_new_playlist_loaded_callback_when_playing(self): @@ -737,9 +740,8 @@ class BasePlaybackControllerTest(object): @populate_playlist def test_time_position_when_playing(self): self.playback.play() - time.sleep(0.2) first = self.playback.time_position - time.sleep(0.2) + time.sleep(1) second = self.playback.time_position self.assert_(second > first, '%s - %s' % (first, second)) diff --git a/tests/data/blank.flac b/tests/data/blank.flac new file mode 100644 index 00000000..b838b98e Binary files /dev/null and b/tests/data/blank.flac differ diff --git a/tests/data/blank.ogg b/tests/data/blank.ogg new file mode 100644 index 00000000..3b1c57a1 Binary files /dev/null and b/tests/data/blank.ogg differ diff --git a/tests/data/blank.wav b/tests/data/blank.wav new file mode 100644 index 00000000..5217ec6f Binary files /dev/null and b/tests/data/blank.wav differ diff --git a/tests/data/song1.flac b/tests/data/song1.flac new file mode 120000 index 00000000..e5e7c129 --- /dev/null +++ b/tests/data/song1.flac @@ -0,0 +1 @@ +blank.flac \ No newline at end of file diff --git a/tests/data/song1.ogg b/tests/data/song1.ogg new file mode 120000 index 00000000..33e773e1 --- /dev/null +++ b/tests/data/song1.ogg @@ -0,0 +1 @@ +blank.ogg \ No newline at end of file diff --git a/tests/data/song1.wav b/tests/data/song1.wav new file mode 120000 index 00000000..72a38fad --- /dev/null +++ b/tests/data/song1.wav @@ -0,0 +1 @@ +blank.wav \ No newline at end of file diff --git a/tests/data/song2.flac b/tests/data/song2.flac new file mode 120000 index 00000000..e5e7c129 --- /dev/null +++ b/tests/data/song2.flac @@ -0,0 +1 @@ +blank.flac \ No newline at end of file diff --git a/tests/data/song2.ogg b/tests/data/song2.ogg new file mode 120000 index 00000000..33e773e1 --- /dev/null +++ b/tests/data/song2.ogg @@ -0,0 +1 @@ +blank.ogg \ No newline at end of file diff --git a/tests/data/song2.wav b/tests/data/song2.wav new file mode 120000 index 00000000..72a38fad --- /dev/null +++ b/tests/data/song2.wav @@ -0,0 +1 @@ +blank.wav \ No newline at end of file diff --git a/tests/data/song3.flac b/tests/data/song3.flac new file mode 120000 index 00000000..e5e7c129 --- /dev/null +++ b/tests/data/song3.flac @@ -0,0 +1 @@ +blank.flac \ No newline at end of file diff --git a/tests/data/song3.ogg b/tests/data/song3.ogg new file mode 120000 index 00000000..33e773e1 --- /dev/null +++ b/tests/data/song3.ogg @@ -0,0 +1 @@ +blank.ogg \ No newline at end of file diff --git a/tests/data/song3.wav b/tests/data/song3.wav new file mode 120000 index 00000000..72a38fad --- /dev/null +++ b/tests/data/song3.wav @@ -0,0 +1 @@ +blank.wav \ No newline at end of file