Bug 971528 - Fix backout issue. r?padenot
MozReview-Commit-ID: L43Lz2WMAhi
--- a/media/libcubeb/gtest/test_record.cpp
+++ b/media/libcubeb/gtest/test_record.cpp
@@ -86,17 +86,17 @@ TEST(cubeb, record)
* have one. */
if (!has_available_input_device(ctx)) {
return;
}
params.format = STREAM_FORMAT;
params.rate = SAMPLE_FREQUENCY;
params.channels = 1;
- params.layout = CUBEB_LAYOUT_MONO;
+ params.layout = CUBEB_LAYOUT_UNDEFINED;
r = cubeb_stream_init(ctx, &stream, "Cubeb record (mono)", NULL, ¶ms, NULL, nullptr,
4096, data_cb_record, state_cb_record, &stream_state);
if (r != CUBEB_OK) {
fprintf(stderr, "Error initializing cubeb stream\n");
ASSERT_EQ(r, CUBEB_OK);
}
--- a/media/libcubeb/src/cubeb_pulse.c
+++ b/media/libcubeb/src/cubeb_pulse.c
@@ -743,30 +743,35 @@ to_pulse_format(cubeb_sample_format form
}
static int
create_pa_stream(cubeb_stream * stm,
pa_stream ** pa_stm,
cubeb_stream_params * stream_params,
char const * stream_name)
{
- assert(stm && stream_params && stream_params->layout != CUBEB_LAYOUT_UNDEFINED &&
- CUBEB_CHANNEL_LAYOUT_MAPS[stream_params->layout].channels == stream_params->channels);
+ assert(stm && stream_params);
+ assert(&stm->input_stream == pa_stm || (&stm->output_stream == pa_stm &&
+ stream_params->layout != CUBEB_LAYOUT_UNDEFINED &&
+ CUBEB_CHANNEL_LAYOUT_MAPS[stream_params->layout].channels == stream_params->channels));
*pa_stm = NULL;
pa_sample_spec ss;
ss.format = to_pulse_format(stream_params->format);
if (ss.format == PA_SAMPLE_INVALID)
return CUBEB_ERROR_INVALID_FORMAT;
ss.rate = stream_params->rate;
ss.channels = stream_params->channels;
- pa_channel_map cm;
- layout_to_channel_map(stream_params->layout, &cm);
-
- *pa_stm = WRAP(pa_stream_new)(stm->context->context, stream_name, &ss, &cm);
+ if (stream_params->layout == CUBEB_LAYOUT_UNDEFINED) {
+ *pa_stm = WRAP(pa_stream_new)(stm->context->context, stream_name, &ss, NULL);
+ } else {
+ pa_channel_map cm;
+ layout_to_channel_map(stream_params->layout, &cm);
+ *pa_stm = WRAP(pa_stream_new)(stm->context->context, stream_name, &ss, &cm);
+ }
return (*pa_stm == NULL) ? CUBEB_ERROR : CUBEB_OK;
}
static pa_buffer_attr
set_buffering_attribute(unsigned int latency_frames, pa_sample_spec * sample_spec)
{
pa_buffer_attr battr;
battr.maxlength = -1;