Add mechanism for tearing down backend cleanly

This commit is contained in:
Thomas Adamcik 2010-02-15 08:35:52 +01:00
parent 62be30df04
commit 66965c041e
3 changed files with 13 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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)