зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1760774 - Update libcubeb to revision 5a2a20. r=cubeb-reviewers,kinetik
Differential Revision: https://phabricator.services.mozilla.com/D141756
This commit is contained in:
Родитель
fb6410005b
Коммит
f99045f6bf
|
@ -338,7 +338,8 @@ void test_resampler_duplex(uint32_t input_channels, uint32_t output_channels,
|
|||
|
||||
cubeb_resampler * resampler =
|
||||
cubeb_resampler_create((cubeb_stream*)nullptr, &input_params, &output_params, target_rate,
|
||||
data_cb_resampler, (void*)&state, CUBEB_RESAMPLER_QUALITY_VOIP);
|
||||
data_cb_resampler, (void*)&state, CUBEB_RESAMPLER_QUALITY_VOIP,
|
||||
CUBEB_RESAMPLER_RECLOCK_NONE);
|
||||
|
||||
long latency = cubeb_resampler_latency(resampler);
|
||||
|
||||
|
@ -484,8 +485,8 @@ TEST(cubeb, resampler_output_only_noop)
|
|||
cubeb_resampler * resampler =
|
||||
cubeb_resampler_create((cubeb_stream*)nullptr, nullptr, &output_params, target_rate,
|
||||
test_output_only_noop_data_cb, nullptr,
|
||||
CUBEB_RESAMPLER_QUALITY_VOIP);
|
||||
|
||||
CUBEB_RESAMPLER_QUALITY_VOIP,
|
||||
CUBEB_RESAMPLER_RECLOCK_NONE);
|
||||
const long out_frames = 128;
|
||||
float out_buffer[out_frames];
|
||||
long got;
|
||||
|
@ -523,7 +524,8 @@ TEST(cubeb, resampler_drain)
|
|||
cubeb_resampler * resampler =
|
||||
cubeb_resampler_create((cubeb_stream*)nullptr, nullptr, &output_params, target_rate,
|
||||
test_drain_data_cb, &cb_count,
|
||||
CUBEB_RESAMPLER_QUALITY_VOIP);
|
||||
CUBEB_RESAMPLER_QUALITY_VOIP,
|
||||
CUBEB_RESAMPLER_RECLOCK_NONE);
|
||||
|
||||
const long out_frames = 128;
|
||||
float out_buffer[out_frames];
|
||||
|
@ -572,7 +574,8 @@ TEST(cubeb, resampler_passthrough_output_only)
|
|||
cubeb_resampler * resampler =
|
||||
cubeb_resampler_create((cubeb_stream*)nullptr, nullptr, &output_params,
|
||||
target_rate, cb_passthrough_resampler_output, nullptr,
|
||||
CUBEB_RESAMPLER_QUALITY_VOIP);
|
||||
CUBEB_RESAMPLER_QUALITY_VOIP,
|
||||
CUBEB_RESAMPLER_RECLOCK_NONE);
|
||||
|
||||
float output_buffer[output_channels * 256];
|
||||
|
||||
|
@ -616,7 +619,8 @@ TEST(cubeb, resampler_passthrough_input_only)
|
|||
cubeb_resampler * resampler =
|
||||
cubeb_resampler_create((cubeb_stream*)nullptr, &input_params, nullptr,
|
||||
target_rate, cb_passthrough_resampler_input, nullptr,
|
||||
CUBEB_RESAMPLER_QUALITY_VOIP);
|
||||
CUBEB_RESAMPLER_QUALITY_VOIP,
|
||||
CUBEB_RESAMPLER_RECLOCK_NONE);
|
||||
|
||||
float input_buffer[input_channels * 256];
|
||||
|
||||
|
@ -737,7 +741,8 @@ TEST(cubeb, resampler_passthrough_duplex_callback_reordering)
|
|||
cubeb_resampler * resampler =
|
||||
cubeb_resampler_create((cubeb_stream*)nullptr, &input_params, &output_params,
|
||||
target_rate, cb_passthrough_resampler_duplex, &c,
|
||||
CUBEB_RESAMPLER_QUALITY_VOIP);
|
||||
CUBEB_RESAMPLER_QUALITY_VOIP,
|
||||
CUBEB_RESAMPLER_RECLOCK_NONE);
|
||||
|
||||
const long BUF_BASE_SIZE = 256;
|
||||
float input_buffer_prebuffer[input_channels * BUF_BASE_SIZE * 2];
|
||||
|
@ -820,7 +825,7 @@ TEST(cubeb, resampler_drift_drop_data)
|
|||
cubeb_resampler * resampler =
|
||||
cubeb_resampler_create((cubeb_stream*)nullptr, &input_params, &output_params,
|
||||
target_rate, cb_passthrough_resampler_duplex, &c,
|
||||
CUBEB_RESAMPLER_QUALITY_VOIP);
|
||||
CUBEB_RESAMPLER_QUALITY_VOIP, CUBEB_RESAMPLER_RECLOCK_NONE);
|
||||
|
||||
const long BUF_BASE_SIZE = 256;
|
||||
|
||||
|
|
|
@ -19,5 +19,5 @@ origin:
|
|||
license: "ISC"
|
||||
|
||||
# update.sh will update this value
|
||||
release: "3a04ed2946e796a15bd37d1900be42244d685bbf (2022-02-28 23:38:46 +1300)"
|
||||
release: "5a2a20c6055d26e0a30fae8f1cf6f6cb975c5c97 (2022-03-22 14:15:59 +1300)"
|
||||
|
||||
|
|
|
@ -935,7 +935,8 @@ aaudio_stream_init_impl(cubeb_stream * stm, cubeb_devid input_device,
|
|||
stm->resampler = cubeb_resampler_create(
|
||||
stm, input_stream_params ? &in_params : NULL,
|
||||
output_stream_params ? &out_params : NULL, target_sample_rate,
|
||||
stm->data_callback, stm->user_ptr, CUBEB_RESAMPLER_QUALITY_DEFAULT);
|
||||
stm->data_callback, stm->user_ptr, CUBEB_RESAMPLER_QUALITY_DEFAULT,
|
||||
CUBEB_RESAMPLER_RECLOCK_NONE);
|
||||
|
||||
if (!stm->resampler) {
|
||||
LOG("Failed to create resampler");
|
||||
|
|
|
@ -2707,7 +2707,8 @@ audiounit_setup_stream(cubeb_stream * stm)
|
|||
stm->resampler.reset(cubeb_resampler_create(
|
||||
stm, has_input(stm) ? &input_unconverted_params : NULL,
|
||||
has_output(stm) ? &stm->output_stream_params : NULL, target_sample_rate,
|
||||
stm->data_callback, stm->user_ptr, CUBEB_RESAMPLER_QUALITY_DESKTOP));
|
||||
stm->data_callback, stm->user_ptr, CUBEB_RESAMPLER_QUALITY_DESKTOP,
|
||||
CUBEB_RESAMPLER_RECLOCK_NONE));
|
||||
if (!stm->resampler) {
|
||||
LOG("(%p) Could not create resampler.", stm);
|
||||
return CUBEB_ERROR;
|
||||
|
|
|
@ -925,15 +925,18 @@ cbjack_stream_init(cubeb * context, cubeb_stream ** stream,
|
|||
if (stm->devs == DUPLEX) {
|
||||
stm->resampler = cubeb_resampler_create(
|
||||
stm, &stm->in_params, &stm->out_params, stream_actual_rate,
|
||||
stm->data_callback, stm->user_ptr, CUBEB_RESAMPLER_QUALITY_DESKTOP);
|
||||
stm->data_callback, stm->user_ptr, CUBEB_RESAMPLER_QUALITY_DESKTOP,
|
||||
CUBEB_RESAMPLER_RECLOCK_NONE);
|
||||
} else if (stm->devs == IN_ONLY) {
|
||||
stm->resampler = cubeb_resampler_create(
|
||||
stm, &stm->in_params, nullptr, stream_actual_rate, stm->data_callback,
|
||||
stm->user_ptr, CUBEB_RESAMPLER_QUALITY_DESKTOP);
|
||||
stm->user_ptr, CUBEB_RESAMPLER_QUALITY_DESKTOP,
|
||||
CUBEB_RESAMPLER_RECLOCK_NONE);
|
||||
} else if (stm->devs == OUT_ONLY) {
|
||||
stm->resampler = cubeb_resampler_create(
|
||||
stm, nullptr, &stm->out_params, stream_actual_rate, stm->data_callback,
|
||||
stm->user_ptr, CUBEB_RESAMPLER_QUALITY_DESKTOP);
|
||||
stm->user_ptr, CUBEB_RESAMPLER_QUALITY_DESKTOP,
|
||||
CUBEB_RESAMPLER_RECLOCK_NONE);
|
||||
}
|
||||
|
||||
if (!stm->resampler) {
|
||||
|
|
|
@ -1479,7 +1479,8 @@ opensl_stream_init(cubeb * ctx, cubeb_stream ** stream,
|
|||
stm->resampler = cubeb_resampler_create(
|
||||
stm, input_stream_params ? &input_params : NULL,
|
||||
output_stream_params ? &output_params : NULL, target_sample_rate,
|
||||
data_callback, user_ptr, CUBEB_RESAMPLER_QUALITY_DEFAULT);
|
||||
data_callback, user_ptr, CUBEB_RESAMPLER_QUALITY_DEFAULT,
|
||||
CUBEB_RESAMPLER_RECLOCK_NONE);
|
||||
if (!stm->resampler) {
|
||||
LOG("Failed to create resampler");
|
||||
opensl_stream_destroy(stm);
|
||||
|
|
|
@ -323,7 +323,8 @@ cubeb_resampler_create(cubeb_stream * stream,
|
|||
cubeb_stream_params * input_params,
|
||||
cubeb_stream_params * output_params,
|
||||
unsigned int target_rate, cubeb_data_callback callback,
|
||||
void * user_ptr, cubeb_resampler_quality quality)
|
||||
void * user_ptr, cubeb_resampler_quality quality,
|
||||
cubeb_resampler_reclock reclock)
|
||||
{
|
||||
cubeb_sample_format format;
|
||||
|
||||
|
@ -337,13 +338,13 @@ cubeb_resampler_create(cubeb_stream * stream,
|
|||
|
||||
switch (format) {
|
||||
case CUBEB_SAMPLE_S16NE:
|
||||
return cubeb_resampler_create_internal<short>(stream, input_params,
|
||||
output_params, target_rate,
|
||||
callback, user_ptr, quality);
|
||||
return cubeb_resampler_create_internal<short>(
|
||||
stream, input_params, output_params, target_rate, callback, user_ptr,
|
||||
quality, reclock);
|
||||
case CUBEB_SAMPLE_FLOAT32NE:
|
||||
return cubeb_resampler_create_internal<float>(stream, input_params,
|
||||
output_params, target_rate,
|
||||
callback, user_ptr, quality);
|
||||
return cubeb_resampler_create_internal<float>(
|
||||
stream, input_params, output_params, target_rate, callback, user_ptr,
|
||||
quality, reclock);
|
||||
default:
|
||||
assert(false);
|
||||
return nullptr;
|
||||
|
|
|
@ -21,6 +21,11 @@ typedef enum {
|
|||
CUBEB_RESAMPLER_QUALITY_DESKTOP
|
||||
} cubeb_resampler_quality;
|
||||
|
||||
typedef enum {
|
||||
CUBEB_RESAMPLER_RECLOCK_NONE,
|
||||
CUBEB_RESAMPLER_RECLOCK_INPUT
|
||||
} cubeb_resampler_reclock;
|
||||
|
||||
/**
|
||||
* Create a resampler to adapt the requested sample rate into something that
|
||||
* is accepted by the audio backend.
|
||||
|
@ -44,7 +49,8 @@ cubeb_resampler_create(cubeb_stream * stream,
|
|||
cubeb_stream_params * input_params,
|
||||
cubeb_stream_params * output_params,
|
||||
unsigned int target_rate, cubeb_data_callback callback,
|
||||
void * user_ptr, cubeb_resampler_quality quality);
|
||||
void * user_ptr, cubeb_resampler_quality quality,
|
||||
cubeb_resampler_reclock reclock);
|
||||
|
||||
/**
|
||||
* Fill the buffer with frames acquired using the data callback. Resampling will
|
||||
|
|
|
@ -496,7 +496,8 @@ cubeb_resampler_create_internal(cubeb_stream * stream,
|
|||
cubeb_stream_params * output_params,
|
||||
unsigned int target_rate,
|
||||
cubeb_data_callback callback, void * user_ptr,
|
||||
cubeb_resampler_quality quality)
|
||||
cubeb_resampler_quality quality,
|
||||
cubeb_resampler_reclock reclock)
|
||||
{
|
||||
std::unique_ptr<cubeb_resampler_speex_one_way<T>> input_resampler = nullptr;
|
||||
std::unique_ptr<cubeb_resampler_speex_one_way<T>> output_resampler = nullptr;
|
||||
|
|
|
@ -11,24 +11,23 @@
|
|||
#include "cubeb-internal.h"
|
||||
#include <windows.h>
|
||||
|
||||
/* This wraps a critical section to track the owner in debug mode, adapted from
|
||||
/* This wraps an SRWLock to track the owner in debug mode, adapted from
|
||||
NSPR and http://blogs.msdn.com/b/oldnewthing/archive/2013/07/12/10433554.aspx
|
||||
*/
|
||||
class owned_critical_section {
|
||||
public:
|
||||
owned_critical_section()
|
||||
: srwlock(SRWLOCK_INIT)
|
||||
#ifndef NDEBUG
|
||||
: owner(0)
|
||||
,
|
||||
owner(0)
|
||||
#endif
|
||||
{
|
||||
InitializeCriticalSection(&critical_section);
|
||||
}
|
||||
|
||||
~owned_critical_section() { DeleteCriticalSection(&critical_section); }
|
||||
|
||||
void lock()
|
||||
{
|
||||
EnterCriticalSection(&critical_section);
|
||||
AcquireSRWLockExclusive(&srwlock);
|
||||
#ifndef NDEBUG
|
||||
XASSERT(owner != GetCurrentThreadId() && "recursive locking");
|
||||
owner = GetCurrentThreadId();
|
||||
|
@ -41,7 +40,7 @@ public:
|
|||
/* GetCurrentThreadId cannot return 0: it is not a the valid thread id */
|
||||
owner = 0;
|
||||
#endif
|
||||
LeaveCriticalSection(&critical_section);
|
||||
ReleaseSRWLockExclusive(&srwlock);
|
||||
}
|
||||
|
||||
/* This is guaranteed to have the good behaviour if it succeeds. The behaviour
|
||||
|
@ -55,12 +54,12 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
CRITICAL_SECTION critical_section;
|
||||
SRWLOCK srwlock;
|
||||
#ifndef NDEBUG
|
||||
DWORD owner;
|
||||
#endif
|
||||
|
||||
// Disallow copy and assignment because CRICICAL_SECTION cannot be copied.
|
||||
// Disallow copy and assignment because SRWLock cannot be copied.
|
||||
owned_critical_section(const owned_critical_section &);
|
||||
owned_critical_section & operator=(const owned_critical_section &);
|
||||
};
|
||||
|
|
|
@ -257,6 +257,7 @@ class monitor_device_notifications;
|
|||
|
||||
struct cubeb {
|
||||
cubeb_ops const * ops = &wasapi_ops;
|
||||
owned_critical_section lock;
|
||||
cubeb_strings * device_ids;
|
||||
/* Device enumerator to get notifications when the
|
||||
device collection change. */
|
||||
|
@ -757,6 +758,8 @@ intern_device_id(cubeb * ctx, wchar_t const * id)
|
|||
{
|
||||
XASSERT(id);
|
||||
|
||||
auto_lock lock(ctx->lock);
|
||||
|
||||
char const * tmp = wstr_to_utf8(id);
|
||||
if (!tmp) {
|
||||
return nullptr;
|
||||
|
@ -1495,6 +1498,7 @@ get_endpoint(com_ptr<IMMDevice> & device, LPCWSTR devid)
|
|||
HRESULT
|
||||
register_collection_notification_client(cubeb * context)
|
||||
{
|
||||
context->lock.assert_current_thread_owns();
|
||||
XASSERT(!context->device_collection_enumerator &&
|
||||
!context->collection_notification_client);
|
||||
HRESULT hr = CoCreateInstance(
|
||||
|
@ -1523,6 +1527,7 @@ register_collection_notification_client(cubeb * context)
|
|||
HRESULT
|
||||
unregister_collection_notification_client(cubeb * context)
|
||||
{
|
||||
context->lock.assert_current_thread_owns();
|
||||
XASSERT(context->device_collection_enumerator &&
|
||||
context->collection_notification_client);
|
||||
HRESULT hr = context->device_collection_enumerator
|
||||
|
@ -1653,6 +1658,7 @@ wasapi_init(cubeb ** context, char const * context_name)
|
|||
cubeb * ctx = new cubeb();
|
||||
|
||||
ctx->ops = &wasapi_ops;
|
||||
auto_lock lock(ctx->lock);
|
||||
if (cubeb_strings_init(&ctx->device_ids) != CUBEB_OK) {
|
||||
delete ctx;
|
||||
return CUBEB_ERROR;
|
||||
|
@ -1727,6 +1733,7 @@ stop_and_join_render_thread(cubeb_stream * stm)
|
|||
void
|
||||
wasapi_destroy(cubeb * context)
|
||||
{
|
||||
auto_lock lock(context->lock);
|
||||
XASSERT(!context->device_collection_enumerator &&
|
||||
!context->collection_notification_client);
|
||||
|
||||
|
@ -2502,7 +2509,8 @@ setup_wasapi_stream(cubeb_stream * stm)
|
|||
has_output(stm) && !stm->has_dummy_output ? &output_params : nullptr,
|
||||
target_sample_rate, stm->data_callback, stm->user_ptr,
|
||||
stm->voice ? CUBEB_RESAMPLER_QUALITY_VOIP
|
||||
: CUBEB_RESAMPLER_QUALITY_DESKTOP));
|
||||
: CUBEB_RESAMPLER_QUALITY_DESKTOP,
|
||||
CUBEB_RESAMPLER_RECLOCK_NONE));
|
||||
if (!stm->resampler) {
|
||||
LOG("Could not get a resampler");
|
||||
return CUBEB_ERROR;
|
||||
|
@ -3344,6 +3352,7 @@ wasapi_register_device_collection_changed(
|
|||
cubeb_device_collection_changed_callback collection_changed_callback,
|
||||
void * user_ptr)
|
||||
{
|
||||
auto_lock lock(context->lock);
|
||||
if (devtype == CUBEB_DEVICE_TYPE_UNKNOWN) {
|
||||
return CUBEB_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче