X-Git-Url: https://code.delx.au/pulseaudio/blobdiff_plain/32e2cd6d3216f780c4cffed0f8eb3c30f2c8d732..89024f6f1216c9fa5afe9c831d4204a184594c05:/src/modules/module-tunnel.c diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c index eaed5f9a..4675a621 100644 --- a/src/modules/module-tunnel.c +++ b/src/modules/module-tunnel.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -41,19 +42,18 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include -#include +#include #include #include #include +#include #ifdef TUNNEL_SINK #include "module-tunnel-sink-symdef.h" @@ -112,7 +112,7 @@ static const char* const valid_modargs[] = { #define DEFAULT_TIMEOUT 5 -#define LATENCY_INTERVAL 10 +#define LATENCY_INTERVAL (10*PA_USEC_PER_SEC) #define MIN_NETWORK_LATENCY_USEC (8*PA_USEC_PER_MSEC) @@ -193,6 +193,7 @@ struct userdata { #else char *source_name; pa_source *source; + pa_mcalign *mcalign; #endif pa_auth_cookie *auth_cookie; @@ -329,7 +330,7 @@ static void command_moved(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa static void command_stream_buffer_attr_changed(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { struct userdata *u = userdata; - uint32_t channel, maxlength, tlength, fragsize, prebuf, minreq; + uint32_t channel, maxlength, tlength = 0, fragsize, prebuf, minreq; pa_usec_t usec; pa_assert(pd); @@ -376,7 +377,7 @@ static void command_stream_buffer_attr_changed(pa_pdispatch *pd, uint32_t comman /* Called from main context */ static void command_started(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { - struct userdata *u = userdata; + struct userdata *u = userdata; pa_assert(pd); pa_assert(t); @@ -390,12 +391,12 @@ static void command_started(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa #endif /* Called from IO thread context */ -static void check_smoother_status(struct userdata *u, pa_bool_t past) { +static void check_smoother_status(struct userdata *u, pa_bool_t past) { pa_usec_t x; pa_assert(u); - x = pa_rtclock_usec(); + x = pa_rtclock_now(); /* Correct by the time the requested issued needs to travel to the * other side. This is a valid thread-safe access, because the @@ -484,7 +485,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse case PA_SINK_MESSAGE_SET_STATE: { int r; - /* First, change the state, because otherwide pa_sink_render() would fail */ + /* First, change the state, because otherwise pa_sink_render() would fail */ if ((r = pa_sink_process_msg(o, code, data, offset, chunk)) >= 0) { stream_cork_within_thread(u, u->sink->state == PA_SINK_SUSPENDED); @@ -500,7 +501,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse pa_usec_t yl, yr, *usec = data; yl = pa_bytes_to_usec((uint64_t) u->counter, &u->sink->sample_spec); - yr = pa_smoother_get(u->smoother, pa_rtclock_usec()); + yr = pa_smoother_get(u->smoother, pa_rtclock_now()); *usec = yl > yr ? yl - yr : 0; return 0; @@ -533,7 +534,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse else y = 0; - pa_smoother_put(u->smoother, pa_rtclock_usec(), y); + pa_smoother_put(u->smoother, pa_rtclock_now(), y); /* We can access this freely here, since the main thread is waiting for us */ u->thread_transport_usec = u->transport_usec; @@ -607,20 +608,29 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off pa_usec_t yr, yl, *usec = data; yl = pa_bytes_to_usec((uint64_t) u->counter, &PA_SOURCE(o)->sample_spec); - yr = pa_smoother_get(u->smoother, pa_rtclock_usec()); + yr = pa_smoother_get(u->smoother, pa_rtclock_now()); *usec = yr > yl ? yr - yl : 0; return 0; } - case SOURCE_MESSAGE_POST: + case SOURCE_MESSAGE_POST: { + pa_memchunk c; + + pa_mcalign_push(u->mcalign, chunk); - if (PA_SOURCE_IS_OPENED(u->source->thread_info.state)) - pa_source_post(u->source, chunk); + while (pa_mcalign_pop(u->mcalign, &c) >= 0) { - u->counter += (int64_t) chunk->length; + if (PA_SOURCE_IS_OPENED(u->source->thread_info.state)) + pa_source_post(u->source, &c); + + pa_memblock_unref(c.memblock); + + u->counter += (int64_t) c.length; + } return 0; + } case SOURCE_MESSAGE_REMOTE_SUSPEND: @@ -633,7 +643,7 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off y = pa_bytes_to_usec((uint64_t) u->counter, &u->source->sample_spec); y += (pa_usec_t) offset; - pa_smoother_put(u->smoother, pa_rtclock_usec(), y); + pa_smoother_put(u->smoother, pa_rtclock_now(), y); /* We can access this freely here, since the main thread is waiting for us */ u->thread_transport_usec = u->transport_usec; @@ -877,9 +887,8 @@ static void request_latency(struct userdata *u) { } /* Called from main context */ -static void timeout_callback(pa_mainloop_api *m, pa_time_event*e, const struct timeval *tv, void *userdata) { +static void timeout_callback(pa_mainloop_api *m, pa_time_event *e, const struct timeval *t, void *userdata) { struct userdata *u = userdata; - struct timeval ntv; pa_assert(m); pa_assert(e); @@ -887,9 +896,7 @@ static void timeout_callback(pa_mainloop_api *m, pa_time_event*e, const struct request_latency(u); - pa_gettimeofday(&ntv); - ntv.tv_sec += LATENCY_INTERVAL; - m->time_restart(e, &ntv); + pa_core_rttime_restart(u->core, e, pa_rtclock_now() + LATENCY_INTERVAL); } /* Called from main context */ @@ -964,8 +971,7 @@ static void server_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa pa_tagstruct_gets(t, &default_sink_name) < 0 || pa_tagstruct_gets(t, &default_source_name) < 0 || pa_tagstruct_getu32(t, &cookie) < 0 || - (u->version >= 15 && - pa_tagstruct_get_channel_map(t, &cm) < 0)) { + (u->version >= 15 && pa_tagstruct_get_channel_map(t, &cm) < 0)) { pa_log("Parse failure"); goto fail; @@ -990,6 +996,63 @@ fail: pa_module_unload_request(u->module, TRUE); } +static int read_ports(struct userdata *u, pa_tagstruct *t) +{ + if (u->version >= 16) { + uint32_t n_ports; + const char *s; + + if (pa_tagstruct_getu32(t, &n_ports)) { + pa_log("Parse failure"); + return -PA_ERR_PROTOCOL; + } + + for (uint32_t j = 0; j < n_ports; j++) { + uint32_t priority; + + if (pa_tagstruct_gets(t, &s) < 0 || /* name */ + pa_tagstruct_gets(t, &s) < 0 || /* description */ + pa_tagstruct_getu32(t, &priority) < 0) { + + pa_log("Parse failure"); + return -PA_ERR_PROTOCOL; + } + if (u->version >= 24 && pa_tagstruct_getu32(t, &priority) < 0) { /* available */ + pa_log("Parse failure"); + return -PA_ERR_PROTOCOL; + } + } + + if (pa_tagstruct_gets(t, &s) < 0) { /* active port */ + pa_log("Parse failure"); + return -PA_ERR_PROTOCOL; + } + } + return 0; +} + + +static int read_formats(struct userdata *u, pa_tagstruct *t) { + uint8_t n_formats; + pa_format_info *format; + + if (pa_tagstruct_getu8(t, &n_formats) < 0) { /* no. of formats */ + pa_log("Parse failure"); + return -PA_ERR_PROTOCOL; + } + + for (uint8_t j = 0; j < n_formats; j++) { + format = pa_format_info_new(); + if (pa_tagstruct_get_format_info(t, format)) { /* format info */ + pa_format_info_free(format); + pa_log("Parse failure"); + return -PA_ERR_PROTOCOL; + } + pa_format_info_free(format); + } + return 0; +} + #ifdef TUNNEL_SINK /* Called from main context */ @@ -1002,13 +1065,10 @@ static void sink_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_t pa_cvolume volume; pa_bool_t mute; pa_usec_t latency; - pa_proplist *pl; pa_assert(pd); pa_assert(u); - pl = pa_proplist_new(); - if (command != PA_COMMAND_REPLY) { if (command == PA_COMMAND_ERROR) pa_log("Failed to get info."); @@ -1038,7 +1098,7 @@ static void sink_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_t if (u->version >= 13) { pa_usec_t configured_latency; - if (pa_tagstruct_get_proplist(t, pl) < 0 || + if (pa_tagstruct_get_proplist(t, NULL) < 0 || pa_tagstruct_get_usec(t, &configured_latency) < 0) { pa_log("Parse failure"); @@ -1060,14 +1120,18 @@ static void sink_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_t } } + if (read_ports(u, t) < 0) + goto fail; + + if (u->version >= 21 && read_formats(u, t) < 0) + goto fail; + if (!pa_tagstruct_eof(t)) { pa_log("Packet too long"); goto fail; } - pa_proplist_free(pl); - - if (!u->sink_name || strcmp(name, u->sink_name)) + if (!u->sink_name || !pa_streq(name, u->sink_name)) return; pa_xfree(u->device_description); @@ -1079,7 +1143,6 @@ static void sink_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_t fail: pa_module_unload_request(u->module, TRUE); - pa_proplist_free(pl); } /* Called from main context */ @@ -1088,17 +1151,15 @@ static void sink_input_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag uint32_t idx, owner_module, client, sink; pa_usec_t buffer_usec, sink_usec; const char *name, *driver, *resample_method; - pa_bool_t mute; + pa_bool_t mute = FALSE; pa_sample_spec sample_spec; pa_channel_map channel_map; pa_cvolume volume; - pa_proplist *pl; + pa_bool_t b; pa_assert(pd); pa_assert(u); - pl = pa_proplist_new(); - if (command != PA_COMMAND_REPLY) { if (command == PA_COMMAND_ERROR) pa_log("Failed to get info."); @@ -1133,39 +1194,64 @@ static void sink_input_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag } if (u->version >= 13) { - if (pa_tagstruct_get_proplist(t, pl) < 0) { + if (pa_tagstruct_get_proplist(t, NULL) < 0) { + + pa_log("Parse failure"); + goto fail; + } + } + + if (u->version >= 19) { + if (pa_tagstruct_get_boolean(t, &b) < 0) { pa_log("Parse failure"); goto fail; } } + if (u->version >= 20) { + if (pa_tagstruct_get_boolean(t, &b) < 0 || + pa_tagstruct_get_boolean(t, &b) < 0) { + + pa_log("Parse failure"); + goto fail; + } + } + + if (u->version >= 21) { + pa_format_info *format = pa_format_info_new(); + + if (pa_tagstruct_get_format_info(t, format) < 0) { + pa_format_info_free(format); + pa_log("Parse failure"); + goto fail; + } + pa_format_info_free(format); + } + if (!pa_tagstruct_eof(t)) { pa_log("Packet too long"); goto fail; } - pa_proplist_free(pl); - if (idx != u->device_index) return; pa_assert(u->sink); if ((u->version < 11 || !!mute == !!u->sink->muted) && - pa_cvolume_equal(&volume, &u->sink->virtual_volume)) + pa_cvolume_equal(&volume, &u->sink->real_volume)) return; - pa_sink_volume_changed(u->sink, &volume, FALSE); + pa_sink_volume_changed(u->sink, &volume); if (u->version >= 11) - pa_sink_mute_changed(u->sink, mute, FALSE); + pa_sink_mute_changed(u->sink, mute); return; fail: pa_module_unload_request(u->module, TRUE); - pa_proplist_free(pl); } #else @@ -1180,13 +1266,10 @@ static void source_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa pa_cvolume volume; pa_bool_t mute; pa_usec_t latency, configured_latency; - pa_proplist *pl; pa_assert(pd); pa_assert(u); - pl = pa_proplist_new(); - if (command != PA_COMMAND_REPLY) { if (command == PA_COMMAND_ERROR) pa_log("Failed to get info."); @@ -1214,7 +1297,7 @@ static void source_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa } if (u->version >= 13) { - if (pa_tagstruct_get_proplist(t, pl) < 0 || + if (pa_tagstruct_get_proplist(t, NULL) < 0 || pa_tagstruct_get_usec(t, &configured_latency) < 0) { pa_log("Parse failure"); @@ -1236,14 +1319,18 @@ static void source_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa } } + if (read_ports(u, t) < 0) + goto fail; + + if (u->version >= 22 && read_formats(u, t) < 0) + goto fail; + if (!pa_tagstruct_eof(t)) { pa_log("Packet too long"); goto fail; } - pa_proplist_free(pl); - - if (!u->source_name || strcmp(name, u->source_name)) + if (!u->source_name || !pa_streq(name, u->source_name)) return; pa_xfree(u->device_description); @@ -1255,7 +1342,6 @@ static void source_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa fail: pa_module_unload_request(u->module, TRUE); - pa_proplist_free(pl); } #endif @@ -1336,12 +1422,11 @@ static void command_subscribe_event(pa_pdispatch *pd, uint32_t command, uint32 /* Called from main context */ static void start_subscribe(struct userdata *u) { pa_tagstruct *t; - uint32_t tag; pa_assert(u); t = pa_tagstruct_new(NULL, 0); pa_tagstruct_putu32(t, PA_COMMAND_SUBSCRIBE); - pa_tagstruct_putu32(t, tag = u->ctag++); + pa_tagstruct_putu32(t, u->ctag++); pa_tagstruct_putu32(t, PA_SUBSCRIPTION_MASK_SERVER| #ifdef TUNNEL_SINK PA_SUBSCRIPTION_MASK_SINK_INPUT|PA_SUBSCRIPTION_MASK_SINK @@ -1356,7 +1441,6 @@ static void start_subscribe(struct userdata *u) { /* Called from main context */ static void create_stream_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { struct userdata *u = userdata; - struct timeval ntv; #ifdef TUNNEL_SINK uint32_t bytes; #endif @@ -1431,6 +1515,17 @@ static void create_stream_callback(pa_pdispatch *pd, uint32_t command, uint32_t /* #endif */ } + if (u->version >= 21) { + pa_format_info *format = pa_format_info_new(); + + if (pa_tagstruct_get_format_info(t, format) < 0) { + pa_format_info_free(format); + goto parse_error; + } + + pa_format_info_free(format); + } + if (!pa_tagstruct_eof(t)) goto parse_error; @@ -1438,9 +1533,7 @@ static void create_stream_callback(pa_pdispatch *pd, uint32_t command, uint32_t request_info(u); pa_assert(!u->time_event); - pa_gettimeofday(&ntv); - ntv.tv_sec += LATENCY_INTERVAL; - u->time_event = u->core->mainloop->time_new(u->core->mainloop, &ntv, timeout_callback, u); + u->time_event = pa_core_rttime_new(u->core, pa_rtclock_now() + LATENCY_INTERVAL, timeout_callback, u); request_latency(u); @@ -1465,9 +1558,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t struct userdata *u = userdata; pa_tagstruct *reply; char name[256], un[128], hn[128]; -#ifdef TUNNEL_SINK pa_cvolume volume; -#endif pa_assert(pd); pa_assert(u); @@ -1520,7 +1611,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t reply = pa_tagstruct_new(NULL, 0); pa_tagstruct_putu32(reply, PA_COMMAND_SET_CLIENT_NAME); - pa_tagstruct_putu32(reply, tag = u->ctag++); + pa_tagstruct_putu32(reply, u->ctag++); if (u->version >= 13) { pa_proplist *pl; @@ -1627,6 +1718,33 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t pa_tagstruct_put_boolean(reply, FALSE); /* fail on suspend */ } +#ifdef TUNNEL_SINK + if (u->version >= 17) + pa_tagstruct_put_boolean(reply, FALSE); /* relative volume */ + + if (u->version >= 18) + pa_tagstruct_put_boolean(reply, FALSE); /* passthrough stream */ +#endif + +#ifdef TUNNEL_SINK + if (u->version >= 21) { + /* We're not using the extended API, so n_formats = 0 and that's that */ + pa_tagstruct_putu8(reply, 0); + } +#else + if (u->version >= 22) { + /* We're not using the extended API, so n_formats = 0 and that's that */ + pa_tagstruct_putu8(reply, 0); + pa_cvolume_reset(&volume, u->source->sample_spec.channels); + pa_tagstruct_put_cvolume(reply, &volume); + pa_tagstruct_put_boolean(reply, FALSE); /* muted */ + pa_tagstruct_put_boolean(reply, FALSE); /* volume_set */ + pa_tagstruct_put_boolean(reply, FALSE); /* muted_set */ + pa_tagstruct_put_boolean(reply, FALSE); /* relative volume */ + pa_tagstruct_put_boolean(reply, FALSE); /* passthrough stream */ + } +#endif + pa_pstream_send_tagstruct(u->pstream, reply); pa_pdispatch_register_reply(u->pdispatch, tag, DEFAULT_TIMEOUT, create_stream_callback, u, NULL); @@ -1705,12 +1823,12 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata } u->pstream = pa_pstream_new(u->core->mainloop, io, u->core->mempool); - u->pdispatch = pa_pdispatch_new(u->core->mainloop, command_table, PA_COMMAND_MAX); + u->pdispatch = pa_pdispatch_new(u->core->mainloop, TRUE, command_table, PA_COMMAND_MAX); pa_pstream_set_die_callback(u->pstream, pstream_die_callback, u); - pa_pstream_set_recieve_packet_callback(u->pstream, pstream_packet_callback, u); + pa_pstream_set_receive_packet_callback(u->pstream, pstream_packet_callback, u); #ifndef TUNNEL_SINK - pa_pstream_set_recieve_memblock_callback(u->pstream, pstream_memblock_callback, u); + pa_pstream_set_receive_memblock_callback(u->pstream, pstream_memblock_callback, u); #endif t = pa_tagstruct_new(NULL, 0); @@ -1747,7 +1865,6 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata static void sink_set_volume(pa_sink *sink) { struct userdata *u; pa_tagstruct *t; - uint32_t tag; pa_assert(sink); u = sink->userdata; @@ -1755,9 +1872,9 @@ static void sink_set_volume(pa_sink *sink) { t = pa_tagstruct_new(NULL, 0); pa_tagstruct_putu32(t, PA_COMMAND_SET_SINK_INPUT_VOLUME); - pa_tagstruct_putu32(t, tag = u->ctag++); + pa_tagstruct_putu32(t, u->ctag++); pa_tagstruct_putu32(t, u->device_index); - pa_tagstruct_put_cvolume(t, &sink->virtual_volume); + pa_tagstruct_put_cvolume(t, &sink->real_volume); pa_pstream_send_tagstruct(u->pstream, t); } @@ -1765,7 +1882,6 @@ static void sink_set_volume(pa_sink *sink) { static void sink_set_mute(pa_sink *sink) { struct userdata *u; pa_tagstruct *t; - uint32_t tag; pa_assert(sink); u = sink->userdata; @@ -1776,7 +1892,7 @@ static void sink_set_mute(pa_sink *sink) { t = pa_tagstruct_new(NULL, 0); pa_tagstruct_putu32(t, PA_COMMAND_SET_SINK_INPUT_MUTE); - pa_tagstruct_putu32(t, tag = u->ctag++); + pa_tagstruct_putu32(t, u->ctag++); pa_tagstruct_putu32(t, u->device_index); pa_tagstruct_put_boolean(t, !!sink->muted); pa_pstream_send_tagstruct(u->pstream, t); @@ -1824,7 +1940,7 @@ int pa__init(pa_module*m) { TRUE, TRUE, 10, - pa_rtclock_usec(), + pa_rtclock_now(), FALSE); u->ctag = 1; u->device_index = u->channel = PA_INVALID_INDEX; @@ -1837,7 +1953,7 @@ int pa__init(pa_module*m) { u->rtpoll = pa_rtpoll_new(); pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll); - if (!(u->auth_cookie = pa_auth_cookie_get(u->core, pa_modargs_get_value(ma, "cookie", PA_NATIVE_COOKIE_FILE), PA_NATIVE_COOKIE_LENGTH))) + if (!(u->auth_cookie = pa_auth_cookie_get(u->core, pa_modargs_get_value(ma, "cookie", PA_NATIVE_COOKIE_FILE), TRUE, PA_NATIVE_COOKIE_LENGTH))) goto fail; if (!(u->server_name = pa_xstrdup(pa_modargs_get_value(ma, "server", NULL)))) { @@ -1852,7 +1968,7 @@ int pa__init(pa_module*m) { goto fail; } - if (!(u->client = pa_socket_client_new_string(m->core->mainloop, u->server_name, PA_NATIVE_DEFAULT_PORT))) { + if (!(u->client = pa_socket_client_new_string(m->core->mainloop, TRUE, u->server_name, PA_NATIVE_DEFAULT_PORT))) { pa_log("Failed to connect to server '%s'", u->server_name); goto fail; } @@ -1862,7 +1978,7 @@ int pa__init(pa_module*m) { #ifdef TUNNEL_SINK if (!(dn = pa_xstrdup(pa_modargs_get_value(ma, "sink_name", NULL)))) - dn = pa_sprintf_malloc("tunnel.%s", u->server_name); + dn = pa_sprintf_malloc("tunnel-sink.%s", u->server_name); pa_sink_new_data_init(&data); data.driver = __FILE__; @@ -1882,7 +1998,7 @@ int pa__init(pa_module*m) { goto fail; } - u->sink = pa_sink_new(m->core, &data, PA_SINK_NETWORK|PA_SINK_LATENCY|PA_SINK_HW_VOLUME_CTRL|PA_SINK_HW_MUTE_CTRL); + u->sink = pa_sink_new(m->core, &data, PA_SINK_NETWORK|PA_SINK_LATENCY); pa_sink_new_data_done(&data); if (!u->sink) { @@ -1893,8 +2009,8 @@ int pa__init(pa_module*m) { u->sink->parent.process_msg = sink_process_msg; u->sink->userdata = u; u->sink->set_state = sink_set_state; - u->sink->set_volume = sink_set_volume; - u->sink->set_mute = sink_set_mute; + pa_sink_set_set_volume_callback(u->sink, sink_set_volume); + pa_sink_set_set_mute_callback(u->sink, sink_set_mute); u->sink->refresh_volume = u->sink->refresh_muted = FALSE; @@ -1906,7 +2022,7 @@ int pa__init(pa_module*m) { #else if (!(dn = pa_xstrdup(pa_modargs_get_value(ma, "source_name", NULL)))) - dn = pa_sprintf_malloc("tunnel.%s", u->server_name); + dn = pa_sprintf_malloc("tunnel-source.%s", u->server_name); pa_source_new_data_init(&data); data.driver = __FILE__; @@ -1942,6 +2058,8 @@ int pa__init(pa_module*m) { pa_source_set_asyncmsgq(u->source, u->thread_mq.inq); pa_source_set_rtpoll(u->source, u->rtpoll); + + u->mcalign = pa_mcalign_new(pa_frame_size(&u->source->sample_spec)); #endif pa_xfree(dn); @@ -1955,7 +2073,7 @@ int pa__init(pa_module*m) { u->fragsize = (uint32_t) -1; #endif - if (!(u->thread = pa_thread_new(thread_func, u))) { + if (!(u->thread = pa_thread_new("module-tunnel", thread_func, u))) { pa_log("Failed to create thread."); goto fail; } @@ -1978,7 +2096,7 @@ fail: pa_xfree(dn); - return -1; + return -1; } void pa__done(pa_module*m) { @@ -2035,6 +2153,11 @@ void pa__done(pa_module*m) { if (u->time_event) u->core->mainloop->time_free(u->time_event); +#ifndef TUNNEL_SINK + if (u->mcalign) + pa_mcalign_free(u->mcalign); +#endif + #ifdef TUNNEL_SINK pa_xfree(u->sink_name); #else