зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1757475 - Update libcubeb to 3a04ed29. r=cubeb-reviewers,chunmin
Differential Revision: https://phabricator.services.mozilla.com/D139892
This commit is contained in:
Родитель
d98490d201
Коммит
746b1aae49
|
@ -137,26 +137,20 @@ void device_collection_changed_callback(cubeb * context, void * user)
|
|||
" called when opening a stream";
|
||||
}
|
||||
|
||||
TEST(cubeb, duplex_collection_change)
|
||||
void
|
||||
duplex_collection_change_impl(cubeb * ctx)
|
||||
{
|
||||
cubeb *ctx;
|
||||
cubeb_stream *stream;
|
||||
cubeb_stream * stream;
|
||||
cubeb_stream_params input_params;
|
||||
cubeb_stream_params output_params;
|
||||
int r;
|
||||
uint32_t latency_frames = 0;
|
||||
|
||||
r = common_init(&ctx, "Cubeb duplex example with collection change");
|
||||
ASSERT_EQ(r, CUBEB_OK) << "Error initializing cubeb library";
|
||||
|
||||
r = cubeb_register_device_collection_changed(ctx,
|
||||
static_cast<cubeb_device_type>(CUBEB_DEVICE_TYPE_INPUT),
|
||||
device_collection_changed_callback,
|
||||
nullptr);
|
||||
r = cubeb_register_device_collection_changed(
|
||||
ctx, static_cast<cubeb_device_type>(CUBEB_DEVICE_TYPE_INPUT),
|
||||
device_collection_changed_callback, nullptr);
|
||||
ASSERT_EQ(r, CUBEB_OK) << "Error initializing cubeb stream";
|
||||
|
||||
std::unique_ptr<cubeb, decltype(&cubeb_destroy)>
|
||||
cleanup_cubeb_at_exit(ctx, cubeb_destroy);
|
||||
|
||||
/* typical user-case: mono input, stereo output, low latency. */
|
||||
input_params.format = STREAM_FORMAT;
|
||||
|
@ -173,13 +167,43 @@ TEST(cubeb, duplex_collection_change)
|
|||
r = cubeb_get_min_latency(ctx, &output_params, &latency_frames);
|
||||
ASSERT_EQ(r, CUBEB_OK) << "Could not get minimal latency";
|
||||
|
||||
r = cubeb_stream_init(ctx, &stream, "Cubeb duplex",
|
||||
NULL, &input_params, NULL, &output_params,
|
||||
latency_frames, data_cb_duplex, state_cb_duplex, nullptr);
|
||||
r = cubeb_stream_init(ctx, &stream, "Cubeb duplex", NULL, &input_params, NULL,
|
||||
&output_params, latency_frames, data_cb_duplex,
|
||||
state_cb_duplex, nullptr);
|
||||
ASSERT_EQ(r, CUBEB_OK) << "Error initializing cubeb stream";
|
||||
cubeb_stream_destroy(stream);
|
||||
}
|
||||
|
||||
TEST(cubeb, duplex_collection_change)
|
||||
{
|
||||
cubeb * ctx;
|
||||
int r;
|
||||
|
||||
r = common_init(&ctx, "Cubeb duplex example with collection change");
|
||||
ASSERT_EQ(r, CUBEB_OK) << "Error initializing cubeb library";
|
||||
std::unique_ptr<cubeb, decltype(&cubeb_destroy)> cleanup_cubeb_at_exit(
|
||||
ctx, cubeb_destroy);
|
||||
|
||||
duplex_collection_change_impl(ctx);
|
||||
r = cubeb_register_device_collection_changed(
|
||||
ctx, static_cast<cubeb_device_type>(CUBEB_DEVICE_TYPE_INPUT), nullptr,
|
||||
nullptr);
|
||||
ASSERT_EQ(r, CUBEB_OK);
|
||||
}
|
||||
|
||||
TEST(cubeb, duplex_collection_change_no_unregister)
|
||||
{
|
||||
cubeb * ctx;
|
||||
int r;
|
||||
|
||||
r = common_init(&ctx, "Cubeb duplex example with collection change");
|
||||
ASSERT_EQ(r, CUBEB_OK) << "Error initializing cubeb library";
|
||||
std::unique_ptr<cubeb, decltype(&cubeb_destroy)> cleanup_cubeb_at_exit(
|
||||
ctx, [](cubeb * p) noexcept { EXPECT_DEATH(cubeb_destroy(p), ""); });
|
||||
|
||||
duplex_collection_change_impl(ctx);
|
||||
}
|
||||
|
||||
long data_cb_input(cubeb_stream * stream, void * user, const void * inputbuffer, void * outputbuffer, long nframes)
|
||||
{
|
||||
if (stream == NULL || inputbuffer == NULL || outputbuffer != NULL) {
|
||||
|
|
|
@ -19,5 +19,5 @@ origin:
|
|||
license: "ISC"
|
||||
|
||||
# update.sh will update this value
|
||||
release: "6f7226953255ebea4ee448a094eec13807620b0e (2022-01-09 08:45:52 +1300)"
|
||||
release: "3a04ed2946e796a15bd37d1900be42244d685bbf (2022-02-28 23:38:46 +1300)"
|
||||
|
||||
|
|
|
@ -1442,6 +1442,13 @@ audiounit_destroy(cubeb * ctx)
|
|||
audiounit_active_streams(ctx));
|
||||
}
|
||||
|
||||
// Destroying a cubeb context with device collection callbacks registered
|
||||
// is misuse of the API, assert then attempt to clean up.
|
||||
assert(!ctx->input_collection_changed_callback &&
|
||||
!ctx->input_collection_changed_user_ptr &&
|
||||
!ctx->output_collection_changed_callback &&
|
||||
!ctx->output_collection_changed_user_ptr);
|
||||
|
||||
/* Unregister the callback if necessary. */
|
||||
if (ctx->input_collection_changed_callback) {
|
||||
audiounit_remove_device_listener(ctx, CUBEB_DEVICE_TYPE_INPUT);
|
||||
|
|
|
@ -97,6 +97,7 @@ struct oss_stream {
|
|||
int fd;
|
||||
void * buf;
|
||||
unsigned int bufframes;
|
||||
unsigned int maxframes;
|
||||
|
||||
struct stream_info {
|
||||
int channels;
|
||||
|
@ -822,9 +823,9 @@ retry:
|
|||
pfds[0].fd = s->play.fd;
|
||||
pfds[1].fd = -1;
|
||||
goto retry;
|
||||
} else if (tnfr > (long)s->play.bufframes) {
|
||||
} else if (tnfr > (long)s->play.maxframes) {
|
||||
/* too many frames available - limit */
|
||||
tnfr = (long)s->play.bufframes;
|
||||
tnfr = (long)s->play.maxframes;
|
||||
}
|
||||
if (nfr > tnfr) {
|
||||
nfr = tnfr;
|
||||
|
@ -840,9 +841,9 @@ retry:
|
|||
pfds[0].fd = -1;
|
||||
pfds[1].fd = s->record.fd;
|
||||
goto retry;
|
||||
} else if (tnfr > (long)s->record.bufframes) {
|
||||
} else if (tnfr > (long)s->record.maxframes) {
|
||||
/* too many frames available - limit */
|
||||
tnfr = (long)s->record.bufframes;
|
||||
tnfr = (long)s->record.maxframes;
|
||||
}
|
||||
if (nfr > tnfr) {
|
||||
nfr = tnfr;
|
||||
|
@ -1146,8 +1147,19 @@ oss_stream_init(cubeb * context, cubeb_stream ** stream,
|
|||
else {
|
||||
s->play.bufframes = (bi.fragsize * bi.fragstotal) / s->play.frame_size;
|
||||
}
|
||||
int lw;
|
||||
|
||||
int lw = s->play.frame_size;
|
||||
/*
|
||||
* Force 32 ms service intervals at most, or when recording is
|
||||
* active, use the recording service intervals as a reference.
|
||||
*/
|
||||
s->play.maxframes = (32 * output_stream_params->rate) / 1000;
|
||||
if (s->record.fd != -1 || s->play.maxframes >= s->play.bufframes) {
|
||||
lw = s->play.frame_size; /* Feed data when possible. */
|
||||
s->play.maxframes = s->play.bufframes;
|
||||
} else {
|
||||
lw = (s->play.bufframes - s->play.maxframes) * s->play.frame_size;
|
||||
}
|
||||
if (ioctl(s->play.fd, SNDCTL_DSP_LOW_WATER, &lw))
|
||||
LOG("Audio device \"%s\" (play) could not set trigger threshold",
|
||||
s->play.name);
|
||||
|
@ -1166,6 +1178,7 @@ oss_stream_init(cubeb * context, cubeb_stream ** stream,
|
|||
(bi.fragsize * bi.fragstotal) / s->record.frame_size;
|
||||
}
|
||||
|
||||
s->record.maxframes = s->record.bufframes;
|
||||
int lw = s->record.frame_size;
|
||||
if (ioctl(s->record.fd, SNDCTL_DSP_LOW_WATER, &lw))
|
||||
LOG("Audio device \"%s\" (record) could not set trigger threshold",
|
||||
|
|
|
@ -1438,7 +1438,7 @@ wasapi_destroy(cubeb * context);
|
|||
HRESULT
|
||||
register_notification_client(cubeb_stream * stm)
|
||||
{
|
||||
XASSERT(stm->device_enumerator);
|
||||
XASSERT(stm->device_enumerator && !stm->notification_client);
|
||||
|
||||
stm->notification_client.reset(new wasapi_endpoint_notification_client(
|
||||
stm->reconfigure_event, stm->role));
|
||||
|
@ -1456,7 +1456,7 @@ register_notification_client(cubeb_stream * stm)
|
|||
HRESULT
|
||||
unregister_notification_client(cubeb_stream * stm)
|
||||
{
|
||||
XASSERT(stm->device_enumerator);
|
||||
XASSERT(stm->device_enumerator && stm->notification_client);
|
||||
|
||||
HRESULT hr = stm->device_enumerator->UnregisterEndpointNotificationCallback(
|
||||
stm->notification_client.get());
|
||||
|
@ -1495,6 +1495,8 @@ get_endpoint(com_ptr<IMMDevice> & device, LPCWSTR devid)
|
|||
HRESULT
|
||||
register_collection_notification_client(cubeb * context)
|
||||
{
|
||||
XASSERT(!context->device_collection_enumerator &&
|
||||
!context->collection_notification_client);
|
||||
HRESULT hr = CoCreateInstance(
|
||||
__uuidof(MMDeviceEnumerator), NULL, CLSCTX_INPROC_SERVER,
|
||||
IID_PPV_ARGS(context->device_collection_enumerator.receive()));
|
||||
|
@ -1521,6 +1523,8 @@ register_collection_notification_client(cubeb * context)
|
|||
HRESULT
|
||||
unregister_collection_notification_client(cubeb * context)
|
||||
{
|
||||
XASSERT(context->device_collection_enumerator &&
|
||||
context->collection_notification_client);
|
||||
HRESULT hr = context->device_collection_enumerator
|
||||
->UnregisterEndpointNotificationCallback(
|
||||
context->collection_notification_client.get());
|
||||
|
@ -1723,6 +1727,9 @@ stop_and_join_render_thread(cubeb_stream * stm)
|
|||
void
|
||||
wasapi_destroy(cubeb * context)
|
||||
{
|
||||
XASSERT(!context->device_collection_enumerator &&
|
||||
!context->collection_notification_client);
|
||||
|
||||
if (context->device_ids) {
|
||||
cubeb_strings_destroy(context->device_ids);
|
||||
}
|
||||
|
@ -2492,8 +2499,8 @@ setup_wasapi_stream(cubeb_stream * stm)
|
|||
|
||||
stm->resampler.reset(cubeb_resampler_create(
|
||||
stm, has_input(stm) ? &input_params : nullptr,
|
||||
has_output(stm) ? &output_params : nullptr, target_sample_rate,
|
||||
stm->data_callback, stm->user_ptr,
|
||||
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));
|
||||
if (!stm->resampler) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче