Commit 0e672cd7 authored by Sylvain Berfini's avatar Sylvain Berfini 🐮
Browse files

Use preferred device buffer size

parent 721fc695
......@@ -35,6 +35,7 @@ static const int flowControlIntervalMs = 5000;
static const int flowControlThresholdMs = 40;
static int DeviceFavoriteSampleRate = 44100;
static int DeviceFavoriteOutputBufferSize = 256;
static MSSndCard *android_snd_card_new(MSSndCardManager *m);
static MSFilter *ms_android_snd_read_new(MSFactory *factory);
......@@ -43,11 +44,13 @@ static MSFilter *ms_android_snd_write_new(MSFactory* factory);
struct AAudioContext {
AAudioContext() {
samplerate = DeviceFavoriteSampleRate;
optimal_output_buffer_size = DeviceFavoriteOutputBufferSize;
nchannels = 1;
builtin_aec = false;
}
int samplerate;
int optimal_output_buffer_size;
int nchannels;
bool builtin_aec;
};
......@@ -549,6 +552,7 @@ static void aaudio_player_init(AAudioOutputContext *octx) {
AAudioStreamBuilder_setErrorCallback(builder, aaudio_player_callback_error, octx);
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_setBufferCapacityInFrames(builder, octx->aaudio_context->optimal_output_buffer_size);
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));
......@@ -726,6 +730,14 @@ MS_PLUGIN_DECLARE(void) libmsaaudio_init(MSFactory* factory) {
DeviceFavoriteSampleRate = (int)ret;
ms_message("[AAudio] Using %i for sample rate value", DeviceFavoriteSampleRate);
}
jmethodID getBufferSize = env->GetStaticMethodID(mediastreamerAndroidContextClass, "getDeviceFavoriteBufferSize", "()I");
if (getBufferSize != NULL) {
jint ret = env->CallStaticIntMethod(mediastreamerAndroidContextClass, getBufferSize);
DeviceFavoriteOutputBufferSize = (int)ret;
ms_message("[AAudio] Using %i for buffer size value", DeviceFavoriteOutputBufferSize);
}
env->DeleteLocalRef(mediastreamerAndroidContextClass);
}
......
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