aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cubeb_pulse.c
diff options
context:
space:
mode:
authorMike Hommey <[email protected]>2017-12-27 17:31:57 +0900
committerDan Glastonbury <[email protected]>2017-12-28 09:32:11 +1000
commit43e15fc92293fc842ecd8a109fbe039c4f3c0c13 (patch)
tree5cef9af5177dbdc484a1aa0a4378578b0caa89a7 /src/cubeb_pulse.c
parent9c1029e3cc4f240ccf55d3977bd992d61bda4820 (diff)
downloadcubeb-43e15fc92293fc842ecd8a109fbe039c4f3c0c13.tar.gz
cubeb-43e15fc92293fc842ecd8a109fbe039c4f3c0c13.zip
pulse: Don't get some default sink info based on the pa_sink_info build-time size
The build-time pa_sink_info might not have the same size as the at run time. This especially becomes a problem when the struct is larger at build-time, since we copy its content for the default sink info. However, we don't need most of the data in there, so create a new struct holding what we do need, and copy that. This new struct has a constant size across versions of pulseaudio. https://bugzilla.mozilla.org/show_bug.cgi?id=1427150
Diffstat (limited to 'src/cubeb_pulse.c')
-rw-r--r--src/cubeb_pulse.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/cubeb_pulse.c b/src/cubeb_pulse.c
index 19f939f..065d900 100644
--- a/src/cubeb_pulse.c
+++ b/src/cubeb_pulse.c
@@ -97,12 +97,18 @@ static int has_pulse_v2 = 0;
static struct cubeb_ops const pulse_ops;
+struct cubeb_default_sink_info {
+ pa_channel_map channel_map;
+ uint32_t sample_spec_rate;
+ pa_sink_flags_t flags;
+};
+
struct cubeb {
struct cubeb_ops const * ops;
void * libpulse;
pa_threaded_mainloop * mainloop;
pa_context * context;
- pa_sink_info * default_sink_info;
+ struct cubeb_default_sink_info * default_sink_info;
char * context_name;
int error;
cubeb_device_collection_changed_callback collection_changed_callback;
@@ -158,8 +164,10 @@ sink_info_callback(pa_context * context, const pa_sink_info * info, int eol, voi
cubeb * ctx = u;
if (!eol) {
free(ctx->default_sink_info);
- ctx->default_sink_info = malloc(sizeof(pa_sink_info));
- memcpy(ctx->default_sink_info, info, sizeof(pa_sink_info));
+ ctx->default_sink_info = malloc(sizeof(struct cubeb_default_sink_info));
+ memcpy(&ctx->default_sink_info->channel_map, &info->channel_map, sizeof(pa_channel_map));
+ ctx->default_sink_info->sample_spec_rate = info->sample_spec.rate;
+ ctx->default_sink_info->flags = info->flags;
}
WRAP(pa_threaded_mainloop_signal)(ctx->mainloop, 0);
}
@@ -699,7 +707,7 @@ pulse_get_preferred_sample_rate(cubeb * ctx, uint32_t * rate)
if (!ctx->default_sink_info)
return CUBEB_ERROR;
- *rate = ctx->default_sink_info->sample_spec.rate;
+ *rate = ctx->default_sink_info->sample_spec_rate;
return CUBEB_OK;
}