Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 21e6a2b

Browse files
committed
Bug 1670917 - Update libcubeb to a7e83aa. r=cubeb-reviewers,chunmin
Differential Revision: https://phabricator.services.mozilla.com/D93361
1 parent 10babee commit 21e6a2b

14 files changed

Lines changed: 1374 additions & 19 deletions

media/libcubeb/gtest/test_sanity.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ TEST(cubeb, configure_stream)
227227
r = cubeb_stream_set_volume(stream, 1.0f);
228228
ASSERT_TRUE(r == 0 || r == CUBEB_ERROR_NOT_SUPPORTED);
229229

230+
r = cubeb_stream_set_name(stream, "test 2");
231+
ASSERT_TRUE(r == 0 || r == CUBEB_ERROR_NOT_SUPPORTED);
232+
230233
cubeb_stream_destroy(stream);
231234
cubeb_destroy(ctx);
232235
}

media/libcubeb/include/cubeb.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,18 @@ typedef enum {
230230
CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING = 0x02, /**< Disable switching
231231
default device on OS
232232
changes. */
233-
CUBEB_STREAM_PREF_VOICE = 0x04 /**< This stream is going to transport voice data.
233+
CUBEB_STREAM_PREF_VOICE = 0x04, /**< This stream is going to transport voice data.
234234
Depending on the backend and platform, this can
235235
change the audio input or output devices
236236
selected, as well as the quality of the stream,
237237
for example to accomodate bluetooth SCO modes on
238238
bluetooth devices. */
239+
CUBEB_STREAM_PREF_RAW = 0x08, /**< Windows only. Bypass all signal processing
240+
except for always on APO, driver and hardware. */
241+
CUBEB_STREAM_PREF_PERSIST = 0x10, /**< Request that the volume and mute settings
242+
should persist across restarts of the stream
243+
and/or application. May not be honored for
244+
all backends and platforms. */
239245
} cubeb_stream_prefs;
240246

241247
/** Stream format initialization parameters. */
@@ -584,6 +590,14 @@ CUBEB_EXPORT int cubeb_stream_get_input_latency(cubeb_stream * stream, uint32_t
584590
@retval CUBEB_ERROR_NOT_SUPPORTED */
585591
CUBEB_EXPORT int cubeb_stream_set_volume(cubeb_stream * stream, float volume);
586592

593+
/** Change a stream's name.
594+
@param stream the stream for which to set the name.
595+
@param stream_name the new name for the stream
596+
@retval CUBEB_OK
597+
@retval CUBEB_ERROR_INVALID_PARAMETER if any pointer is invalid
598+
@retval CUBEB_ERROR_NOT_SUPPORTED */
599+
CUBEB_EXPORT int cubeb_stream_set_name(cubeb_stream * stream, char const * stream_name);
600+
587601
/** Get the current output device for this stream.
588602
@param stm the stream for which to query the current output device
589603
@param device a pointer in which the current output device will be stored.

media/libcubeb/moz.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ origin:
1919
license: "ISC"
2020

2121
# update.sh will update this value
22-
release: "1358724f731b9813410f1ef4015ea8c26a201ab2 (2020-09-22 11:09:51 +0200)"
22+
release: "a7e83aa2b1571b842a555158e8f25aeb1419ebd1 (2020-10-13 12:05:17 +0100)"
2323

media/libcubeb/src/cubeb-internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct cubeb_ops {
6565
int (* stream_get_latency)(cubeb_stream * stream, uint32_t * latency);
6666
int (* stream_get_input_latency)(cubeb_stream * stream, uint32_t * latency);
6767
int (* stream_set_volume)(cubeb_stream * stream, float volumes);
68+
int (* stream_set_name)(cubeb_stream * stream, char const * stream_name);
6869
int (* stream_get_current_device)(cubeb_stream * stream,
6970
cubeb_device ** const device);
7071
int (* stream_device_destroy)(cubeb_stream * stream,

media/libcubeb/src/cubeb.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ int sun_init(cubeb ** context, char const * context_name);
6060
#if defined(USE_OPENSL)
6161
int opensl_init(cubeb ** context, char const * context_name);
6262
#endif
63+
#if defined(USE_OSS)
64+
int oss_init(cubeb ** context, char const * context_name);
65+
#endif
6366
#if defined(USE_AUDIOTRACK)
6467
int audiotrack_init(cubeb ** context, char const * context_name);
6568
#endif
@@ -165,6 +168,10 @@ cubeb_init(cubeb ** context, char const * context_name, char const * backend_nam
165168
} else if (!strcmp(backend_name, "opensl")) {
166169
#if defined(USE_OPENSL)
167170
init_oneshot = opensl_init;
171+
#endif
172+
} else if (!strcmp(backend_name, "oss")) {
173+
#if defined(USE_OSS)
174+
init_oneshot = oss_init;
168175
#endif
169176
} else if (!strcmp(backend_name, "audiotrack")) {
170177
#if defined(USE_AUDIOTRACK)
@@ -200,6 +207,9 @@ cubeb_init(cubeb ** context, char const * context_name, char const * backend_nam
200207
#if defined(USE_ALSA)
201208
alsa_init,
202209
#endif
210+
#if defined (USE_OSS)
211+
oss_init,
212+
#endif
203213
#if defined(USE_AUDIOUNIT_RUST)
204214
audiounit_rust_init,
205215
#endif
@@ -448,6 +458,20 @@ cubeb_stream_set_volume(cubeb_stream * stream, float volume)
448458
return stream->context->ops->stream_set_volume(stream, volume);
449459
}
450460

461+
int
462+
cubeb_stream_set_name(cubeb_stream * stream, char const * stream_name)
463+
{
464+
if (!stream || !stream_name) {
465+
return CUBEB_ERROR_INVALID_PARAMETER;
466+
}
467+
468+
if (!stream->context->ops->stream_set_name) {
469+
return CUBEB_ERROR_NOT_SUPPORTED;
470+
}
471+
472+
return stream->context->ops->stream_set_name(stream, stream_name);
473+
}
474+
451475
int cubeb_stream_get_current_device(cubeb_stream * stream,
452476
cubeb_device ** const device)
453477
{
@@ -676,4 +700,3 @@ int cubeb_set_log_callback(cubeb_log_level log_level,
676700

677701
return CUBEB_OK;
678702
}
679-

media/libcubeb/src/cubeb_alsa.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,7 @@ static struct cubeb_ops const alsa_ops = {
14461446
.stream_get_latency = alsa_stream_get_latency,
14471447
.stream_get_input_latency = NULL,
14481448
.stream_set_volume = alsa_stream_set_volume,
1449+
.stream_set_name = NULL,
14491450
.stream_get_current_device = NULL,
14501451
.stream_device_destroy = NULL,
14511452
.stream_register_device_changed_callback = NULL,

media/libcubeb/src/cubeb_audiounit.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,6 @@ audiounit_set_channel_layout(AudioUnit unit,
15131513
return CUBEB_OK;
15141514
}
15151515

1516-
15171516
OSStatus r;
15181517
uint32_t nb_channels = cubeb_channel_layout_nb_channels(layout);
15191518

@@ -2070,7 +2069,6 @@ audiounit_create_unit(AudioUnit * unit, device_info * device)
20702069
return CUBEB_OK;
20712070
}
20722071

2073-
20742072
if (device->flags & DEV_INPUT) {
20752073
r = audiounit_enable_unit_scope(unit, io_side::INPUT, ENABLE);
20762074
if (r != CUBEB_OK) {
@@ -2217,7 +2215,6 @@ buffer_size_changed_callback(void * inClientData,
22172215
}
22182216

22192217
switch (inPropertyID) {
2220-
22212218
case kAudioDevicePropertyBufferFrameSize: {
22222219
if (inScope != au_scope) {
22232220
break;
@@ -2731,7 +2728,6 @@ audiounit_setup_stream(cubeb_stream * stm)
27312728
LOG("(%p) Could not install all device change callback.", stm);
27322729
}
27332730

2734-
27352731
return CUBEB_OK;
27362732
}
27372733

@@ -3212,7 +3208,6 @@ audiounit_get_available_samplerate(AudioObjectID devid, AudioObjectPropertyScope
32123208
} else {
32133209
*min = *max = 0;
32143210
}
3215-
32163211
}
32173212

32183213
static UInt32
@@ -3623,6 +3618,7 @@ cubeb_ops const audiounit_ops = {
36233618
/*.stream_get_latency =*/ audiounit_stream_get_latency,
36243619
/*.stream_get_input_latency =*/ NULL,
36253620
/*.stream_set_volume =*/ audiounit_stream_set_volume,
3621+
/*.stream_set_name =*/ NULL,
36263622
/*.stream_get_current_device =*/ audiounit_stream_get_current_device,
36273623
/*.stream_device_destroy =*/ audiounit_stream_device_destroy,
36283624
/*.stream_register_device_changed_callback =*/ audiounit_stream_register_device_changed_callback,

media/libcubeb/src/cubeb_jack.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ static struct cubeb_ops const cbjack_ops = {
134134
.stream_get_latency = cbjack_get_latency,
135135
.stream_get_input_latency = NULL,
136136
.stream_set_volume = cbjack_stream_set_volume,
137+
.stream_set_name = NULL,
137138
.stream_get_current_device = cbjack_stream_get_current_device,
138139
.stream_device_destroy = cbjack_stream_device_destroy,
139140
.stream_register_device_changed_callback = NULL,
@@ -238,6 +239,22 @@ load_jack_lib(cubeb * context)
238239
return CUBEB_OK;
239240
}
240241

242+
static void
243+
cbjack_connect_port_out (cubeb_stream * stream, const size_t out_port, const char * const phys_in_port)
244+
{
245+
const char *src_port = api_jack_port_name (stream->output_ports[out_port]);
246+
247+
api_jack_connect (stream->context->jack_client, src_port, phys_in_port);
248+
}
249+
250+
static void
251+
cbjack_connect_port_in (cubeb_stream * stream, const char * const phys_out_port, size_t in_port)
252+
{
253+
const char *src_port = api_jack_port_name (stream->input_ports[in_port]);
254+
255+
api_jack_connect (stream->context->jack_client, phys_out_port, src_port);
256+
}
257+
241258
static int
242259
cbjack_connect_ports (cubeb_stream * stream)
243260
{
@@ -257,10 +274,14 @@ cbjack_connect_ports (cubeb_stream * stream)
257274

258275
// Connect outputs to playback
259276
for (unsigned int c = 0; c < stream->out_params.channels && phys_in_ports[c] != NULL; c++) {
260-
const char *src_port = api_jack_port_name (stream->output_ports[c]);
277+
cbjack_connect_port_out(stream, c, phys_in_ports[c]);
278+
}
261279

262-
api_jack_connect (stream->context->jack_client, src_port, phys_in_ports[c]);
280+
// Special case playing mono source in stereo
281+
if (stream->out_params.channels == 1 && phys_in_ports[1] != NULL) {
282+
cbjack_connect_port_out(stream, 0, phys_in_ports[1]);
263283
}
284+
264285
r = CUBEB_OK;
265286

266287
skipplayback:
@@ -269,9 +290,7 @@ cbjack_connect_ports (cubeb_stream * stream)
269290
}
270291
// Connect inputs to capture
271292
for (unsigned int c = 0; c < stream->in_params.channels && phys_out_ports[c] != NULL; c++) {
272-
const char *src_port = api_jack_port_name (stream->input_ports[c]);
273-
274-
api_jack_connect (stream->context->jack_client, phys_out_ports[c], src_port);
293+
cbjack_connect_port_in(stream, phys_out_ports[c], c);
275294
}
276295
r = CUBEB_OK;
277296
end:
@@ -381,7 +400,6 @@ cbjack_process(jack_nframes_t nframes, void * arg)
381400
}
382401
}
383402
} else {
384-
385403
// try to lock stream mutex
386404
if (pthread_mutex_trylock(&stm->mutex) == 0) {
387405

media/libcubeb/src/cubeb_opensl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,6 @@ opensl_configure_capture(cubeb_stream * stm, cubeb_stream_params * params)
943943
}
944944
}
945945

946-
947946
if (get_android_version() > ANDROID_VERSION_JELLY_BEAN) {
948947
SLAndroidConfigurationItf recorderConfig;
949948
res = (*stm->recorderObj)
@@ -1756,6 +1755,7 @@ static struct cubeb_ops const opensl_ops = {
17561755
.stream_get_latency = opensl_stream_get_latency,
17571756
.stream_get_input_latency = NULL,
17581757
.stream_set_volume = opensl_stream_set_volume,
1758+
.stream_set_name = NULL,
17591759
.stream_get_current_device = NULL,
17601760
.stream_device_destroy = NULL,
17611761
.stream_register_device_changed_callback = NULL,

0 commit comments

Comments
 (0)