Bug 1359451 - Update cubeb from upstream to 17503c4. r=padenot

MozReview-Commit-ID: C3NXIvjwjgD

--HG--
extra : rebase_source : 06cc2449c9892ba431662e9cd72633a91efcba2e
This commit is contained in:
Alex Chronopoulos 2017-04-25 18:25:01 +03:00
Родитель c03792963c
Коммит ff2192eef4
7 изменённых файлов: 39 добавлений и 25 удалений

Просмотреть файл

@ -5,4 +5,4 @@ Makefile.in build files for the Mozilla build system.
The cubeb git repository is: git://github.com/kinetiknz/cubeb.git
The git commit ID used was 6e52314f24bba463d6ca97951f7d9fcc677d76a4 (2017-04-18 17:28:50 +0200)
The git commit ID used was 17503c41318ec7a18ba3d728fb803a66ec60cf84 (2017-04-25 15:26:11 +0200)

Просмотреть файл

@ -92,7 +92,7 @@ TEST(cubeb, record)
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, &params, NULL, nullptr,
4096, data_cb_record, state_cb_record, &stream_state);

Просмотреть файл

@ -226,6 +226,7 @@ channel_label_to_cubeb_channel(UInt32 label)
case kAudioChannelLabel_RearSurroundLeft: return CHANNEL_RLS;
case kAudioChannelLabel_RearSurroundRight: return CHANNEL_RRS;
case kAudioChannelLabel_CenterSurround: return CHANNEL_RCENTER;
case kAudioChannelLabel_Unknown: return CHANNEL_UNMAPPED;
default: return CHANNEL_INVALID;
}
}
@ -244,6 +245,7 @@ cubeb_channel_to_channel_label(cubeb_channel channel)
case CHANNEL_RLS: return kAudioChannelLabel_RearSurroundLeft;
case CHANNEL_RRS: return kAudioChannelLabel_RearSurroundRight;
case CHANNEL_RCENTER: return kAudioChannelLabel_CenterSurround;
case CHANNEL_UNMAPPED: return kAudioChannelLabel_Unknown;
default: return kAudioChannelLabel_Unknown;
}
}
@ -643,10 +645,10 @@ static int audiounit_stream_get_volume(cubeb_stream * stm, float * volume);
static int audiounit_stream_set_volume(cubeb_stream * stm, float volume);
static int
audiounit_reinit_stream(cubeb_stream * stm, bool is_started)
audiounit_reinit_stream(cubeb_stream * stm)
{
auto_lock context_lock(stm->context->mutex);
if (is_started) {
if (!stm->shutdown) {
audiounit_stream_stop_internal(stm);
}
@ -671,7 +673,7 @@ audiounit_reinit_stream(cubeb_stream * stm, bool is_started)
stm->frames_read = 0;
// If the stream was running, start it again.
if (is_started) {
if (!stm->shutdown) {
audiounit_stream_start_internal(stm);
}
}
@ -685,8 +687,6 @@ audiounit_property_listener_callback(AudioObjectID /* id */, UInt32 address_coun
{
cubeb_stream * stm = (cubeb_stream*) user;
stm->switching_device = true;
// Note if the stream was running or not
bool was_running = !stm->shutdown;
LOG("(%p) Audio device changed, %u events.", stm, (unsigned int) address_count);
for (UInt32 i = 0; i < address_count; i++) {
@ -715,8 +715,12 @@ audiounit_property_listener_callback(AudioObjectID /* id */, UInt32 address_coun
stm->input_device = 0;
}
break;
case kAudioDevicePropertyDataSource:
case kAudioDevicePropertyDataSource: {
LOG("Event[%u] - mSelector == kAudioHardwarePropertyDataSource", (unsigned int) i);
if (has_output(stm)) {
stm->output_device = 0;
}
}
break;
default:
LOG("Event[%u] - mSelector == Unexpected Event id %d, return", (unsigned int) i, addresses[i].mSelector);
@ -743,7 +747,7 @@ audiounit_property_listener_callback(AudioObjectID /* id */, UInt32 address_coun
// Use a new thread, through the queue, to avoid deadlock when calling
// Get/SetProperties method from inside notify callback
dispatch_async(stm->context->serial_queue, ^() {
if (audiounit_reinit_stream(stm, was_running) != CUBEB_OK) {
if (audiounit_reinit_stream(stm) != CUBEB_OK) {
stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_STOPPED);
LOG("(%p) Could not reopen the stream after switching.", stm);
}
@ -1089,6 +1093,12 @@ audiounit_convert_channel_layout(AudioChannelLayout * layout)
return CUBEB_LAYOUT_UNDEFINED;
}
// This devices has more channels that we can support, bail out.
if (layout->mNumberChannelDescriptions >= CHANNEL_MAX) {
LOG("Audio device has more than %d channels, bailing out.", CHANNEL_MAX);
return CUBEB_LAYOUT_UNDEFINED;
}
cubeb_channel_map cm;
cm.channels = layout->mNumberChannelDescriptions;
for (UInt32 i = 0; i < layout->mNumberChannelDescriptions; ++i) {
@ -2579,10 +2589,10 @@ audiounit_stream_start_internal(cubeb_stream * stm)
static int
audiounit_stream_start(cubeb_stream * stm)
{
auto_lock context_lock(stm->context->mutex);
stm->shutdown = false;
stm->draining = false;
auto_lock context_lock(stm->context->mutex);
audiounit_stream_start_internal(stm);
stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_STARTED);
@ -2608,9 +2618,9 @@ audiounit_stream_stop_internal(cubeb_stream * stm)
static int
audiounit_stream_stop(cubeb_stream * stm)
{
auto_lock context_lock(stm->context->mutex);
stm->shutdown = true;
auto_lock context_lock(stm->context->mutex);
audiounit_stream_stop_internal(stm);
stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_STOPPED);

Просмотреть файл

@ -31,7 +31,8 @@ cubeb_channel_layout cubeb_channel_map_to_layout(cubeb_channel_map const * chann
{
uint32_t channel_mask = 0;
for (uint8_t i = 0 ; i < channel_map->channels ; ++i) {
if (channel_map->map[i] == CHANNEL_INVALID) {
if (channel_map->map[i] == CHANNEL_INVALID ||
channel_map->map[i] == CHANNEL_UNMAPPED) {
return CUBEB_LAYOUT_UNDEFINED;
}
channel_mask |= 1 << channel_map->map[i];

Просмотреть файл

@ -27,7 +27,8 @@ typedef enum {
CHANNEL_RCENTER,
CHANNEL_RRS,
CHANNEL_LFE,
CHANNEL_MAX // Max number of supported channels.
CHANNEL_UNMAPPED,
CHANNEL_MAX = 256 // Max number of supported channels.
} cubeb_channel;
static cubeb_channel const CHANNEL_INDEX_TO_ORDER[CUBEB_LAYOUT_MAX][CHANNEL_MAX] = {
@ -50,6 +51,8 @@ static cubeb_channel const CHANNEL_INDEX_TO_ORDER[CUBEB_LAYOUT_MAX][CHANNEL_MAX]
{ CHANNEL_LEFT, CHANNEL_RIGHT, CHANNEL_CENTER, CHANNEL_LFE, CHANNEL_LS, CHANNEL_RS }, // 3F2_LFE
{ CHANNEL_LEFT, CHANNEL_RIGHT, CHANNEL_CENTER, CHANNEL_LFE, CHANNEL_RCENTER, CHANNEL_LS, CHANNEL_RS }, // 3F3R_LFE
{ CHANNEL_LEFT, CHANNEL_RIGHT, CHANNEL_CENTER, CHANNEL_LFE, CHANNEL_RLS, CHANNEL_RRS, CHANNEL_LS, CHANNEL_RS } // 3F4_LFE
// When more channels are present, the stream is considered unmapped to a
// particular speaker set.
};
typedef struct {

Просмотреть файл

@ -748,8 +748,10 @@ create_pa_stream(cubeb_stream * 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);
@ -758,10 +760,13 @@ create_pa_stream(cubeb_stream * stm,
ss.rate = stream_params->rate;
ss.channels = stream_params->channels;
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;
}

Просмотреть файл

@ -1556,11 +1556,6 @@ int setup_wasapi_stream_one_side(cubeb_stream * stm,
* use the default setting retrieved from the stream format of the audio
* engine's internal processing by GetMixFormat. */
if (mix_format->nChannels > 2) {
/* Currently, we only support mono and stereo for capture stream. */
if (direction == eCapture) {
XASSERT(false && "Multichannel recording is not supported.");
}
handle_channel_layout(stm, mix_format, stream_params);
}