tunnel-new: remove uncorking in thread_func. Now handled by state change callback.

tunnel-new handled a corked stream conditional in the thread_func to be
sure the stream isn't corked. Un/Corking is now handled in the
state change callback.

Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
This commit is contained in:
Alexander Couzens 2013-11-25 19:44:14 +01:00 committed by Tanu Kaskinen
parent 5170df86b3
commit c187441ff9

View file

@ -181,39 +181,34 @@ static void thread_func(void *userdata) {
if (u->connected && if (u->connected &&
pa_stream_get_state(u->stream) == PA_STREAM_READY && pa_stream_get_state(u->stream) == PA_STREAM_READY &&
PA_SINK_IS_LINKED(u->sink->thread_info.state)) { PA_SINK_IS_LINKED(u->sink->thread_info.state)) {
/* TODO: Cork the stream when the sink is suspended. */ size_t writable;
if (pa_stream_is_corked(u->stream)) { writable = pa_stream_writable_size(u->stream);
cork_stream(u, false); if (writable > 0) {
} else { pa_memchunk memchunk;
size_t writable; const void *p;
writable = pa_stream_writable_size(u->stream); pa_sink_render_full(u->sink, writable, &memchunk);
if (writable > 0) {
pa_memchunk memchunk;
const void *p;
pa_sink_render_full(u->sink, writable, &memchunk); pa_assert(memchunk.length > 0);
pa_assert(memchunk.length > 0); /* we have new data to write */
p = pa_memblock_acquire(memchunk.memblock);
/* TODO: Use pa_stream_begin_write() to reduce copying. */
ret = pa_stream_write(u->stream,
(uint8_t*) p + memchunk.index,
memchunk.length,
NULL, /**< A cleanup routine for the data or NULL to request an internal copy */
0, /** offset */
PA_SEEK_RELATIVE);
pa_memblock_release(memchunk.memblock);
pa_memblock_unref(memchunk.memblock);
/* we have new data to write */ if (ret != 0) {
p = pa_memblock_acquire(memchunk.memblock); pa_log_error("Could not write data into the stream ... ret = %i", ret);
/* TODO: Use pa_stream_begin_write() to reduce copying. */ u->thread_mainloop_api->quit(u->thread_mainloop_api, TUNNEL_THREAD_FAILED_MAINLOOP);
ret = pa_stream_write(u->stream,
(uint8_t*) p + memchunk.index,
memchunk.length,
NULL, /**< A cleanup routine for the data or NULL to request an internal copy */
0, /** offset */
PA_SEEK_RELATIVE);
pa_memblock_release(memchunk.memblock);
pa_memblock_unref(memchunk.memblock);
if (ret != 0) {
pa_log_error("Could not write data into the stream ... ret = %i", ret);
u->thread_mainloop_api->quit(u->thread_mainloop_api, TUNNEL_THREAD_FAILED_MAINLOOP);
}
} }
} }
} }
} }