[vlc-devel] [PATCH 1/4] audiotrack: check init state
Thomas Guillem
thomas at gllm.fr
Tue Mar 3 18:05:37 CET 2015
---
modules/audio_output/audiotrack.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/modules/audio_output/audiotrack.c b/modules/audio_output/audiotrack.c
index 7b2646f..4ccd5c7 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -138,6 +138,7 @@ static struct
jclass clazz;
jmethodID ctor;
jmethodID release;
+ jmethodID getState;
jmethodID play;
jmethodID stop;
jmethodID flush;
@@ -146,6 +147,7 @@ static struct
jmethodID getPlaybackHeadPosition;
jmethodID getTimestamp;
jmethodID getMinBufferSize;
+ jint STATE_INITIALIZED;
jint MODE_STREAM;
jint ERROR;
jint ERROR_BAD_VALUE;
@@ -238,6 +240,7 @@ InitJNIFields( audio_output_t *p_aout )
GET_ID( GetMethodID, AudioTrack.ctor, "<init>", "(IIIIII)V", true );
GET_ID( GetMethodID, AudioTrack.release, "release", "()V", true );
+ GET_ID( GetMethodID, AudioTrack.getState, "getState", "()I", true );
GET_ID( GetMethodID, AudioTrack.play, "play", "()V", true );
GET_ID( GetMethodID, AudioTrack.stop, "stop", "()V", true );
GET_ID( GetMethodID, AudioTrack.flush, "flush", "()V", true );
@@ -251,6 +254,7 @@ InitJNIFields( audio_output_t *p_aout )
GET_ID( GetStaticMethodID, AudioTrack.getMinBufferSize, "getMinBufferSize",
"(III)I", true );
+ GET_CONST_INT( AudioTrack.STATE_INITIALIZED, "STATE_INITIALIZED", true );
GET_CONST_INT( AudioTrack.MODE_STREAM, "MODE_STREAM", true );
GET_CONST_INT( AudioTrack.ERROR, "ERROR", true );
GET_CONST_INT( AudioTrack.ERROR_BAD_VALUE , "ERROR_BAD_VALUE", true );
@@ -570,6 +574,11 @@ JNIThread_Start( JNIEnv *env, audio_output_t *p_aout )
(*env)->DeleteLocalRef( env, p_audiotrack );
if( !p_sys->p_audiotrack )
return VLC_EGENERIC;
+ if( JNI_AT_CALL_INT( getState ) != jfields.AudioTrack.STATE_INITIALIZED )
+ {
+ msg_Err( p_aout, "AudioTrack init failed" );
+ goto error;
+ }
if( jfields.AudioTimestamp.clazz )
{
--
2.1.3
More information about the vlc-devel
mailing list