Bug 1670917 - Update libcubeb to a7e83aa. r=cubeb-reviewers,chunmin

Differential Revision: https://phabricator.services.mozilla.com/D93361
This commit is contained in:
Paul Adenot 2020-10-20 13:48:14 +00:00
Родитель 4c0e069936
Коммит cf7a8a8f15
14 изменённых файлов: 1375 добавлений и 20 удалений

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

@ -227,6 +227,9 @@ TEST(cubeb, configure_stream)
r = cubeb_stream_set_volume(stream, 1.0f);
ASSERT_TRUE(r == 0 || r == CUBEB_ERROR_NOT_SUPPORTED);
r = cubeb_stream_set_name(stream, "test 2");
ASSERT_TRUE(r == 0 || r == CUBEB_ERROR_NOT_SUPPORTED);
cubeb_stream_destroy(stream);
cubeb_destroy(ctx);
}

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

@ -230,12 +230,18 @@ typedef enum {
CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING = 0x02, /**< Disable switching
default device on OS
changes. */
CUBEB_STREAM_PREF_VOICE = 0x04 /**< This stream is going to transport voice data.
CUBEB_STREAM_PREF_VOICE = 0x04, /**< This stream is going to transport voice data.
Depending on the backend and platform, this can
change the audio input or output devices
selected, as well as the quality of the stream,
for example to accomodate bluetooth SCO modes on
bluetooth devices. */
CUBEB_STREAM_PREF_RAW = 0x08, /**< Windows only. Bypass all signal processing
except for always on APO, driver and hardware. */
CUBEB_STREAM_PREF_PERSIST = 0x10, /**< Request that the volume and mute settings
should persist across restarts of the stream
and/or application. May not be honored for
all backends and platforms. */
} cubeb_stream_prefs;
/** Stream format initialization parameters. */
@ -584,6 +590,14 @@ CUBEB_EXPORT int cubeb_stream_get_input_latency(cubeb_stream * stream, uint32_t
@retval CUBEB_ERROR_NOT_SUPPORTED */
CUBEB_EXPORT int cubeb_stream_set_volume(cubeb_stream * stream, float volume);
/** Change a stream's name.
@param stream the stream for which to set the name.
@param stream_name the new name for the stream
@retval CUBEB_OK
@retval CUBEB_ERROR_INVALID_PARAMETER if any pointer is invalid
@retval CUBEB_ERROR_NOT_SUPPORTED */
CUBEB_EXPORT int cubeb_stream_set_name(cubeb_stream * stream, char const * stream_name);
/** Get the current output device for this stream.
@param stm the stream for which to query the current output device
@param device a pointer in which the current output device will be stored.

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

@ -19,5 +19,5 @@ origin:
license: "ISC"
# update.sh will update this value
release: "1358724f731b9813410f1ef4015ea8c26a201ab2 (2020-09-22 11:09:51 +0200)"
release: "a7e83aa2b1571b842a555158e8f25aeb1419ebd1 (2020-10-13 12:05:17 +0100)"

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

@ -65,6 +65,7 @@ struct cubeb_ops {
int (* stream_get_latency)(cubeb_stream * stream, uint32_t * latency);
int (* stream_get_input_latency)(cubeb_stream * stream, uint32_t * latency);
int (* stream_set_volume)(cubeb_stream * stream, float volumes);
int (* stream_set_name)(cubeb_stream * stream, char const * stream_name);
int (* stream_get_current_device)(cubeb_stream * stream,
cubeb_device ** const device);
int (* stream_device_destroy)(cubeb_stream * stream,

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

@ -60,6 +60,9 @@ int sun_init(cubeb ** context, char const * context_name);
#if defined(USE_OPENSL)
int opensl_init(cubeb ** context, char const * context_name);
#endif
#if defined(USE_OSS)
int oss_init(cubeb ** context, char const * context_name);
#endif
#if defined(USE_AUDIOTRACK)
int audiotrack_init(cubeb ** context, char const * context_name);
#endif
@ -165,6 +168,10 @@ cubeb_init(cubeb ** context, char const * context_name, char const * backend_nam
} else if (!strcmp(backend_name, "opensl")) {
#if defined(USE_OPENSL)
init_oneshot = opensl_init;
#endif
} else if (!strcmp(backend_name, "oss")) {
#if defined(USE_OSS)
init_oneshot = oss_init;
#endif
} else if (!strcmp(backend_name, "audiotrack")) {
#if defined(USE_AUDIOTRACK)
@ -200,6 +207,9 @@ cubeb_init(cubeb ** context, char const * context_name, char const * backend_nam
#if defined(USE_ALSA)
alsa_init,
#endif
#if defined (USE_OSS)
oss_init,
#endif
#if defined(USE_AUDIOUNIT_RUST)
audiounit_rust_init,
#endif
@ -448,6 +458,20 @@ cubeb_stream_set_volume(cubeb_stream * stream, float volume)
return stream->context->ops->stream_set_volume(stream, volume);
}
int
cubeb_stream_set_name(cubeb_stream * stream, char const * stream_name)
{
if (!stream || !stream_name) {
return CUBEB_ERROR_INVALID_PARAMETER;
}
if (!stream->context->ops->stream_set_name) {
return CUBEB_ERROR_NOT_SUPPORTED;
}
return stream->context->ops->stream_set_name(stream, stream_name);
}
int cubeb_stream_get_current_device(cubeb_stream * stream,
cubeb_device ** const device)
{
@ -676,4 +700,3 @@ int cubeb_set_log_callback(cubeb_log_level log_level,
return CUBEB_OK;
}

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

@ -1446,6 +1446,7 @@ static struct cubeb_ops const alsa_ops = {
.stream_get_latency = alsa_stream_get_latency,
.stream_get_input_latency = NULL,
.stream_set_volume = alsa_stream_set_volume,
.stream_set_name = NULL,
.stream_get_current_device = NULL,
.stream_device_destroy = NULL,
.stream_register_device_changed_callback = NULL,

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

@ -1513,7 +1513,6 @@ audiounit_set_channel_layout(AudioUnit unit,
return CUBEB_OK;
}
OSStatus r;
uint32_t nb_channels = cubeb_channel_layout_nb_channels(layout);
@ -2070,7 +2069,6 @@ audiounit_create_unit(AudioUnit * unit, device_info * device)
return CUBEB_OK;
}
if (device->flags & DEV_INPUT) {
r = audiounit_enable_unit_scope(unit, io_side::INPUT, ENABLE);
if (r != CUBEB_OK) {
@ -2217,7 +2215,6 @@ buffer_size_changed_callback(void * inClientData,
}
switch (inPropertyID) {
case kAudioDevicePropertyBufferFrameSize: {
if (inScope != au_scope) {
break;
@ -2731,7 +2728,6 @@ audiounit_setup_stream(cubeb_stream * stm)
LOG("(%p) Could not install all device change callback.", stm);
}
return CUBEB_OK;
}
@ -3212,7 +3208,6 @@ audiounit_get_available_samplerate(AudioObjectID devid, AudioObjectPropertyScope
} else {
*min = *max = 0;
}
}
static UInt32
@ -3623,6 +3618,7 @@ cubeb_ops const audiounit_ops = {
/*.stream_get_latency =*/ audiounit_stream_get_latency,
/*.stream_get_input_latency =*/ NULL,
/*.stream_set_volume =*/ audiounit_stream_set_volume,
/*.stream_set_name =*/ NULL,
/*.stream_get_current_device =*/ audiounit_stream_get_current_device,
/*.stream_device_destroy =*/ audiounit_stream_device_destroy,
/*.stream_register_device_changed_callback =*/ audiounit_stream_register_device_changed_callback,

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

@ -134,6 +134,7 @@ static struct cubeb_ops const cbjack_ops = {
.stream_get_latency = cbjack_get_latency,
.stream_get_input_latency = NULL,
.stream_set_volume = cbjack_stream_set_volume,
.stream_set_name = NULL,
.stream_get_current_device = cbjack_stream_get_current_device,
.stream_device_destroy = cbjack_stream_device_destroy,
.stream_register_device_changed_callback = NULL,
@ -238,6 +239,22 @@ load_jack_lib(cubeb * context)
return CUBEB_OK;
}
static void
cbjack_connect_port_out (cubeb_stream * stream, const size_t out_port, const char * const phys_in_port)
{
const char *src_port = api_jack_port_name (stream->output_ports[out_port]);
api_jack_connect (stream->context->jack_client, src_port, phys_in_port);
}
static void
cbjack_connect_port_in (cubeb_stream * stream, const char * const phys_out_port, size_t in_port)
{
const char *src_port = api_jack_port_name (stream->input_ports[in_port]);
api_jack_connect (stream->context->jack_client, phys_out_port, src_port);
}
static int
cbjack_connect_ports (cubeb_stream * stream)
{
@ -257,10 +274,14 @@ cbjack_connect_ports (cubeb_stream * stream)
// Connect outputs to playback
for (unsigned int c = 0; c < stream->out_params.channels && phys_in_ports[c] != NULL; c++) {
const char *src_port = api_jack_port_name (stream->output_ports[c]);
api_jack_connect (stream->context->jack_client, src_port, phys_in_ports[c]);
cbjack_connect_port_out(stream, c, phys_in_ports[c]);
}
// Special case playing mono source in stereo
if (stream->out_params.channels == 1 && phys_in_ports[1] != NULL) {
cbjack_connect_port_out(stream, 0, phys_in_ports[1]);
}
r = CUBEB_OK;
skipplayback:
@ -269,9 +290,7 @@ skipplayback:
}
// Connect inputs to capture
for (unsigned int c = 0; c < stream->in_params.channels && phys_out_ports[c] != NULL; c++) {
const char *src_port = api_jack_port_name (stream->input_ports[c]);
api_jack_connect (stream->context->jack_client, phys_out_ports[c], src_port);
cbjack_connect_port_in(stream, phys_out_ports[c], c);
}
r = CUBEB_OK;
end:
@ -381,7 +400,6 @@ cbjack_process(jack_nframes_t nframes, void * arg)
}
}
} else {
// try to lock stream mutex
if (pthread_mutex_trylock(&stm->mutex) == 0) {

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

@ -943,7 +943,6 @@ opensl_configure_capture(cubeb_stream * stm, cubeb_stream_params * params)
}
}
if (get_android_version() > ANDROID_VERSION_JELLY_BEAN) {
SLAndroidConfigurationItf recorderConfig;
res = (*stm->recorderObj)
@ -1756,6 +1755,7 @@ static struct cubeb_ops const opensl_ops = {
.stream_get_latency = opensl_stream_get_latency,
.stream_get_input_latency = NULL,
.stream_set_volume = opensl_stream_set_volume,
.stream_set_name = NULL,
.stream_get_current_device = NULL,
.stream_device_destroy = NULL,
.stream_register_device_changed_callback = NULL,

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

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

@ -220,7 +220,6 @@ sndio_mainloop(void *arg)
/* was this last call-back invocation (aka end-of-stream) ? */
if (nfr < s->nfr) {
if (!(s->mode & SIO_PLAY) || nfr == 0) {
state = CUBEB_STATE_DRAINED;
break;
@ -662,6 +661,7 @@ static struct cubeb_ops const sndio_ops = {
.stream_get_position = sndio_stream_get_position,
.stream_get_latency = sndio_stream_get_latency,
.stream_set_volume = sndio_stream_set_volume,
.stream_set_name = NULL,
.stream_get_current_device = NULL,
.stream_device_destroy = NULL,
.stream_register_device_changed_callback = NULL,

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

@ -723,6 +723,7 @@ static struct cubeb_ops const sun_ops = {
.stream_get_latency = sun_stream_get_latency,
.stream_get_input_latency = NULL,
.stream_set_volume = sun_stream_set_volume,
.stream_set_name = NULL,
.stream_get_current_device = sun_get_current_device,
.stream_device_destroy = sun_stream_device_destroy,
.stream_register_device_changed_callback = NULL,

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

@ -4,7 +4,7 @@
* This program is made available under an ISC-style license. See the
* accompanying file LICENSE for details.
*/
#define _WIN32_WINNT 0x0600
#define _WIN32_WINNT 0x0603
#define NOMINMAX
#include <initguid.h>
@ -1812,6 +1812,28 @@ handle_channel_layout(cubeb_stream * stm, EDataFlow direction, com_heap_ptr<WAV
}
}
static bool
initialize_iaudioclient2(com_ptr<IAudioClient> & audio_client)
{
com_ptr<IAudioClient2> audio_client2;
audio_client->QueryInterface<IAudioClient2>(audio_client2.receive());
if (!audio_client2) {
LOG("Could not get IAudioClient2 interface, not setting AUDCLNT_STREAMOPTIONS_RAW.");
return CUBEB_OK;
}
AudioClientProperties properties = { 0 };
properties.cbSize = sizeof(AudioClientProperties);
#ifndef __MINGW32__
properties.Options |= AUDCLNT_STREAMOPTIONS_RAW;
#endif
HRESULT hr = audio_client2->SetClientProperties(&properties);
if (FAILED(hr)) {
LOG("IAudioClient2::SetClientProperties error: %lx", GetLastError());
return CUBEB_ERROR;
}
return CUBEB_OK;
}
static bool
initialize_iaudioclient3(com_ptr<IAudioClient> & audio_client,
cubeb_stream * stm,
@ -1835,7 +1857,7 @@ initialize_iaudioclient3(com_ptr<IAudioClient> & audio_client,
// IAudioClient3 doesn't support AUDCLNT_STREAMFLAGS_NOPERSIST, and will return
// AUDCLNT_E_INVALID_STREAM_FLAG. This is undocumented.
flags = flags ^ AUDCLNT_STREAMFLAGS_NOPERSIST;
flags = flags & ~AUDCLNT_STREAMFLAGS_NOPERSIST;
// Some people have reported glitches with capture streams:
// http://blog.nirbheek.in/2018/03/low-latency-audio-on-windows-with.html
@ -2032,7 +2054,13 @@ int setup_wasapi_stream_one_side(cubeb_stream * stm,
mix_params->format, mix_params->rate, mix_params->channels,
mix_params->layout);
DWORD flags = AUDCLNT_STREAMFLAGS_NOPERSIST;
DWORD flags = 0;
bool is_persist = stream_params->prefs & CUBEB_STREAM_PREF_PERSIST;
if (!is_persist) {
flags |= AUDCLNT_STREAMFLAGS_NOPERSIST;
}
// Check if a loopback device should be requested. Note that event callbacks
// do not work with loopback devices, so only request these if not looping.
@ -2082,6 +2110,13 @@ int setup_wasapi_stream_one_side(cubeb_stream * stm,
LOG("Could not get cubeb_device_info.");
}
if (stream_params->prefs & CUBEB_STREAM_PREF_RAW) {
if (initialize_iaudioclient2(audio_client) != CUBEB_OK) {
LOG("Can't initialize an IAudioClient2, error: %lx", GetLastError());
// This is not fatal.
}
}
#if 0 // See https://bugzilla.mozilla.org/show_bug.cgi?id=1590902
if (initialize_iaudioclient3(audio_client, stm, mix_format, flags, direction)) {
LOG("Initialized with IAudioClient3");
@ -3211,6 +3246,7 @@ cubeb_ops const wasapi_ops = {
/*.stream_get_latency =*/ wasapi_stream_get_latency,
/*.stream_get_input_latency =*/ wasapi_stream_get_input_latency,
/*.stream_set_volume =*/ wasapi_stream_set_volume,
/*.stream_set_name =*/ NULL,
/*.stream_get_current_device =*/ NULL,
/*.stream_device_destroy =*/ NULL,
/*.stream_register_device_changed_callback =*/ NULL,

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

@ -1061,6 +1061,7 @@ static struct cubeb_ops const winmm_ops = {
/*.stream_get_latency = */ winmm_stream_get_latency,
/*.stream_get_input_latency = */ NULL,
/*.stream_set_volume =*/ winmm_stream_set_volume,
/*.stream_set_name =*/ NULL,
/*.stream_get_current_device =*/ NULL,
/*.stream_device_destroy =*/ NULL,
/*.stream_register_device_changed_callback=*/ NULL,