Add mechanism for tearing down backend cleanly
This commit is contained in:
parent
62be30df04
commit
66965c041e
@ -14,6 +14,9 @@ class BaseBackend(object):
|
||||
stored_playlists = None
|
||||
uri_handlers = []
|
||||
|
||||
def destroy(self):
|
||||
self.playback.destroy()
|
||||
|
||||
class BaseCurrentPlaylistController(object):
|
||||
def __init__(self, backend):
|
||||
self.backend = backend
|
||||
@ -164,3 +167,6 @@ class BasePlaybackController(object):
|
||||
@property
|
||||
def volume(self):
|
||||
return self._volume
|
||||
|
||||
def destroy(self):
|
||||
pass
|
||||
|
||||
@ -93,3 +93,7 @@ class GStreamerPlaybackController(BasePlaybackController):
|
||||
@volume.setter
|
||||
def volume(self, value):
|
||||
return self.bin.set_property('volume', float(value) / 100)
|
||||
|
||||
def destroy(self):
|
||||
self.bin.set_state(gst.STATE_NULL)
|
||||
del self.bin
|
||||
|
||||
@ -196,6 +196,9 @@ class BasePlaybackControllerTest(object):
|
||||
self.backend = self.backend_class()
|
||||
self.playback = self.backend.playback
|
||||
|
||||
def tearDown(self):
|
||||
self.backend.destroy()
|
||||
|
||||
def test_initial_state_is_stopped(self):
|
||||
self.assertEqual(self.playback.state, self.playback.STOPPED)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user