Commit 1c4f9008 authored by Andrea Gianarda's avatar Andrea Gianarda
Browse files

Do not ref card before prepending it as prepend function already takes a ref

Take into account ms2 mandroid specific method name change
parent 4188c280
......@@ -36,7 +36,7 @@ static void android_snd_card_detect(MSSndCardManager *m) {
JNIEnv *env = ms_get_jni_env();
// Get all devices
jobject devices = get_all_devices(env, "all");
jobject devices = ms_android_get_all_devices(env, "all");
// extract required information from every device
jobjectArray deviceArray = (jobjectArray) devices;
......@@ -77,7 +77,7 @@ MSSndCardDesc android_native_snd_aaudio_card_desc = {
static void android_snd_card_device_create(JNIEnv *env, jobject deviceInfo, MSSndCardManager *m) {
MSSndCardDeviceType type = get_device_type(env, deviceInfo);
MSSndCardDeviceType type = ms_android_get_device_type(env, deviceInfo);
if (
(type == MSSndCardDeviceType::MS_SND_CARD_DEVICE_TYPE_BLUETOOTH) ||
(type == MSSndCardDeviceType::MS_SND_CARD_DEVICE_TYPE_EARPIECE) ||
......@@ -89,15 +89,15 @@ static void android_snd_card_device_create(JNIEnv *env, jobject deviceInfo, MSSn
) {
MSSndCard *card = ms_snd_card_new(&android_native_snd_aaudio_card_desc);
card->name = ms_strdup(get_device_product_name(env, deviceInfo));
card->internal_id = get_device_id(env, deviceInfo);
card->name = ms_strdup(ms_android_get_device_product_name(env, deviceInfo));
card->internal_id = ms_android_get_device_id(env, deviceInfo);
card->device_type = type;
AAudioContext *card_data = (AAudioContext*)card->data;
// Card capabilities
// Assign the value because the default value is MS_SND_CARD_CAP_CAPTURE|MS_SND_CARD_CAP_PLAYBACK
card->capabilities = get_device_capabilities(env, deviceInfo);
card->capabilities = ms_android_get_device_capabilities(env, deviceInfo);
MSDevicesInfo *devices = ms_factory_get_devices_info(m->factory);
SoundDeviceDescription *d = ms_devices_info_get_sound_device_description(devices);
if (d->flags & DEVICE_HAS_BUILTIN_AEC) {
......@@ -116,6 +116,8 @@ static void android_snd_card_device_create(JNIEnv *env, jobject deviceInfo, MSSn
ms_snd_card_manager_prepend_card(m, card);
ms_message("[AAudio] Added card: id %s name %s device ID %0d device_type %s capabilities 0'h%0X ", card->id, card->name, card->internal_id, ms_snd_card_device_type_to_string(card->device_type), card->capabilities);
} else {
free(card);
}
}
......@@ -153,7 +155,7 @@ MS_PLUGIN_DECLARE(void) libmsaaudio_init(MSFactory* factory) {
ms_message("[AAudio] libmsaaudio plugin loaded");
DeviceFavoriteSampleRate = get_preferred_sample_rate();
DeviceFavoriteSampleRate = ms_android_get_preferred_sample_rate();
const bool loadOk = loadLib();
......
......@@ -261,8 +261,8 @@ static void android_snd_write_preprocess(MSFilter *obj) {
aaudio_player_init(octx);
JNIEnv *env = ms_get_jni_env();
set_bt_enable(env, (ms_snd_card_get_device_type(octx->soundCard) == MSSndCardDeviceType::MS_SND_CARD_DEVICE_TYPE_BLUETOOTH));
hack_volume(env);
ms_android_set_bt_enable(env, (ms_snd_card_get_device_type(octx->soundCard) == MSSndCardDeviceType::MS_SND_CARD_DEVICE_TYPE_BLUETOOTH));
ms_android_hack_volume(env);
}
static void android_snd_adjust_buffer_size(AAudioOutputContext *octx) {
......@@ -323,7 +323,7 @@ static void android_snd_write_postprocess(MSFilter *obj) {
aaudio_player_close(octx);
// At the end of a call, postprocess is called therefore here the bluetooth device is disabled
JNIEnv *env = ms_get_jni_env();
set_bt_enable(env, FALSE);
ms_android_set_bt_enable(env, FALSE);
}
static int android_snd_write_set_device_id(MSFilter *obj, void *data) {
......@@ -346,8 +346,8 @@ static int android_snd_write_set_device_id(MSFilter *obj, void *data) {
aaudio_player_init(octx);
JNIEnv *env = ms_get_jni_env();
set_bt_enable(env, (ms_snd_card_get_device_type(octx->soundCard) == MSSndCardDeviceType::MS_SND_CARD_DEVICE_TYPE_BLUETOOTH));
hack_volume(env);
ms_android_set_bt_enable(env, (ms_snd_card_get_device_type(octx->soundCard) == MSSndCardDeviceType::MS_SND_CARD_DEVICE_TYPE_BLUETOOTH));
ms_android_hack_volume(env);
ms_mutex_unlock(&octx->stream_mutex);
}
......
......@@ -205,7 +205,7 @@ static void android_snd_read_preprocess(MSFilter *obj) {
aaudio_recorder_init(ictx);
JNIEnv *env = ms_get_jni_env();
set_bt_enable(env, (ms_snd_card_get_device_type(ictx->soundCard) == MSSndCardDeviceType::MS_SND_CARD_DEVICE_TYPE_BLUETOOTH));
ms_android_set_bt_enable(env, (ms_snd_card_get_device_type(ictx->soundCard) == MSSndCardDeviceType::MS_SND_CARD_DEVICE_TYPE_BLUETOOTH));
}
static void android_snd_read_process(MSFilter *obj) {
......@@ -265,7 +265,7 @@ static void android_snd_read_postprocess(MSFilter *obj) {
ms_message("[AAudio] Hardware echo canceller deleted");
}
set_bt_enable(env, FALSE);
ms_android_set_bt_enable(env, FALSE);
ms_mutex_unlock(&ictx->mutex);
}
......@@ -320,7 +320,7 @@ static int android_snd_read_set_device_id(MSFilter *obj, void *data) {
ictx->aaudio_context->device_changed = true;
JNIEnv *env = ms_get_jni_env();
set_bt_enable(env, (ms_snd_card_get_device_type(ictx->soundCard) == MSSndCardDeviceType::MS_SND_CARD_DEVICE_TYPE_BLUETOOTH));
ms_android_set_bt_enable(env, (ms_snd_card_get_device_type(ictx->soundCard) == MSSndCardDeviceType::MS_SND_CARD_DEVICE_TYPE_BLUETOOTH));
ms_mutex_unlock(&ictx->stream_mutex);
}
return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment