aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndreas Pehrson <[email protected]>2024-06-13 23:59:41 +0200
committerAndreas Pehrson <[email protected]>2024-06-14 01:32:12 +0200
commit3d5fc7133faf9c629258e98a81e2055ec0ad97cb (patch)
tree9a3e36a32449959a0b917c145d3aaad1c78ee34d
parent05bfc896db1555588a3bdea80b30215eb518ae9f (diff)
downloadcubeb-3d5fc7133faf9c629258e98a81e2055ec0ad97cb.tar.gz
cubeb-3d5fc7133faf9c629258e98a81e2055ec0ad97cb.zip
Implement aaudio_get_supported_input_processing_params
-rw-r--r--src/cubeb_aaudio.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/cubeb_aaudio.cpp b/src/cubeb_aaudio.cpp
index 9e81ed3..a8f596f 100644
--- a/src/cubeb_aaudio.cpp
+++ b/src/cubeb_aaudio.cpp
@@ -5,6 +5,7 @@
* accompanying file LICENSE for details.
*/
#include "cubeb-internal.h"
+#include "cubeb-jni.h"
#include "cubeb/cubeb.h"
#include "cubeb_android.h"
#include "cubeb_log.h"
@@ -175,10 +176,16 @@ struct cubeb_stream {
uint64_t previous_clock{};
};
+struct cubeb_jni_delete {
+ void operator()(cubeb_jni * jni) { cubeb_jni_destroy(jni); }
+};
+
struct cubeb {
struct cubeb_ops const * ops{};
void * libaaudio{};
+ std::unique_ptr<cubeb_jni, cubeb_jni_delete> jni;
+
struct {
// The state thread: it waits for state changes and stops
// drained streams.
@@ -1743,6 +1750,29 @@ aaudio_get_preferred_sample_rate(cubeb * ctx, uint32_t * rate)
return CUBEB_OK;
}
+int
+aaudio_get_supported_input_processing_params(
+ cubeb * ctx, cubeb_input_processing_params * params)
+{
+ int ps = CUBEB_INPUT_PROCESSING_PARAM_NONE;
+
+ if (cubeb_fx_is_available(ctx->jni.get(), CUBEB_FX_ACOUSTIC_ECHO_CANCELER)) {
+ LOG("%s: AEC is supported", __func__);
+ ps |= CUBEB_INPUT_PROCESSING_PARAM_ECHO_CANCELLATION;
+ }
+ if (cubeb_fx_is_available(ctx->jni.get(), CUBEB_FX_AUTOMATIC_GAIN_CONTROL)) {
+ LOG("%s: AGC is supported", __func__);
+ ps |= CUBEB_INPUT_PROCESSING_PARAM_AUTOMATIC_GAIN_CONTROL;
+ }
+ if (cubeb_fx_is_available(ctx->jni.get(), CUBEB_FX_NOISE_SUPPRESSOR)) {
+ LOG("%s: NS is supported", __func__);
+ ps |= CUBEB_INPUT_PROCESSING_PARAM_NOISE_SUPPRESSION;
+ }
+
+ *params = static_cast<cubeb_input_processing_params>(ps);
+ return CUBEB_OK;
+}
+
extern "C" int
aaudio_init(cubeb ** context, char const * context_name);
@@ -1750,9 +1780,10 @@ const static struct cubeb_ops aaudio_ops = {
/*.init =*/aaudio_init,
/*.get_backend_id =*/aaudio_get_backend_id,
/*.get_max_channel_count =*/aaudio_get_max_channel_count,
- /* .get_min_latency =*/aaudio_get_min_latency,
+ /*.get_min_latency =*/aaudio_get_min_latency,
/*.get_preferred_sample_rate =*/aaudio_get_preferred_sample_rate,
- /*.get_supported_input_processing_params =*/nullptr,
+ /*.get_supported_input_processing_params =*/
+ aaudio_get_supported_input_processing_params,
/*.enumerate_devices =*/nullptr,
/*.device_collection_destroy =*/nullptr,
/*.destroy =*/aaudio_destroy,
@@ -1800,6 +1831,7 @@ aaudio_init(cubeb ** context, char const * /* context_name */)
cubeb * ctx = new cubeb;
ctx->ops = &aaudio_ops;
ctx->libaaudio = libaaudio;
+ ctx->jni.reset(cubeb_jni_init());
ctx->state.thread = std::thread(state_thread, ctx);