Ticket #593 (closed enhancement: fixed)
How to modify pacat to route source to sink with minimum latency
| Reported by: | knightk | Owned by: | lennart |
|---|---|---|---|
| Milestone: | 0.9.16 | Component: | clients |
| Keywords: | Cc: |
Description (last modified by coling) (diff)
I'm capturing stereo analog audio at rate=44100, format=s16le channels=2 using module-alsa-source. I'm sinking out to USB at rate=44100, format=s16le, channels=2 using module-alsa-sink.
pacat -r --format=s16le --rate=44100 --channels=2 | pacat -p --format=s16le --rate=44100 --channels=2
is working but the latency is 1-2 seconds and a lot of packets are dropped.
I want to modify pacat to route source to sink internally without piping.
Can anyone confirm that my approach is OK, which is as follows:-
- in main() comment out stdio_event = mainloop_api->io_new (because I don't want the daemon to poll stdin/stdout callbacks.
- in context_state_callback() create both sink_stream and source_stream but only callback on the source_stream. Set up attr so that prebuf is 0 and call pa_stream_trigger(sink_stream, stream_trigger_complet_cb, NULL) [for immediate playback], then connect for both source and sink streams.
- When source_callback is called pa_stream_peek(source_stream, &data, &length) then pa_stream_write(sink_stream, data, length, PA_SEEK_RELATIVE).
I'm unsure about using zero_copy i.e. data points to captured packet in the source buffer. Am I transferring from the source buffer to the sink buffer?
Change History
Note: See
TracTickets for help on using
tickets.
