зеркало из https://github.com/mozilla/cubeb.git
Add APIs for input processing
This commit is contained in:
Родитель
ffec8ede4c
Коммит
5a2df9b0aa
|
@ -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
|
||||
|
@ -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.*/
|
||||
|
@ -641,6 +665,18 @@ CUBEB_EXPORT int
|
|||
cubeb_stream_get_current_device(cubeb_stream * stm,
|
||||
cubeb_device ** const device);
|
||||
|
||||
/** 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
|
||||
|
|
|
@ -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,
|
||||
|
@ -62,6 +64,8 @@ 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_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,
|
||||
|
|
31
src/cubeb.c
31
src/cubeb.c
|
@ -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)
|
||||
{
|
||||
|
@ -500,6 +515,22 @@ cubeb_stream_get_current_device(cubeb_stream * stream,
|
|||
return stream->context->ops->stream_get_current_device(stream, device);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -1736,6 +1736,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,
|
||||
|
@ -1749,6 +1750,7 @@ 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_processing_params =*/nullptr,
|
||||
/*.stream_device_destroy =*/nullptr,
|
||||
/*.stream_register_device_changed_callback =*/nullptr,
|
||||
/*.register_device_collection_changed =*/nullptr};
|
||||
|
|
|
@ -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,
|
||||
|
@ -1485,6 +1486,7 @@ 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_processing_params = NULL,
|
||||
.stream_device_destroy = NULL,
|
||||
.stream_register_device_changed_callback = NULL,
|
||||
.register_device_collection_changed = NULL};
|
||||
|
|
|
@ -454,6 +454,7 @@ static struct cubeb_ops const audiotrack_ops = {
|
|||
.get_max_channel_count = audiotrack_get_max_channel_count,
|
||||
.get_min_latency = audiotrack_get_min_latency,
|
||||
.get_preferred_sample_rate = audiotrack_get_preferred_sample_rate,
|
||||
.get_supported_input_processing_params = NULL,
|
||||
.enumerate_devices = NULL,
|
||||
.device_collection_destroy = NULL,
|
||||
.destroy = audiotrack_destroy,
|
||||
|
@ -467,6 +468,7 @@ static struct cubeb_ops const audiotrack_ops = {
|
|||
.stream_set_volume = audiotrack_stream_set_volume,
|
||||
.stream_set_name = NULL,
|
||||
.stream_get_current_device = NULL,
|
||||
.stream_set_input_processing_params = NULL,
|
||||
.stream_device_destroy = NULL,
|
||||
.stream_register_device_changed_callback = NULL,
|
||||
.register_device_collection_changed = NULL};
|
||||
|
|
|
@ -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,
|
||||
|
@ -3678,6 +3679,7 @@ 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_processing_params =*/NULL,
|
||||
/*.stream_device_destroy =*/audiounit_stream_device_destroy,
|
||||
/*.stream_register_device_changed_callback =*/
|
||||
audiounit_stream_register_device_changed_callback,
|
||||
|
|
|
@ -160,6 +160,7 @@ static struct cubeb_ops const cbjack_ops = {
|
|||
.get_max_channel_count = cbjack_get_max_channel_count,
|
||||
.get_min_latency = cbjack_get_min_latency,
|
||||
.get_preferred_sample_rate = cbjack_get_preferred_sample_rate,
|
||||
.get_supported_input_processing_params = NULL,
|
||||
.enumerate_devices = cbjack_enumerate_devices,
|
||||
.device_collection_destroy = cbjack_device_collection_destroy,
|
||||
.destroy = cbjack_destroy,
|
||||
|
@ -173,6 +174,7 @@ static struct cubeb_ops const cbjack_ops = {
|
|||
.stream_set_volume = cbjack_stream_set_volume,
|
||||
.stream_set_name = NULL,
|
||||
.stream_get_current_device = cbjack_stream_get_current_device,
|
||||
.stream_set_input_processing_params = NULL,
|
||||
.stream_device_destroy = cbjack_stream_device_destroy,
|
||||
.stream_register_device_changed_callback = NULL,
|
||||
.register_device_collection_changed = NULL};
|
||||
|
|
|
@ -351,6 +351,7 @@ static struct cubeb_ops const kai_ops = {
|
|||
/*.get_min_latency=*/kai_get_min_latency,
|
||||
/*.get_preferred_sample_rate =*/kai_get_preferred_sample_rate,
|
||||
/*.get_preferred_channel_layout =*/NULL,
|
||||
/*.get_supported_input_processing_params =*/NULL,
|
||||
/*.enumerate_devices =*/NULL,
|
||||
/*.device_collection_destroy =*/NULL,
|
||||
/*.destroy =*/kai_destroy,
|
||||
|
@ -364,6 +365,7 @@ static struct cubeb_ops const kai_ops = {
|
|||
/*.stream_set_volume =*/kai_stream_set_volume,
|
||||
/*.stream_set_name =*/NULL,
|
||||
/*.stream_get_current_device =*/NULL,
|
||||
/*.stream_set_input_processing_params =*/NULL,
|
||||
/*.stream_device_destroy =*/NULL,
|
||||
/*.stream_register_device_changed_callback=*/NULL,
|
||||
/*.register_device_collection_changed=*/NULL};
|
||||
|
|
|
@ -1934,6 +1934,7 @@ struct cubeb_ops const opensl_ops = {
|
|||
.get_max_channel_count = opensl_get_max_channel_count,
|
||||
.get_min_latency = nullptr,
|
||||
.get_preferred_sample_rate = nullptr,
|
||||
.get_supported_input_processing_params = nullptr,
|
||||
.enumerate_devices = nullptr,
|
||||
.device_collection_destroy = nullptr,
|
||||
.destroy = opensl_destroy,
|
||||
|
@ -1947,6 +1948,7 @@ struct cubeb_ops const opensl_ops = {
|
|||
.stream_set_volume = opensl_stream_set_volume,
|
||||
.stream_set_name = nullptr,
|
||||
.stream_get_current_device = nullptr,
|
||||
.stream_set_input_processing_params = nullptr,
|
||||
.stream_device_destroy = nullptr,
|
||||
.stream_register_device_changed_callback = nullptr,
|
||||
.register_device_collection_changed = nullptr};
|
||||
|
|
|
@ -1335,6 +1335,7 @@ static struct cubeb_ops const oss_ops = {
|
|||
.get_max_channel_count = oss_get_max_channel_count,
|
||||
.get_min_latency = oss_get_min_latency,
|
||||
.get_preferred_sample_rate = oss_get_preferred_sample_rate,
|
||||
.get_supported_input_processing_params = NULL,
|
||||
.enumerate_devices = oss_enumerate_devices,
|
||||
.device_collection_destroy = oss_device_collection_destroy,
|
||||
.destroy = oss_destroy,
|
||||
|
@ -1348,6 +1349,7 @@ static struct cubeb_ops const oss_ops = {
|
|||
.stream_set_volume = oss_stream_set_volume,
|
||||
.stream_set_name = NULL,
|
||||
.stream_get_current_device = oss_get_current_device,
|
||||
.stream_set_input_processing_params = NULL,
|
||||
.stream_device_destroy = oss_stream_device_destroy,
|
||||
.stream_register_device_changed_callback = NULL,
|
||||
.register_device_collection_changed = NULL};
|
||||
|
|
|
@ -1690,6 +1690,7 @@ static struct cubeb_ops const pulse_ops = {
|
|||
.get_max_channel_count = pulse_get_max_channel_count,
|
||||
.get_min_latency = pulse_get_min_latency,
|
||||
.get_preferred_sample_rate = pulse_get_preferred_sample_rate,
|
||||
.get_supported_input_processing_params = NULL,
|
||||
.enumerate_devices = pulse_enumerate_devices,
|
||||
.device_collection_destroy = pulse_device_collection_destroy,
|
||||
.destroy = pulse_destroy,
|
||||
|
@ -1703,6 +1704,7 @@ static struct cubeb_ops const pulse_ops = {
|
|||
.stream_set_volume = pulse_stream_set_volume,
|
||||
.stream_set_name = pulse_stream_set_name,
|
||||
.stream_get_current_device = pulse_stream_get_current_device,
|
||||
.stream_set_input_processing_params = NULL,
|
||||
.stream_device_destroy = pulse_stream_device_destroy,
|
||||
.stream_register_device_changed_callback = NULL,
|
||||
.register_device_collection_changed =
|
||||
|
|
|
@ -667,6 +667,7 @@ static struct cubeb_ops const sndio_ops = {
|
|||
.get_max_channel_count = sndio_get_max_channel_count,
|
||||
.get_min_latency = sndio_get_min_latency,
|
||||
.get_preferred_sample_rate = sndio_get_preferred_sample_rate,
|
||||
.get_supported_input_processing_params = NULL,
|
||||
.enumerate_devices = sndio_enumerate_devices,
|
||||
.device_collection_destroy = sndio_device_collection_destroy,
|
||||
.destroy = sndio_destroy,
|
||||
|
@ -679,6 +680,7 @@ static struct cubeb_ops const sndio_ops = {
|
|||
.stream_set_volume = sndio_stream_set_volume,
|
||||
.stream_set_name = NULL,
|
||||
.stream_get_current_device = NULL,
|
||||
.stream_set_input_processing_params = NULL,
|
||||
.stream_device_destroy = NULL,
|
||||
.stream_register_device_changed_callback = NULL,
|
||||
.register_device_collection_changed = NULL};
|
||||
|
|
|
@ -719,6 +719,7 @@ static struct cubeb_ops const sun_ops = {
|
|||
.get_max_channel_count = sun_get_max_channel_count,
|
||||
.get_min_latency = sun_get_min_latency,
|
||||
.get_preferred_sample_rate = sun_get_preferred_sample_rate,
|
||||
.get_supported_input_processing_params = NULL,
|
||||
.enumerate_devices = sun_enumerate_devices,
|
||||
.device_collection_destroy = sun_device_collection_destroy,
|
||||
.destroy = sun_destroy,
|
||||
|
@ -732,6 +733,7 @@ static struct cubeb_ops const sun_ops = {
|
|||
.stream_set_volume = sun_stream_set_volume,
|
||||
.stream_set_name = NULL,
|
||||
.stream_get_current_device = sun_get_current_device,
|
||||
.stream_set_input_processing_params = NULL,
|
||||
.stream_device_destroy = sun_stream_device_destroy,
|
||||
.stream_register_device_changed_callback = NULL,
|
||||
.register_device_collection_changed = NULL};
|
||||
|
|
|
@ -3561,6 +3561,7 @@ cubeb_ops const wasapi_ops = {
|
|||
/*.get_max_channel_count =*/wasapi_get_max_channel_count,
|
||||
/*.get_min_latency =*/wasapi_get_min_latency,
|
||||
/*.get_preferred_sample_rate =*/wasapi_get_preferred_sample_rate,
|
||||
/*.get_supported_input_processing_params =*/NULL,
|
||||
/*.enumerate_devices =*/wasapi_enumerate_devices,
|
||||
/*.device_collection_destroy =*/wasapi_device_collection_destroy,
|
||||
/*.destroy =*/wasapi_destroy,
|
||||
|
@ -3574,6 +3575,7 @@ cubeb_ops const wasapi_ops = {
|
|||
/*.stream_set_volume =*/wasapi_stream_set_volume,
|
||||
/*.stream_set_name =*/NULL,
|
||||
/*.stream_get_current_device =*/NULL,
|
||||
/*.stream_set_input_processing_params =*/NULL,
|
||||
/*.stream_device_destroy =*/NULL,
|
||||
/*.stream_register_device_changed_callback =*/NULL,
|
||||
/*.register_device_collection_changed =*/
|
||||
|
|
|
@ -1192,6 +1192,7 @@ static struct cubeb_ops const winmm_ops = {
|
|||
/*.get_max_channel_count=*/winmm_get_max_channel_count,
|
||||
/*.get_min_latency=*/winmm_get_min_latency,
|
||||
/*.get_preferred_sample_rate =*/winmm_get_preferred_sample_rate,
|
||||
/*.get_supported_input_processing_params =*/NULL,
|
||||
/*.enumerate_devices =*/winmm_enumerate_devices,
|
||||
/*.device_collection_destroy =*/winmm_device_collection_destroy,
|
||||
/*.destroy =*/winmm_destroy,
|
||||
|
@ -1205,6 +1206,7 @@ static struct cubeb_ops const winmm_ops = {
|
|||
/*.stream_set_volume =*/winmm_stream_set_volume,
|
||||
/*.stream_set_name =*/NULL,
|
||||
/*.stream_get_current_device =*/NULL,
|
||||
/*.stream_set_input_processing_params =*/NULL,
|
||||
/*.stream_device_destroy =*/NULL,
|
||||
/*.stream_register_device_changed_callback=*/NULL,
|
||||
/*.register_device_collection_changed =*/NULL};
|
||||
|
|
Загрузка…
Ссылка в новой задаче