mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-31 22:25:33 -04:00
tunnel modules: Fix threading issues
The old tunnel modules switched wrongly between main thread and I/O-thread while the new tunnel modules sent unnecessary messages to the main thread. This patch fixes the issues. Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/705>
This commit is contained in:
parent
0adb12e099
commit
c3d1db2f28
3 changed files with 23 additions and 39 deletions
|
|
@ -342,7 +342,7 @@ static void maybe_restart(struct userdata *u) {
|
||||||
pa_restart_module_reinit(u->module, do_init, do_done, u->reconnect_interval_us);
|
pa_restart_module_reinit(u->module, do_init, do_done, u->reconnect_interval_us);
|
||||||
} else {
|
} else {
|
||||||
/* exit the module */
|
/* exit the module */
|
||||||
pa_asyncmsgq_post(u->thread_mq->outq, PA_MSGOBJECT(u->module->core), PA_CORE_MESSAGE_UNLOAD_MODULE, u->module, 0, NULL, NULL);
|
pa_module_unload_request(u->module, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -328,7 +328,7 @@ static void maybe_restart(struct userdata *u) {
|
||||||
pa_restart_module_reinit(u->module, do_init, do_done, u->reconnect_interval_us);
|
pa_restart_module_reinit(u->module, do_init, do_done, u->reconnect_interval_us);
|
||||||
} else {
|
} else {
|
||||||
/* exit the module */
|
/* exit the module */
|
||||||
pa_asyncmsgq_post(u->thread_mq->outq, PA_MSGOBJECT(u->module->core), PA_CORE_MESSAGE_UNLOAD_MODULE, u->module, 0, NULL, NULL);
|
pa_module_unload_request(u->module, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,6 @@ enum {
|
||||||
SINK_MESSAGE_UPDATE_LATENCY,
|
SINK_MESSAGE_UPDATE_LATENCY,
|
||||||
SINK_MESSAGE_GET_LATENCY_SNAPSHOT,
|
SINK_MESSAGE_GET_LATENCY_SNAPSHOT,
|
||||||
SINK_MESSAGE_POST,
|
SINK_MESSAGE_POST,
|
||||||
SINK_MESSAGE_CREATED
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFAULT_LATENCY_MSEC 100
|
#define DEFAULT_LATENCY_MSEC 100
|
||||||
|
|
@ -159,7 +158,6 @@ enum {
|
||||||
SOURCE_MESSAGE_REMOTE_SUSPEND,
|
SOURCE_MESSAGE_REMOTE_SUSPEND,
|
||||||
SOURCE_MESSAGE_UPDATE_LATENCY,
|
SOURCE_MESSAGE_UPDATE_LATENCY,
|
||||||
SOURCE_MESSAGE_GET_LATENCY_SNAPSHOT,
|
SOURCE_MESSAGE_GET_LATENCY_SNAPSHOT,
|
||||||
SOURCE_MESSAGE_CREATED
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFAULT_LATENCY_MSEC 25
|
#define DEFAULT_LATENCY_MSEC 25
|
||||||
|
|
@ -174,11 +172,6 @@ typedef struct tunnel_msg tunnel_msg;
|
||||||
PA_DEFINE_PRIVATE_CLASS(tunnel_msg, pa_msgobject);
|
PA_DEFINE_PRIVATE_CLASS(tunnel_msg, pa_msgobject);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
#ifdef TUNNEL_SINK
|
|
||||||
TUNNEL_MESSAGE_CREATE_SINK_REQUEST,
|
|
||||||
#else
|
|
||||||
TUNNEL_MESSAGE_CREATE_SOURCE_REQUEST,
|
|
||||||
#endif
|
|
||||||
TUNNEL_MESSAGE_MAYBE_RESTART,
|
TUNNEL_MESSAGE_MAYBE_RESTART,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -301,8 +294,10 @@ struct userdata {
|
||||||
|
|
||||||
static void request_latency(struct userdata *u);
|
static void request_latency(struct userdata *u);
|
||||||
#ifdef TUNNEL_SINK
|
#ifdef TUNNEL_SINK
|
||||||
|
static void create_sink(struct userdata *u);
|
||||||
static void on_sink_created(struct userdata *u);
|
static void on_sink_created(struct userdata *u);
|
||||||
#else
|
#else
|
||||||
|
static void create_source(struct userdata *u);
|
||||||
static void on_source_created(struct userdata *u);
|
static void on_source_created(struct userdata *u);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -671,12 +666,6 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
|
||||||
|
|
||||||
u->receive_counter += chunk->length;
|
u->receive_counter += chunk->length;
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case SINK_MESSAGE_CREATED:
|
|
||||||
|
|
||||||
on_sink_created(u);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -805,12 +794,6 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SOURCE_MESSAGE_CREATED:
|
|
||||||
|
|
||||||
on_source_created(u);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pa_source_process_msg(o, code, data, offset, chunk);
|
return pa_source_process_msg(o, code, data, offset, chunk);
|
||||||
|
|
@ -1982,6 +1965,8 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t o
|
||||||
static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata) {
|
static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata) {
|
||||||
struct userdata *u = userdata;
|
struct userdata *u = userdata;
|
||||||
|
|
||||||
|
pa_assert_ctl_context();
|
||||||
|
|
||||||
pa_assert(sc);
|
pa_assert(sc);
|
||||||
pa_assert(u);
|
pa_assert(u);
|
||||||
pa_assert(u->client == sc);
|
pa_assert(u->client == sc);
|
||||||
|
|
@ -1998,11 +1983,19 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
|
||||||
u->io = io;
|
u->io = io;
|
||||||
|
|
||||||
#ifdef TUNNEL_SINK
|
#ifdef TUNNEL_SINK
|
||||||
pa_log_debug("Asking ctl thread to create sink.");
|
create_sink(u);
|
||||||
pa_asyncmsgq_post(u->thread_mq.outq, PA_MSGOBJECT(u->msg), TUNNEL_MESSAGE_CREATE_SINK_REQUEST, u, 0, NULL, NULL);
|
if (!u->sink) {
|
||||||
|
unload_module(u);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
on_sink_created(u);
|
||||||
#else
|
#else
|
||||||
pa_log_debug("Asking ctl thread to create source.");
|
create_source(u);
|
||||||
pa_asyncmsgq_post(u->thread_mq.outq, PA_MSGOBJECT(u->msg), TUNNEL_MESSAGE_CREATE_SOURCE_REQUEST, u, 0, NULL, NULL);
|
if (!u->source) {
|
||||||
|
unload_module(u);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
on_source_created(u);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2141,8 +2134,6 @@ static void create_sink(struct userdata *u) {
|
||||||
finish:
|
finish:
|
||||||
pa_sink_new_data_done(&data);
|
pa_sink_new_data_done(&data);
|
||||||
pa_xfree(data_name);
|
pa_xfree(data_name);
|
||||||
|
|
||||||
pa_asyncmsgq_post(u->sink->asyncmsgq, PA_MSGOBJECT(u->sink), SINK_MESSAGE_CREATED, u, 0, NULL, NULL);
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static void create_source(struct userdata *u) {
|
static void create_source(struct userdata *u) {
|
||||||
|
|
@ -2190,8 +2181,6 @@ static void create_source(struct userdata *u) {
|
||||||
finish:
|
finish:
|
||||||
pa_source_new_data_done(&data);
|
pa_source_new_data_done(&data);
|
||||||
pa_xfree(data_name);
|
pa_xfree(data_name);
|
||||||
|
|
||||||
pa_asyncmsgq_post(u->source->asyncmsgq, PA_MSGOBJECT(u->source), SOURCE_MESSAGE_CREATED, u, 0, NULL, NULL);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -2206,15 +2195,7 @@ static int tunnel_process_msg(pa_msgobject *o, int code, void *data, int64_t off
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
#ifdef TUNNEL_SINK
|
|
||||||
case TUNNEL_MESSAGE_CREATE_SINK_REQUEST:
|
|
||||||
create_sink(u);
|
|
||||||
break;
|
|
||||||
#else
|
|
||||||
case TUNNEL_MESSAGE_CREATE_SOURCE_REQUEST:
|
|
||||||
create_source(u);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case TUNNEL_MESSAGE_MAYBE_RESTART:
|
case TUNNEL_MESSAGE_MAYBE_RESTART:
|
||||||
unload_module(u);
|
unload_module(u);
|
||||||
break;
|
break;
|
||||||
|
|
@ -2258,7 +2239,10 @@ static int start_connect(struct userdata *u, char *server, bool automatic) {
|
||||||
server_list = pa_strlist_pop(server_list, &u->server_name);
|
server_list = pa_strlist_pop(server_list, &u->server_name);
|
||||||
|
|
||||||
if (!u->server_name) {
|
if (!u->server_name) {
|
||||||
pa_log("Failed to connect to server '%s'", server);
|
if (server)
|
||||||
|
pa_log("Failed to connect to server '%s'", server);
|
||||||
|
else
|
||||||
|
pa_log("Failed to connect");
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue