Bug 1280280 - Update cubeb to 073c9f011114. r=kinetik

MozReview-Commit-ID: 8mARVNKAG7P
This commit is contained in:
Paul Adenot 2016-06-16 14:52:51 +01:00
Родитель 6145a952fe
Коммит 279fbfd34c
9 изменённых файлов: 1139 добавлений и 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 2b3d6dc8c4353c38d3e9e2bdc9a688d6d632ac19.
The git commit ID used was 073c9f011114fe4208b4aa49e99e33cde1deb6f1.

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

@ -66,6 +66,7 @@ int
validate_stream_params(cubeb_stream_params * input_stream_params,
cubeb_stream_params * output_stream_params)
{
XASSERT(input_stream_params || output_stream_params);
if (output_stream_params) {
if (output_stream_params->rate < 1000 || output_stream_params->rate > 192000 ||
output_stream_params->channels < 1 || output_stream_params->channels > 8) {

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -37,12 +37,16 @@ to_speex_quality(cubeb_resampler_quality q)
long noop_resampler::fill(void * input_buffer, long * input_frames_count,
void * output_buffer, long output_frames)
{
if (input_buffer) {
assert(input_frames_count);
}
assert((input_buffer && output_buffer &&
*input_frames_count >= output_frames) ||
(!input_buffer && (!input_frames_count || *input_frames_count == 0)) ||
(!output_buffer && output_frames == 0));
if (output_buffer == nullptr) {
assert(input_buffer);
output_frames = *input_frames_count;
}
@ -131,6 +135,10 @@ cubeb_resampler_speex<T, InputProcessor, OutputProcessor>
nullptr, out_unprocessed,
output_frames_before_processing);
if (got < 0) {
return got;
}
output_processor->written(got);
/* Process the output. If not enough frames have been returned from the
@ -156,8 +164,13 @@ cubeb_resampler_speex<T, InputProcessor, OutputProcessor>
input_processor->input(input_buffer, *input_frames_count);
resampled_input = input_processor->output(resampled_frame_count);
return data_callback(stream, user_ptr,
resampled_input, nullptr, resampled_frame_count);
long got = data_callback(stream, user_ptr,
resampled_input, nullptr, resampled_frame_count);
/* Return the number of initial input frames or part of it.
* Since output_frames_needed == 0 in input scenario, the only
* available number outside resampler is the initial number of frames. */
return (*input_frames_count) * (got / resampled_frame_count);
}
@ -206,6 +219,10 @@ cubeb_resampler_speex<T, InputProcessor, OutputProcessor>
resampled_input, out_unprocessed,
output_frames_before_processing);
if (got < 0) {
return got;
}
output_processor->written(got);
/* Process the output. If not enough frames have been returned from the

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

@ -215,8 +215,8 @@ public:
size_t output_for_input(uint32_t input_frames)
{
return ceilf(input_frames * resampling_ratio) + 1
- resampling_in_buffer.length() / channels;
return size_t(ceilf(input_frames / resampling_ratio)
- resampling_in_buffer.length() / channels);
}
/** Returns a buffer containing exactly `output_frame_count` resampled frames.
@ -263,8 +263,8 @@ public:
* number of output frames will be exactly equal. */
uint32_t input_needed_for_output(uint32_t output_frame_count)
{
return ceilf(output_frame_count * resampling_ratio) + 1
- samples_to_frames(resampling_in_buffer.length());
return uint32_t(ceilf(output_frame_count * resampling_ratio) + 1
- samples_to_frames(resampling_in_buffer.length()));
}
/** Returns a pointer to the input buffer, that contains empty space for at

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

@ -122,7 +122,7 @@ public:
owner = GetCurrentThreadId();
#endif
}
void leave()
{
#ifdef DEBUG
@ -729,7 +729,7 @@ refill_callback_duplex(cubeb_stream * stm)
double output_duration = double(output_frames) / stm->output_mix_params.rate;
double input_duration = double(input_frames) / stm->input_mix_params.rate;
if (input_duration < output_duration) {
size_t padding = round((output_duration - input_duration) * stm->input_mix_params.rate);
size_t padding = size_t(round((output_duration - input_duration) * stm->input_mix_params.rate));
LOG("padding silence: out=%f in=%f pad=%u\n", output_duration, input_duration, padding);
stm->linear_input_buffer.push_front_silence(padding * stm->input_stream_params.channels);
}
@ -867,6 +867,7 @@ wasapi_stream_render_loop(LPVOID stream)
continue;
}
case WAIT_OBJECT_0 + 1: { /* reconfigure */
XASSERT(stm->output_client || stm->input_client);
/* Close the stream */
if (stm->output_client) {
stm->output_client->Stop();
@ -888,6 +889,7 @@ wasapi_stream_render_loop(LPVOID stream)
continue;
}
}
XASSERT(stm->output_client || stm->input_client);
if (stm->output_client) {
stm->output_client->Start();
}
@ -1529,7 +1531,7 @@ int setup_wasapi_stream(cubeb_stream * stm)
return CUBEB_ERROR;
}
XASSERT(!stm->output_client && "WASAPI stream already setup, close it first.");
XASSERT((!stm->output_client || !stm->input_client) && "WASAPI stream already setup, close it first.");
if (has_input(stm)) {
LOG("Setup capture: device=%x\n", (int)stm->input_device);
@ -1728,10 +1730,12 @@ wasapi_stream_init(cubeb * context, cubeb_stream ** stream,
void close_wasapi_stream(cubeb_stream * stm)
{
XASSERT(stm);
XASSERT(stm && !stm->thread && !stm->shutdown_event);
stm->stream_reset_lock->assert_current_thread_owns();
XASSERT(stm->output_client || stm->input_client);
SafeRelease(stm->output_client);
stm->output_client = NULL;
SafeRelease(stm->input_client);
@ -1807,8 +1811,8 @@ int stream_start_one_side(cubeb_stream * stm, StreamDirection dir)
return r;
}
HRESULT hr = dir == OUTPUT ? stm->output_client->Start() : stm->input_client->Start();
if (FAILED(hr)) {
HRESULT hr2 = dir == OUTPUT ? stm->output_client->Start() : stm->input_client->Start();
if (FAILED(hr2)) {
LOG("could not start the %s stream after reconfig: %x\n",
dir == OUTPUT ? "output" : "input", hr);
return CUBEB_ERROR;
@ -1824,20 +1828,20 @@ int stream_start_one_side(cubeb_stream * stm, StreamDirection dir)
int wasapi_stream_start(cubeb_stream * stm)
{
int rv;
XASSERT(stm && !stm->thread && !stm->shutdown_event);
XASSERT(stm->output_client || stm->input_client);
auto_lock lock(stm->stream_reset_lock);
XASSERT(stm && !stm->thread && !stm->shutdown_event);
if (stm->output_client) {
rv = stream_start_one_side(stm, OUTPUT);
int rv = stream_start_one_side(stm, OUTPUT);
if (rv != CUBEB_OK) {
return rv;
}
}
if (stm->input_client) {
rv = stream_start_one_side(stm, INPUT);
int rv = stream_start_one_side(stm, INPUT);
if (rv != CUBEB_OK) {
return rv;
}
@ -1849,7 +1853,7 @@ int wasapi_stream_start(cubeb_stream * stm)
return CUBEB_ERROR;
}
stm->thread = (HANDLE) _beginthreadex(NULL, 256 * 1024, wasapi_stream_render_loop, stm, STACK_SIZE_PARAM_IS_A_RESERVATION, NULL);
stm->thread = (HANDLE) _beginthreadex(NULL, 512 * 1024, wasapi_stream_render_loop, stm, STACK_SIZE_PARAM_IS_A_RESERVATION, NULL);
if (stm->thread == NULL) {
LOG("could not create WASAPI render thread.\n");
return CUBEB_ERROR;
@ -1865,6 +1869,8 @@ int wasapi_stream_stop(cubeb_stream * stm)
XASSERT(stm);
HRESULT hr;
XASSERT(stm->output_client || stm->input_client);
{
auto_lock lock(stm->stream_reset_lock);
@ -2198,6 +2204,9 @@ wasapi_enumerate_devices(cubeb * context, cubeb_device_type type,
}
*out = (cubeb_device_collection *) malloc(sizeof(cubeb_device_collection) +
sizeof(cubeb_device_info*) * (cc > 0 ? cc - 1 : 0));
if (!*out) {
return CUBEB_ERROR;
}
(*out)->count = 0;
for (i = 0; i < cc; i++) {
hr = collection->Item(i, &dev);

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

@ -207,7 +207,7 @@ winmm_refill_stream(cubeb_stream * stm)
short * b = (short *) hdr->lpData;
uint32_t i;
for (i = 0; i < got * stm->params.channels; i++) {
b[i] *= stm->soft_volume;
b[i] = (short) (b[i] * stm->soft_volume);
}
}
}
@ -701,7 +701,8 @@ winmm_stream_get_latency(cubeb_stream * stm, uint32_t * latency)
return CUBEB_ERROR;
}
*latency = written - time.u.sample;
XASSERT(written - time.u.sample <= UINT32_MAX);
*latency = (uint32_t) (written - time.u.sample);
return CUBEB_OK;
}
@ -787,7 +788,10 @@ static char *
guid_to_cstr(LPGUID guid)
{
char * ret = malloc(sizeof(char) * 40);
_snprintf(ret, sizeof(char) * 40,
if (!ret) {
return NULL;
}
_snprintf_s(ret, sizeof(char) * 40, _TRUNCATE,
"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
guid->Data1, guid->Data2, guid->Data3,
guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
@ -818,7 +822,10 @@ static char *
device_id_idx(UINT devid)
{
char * ret = (char *)malloc(sizeof(char)*16);
_snprintf(ret, 16, "%u", devid);
if (!ret) {
return NULL;
}
_snprintf_s(ret, 16, _TRUNCATE, "%u", devid);
return ret;
}
@ -828,6 +835,9 @@ winmm_create_device_from_outcaps2(LPWAVEOUTCAPS2A caps, UINT devid)
cubeb_device_info * ret;
ret = calloc(1, sizeof(cubeb_device_info));
if (!ret) {
return NULL;
}
ret->devid = (cubeb_devid)(size_t)devid;
ret->device_id = device_id_idx(devid);
ret->friendly_name = _strdup(caps->szPname);
@ -856,6 +866,9 @@ winmm_create_device_from_outcaps(LPWAVEOUTCAPSA caps, UINT devid)
cubeb_device_info * ret;
ret = calloc(1, sizeof(cubeb_device_info));
if (!ret) {
return NULL;
}
ret->devid = (cubeb_devid)(size_t)devid;
ret->device_id = device_id_idx(devid);
ret->friendly_name = _strdup(caps->szPname);
@ -903,6 +916,9 @@ winmm_create_device_from_incaps2(LPWAVEINCAPS2A caps, UINT devid)
cubeb_device_info * ret;
ret = calloc(1, sizeof(cubeb_device_info));
if (!ret) {
return NULL;
}
ret->devid = (cubeb_devid)(size_t)devid;
ret->device_id = device_id_idx(devid);
ret->friendly_name = _strdup(caps->szPname);
@ -931,6 +947,9 @@ winmm_create_device_from_incaps(LPWAVEINCAPSA caps, UINT devid)
cubeb_device_info * ret;
ret = calloc(1, sizeof(cubeb_device_info));
if (!ret) {
return NULL;
}
ret->devid = (cubeb_devid)(size_t)devid;
ret->device_id = device_id_idx(devid);
ret->friendly_name = _strdup(caps->szPname);

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

@ -2,7 +2,7 @@
#undef NDEBUG
#endif
#include <stdlib.h>
#include <cubeb/cubeb.h>
#include "cubeb/cubeb.h"
#include <assert.h>
#include <stdio.h>
#ifdef CUBEB_GECKO_BUILD

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

@ -43,7 +43,6 @@ static long
test_data_callback(cubeb_stream * stm, void * user_ptr, const void * inputbuffer, void * outputbuffer, long nframes)
{
assert(stm && user_ptr == &dummy && outputbuffer && nframes > 0);
memset(outputbuffer, 0, nframes * sizeof(short));
#if (defined(_WIN32) || defined(__WIN32__))
memset(outputbuffer, 0, nframes * sizeof(float));
#else
@ -125,6 +124,9 @@ test_context_variables(void)
params.channels = STREAM_CHANNELS;
params.format = STREAM_FORMAT;
params.rate = STREAM_RATE;
#if defined(__ANDROID__)
params.stream_type = CUBEB_STREAM_TYPE_MUSIC;
#endif
r = cubeb_get_min_latency(ctx, params, &value);
assert(r == CUBEB_OK || r == CUBEB_ERROR_NOT_SUPPORTED);
if (r == CUBEB_OK) {
@ -158,6 +160,9 @@ test_init_destroy_stream(void)
params.format = STREAM_FORMAT;
params.rate = STREAM_RATE;
params.channels = STREAM_CHANNELS;
#if defined(__ANDROID__)
params.stream_type = CUBEB_STREAM_TYPE_MUSIC;
#endif
r = cubeb_stream_init(ctx, &stream, "test", NULL, NULL, NULL, &params, STREAM_LATENCY,
test_data_callback, test_state_callback, &dummy);
@ -186,6 +191,9 @@ test_init_destroy_multiple_streams(void)
params.format = STREAM_FORMAT;
params.rate = STREAM_RATE;
params.channels = STREAM_CHANNELS;
#if defined(__ANDROID__)
params.stream_type = CUBEB_STREAM_TYPE_MUSIC;
#endif
for (i = 0; i < ARRAY_LENGTH(stream); ++i) {
r = cubeb_stream_init(ctx, &stream[i], "test", NULL, NULL, NULL, &params, STREAM_LATENCY,
@ -219,6 +227,9 @@ test_configure_stream(void)
params.format = STREAM_FORMAT;
params.rate = STREAM_RATE;
params.channels = 2; // panning
#if defined(__ANDROID__)
params.stream_type = CUBEB_STREAM_TYPE_MUSIC;
#endif
r = cubeb_stream_init(ctx, &stream, "test", NULL, NULL, NULL, &params, STREAM_LATENCY,
test_data_callback, test_state_callback, &dummy);
@ -252,6 +263,9 @@ test_init_start_stop_destroy_multiple_streams(int early, int delay_ms)
params.format = STREAM_FORMAT;
params.rate = STREAM_RATE;
params.channels = STREAM_CHANNELS;
#if defined(__ANDROID__)
params.stream_type = CUBEB_STREAM_TYPE_MUSIC;
#endif
for (i = 0; i < ARRAY_LENGTH(stream); ++i) {
r = cubeb_stream_init(ctx, &stream[i], "test", NULL, NULL, NULL, &params, STREAM_LATENCY,
@ -312,6 +326,9 @@ test_init_destroy_multiple_contexts_and_streams(void)
params.format = STREAM_FORMAT;
params.rate = STREAM_RATE;
params.channels = STREAM_CHANNELS;
#if defined(__ANDROID__)
params.stream_type = CUBEB_STREAM_TYPE_MUSIC;
#endif
for (i = 0; i < ARRAY_LENGTH(ctx); ++i) {
r = cubeb_init(&ctx[i], "test_sanity");
@ -352,6 +369,9 @@ test_basic_stream_operations(void)
params.format = STREAM_FORMAT;
params.rate = STREAM_RATE;
params.channels = STREAM_CHANNELS;
#if defined(__ANDROID__)
params.stream_type = CUBEB_STREAM_TYPE_MUSIC;
#endif
r = cubeb_stream_init(ctx, &stream, "test", NULL, NULL, NULL, &params, STREAM_LATENCY,
test_data_callback, test_state_callback, &dummy);
@ -401,6 +421,9 @@ test_stream_position(void)
params.format = STREAM_FORMAT;
params.rate = STREAM_RATE;
params.channels = STREAM_CHANNELS;
#if defined(__ANDROID__)
params.stream_type = CUBEB_STREAM_TYPE_MUSIC;
#endif
r = cubeb_stream_init(ctx, &stream, "test", NULL, NULL, NULL, &params, STREAM_LATENCY,
test_data_callback, test_state_callback, &dummy);
@ -484,7 +507,11 @@ test_drain_data_callback(cubeb_stream * stm, void * user_ptr, const void * input
}
/* once drain has started, callback must never be called again */
assert(do_drain != 2);
#if (defined(_WIN32) || defined(__WIN32__))
memset(outputbuffer, 0, nframes * sizeof(float));
#else
memset(outputbuffer, 0, nframes * sizeof(short));
#endif
total_frames_written += nframes;
return nframes;
}
@ -517,6 +544,9 @@ test_drain(void)
params.format = STREAM_FORMAT;
params.rate = STREAM_RATE;
params.channels = STREAM_CHANNELS;
#if defined(__ANDROID__)
params.stream_type = CUBEB_STREAM_TYPE_MUSIC;
#endif
r = cubeb_stream_init(ctx, &stream, "test", NULL, NULL, NULL, &params, STREAM_LATENCY,
test_drain_data_callback, test_drain_state_callback, &dummy);