Commit cbf9ed0a authored by Thomas Guillem's avatar Thomas Guillem

opensles: remove external aout_get_native_sample_rate

Implement it directly in this module.
This avoid a dependency towards android libvlcjni.
parent 61e7080d
......@@ -41,7 +41,8 @@
#include <SLES/OpenSLES.h>
#include <SLES/OpenSLES_Android.h>
int aout_get_native_sample_rate(void);
#include <jni.h>
JNIEnv *android_getEnv(vlc_object_t *p_obj, const char *psz_thread_name);
#define OPENSLES_BUFFERS 255 /* maximum number of buffers */
#define OPENSLES_BUFLEN 10 /* ms */
......@@ -351,6 +352,28 @@ static void PlayedCallback (SLAndroidSimpleBufferQueueItf caller, void *pContext
sys->started = true;
vlc_mutex_unlock(&sys->lock);
}
static int aout_get_native_sample_rate(audio_output_t *aout)
{
JNIEnv *p_env;
if (!(p_env = android_getEnv(VLC_OBJECT(aout), "opensles")))
return -1;
jclass cls = (*p_env)->FindClass (p_env, "android/media/AudioTrack");
if ((*p_env)->ExceptionCheck(p_env))
{
(*p_env)->ExceptionClear(p_env);
return -1;
}
jmethodID method = (*p_env)->GetStaticMethodID(p_env, cls,
"getNativeOutputSampleRate",
"(I)I");
/* 3 for AudioManager.STREAM_MUSIC */
int sample_rate = (*p_env)->CallStaticIntMethod(p_env, cls, method, 3);
(*p_env)->DeleteLocalRef(p_env, cls);
fprintf(stderr, "aout_get_native_sample_rate: %d\n", sample_rate);
return sample_rate;
}
/*****************************************************************************
*
*****************************************************************************/
......@@ -388,7 +411,7 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
const SLInterfaceID ids2[] = { sys->SL_IID_ANDROIDSIMPLEBUFFERQUEUE, sys->SL_IID_VOLUME };
static const SLboolean req2[] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE };
if (aout_get_native_sample_rate() >= fmt->i_rate) {
if (aout_get_native_sample_rate(aout) >= fmt->i_rate) {
result = CreateAudioPlayer(sys->engineEngine, &sys->playerObject, &audioSrc,
&audioSnk, sizeof(ids2) / sizeof(*ids2),
ids2, req2);
......
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