transports: don't queue system frames
This commit is contained in:
@@ -83,9 +83,9 @@ class BaseInputTransport(FrameProcessor):
|
|||||||
await super().process_frame(frame, direction)
|
await super().process_frame(frame, direction)
|
||||||
|
|
||||||
if isinstance(frame, CancelFrame):
|
if isinstance(frame, CancelFrame):
|
||||||
|
await self.stop()
|
||||||
# We don't queue a CancelFrame since we want to stop ASAP.
|
# We don't queue a CancelFrame since we want to stop ASAP.
|
||||||
await self.push_frame(frame, direction)
|
await self.push_frame(frame, direction)
|
||||||
await self.stop()
|
|
||||||
elif isinstance(frame, StartFrame):
|
elif isinstance(frame, StartFrame):
|
||||||
await self.start(frame)
|
await self.start(frame)
|
||||||
await self._internal_push_frame(frame, direction)
|
await self._internal_push_frame(frame, direction)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ from pipecat.frames.frames import (
|
|||||||
ImageRawFrame,
|
ImageRawFrame,
|
||||||
StartInterruptionFrame,
|
StartInterruptionFrame,
|
||||||
StopInterruptionFrame,
|
StopInterruptionFrame,
|
||||||
|
SystemFrame,
|
||||||
TransportMessageFrame)
|
TransportMessageFrame)
|
||||||
from pipecat.transports.base_transport import TransportParams
|
from pipecat.transports.base_transport import TransportParams
|
||||||
|
|
||||||
@@ -53,6 +54,7 @@ class BaseOutputTransport(FrameProcessor):
|
|||||||
if self._params.camera_out_enabled:
|
if self._params.camera_out_enabled:
|
||||||
self._camera_out_queue = queue.Queue()
|
self._camera_out_queue = queue.Queue()
|
||||||
self._sink_queue = queue.Queue()
|
self._sink_queue = queue.Queue()
|
||||||
|
self._sink_thread = None
|
||||||
|
|
||||||
self._stopped_event = asyncio.Event()
|
self._stopped_event = asyncio.Event()
|
||||||
self._is_interrupted = threading.Event()
|
self._is_interrupted = threading.Event()
|
||||||
@@ -106,7 +108,8 @@ class BaseOutputTransport(FrameProcessor):
|
|||||||
if self._params.camera_out_enabled:
|
if self._params.camera_out_enabled:
|
||||||
await self._camera_out_thread
|
await self._camera_out_thread
|
||||||
|
|
||||||
await self._sink_thread
|
if self._sink_thread:
|
||||||
|
await self._sink_thread
|
||||||
|
|
||||||
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
||||||
await super().process_frame(frame, direction)
|
await super().process_frame(frame, direction)
|
||||||
@@ -121,11 +124,13 @@ class BaseOutputTransport(FrameProcessor):
|
|||||||
self._sink_queue.put_nowait(frame)
|
self._sink_queue.put_nowait(frame)
|
||||||
# EndFrame is managed in the queue handler.
|
# EndFrame is managed in the queue handler.
|
||||||
elif isinstance(frame, CancelFrame):
|
elif isinstance(frame, CancelFrame):
|
||||||
await self.push_frame(frame, direction)
|
|
||||||
await self.stop()
|
await self.stop()
|
||||||
elif isinstance(frame, StartInterruptionFrame) or isinstance(frame, StopInterruptionFrame):
|
|
||||||
await self.push_frame(frame, direction)
|
await self.push_frame(frame, direction)
|
||||||
|
elif isinstance(frame, StartInterruptionFrame) or isinstance(frame, StopInterruptionFrame):
|
||||||
await self._handle_interruptions(frame)
|
await self._handle_interruptions(frame)
|
||||||
|
await self.push_frame(frame, direction)
|
||||||
|
elif isinstance(frame, SystemFrame):
|
||||||
|
await self.push_frame(frame, direction)
|
||||||
else:
|
else:
|
||||||
self._sink_queue.put_nowait(frame)
|
self._sink_queue.put_nowait(frame)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user