GUACAMOLE-240: Always pass guac_pa_stream to PulseAudio callbacks.

This commit is contained in:
Michael Jumper 2017-03-16 02:53:32 +00:00
parent 145762a2b0
commit adf9db7454

View File

@ -122,7 +122,9 @@ static void __stream_state_callback(pa_stream* stream, void* data) {
static void __context_get_sink_info_callback(pa_context* context, static void __context_get_sink_info_callback(pa_context* context,
const pa_sink_info* info, int is_last, void* data) { const pa_sink_info* info, int is_last, void* data) {
guac_client* client = (guac_client*) data; guac_pa_stream* guac_stream = (guac_pa_stream*) data;
guac_client* client = guac_stream->client;
pa_stream* stream; pa_stream* stream;
pa_sample_spec spec; pa_sample_spec spec;
pa_buffer_attr attr; pa_buffer_attr attr;
@ -146,8 +148,8 @@ static void __context_get_sink_info_callback(pa_context* context,
stream = pa_stream_new(context, "Guacamole Audio", &spec, NULL); stream = pa_stream_new(context, "Guacamole Audio", &spec, NULL);
/* Set stream callbacks */ /* Set stream callbacks */
pa_stream_set_state_callback(stream, __stream_state_callback, client); pa_stream_set_state_callback(stream, __stream_state_callback, guac_stream);
pa_stream_set_read_callback(stream, __stream_read_callback, client); pa_stream_set_read_callback(stream, __stream_read_callback, guac_stream);
/* Start stream */ /* Start stream */
pa_stream_connect_record(stream, info->monitor_source_name, &attr, pa_stream_connect_record(stream, info->monitor_source_name, &attr,
@ -159,7 +161,8 @@ static void __context_get_sink_info_callback(pa_context* context,
static void __context_get_server_info_callback(pa_context* context, static void __context_get_server_info_callback(pa_context* context,
const pa_server_info* info, void* data) { const pa_server_info* info, void* data) {
guac_client* client = (guac_client*) data; guac_pa_stream* guac_stream = (guac_pa_stream*) data;
guac_client* client = guac_stream->client;
/* If no default sink, cannot continue */ /* If no default sink, cannot continue */
if (info->default_sink_name == NULL) { if (info->default_sink_name == NULL) {
@ -174,13 +177,14 @@ static void __context_get_server_info_callback(pa_context* context,
pa_operation_unref( pa_operation_unref(
pa_context_get_sink_info_by_name(context, pa_context_get_sink_info_by_name(context,
info->default_sink_name, __context_get_sink_info_callback, info->default_sink_name, __context_get_sink_info_callback,
client)); guac_stream));
} }
static void __context_state_callback(pa_context* context, void* data) { static void __context_state_callback(pa_context* context, void* data) {
guac_client* client = (guac_client*) data; guac_pa_stream* guac_stream = (guac_pa_stream*) data;
guac_client* client = guac_stream->client;
switch (pa_context_get_state(context)) { switch (pa_context_get_state(context)) {
@ -205,7 +209,7 @@ static void __context_state_callback(pa_context* context, void* data) {
case PA_CONTEXT_READY: case PA_CONTEXT_READY:
guac_client_log(client, GUAC_LOG_INFO, "PulseAudio now ready"); guac_client_log(client, GUAC_LOG_INFO, "PulseAudio now ready");
pa_operation_unref(pa_context_get_server_info(context, pa_operation_unref(pa_context_get_server_info(context,
__context_get_server_info_callback, client)); __context_get_server_info_callback, guac_stream));
break; break;
case PA_CONTEXT_FAILED: case PA_CONTEXT_FAILED: