audio: Remove blocking get_state() calls in get_position() and seek()
This commit is contained in:
parent
8fcc7966b2
commit
167932278b
@ -274,13 +274,11 @@ class Audio(pykka.ThreadingActor):
|
|||||||
|
|
||||||
:rtype: int
|
:rtype: int
|
||||||
"""
|
"""
|
||||||
if self._playbin.get_state()[1] == gst.STATE_NULL:
|
|
||||||
return 0
|
|
||||||
try:
|
try:
|
||||||
position = self._playbin.query_position(gst.FORMAT_TIME)[0]
|
position = self._playbin.query_position(gst.FORMAT_TIME)[0]
|
||||||
return position // gst.MSECOND
|
return position // gst.MSECOND
|
||||||
except gst.QueryError, e:
|
except gst.QueryError:
|
||||||
logger.error('time_position failed: %s', e)
|
logger.debug('Position query failed')
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def set_position(self, position):
|
def set_position(self, position):
|
||||||
@ -291,12 +289,9 @@ class Audio(pykka.ThreadingActor):
|
|||||||
:type position: int
|
:type position: int
|
||||||
:rtype: :class:`True` if successful, else :class:`False`
|
:rtype: :class:`True` if successful, else :class:`False`
|
||||||
"""
|
"""
|
||||||
self._playbin.get_state() # block until state changes are done
|
return self._playbin.seek_simple(
|
||||||
handeled = self._playbin.seek_simple(
|
|
||||||
gst.Format(gst.FORMAT_TIME), gst.SEEK_FLAG_FLUSH,
|
gst.Format(gst.FORMAT_TIME), gst.SEEK_FLAG_FLUSH,
|
||||||
position * gst.MSECOND)
|
position * gst.MSECOND)
|
||||||
self._playbin.get_state() # block until seek is done
|
|
||||||
return handeled
|
|
||||||
|
|
||||||
def start_playback(self):
|
def start_playback(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user