Commit ad5b2e3c authored by Thomas Guillem's avatar Thomas Guillem Committed by Jean-Baptiste Kempf

audiotrack: fix play wait delay

Don't postpone delay when a command is received.
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent c65d83da
...@@ -893,7 +893,7 @@ JNIThread( void *data ) ...@@ -893,7 +893,7 @@ JNIThread( void *data )
bool b_error = false; bool b_error = false;
bool b_paused = false; bool b_paused = false;
block_t *p_buffer = NULL; block_t *p_buffer = NULL;
mtime_t i_play_wait = 0; mtime_t i_play_deadline = 0;
JNIEnv* env; JNIEnv* env;
jni_attach_thread( &env, THREAD_NAME ); jni_attach_thread( &env, THREAD_NAME );
...@@ -921,18 +921,19 @@ JNIThread( void *data ) ...@@ -921,18 +921,19 @@ JNIThread( void *data )
continue; continue;
} }
if( p_cmd->id == CMD_PLAY && p_buffer == p_cmd->in.play.p_buffer if( p_cmd->id == CMD_PLAY && i_play_deadline > 0 )
&& i_play_wait > 0 )
{ {
int i_ret = 0; if( mdate() > i_play_deadline )
mtime_t i_deadline = mdate() + i_play_wait; i_play_deadline = 0;
else
while( p_cmd == TAILQ_FIRST( &p_sys->thread_cmd_queue ) {
&& i_ret != ETIMEDOUT && p_sys->b_thread_run ) int i_ret = 0;
i_ret = vlc_cond_timedwait( &p_sys->cond, &p_sys->mutex, while( p_cmd == TAILQ_FIRST( &p_sys->thread_cmd_queue )
i_deadline ); && i_ret != ETIMEDOUT && p_sys->b_thread_run )
i_play_wait = 0; i_ret = vlc_cond_timedwait( &p_sys->cond, &p_sys->mutex,
continue; i_play_deadline );
continue;
}
} }
/* process a command */ /* process a command */
...@@ -960,6 +961,9 @@ JNIThread( void *data ) ...@@ -960,6 +961,9 @@ JNIThread( void *data )
p_buffer = NULL; p_buffer = NULL;
break; break;
case CMD_PLAY: case CMD_PLAY:
{
mtime_t i_play_wait = 0;
assert( p_sys->p_audiotrack ); assert( p_sys->p_audiotrack );
if( b_error ) if( b_error )
break; break;
...@@ -969,7 +973,10 @@ JNIThread( void *data ) ...@@ -969,7 +973,10 @@ JNIThread( void *data )
&i_play_wait ) != VLC_SUCCESS; &i_play_wait ) != VLC_SUCCESS;
if( p_buffer != NULL ) if( p_buffer != NULL )
b_remove_cmd = false; b_remove_cmd = false;
if( i_play_wait > 0 )
i_play_deadline = mdate() + i_play_wait;
break; break;
}
case CMD_PAUSE: case CMD_PAUSE:
assert( p_sys->p_audiotrack ); assert( p_sys->p_audiotrack );
if( b_error ) if( b_error )
......
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