* morituri/common/gstreamer.py:

Add a stop method and a stopped overridable handler.
	* morituri/common/checksum.py:
	* morituri/common/encode.py:
	  Adapt to using stopped.
This commit is contained in:
Thomas Vander Stichele
2011-05-23 15:26:19 +00:00
parent 1ce46272a9
commit 3482288750
4 changed files with 35 additions and 24 deletions

View File

@@ -1,3 +1,11 @@
2011-05-23 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/common/gstreamer.py:
Add a stop method and a stopped overridable handler.
* morituri/common/checksum.py:
* morituri/common/encode.py:
Adapt to using stopped.
2011-05-23 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/test/test_common_encode.py:

View File

@@ -177,11 +177,7 @@ class ChecksumTask(gstreamer.GstPipelineTask):
self.debug('eos, scheduling stop')
self.runner.schedule(0, self.stop)
def stop(self):
self.debug('stopping')
self.debug('setting state to NULL')
self.pipeline.set_state(gst.STATE_NULL)
def stopped(self):
if not self._last:
# see http://bugzilla.gnome.org/show_bug.cgi?id=578612
print 'ERROR: checksum: not a single buffer gotten'
@@ -199,9 +195,7 @@ class ChecksumTask(gstreamer.GstPipelineTask):
print 'ERROR: did not get all frames, %d missing' % (
self._frameEnd - last)
# publicize and stop
self.checksum = self._checksum
task.Task.stop(self)
class CRC32Task(ChecksumTask):
"""
@@ -336,11 +330,5 @@ class TRMTask(gstreamer.GstPipelineTask):
position += buf.duration
self.setProgress(float(position) / self._length)
def stop(self):
gst.debug('stopping')
gst.debug('setting state to NULL')
self.pipeline.set_state(gst.STATE_NULL)
# publicize and stop
def stopped(self):
self.trm = self._trm
task.Task.stop(self)

View File

@@ -259,16 +259,7 @@ class EncodeTask(gstreamer.GstPipelineTask):
self.log('higher peakdB found, now %r', self._peakdB)
self._peakdB = p
# FIXME: move to base class, have stopped handler ?
def stop(self):
self.debug('stopping')
self.debug('setting state to NULL')
self.pipeline.set_state(self.gst.STATE_NULL)
self.debug('set state to NULL')
# FIXME: maybe this should move lower ? If used by BaseMultiTask,
# this starts the next task without showing us the peakdB
task.Task.stop(self)
def stopped(self):
if self._peakdB is not None:
self.debug('peakdB %r', self._peakdB)
self.peak = math.sqrt(math.pow(10, self._peakdB / 10.0))

View File

@@ -40,6 +40,7 @@ class GstPipelineTask(task.Task):
gst = None
### task.Task implementations
def start(self, runner):
import gst
self.gst = gst
@@ -76,9 +77,25 @@ class GstPipelineTask(task.Task):
else:
raise self.exception
def stop(self):
self.debug('stopping')
self.debug('setting state to NULL')
self.pipeline.set_state(self.gst.STATE_NULL)
self.debug('set state to NULL')
self.stopped()
task.Task.stop(self)
### subclass required implementations
def getPipelineDesc(self):
"""
subclasses should implement this to provide a pipeline description.
@rtype: str
"""
raise NotImplementedError
### subclass optional implementations
def parsed(self):
"""
Called after parsing the pipeline but before setting it to paused.
@@ -91,6 +108,13 @@ class GstPipelineTask(task.Task):
"""
pass
def stopped(self):
"""
Called after pipeline is set back to NULL but before chaining up to
stop()
"""
pass
def bus_eos_cb(self, bus, message):
"""
Called synchronously (ie from messaging thread) on eos message.