Commit fd923e8e authored by Andrea Gianarda's avatar Andrea Gianarda
Browse files

Set InputPreset to AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION during calls...

Set InputPreset to AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION during calls otherwise  AAUDIO_INPUT_PRESET_GENERIC

This significantly improves audio quality during calls and has no side effect when ringing
parent 9cfbe80a
...@@ -40,6 +40,7 @@ struct AAudioOutputContext { ...@@ -40,6 +40,7 @@ struct AAudioOutputContext {
soundCard = NULL; soundCard = NULL;
usage = AAUDIO_USAGE_VOICE_COMMUNICATION; usage = AAUDIO_USAGE_VOICE_COMMUNICATION;
content_type = AAUDIO_CONTENT_TYPE_SPEECH; content_type = AAUDIO_CONTENT_TYPE_SPEECH;
input_preset = AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION;
} }
~AAudioOutputContext() { ~AAudioOutputContext() {
...@@ -62,21 +63,25 @@ struct AAudioOutputContext { ...@@ -62,21 +63,25 @@ struct AAudioOutputContext {
case MS_SND_CARD_STREAM_RING: case MS_SND_CARD_STREAM_RING:
usage = AAUDIO_USAGE_NOTIFICATION_RINGTONE; usage = AAUDIO_USAGE_NOTIFICATION_RINGTONE;
content_type = AAUDIO_CONTENT_TYPE_SONIFICATION; content_type = AAUDIO_CONTENT_TYPE_SONIFICATION;
input_preset = AAUDIO_INPUT_PRESET_GENERIC;
ms_message("[AAudio] Using RING mode"); ms_message("[AAudio] Using RING mode");
break; break;
case MS_SND_CARD_STREAM_MEDIA: case MS_SND_CARD_STREAM_MEDIA:
usage = AAUDIO_USAGE_MEDIA; usage = AAUDIO_USAGE_MEDIA;
content_type = AAUDIO_CONTENT_TYPE_MUSIC; content_type = AAUDIO_CONTENT_TYPE_MUSIC;
input_preset = AAUDIO_INPUT_PRESET_GENERIC;
ms_message("[AAudio] Using MEDIA mode"); ms_message("[AAudio] Using MEDIA mode");
break; break;
case MS_SND_CARD_STREAM_DTMF: case MS_SND_CARD_STREAM_DTMF:
usage = AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING; usage = AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING;
content_type = AAUDIO_CONTENT_TYPE_SONIFICATION ; content_type = AAUDIO_CONTENT_TYPE_SONIFICATION ;
input_preset = AAUDIO_INPUT_PRESET_GENERIC;
ms_message("[AAudio] Using DTMF mode"); ms_message("[AAudio] Using DTMF mode");
break; break;
case MS_SND_CARD_STREAM_VOICE: case MS_SND_CARD_STREAM_VOICE:
usage = AAUDIO_USAGE_VOICE_COMMUNICATION; usage = AAUDIO_USAGE_VOICE_COMMUNICATION;
content_type = AAUDIO_CONTENT_TYPE_SPEECH; content_type = AAUDIO_CONTENT_TYPE_SPEECH;
input_preset = AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION;
ms_message("[AAudio] Using COMMUNICATION mode"); ms_message("[AAudio] Using COMMUNICATION mode");
break; break;
default: default:
...@@ -96,6 +101,7 @@ struct AAudioOutputContext { ...@@ -96,6 +101,7 @@ struct AAudioOutputContext {
ms_mutex_t mutex; ms_mutex_t mutex;
aaudio_usage_t usage; aaudio_usage_t usage;
aaudio_content_type_t content_type; aaudio_content_type_t content_type;
aaudio_input_preset_t input_preset;
int32_t deviceId; int32_t deviceId;
}; };
...@@ -180,6 +186,8 @@ static void aaudio_player_init(AAudioOutputContext *octx) { ...@@ -180,6 +186,8 @@ static void aaudio_player_init(AAudioOutputContext *octx) {
AAudioStreamBuilder_setErrorCallback(builder, aaudio_player_callback_error, octx); AAudioStreamBuilder_setErrorCallback(builder, aaudio_player_callback_error, octx);
AAudioStreamBuilder_setUsage(builder, octx->usage); // Requires NDK build target of 28 instead of 26 ! AAudioStreamBuilder_setUsage(builder, octx->usage); // Requires NDK build target of 28 instead of 26 !
AAudioStreamBuilder_setContentType(builder, octx->content_type); // Requires NDK build target of 28 instead of 26 ! AAudioStreamBuilder_setContentType(builder, octx->content_type); // Requires NDK build target of 28 instead of 26 !
AAudioStreamBuilder_setInputPreset(builder, octx->input_preset); // Requires NDK build target of 28 instead of 26 !
ms_message("[AAudio] Player stream configured with samplerate %i and %i channels", octx->aaudio_context->samplerate, octx->aaudio_context->nchannels); ms_message("[AAudio] Player stream configured with samplerate %i and %i channels", octx->aaudio_context->samplerate, octx->aaudio_context->nchannels);
result = AAudioStreamBuilder_openStream(builder, &(octx->stream)); result = AAudioStreamBuilder_openStream(builder, &(octx->stream));
......
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