forked from platypush/platypush
Fixed ffmpeg/audio consumer synchronization upon timeout.
This commit is contained in:
parent
77f7cd8b90
commit
a103ea49f1
2 changed files with 10 additions and 5 deletions
|
@ -253,13 +253,18 @@ class AudioConverter(Thread, ABC):
|
|||
), 'The stdout is closed for the ffmpeg process'
|
||||
|
||||
self._ffmpeg_terminated.clear()
|
||||
|
||||
try:
|
||||
data = await asyncio.wait_for(
|
||||
self.ffmpeg.stdout.read(self._chunk_size), timeout
|
||||
)
|
||||
reader = asyncio.create_task(self.ffmpeg.stdout.read(self._chunk_size))
|
||||
data = await asyncio.wait_for(reader, timeout)
|
||||
self._out_queue.put(data)
|
||||
except asyncio.TimeoutError:
|
||||
self._out_queue.put(b'')
|
||||
pass
|
||||
except Exception as e:
|
||||
self.logger.warning('Audio proxy error: %s', e)
|
||||
break
|
||||
|
||||
self._out_queue.put(b'')
|
||||
|
||||
def write(self, data: bytes):
|
||||
"""
|
||||
|
|
|
@ -324,7 +324,7 @@ class AudioThread(Thread, ABC):
|
|||
"""
|
||||
self.logger.debug('Timeout on converter %s', converter.__class__.__name__)
|
||||
# Continue only if the converter hasn't terminated
|
||||
return self._converter_terminated.is_set()
|
||||
return not self._converter_terminated.is_set()
|
||||
|
||||
@override
|
||||
def run(self):
|
||||
|
|
Loading…
Reference in a new issue