Postby johnsheng » 16 Dec 2010 11:12
about the above problem , I have fine a bug:
problem: launch a rtsp player(develop with libvlc) , a short time later , when no net data reach player , the live demux of player can exit . you can get the debug info of "msg_Dbg( p_input, "EOF reached" )" in MainLoopDemux when exit , but the thread "RunThread" in video_output.c dose not stop and exit after input thread is dead , the thread always display last picture .
To find cause , we can compare the two kinds of call method , one is vlc.exe call ,the other is our program call to libvlc .
one: vlc.exe call like as :
/* Initialize libvlc */
libvlc_instance_t *vlc;
vlc = libvlc_new (argc - 1, (const char **)argv + 1, &ex);
if (vlc != NULL)
{
libvlc_add_intf (vlc, "globalhotkeys , none", &ex);
libvlc_add_intf (vlc, NULL, &ex);
libvlc_playlist_play (vlc, -1, 0, NULL, &dummy);
libvlc_wait (vlc);
libvlc_release (vlc);
}
url is send to libvlc_new as a parameter , the call of libvlc_playlist_play is very importment , the two sequences are
call sequence 1: libvlc_playlist_play -> playlist_Control(.. PLAYLIST_PLAY..)->pl_priv(p_playlist)->request.b_request = true
call sequence 2: libvlc_new->...>libvlc_InternalInit-> playlist_Activate->vlc_clone( ..Thread..)->LoopRequest( if( i_status == PLAYLIST_STOPPED || !vlc_object_alive( p_playlist ) ) )->
PlayItem->var_AddCallback(.. "intf-event", InputEvent.. );
the function InputEvent is very importment . when EOF reach , the thread of "Run" in input.c call input_SendEventDead( p_input ) , at last input_SendEventDead will call InputEvent , then InputEvent set a
signal (vlc_cond_signal( &pl_priv(p_playlist)->signal )) , later the thread of "thread" in thread.c get to know "vlc_cond_wait( &p_sys->signal,
&p_sys->lock )", call 2 will receive the signal , in this way all thread exit .
the other :
p_media = libvlc_media_new( m_pVLCInstance , psz_name, &m_VLCex );
libvlc_media_player_set_media( m_pMediaPlayer , p_media, &m_VLCex );
libvlc_media_player_play( m_pMediaPlayer , &m_VLCex );
libvlc_media_player_set_drawable()
libvlc_media_player_set_media (m_pMediaPlayer, m_pMedia, &m_VLCex);
libvlc_media_player_play( m_pMediaPlayer , &m_VLCex );
in this call method , player register input_event_changed in libvlc_media_player_play(src:var_AddCallback( p_input_thread, "intf-event", input_event_changed, p_mi )) as a callback , instead of InputEvent . as a result the thread of "Run" in input.c can not call function of InputEvent to tell video output thread when EOF reach.
hope that somebody can give some suggestion to fix bug .
thank you .