Skip to content

Commit

Permalink
Bug 1874909 - Update all cubeb libraries to include input processing.…
Browse files Browse the repository at this point in the history
… r=cubeb-reviewers,supply-chain-reviewers,padenot

This patch updates
media/libcubeb to dd8a91f98260d2c6171a7cf8a73f8fd4bdbb5337 which includes an ABI change, thus also
cubeb-rs to 0.12.0
audioipc to 8b391135f9421dc5ab0c45f646c21651a906ce7f
cubeb-coreaudio-rs to a0534f6e910213fd4f7387a9ed03c980ff20da1d
cubeb-pulse-rs to 8ff972c8e2ec1782ff262ac4071c0415e69b1367

Depends on D198762

Differential Revision: https://phabricator.services.mozilla.com/D198933
  • Loading branch information
Pehrsons committed Jan 24, 2024
1 parent 0b17172 commit 91e4965
Show file tree
Hide file tree
Showing 71 changed files with 688 additions and 122 deletions.
12 changes: 6 additions & 6 deletions .cargo/config.in
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ git = "https://github.com/mozilla/application-services"
rev = "63a6260c14847c21c5a1fa3003efaf0114a3e4e5"
replace-with = "vendored-sources"

[source."git+https://github.com/mozilla/audioipc?rev=44fbcd2b5417f8b5ff4907eec17b32a0fb633e03"]
[source."git+https://github.com/mozilla/audioipc?rev=8b391135f9421dc5ab0c45f646c21651a906ce7f"]
git = "https://github.com/mozilla/audioipc"
rev = "44fbcd2b5417f8b5ff4907eec17b32a0fb633e03"
rev = "8b391135f9421dc5ab0c45f646c21651a906ce7f"
replace-with = "vendored-sources"

[source."git+https://github.com/mozilla/cubeb-coreaudio-rs?rev=89abc256a2eab3398f880e114b2d8308f5bc1d1a"]
[source."git+https://github.com/mozilla/cubeb-coreaudio-rs?rev=a0534f6e910213fd4f7387a9ed03c980ff20da1d"]
git = "https://github.com/mozilla/cubeb-coreaudio-rs"
rev = "89abc256a2eab3398f880e114b2d8308f5bc1d1a"
rev = "a0534f6e910213fd4f7387a9ed03c980ff20da1d"
replace-with = "vendored-sources"

[source."git+https://github.com/mozilla/cubeb-pulse-rs?rev=c04c4d2c7f2291cb81a1c48f5a8c425748f18cd8"]
[source."git+https://github.com/mozilla/cubeb-pulse-rs?rev=8ff972c8e2ec1782ff262ac4071c0415e69b1367"]
git = "https://github.com/mozilla/cubeb-pulse-rs"
rev = "c04c4d2c7f2291cb81a1c48f5a8c425748f18cd8"
rev = "8ff972c8e2ec1782ff262ac4071c0415e69b1367"
replace-with = "vendored-sources"

[source."git+https://github.com/mozilla/midir.git?rev=85156e360a37d851734118104619f86bd18e94c6"]
Expand Down
40 changes: 20 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions media/libcubeb/include/cubeb/cubeb.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,18 @@ typedef enum {
the jack backend. */
} cubeb_stream_prefs;

/**
* Input stream audio processing parameters. Only applicable with
* CUBEB_STREAM_PREF_VOICE.
*/
typedef enum {
CUBEB_INPUT_PROCESSING_PARAM_NONE = 0x00,
CUBEB_INPUT_PROCESSING_PARAM_ECHO_CANCELLATION = 0x01,
CUBEB_INPUT_PROCESSING_PARAM_NOISE_SUPPRESSION = 0x02,
CUBEB_INPUT_PROCESSING_PARAM_AUTOMATIC_GAIN_CONTROL = 0x04,
CUBEB_INPUT_PROCESSING_PARAM_VOICE_ISOLATION = 0x08,
} cubeb_input_processing_params;

/** Stream format initialization parameters. */
typedef struct {
cubeb_sample_format format; /**< Requested sample format. One of
Expand Down Expand Up @@ -514,6 +526,18 @@ cubeb_get_min_latency(cubeb * context, cubeb_stream_params * params,
CUBEB_EXPORT int
cubeb_get_preferred_sample_rate(cubeb * context, uint32_t * rate);

/** Get the supported input processing features for this backend. See
cubeb_stream_set_input_processing for how to set them for a particular input
stream.
@param context A pointer to the cubeb context.
@param params Out parameter for the input processing params supported by
this backend.
@retval CUBEB_OK
@retval CUBEB_ERROR_NOT_SUPPORTED */
CUBEB_EXPORT int
cubeb_get_supported_input_processing_params(
cubeb * context, cubeb_input_processing_params * params);

/** Destroy an application context. This must be called after all stream have
* been destroyed.
@param context A pointer to the cubeb context.*/
Expand Down Expand Up @@ -641,6 +665,30 @@ CUBEB_EXPORT int
cubeb_stream_get_current_device(cubeb_stream * stm,
cubeb_device ** const device);

/** Set input mute state for this stream. Some platforms notify the user when an
application is accessing audio input. When all inputs are muted they can
prove to the user that the application is not actively capturing any input.
@param stream the stream for which to set input mute state
@param muted whether the input should mute or not
@retval CUBEB_OK
@retval CUBEB_ERROR_INVALID_PARAMETER if this stream does not have an input
device
@retval CUBEB_ERROR_NOT_SUPPORTED */
CUBEB_EXPORT int
cubeb_stream_set_input_mute(cubeb_stream * stream, int mute);

/** Set what input processing features to enable for this stream.
@param stream the stream for which to set input processing features.
@param params what input processing features to use
@retval CUBEB_OK
@retval CUBEB_ERROR if params could not be applied
@retval CUBEB_ERROR_INVALID_PARAMETER if a given param is not supported by
this backend, or if this stream does not have an input device
@retval CUBEB_ERROR_NOT_SUPPORTED */
CUBEB_EXPORT int
cubeb_stream_set_input_processing_params(cubeb_stream * stream,
cubeb_input_processing_params params);

/** Destroy a cubeb_device structure.
@param stream the stream passed in cubeb_stream_get_current_device
@param devices the devices to destroy
Expand Down
4 changes: 2 additions & 2 deletions media/libcubeb/moz.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ origin:
description: "Cross platform audio library"
url: https://github.com/mozilla/cubeb
license: ISC
release: 54217bca3f3e0cd53c073690a23dd25d83557909 (2023-11-21T10:08:34Z).
revision: 54217bca3f3e0cd53c073690a23dd25d83557909
release: dd8a91f98260d2c6171a7cf8a73f8fd4bdbb5337 (2024-01-15T14:25:40Z).
revision: dd8a91f98260d2c6171a7cf8a73f8fd4bdbb5337

vendoring:
url: https://github.com/mozilla/cubeb
Expand Down
5 changes: 5 additions & 0 deletions media/libcubeb/src/cubeb-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ struct cubeb_ops {
int (*get_min_latency)(cubeb * context, cubeb_stream_params params,
uint32_t * latency_ms);
int (*get_preferred_sample_rate)(cubeb * context, uint32_t * rate);
int (*get_supported_input_processing_params)(
cubeb * context, cubeb_input_processing_params * params);
int (*enumerate_devices)(cubeb * context, cubeb_device_type type,
cubeb_device_collection * collection);
int (*device_collection_destroy)(cubeb * context,
Expand All @@ -62,6 +64,9 @@ struct cubeb_ops {
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_set_input_mute)(cubeb_stream * stream, int mute);
int (*stream_set_input_processing_params)(
cubeb_stream * stream, cubeb_input_processing_params params);
int (*stream_device_destroy)(cubeb_stream * stream, cubeb_device * device);
int (*stream_register_device_changed_callback)(
cubeb_stream * stream,
Expand Down
45 changes: 45 additions & 0 deletions media/libcubeb/src/cubeb.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,21 @@ cubeb_get_preferred_sample_rate(cubeb * context, uint32_t * rate)
return context->ops->get_preferred_sample_rate(context, rate);
}

int
cubeb_get_supported_input_processing_params(
cubeb * context, cubeb_input_processing_params * params)
{
if (!context || !params) {
return CUBEB_ERROR_INVALID_PARAMETER;
}

if (!context->ops->get_supported_input_processing_params) {
return CUBEB_ERROR_NOT_SUPPORTED;
}

return context->ops->get_supported_input_processing_params(context, params);
}

void
cubeb_destroy(cubeb * context)
{
Expand Down Expand Up @@ -500,6 +515,36 @@ cubeb_stream_get_current_device(cubeb_stream * stream,
return stream->context->ops->stream_get_current_device(stream, device);
}

int
cubeb_stream_set_input_mute(cubeb_stream * stream, int mute)
{
if (!stream) {
return CUBEB_ERROR_INVALID_PARAMETER;
}

if (!stream->context->ops->stream_set_input_mute) {
return CUBEB_ERROR_NOT_SUPPORTED;
}

return stream->context->ops->stream_set_input_mute(stream, mute);
}

int
cubeb_stream_set_input_processing_params(cubeb_stream * stream,
cubeb_input_processing_params params)
{
if (!stream || !params) {
return CUBEB_ERROR_INVALID_PARAMETER;
}

if (!stream->context->ops->stream_set_input_processing_params) {
return CUBEB_ERROR_NOT_SUPPORTED;
}

return stream->context->ops->stream_set_input_processing_params(stream,
params);
}

int
cubeb_stream_device_destroy(cubeb_stream * stream, cubeb_device * device)
{
Expand Down
3 changes: 3 additions & 0 deletions media/libcubeb/src/cubeb_aaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,7 @@ const static struct cubeb_ops aaudio_ops = {
/*.get_max_channel_count =*/aaudio_get_max_channel_count,
/* .get_min_latency =*/aaudio_get_min_latency,
/*.get_preferred_sample_rate =*/aaudio_get_preferred_sample_rate,
/*.get_supported_input_processing_params =*/nullptr,
/*.enumerate_devices =*/nullptr,
/*.device_collection_destroy =*/nullptr,
/*.destroy =*/aaudio_destroy,
Expand All @@ -1750,6 +1751,8 @@ const static struct cubeb_ops aaudio_ops = {
/*.stream_set_volume =*/aaudio_stream_set_volume,
/*.stream_set_name =*/nullptr,
/*.stream_get_current_device =*/nullptr,
/*.stream_set_input_mute =*/nullptr,
/*.stream_set_input_processing_params =*/nullptr,
/*.stream_device_destroy =*/nullptr,
/*.stream_register_device_changed_callback =*/nullptr,
/*.register_device_collection_changed =*/nullptr};
Expand Down
3 changes: 3 additions & 0 deletions media/libcubeb/src/cubeb_alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,7 @@ static struct cubeb_ops const alsa_ops = {
.get_max_channel_count = alsa_get_max_channel_count,
.get_min_latency = alsa_get_min_latency,
.get_preferred_sample_rate = alsa_get_preferred_sample_rate,
.get_supported_input_processing_params = NULL,
.enumerate_devices = alsa_enumerate_devices,
.device_collection_destroy = alsa_device_collection_destroy,
.destroy = alsa_destroy,
Expand All @@ -1485,6 +1486,8 @@ static struct cubeb_ops const alsa_ops = {
.stream_set_volume = alsa_stream_set_volume,
.stream_set_name = NULL,
.stream_get_current_device = NULL,
.stream_set_input_mute = NULL,
.stream_set_input_processing_params = NULL,
.stream_device_destroy = NULL,
.stream_register_device_changed_callback = NULL,
.register_device_collection_changed = NULL};
3 changes: 3 additions & 0 deletions media/libcubeb/src/cubeb_audiounit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3665,6 +3665,7 @@ cubeb_ops const audiounit_ops = {
/*.get_max_channel_count =*/audiounit_get_max_channel_count,
/*.get_min_latency =*/audiounit_get_min_latency,
/*.get_preferred_sample_rate =*/audiounit_get_preferred_sample_rate,
/*.get_supported_input_processing_params =*/NULL,
/*.enumerate_devices =*/audiounit_enumerate_devices,
/*.device_collection_destroy =*/audiounit_device_collection_destroy,
/*.destroy =*/audiounit_destroy,
Expand All @@ -3678,6 +3679,8 @@ cubeb_ops const audiounit_ops = {
/*.stream_set_volume =*/audiounit_stream_set_volume,
/*.stream_set_name =*/NULL,
/*.stream_get_current_device =*/audiounit_stream_get_current_device,
/*.stream_set_input_mute =*/NULL,
/*.stream_set_input_processing_params =*/NULL,
/*.stream_device_destroy =*/audiounit_stream_device_destroy,
/*.stream_register_device_changed_callback =*/
audiounit_stream_register_device_changed_callback,
Expand Down
Loading

0 comments on commit 91e4965

Please sign in to comment.