Bug 1432733 - Update cubeb from upstream to 2b98e3d. r=padenot

MozReview-Commit-ID: 7R7S3MLf6tm

--HG--
extra : rebase_source : ba605c371bb4a27379af26c73ff99b951f669ec6
This commit is contained in:
Alex Chronopoulos 2018-01-24 12:56:54 +02:00
Родитель 0ba9a8102b
Коммит 80ad267a67
8 изменённых файлов: 81 добавлений и 21 удалений

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

@ -9,4 +9,4 @@ https://github.com/kinetiknz/cubeb/pull/398/commits/2ed979bc891cf1a7822799947a35
The cubeb git repository is: git://github.com/kinetiknz/cubeb.git
The git commit ID used was bda37c26b0ed46c568e35b10728fc498262778f3 (2017-12-28 09:34:08 +1000)
The git commit ID used was 2b98e3d3279322ce0764ae2b9f28a9ea9000418b (2018-01-19 10:17:28 +1300)

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

@ -15,6 +15,17 @@
#include "cubeb/cubeb.h"
#include "common.h"
long data_cb_duplex(cubeb_stream * stream, void * user, const void * inputbuffer, void * outputbuffer, long nframes)
{
// noop, unused
return 0;
}
void state_cb_duplex(cubeb_stream * stream, void * /*user*/, cubeb_state state)
{
// noop, unused
}
static void
print_device_info(cubeb_device_info * info, FILE * f)
{
@ -164,4 +175,32 @@ TEST(cubeb, enumerate_devices)
fprintf(stdout, "Found %zu output devices\n", collection.count);
print_device_collection(&collection, stdout);
cubeb_device_collection_destroy(ctx, &collection);
uint32_t count_before_creating_duplex_stream;
r = cubeb_enumerate_devices(ctx, CUBEB_DEVICE_TYPE_OUTPUT, &collection);
ASSERT_EQ(r, CUBEB_OK) << "Error enumerating devices " << r;
count_before_creating_duplex_stream = collection.count;
cubeb_device_collection_destroy(ctx, &collection);
cubeb_stream * stream;
cubeb_stream_params input_params;
cubeb_stream_params output_params;
input_params.format = output_params.format = CUBEB_SAMPLE_FLOAT32NE;
input_params.rate = output_params.rate = 48000;
input_params.channels = output_params.channels = 1;
input_params.layout = output_params.layout = CUBEB_LAYOUT_MONO;
r = cubeb_stream_init(ctx, &stream, "Cubeb duplex",
NULL, &input_params, NULL, &output_params,
1024, data_cb_duplex, state_cb_duplex, nullptr);
ASSERT_EQ(r, CUBEB_OK) << "Error initializing cubeb stream";
r = cubeb_enumerate_devices(ctx, CUBEB_DEVICE_TYPE_OUTPUT, &collection);
ASSERT_EQ(r, CUBEB_OK) << "Error enumerating devices " << r;
ASSERT_EQ(count_before_creating_duplex_stream, collection.count);
cubeb_device_collection_destroy(ctx, &collection);
cubeb_stream_destroy(stream);
}

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

@ -43,6 +43,7 @@ typedef UInt32 AudioFormatFlags;
#define AU_IN_BUS 1
const char * DISPATCH_QUEUE_LABEL = "org.mozilla.cubeb";
const char * PRIVATE_AGGREGATE_DEVICE_NAME = "CubebAggregateDevice";
#ifdef ALOGV
#undef ALOGV
@ -1497,11 +1498,11 @@ audiounit_create_blank_aggregate_device(AudioObjectID * plugin_id, AudioDeviceID
struct timeval timestamp;
gettimeofday(&timestamp, NULL);
long long int time_id = timestamp.tv_sec * 1000000LL + timestamp.tv_usec;
CFStringRef aggregate_device_name = CFStringCreateWithFormat(NULL, NULL, CFSTR("CubebAggregateDevice_%llx"), time_id);
CFStringRef aggregate_device_name = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s_%llx"), PRIVATE_AGGREGATE_DEVICE_NAME, time_id);
CFDictionaryAddValue(aggregate_device_dict, CFSTR(kAudioAggregateDeviceNameKey), aggregate_device_name);
CFRelease(aggregate_device_name);
CFStringRef aggregate_device_UID = CFStringCreateWithFormat(NULL, NULL, CFSTR("org.mozilla.CubebAggregateDevice_%llx"), time_id);
CFStringRef aggregate_device_UID = CFStringCreateWithFormat(NULL, NULL, CFSTR("org.mozilla.%s_%llx"), PRIVATE_AGGREGATE_DEVICE_NAME, time_id);
CFDictionaryAddValue(aggregate_device_dict, CFSTR(kAudioAggregateDeviceUIDKey), aggregate_device_UID);
CFRelease(aggregate_device_UID);
@ -3181,6 +3182,13 @@ audiounit_create_device_from_hwdev(cubeb_device_info * ret, AudioObjectID devid,
return CUBEB_OK;
}
bool
is_aggregate_device(cubeb_device_info * device_info)
{
return !strncmp(device_info->friendly_name, PRIVATE_AGGREGATE_DEVICE_NAME,
strlen(PRIVATE_AGGREGATE_DEVICE_NAME));
}
static int
audiounit_enumerate_devices(cubeb * /* context */, cubeb_device_type type,
cubeb_device_collection * collection)
@ -3209,7 +3217,7 @@ audiounit_enumerate_devices(cubeb * /* context */, cubeb_device_type type,
for (auto dev: output_devs) {
auto device = &devices[collection->count];
auto err = audiounit_create_device_from_hwdev(device, dev, CUBEB_DEVICE_TYPE_OUTPUT);
if (err != CUBEB_OK) {
if (err != CUBEB_OK || is_aggregate_device(device)) {
continue;
}
collection->count += 1;
@ -3220,7 +3228,7 @@ audiounit_enumerate_devices(cubeb * /* context */, cubeb_device_type type,
for (auto dev: input_devs) {
auto device = &devices[collection->count];
auto err = audiounit_create_device_from_hwdev(device, dev, CUBEB_DEVICE_TYPE_INPUT);
if (err != CUBEB_OK) {
if (err != CUBEB_OK || is_aggregate_device(device)) {
continue;
}
collection->count += 1;

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

@ -231,9 +231,10 @@ load_jack_lib(cubeb * context)
return CUBEB_OK;
}
static void
static int
cbjack_connect_ports (cubeb_stream * stream)
{
int r = CUBEB_ERROR;
const char ** phys_in_ports = api_jack_get_ports (stream->context->jack_client,
NULL, NULL,
JackPortIsInput
@ -243,7 +244,7 @@ cbjack_connect_ports (cubeb_stream * stream)
JackPortIsOutput
| JackPortIsPhysical);
if (*phys_in_ports == NULL) {
if (phys_in_ports == NULL || *phys_in_ports == NULL) {
goto skipplayback;
}
@ -253,9 +254,10 @@ cbjack_connect_ports (cubeb_stream * stream)
api_jack_connect (stream->context->jack_client, src_port, phys_in_ports[c]);
}
r = CUBEB_OK;
skipplayback:
if (*phys_out_ports == NULL) {
if (phys_out_ports == NULL || *phys_out_ports == NULL) {
goto end;
}
// Connect inputs to capture
@ -264,9 +266,15 @@ skipplayback:
api_jack_connect (stream->context->jack_client, phys_out_ports[c], src_port);
}
r = CUBEB_OK;
end:
api_jack_free(phys_out_ports);
api_jack_free(phys_in_ports);
if (phys_out_ports) {
api_jack_free(phys_out_ports);
}
if (phys_in_ports) {
api_jack_free(phys_in_ports);
}
return r;
}
static int
@ -866,7 +874,11 @@ cbjack_stream_init(cubeb * context, cubeb_stream ** stream, char const * stream_
}
}
cbjack_connect_ports(stm);
if (cbjack_connect_ports(stm) != CUBEB_OK) {
pthread_mutex_unlock(&stm->mutex);
cbjack_stream_destroy(stm);
return CUBEB_ERROR;
}
*stream = stm;

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

@ -460,7 +460,7 @@ cubeb_upmix(long inframes,
/* Put silence in remaining channels. */
for (long i = 0, o = 0; i < inframes; ++i, o += out_channels) {
for (unsigned int j = 2; j < out_channels; ++j) {
for (unsigned int j = in_channels; j < out_channels; ++j) {
assert((unsigned long)o + j < out_len);
out[o + j] = 0.0;
}

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

@ -1565,6 +1565,7 @@ pulse_register_device_collection_changed(cubeb * context,
pa_operation * o;
o = WRAP(pa_context_subscribe)(context->context, mask, subscribe_success, context);
if (o == NULL) {
WRAP(pa_threaded_mainloop_unlock)(context->mainloop);
LOG("Context subscribe failed");
return CUBEB_ERROR;
}

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

@ -1190,7 +1190,7 @@ int wasapi_init(cubeb ** context, char const * context_name)
ctx->ops = &wasapi_ops;
if (cubeb_strings_init(&ctx->device_ids) != CUBEB_OK) {
free(ctx);
delete ctx;
return CUBEB_ERROR;
}
@ -1671,6 +1671,10 @@ int setup_wasapi_stream(cubeb_stream * stm)
stm->input_available_event,
stm->capture_client,
&stm->input_mix_params);
if (rv != CUBEB_OK) {
LOG("Failure to open the input side.");
return rv;
}
// We initializing an input stream, buffer ahead two buffers worth of silence.
// This delays the input side slightly, but allow to not glitch when no input
@ -1680,16 +1684,11 @@ int setup_wasapi_stream(cubeb_stream * stm)
#if !defined(DEBUG)
const int silent_buffer_count = 2;
#else
const int silent_buffer_count = 4;
const int silent_buffer_count = 6;
#endif
stm->linear_input_buffer->push_silence(stm->input_buffer_frame_count *
stm->input_stream_params.channels *
silent_buffer_count);
if (rv != CUBEB_OK) {
LOG("Failure to open the input side.");
return rv;
}
stm->input_stream_params.channels *
silent_buffer_count);
}
if (has_output(stm)) {

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

@ -402,6 +402,7 @@ winmm_stream_init(cubeb * context, cubeb_stream ** stream, char const * stream_n
XASSERT(context);
XASSERT(stream);
XASSERT(output_stream_params);
if (input_stream_params) {
/* Capture support not yet implemented. */