[Android] [PATCH] aout: reset sample rate default to 4kHz~48kHz
Rafaël Carré
funman at videolan.org
Wed Oct 23 02:27:17 CEST 2013
Le 22/10/2013 21:03, Zhang Rui a écrit :
> ---
> vlc-android/jni/aout.c | 27 +++++++++++++++++++++++----
> 1 file changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/vlc-android/jni/aout.c b/vlc-android/jni/aout.c
> index 859509b..201c62a 100644
> --- a/vlc-android/jni/aout.c
> +++ b/vlc-android/jni/aout.c
> @@ -79,10 +79,29 @@ int aout_open(void **opaque, char *format, unsigned *rate, unsigned *nb_channels
> LOGV ("Number of channels forced to 2, number of samples to %d", FRAME_SIZE);
> *nb_channels = 2;
>
> - (*p_env)->CallVoidMethod (p_env, p_sys->j_libVlc, methodIdInitAout,
> - *rate, *nb_channels, FRAME_SIZE);
> - if ((*p_env)->ExceptionCheck (p_env))
> - {
> + int aout_rate = *rate;
> + assert(aout_rate > 0);
> + while (1) {
No risk of infinite loop here?
> + (*p_env)->CallVoidMethod (p_env, p_sys->j_libVlc, methodIdInitAout,
> + aout_rate, *nb_channels, FRAME_SIZE);
> + if ((*p_env)->ExceptionCheck (p_env) == 0) {
> + *rate = aout_rate;
> + break;
> + }
> +
> + if (aout_rate < 4000) {
> + while (aout_rate < 4000)
> + aout_rate *= 2;
> + LOGE ("failed initAout, try new sample rate %dHz", aout_rate);
> + (*p_env)->ExceptionClear (p_env);
> + continue;
> + } else if (aout_rate > 48000) {
> + aout_rate /= 2;
> + LOGE ("failed initAout, try new sample rate %dHz", aout_rate);
> + (*p_env)->ExceptionClear (p_env);
> + continue;
> + }
> +
> LOGE ("Unable to create audio player!");
> #ifndef NDEBUG
> (*p_env)->ExceptionDescribe (p_env);
>
More information about the Android
mailing list