libvlc_media_player_stop hangs periodically

This forum is about all development around libVLC.
xdenser
Blank Cone
Blank Cone
Posts: 23
Joined: 30 Aug 2010 23:39
Contact:

libvlc_media_player_stop hangs periodically

Postby xdenser » 30 Aug 2010 23:58

I use libvlc to display UDP stream trhough libvlc_video_set_callbacks.
Task of getting size of frame is solved by creating dummy instance of player to render in 10x10 buffer,
I also use libvlc_event_manager_t to call libvlc_video_get_size from every event
when proper proper size is returned i stop and destroy that dummy instance and start new one with native frame size.

Platform is Windows, language is Delphi

Everything works ok, but in 1 case from 20 or 30 it hangs on libvlc_media_player_stop call on that first dummy instance.
I mean I call libvlc_media_player_stop and it never returns :-(.

Rémi Denis-Courmont
Developer
Developer
Posts: 15215
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: libvlc_media_player_stop hangs periodically

Postby Rémi Denis-Courmont » 31 Aug 2010 02:18

Make sure your callbacks are not causing a deadlock. Otherwise, it could be a LibVLC bug. In this case, we need a full thread stack trace or we cannot help you.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

xdenser
Blank Cone
Blank Cone
Posts: 23
Joined: 30 Aug 2010 23:39
Contact:

Re: libvlc_media_player_stop hangs periodically

Postby xdenser » 31 Aug 2010 11:17

Here is how it looks like in Delphi debugger

:7c90e4f4 ntdll.KiFastSystemCallRet
:7c90df3c ntdll.NtWaitForSingleObject + 0xc
:6a5dfb7c libvlccore.vlc_cond_wait + 0x4c
libvlc_ds_sfilter.TlibvlcSrcPin.Create(???,???,$EC10D0)
libvlc_ds_sfilter.TlibvlcSource.Create('udp://@:1234',0)
VideoWin.TGraphHandler.PreopenFile('udp://@:1234',???)
VideoWin.TTimeCtrl.Preopen
VideoWin.TTimeCtrl.Execute
:0042b68b ThreadProc + $37
:004056e2 ThreadWrapper + $2A
:7c80b713 ; C:\SYS\system32\kernel32.dll

I do not understand yet why it does not display other calls between

:6a5dfb7c libvlccore.vlc_cond_wait + 0x4c
and
libvlc_ds_sfilter.TlibvlcSrcPin.Create(???,???,$EC10D0)

when i set compiler to generate stack frames
it looks like

:7c90e4f4 ntdll.KiFastSystemCallRet
:7c90df3c ntdll.NtWaitForSingleObject + 0xc
:6a5dfb7c libvlccore.vlc_cond_wait + 0x4c
libvlc_player.TLibVLC_CustomRenderPlayer.Destroy
libvlc_dummy_player.Tlibvlc_DummyPlayer.Destroy
libvlc_dummy_player.TSizeGetPlayer.Destroy
:00404757 TObject.Free + $B
libvlc_ds_sfilter.TlibvlcSrcPin.Create(???,???,$EBBDD0)
libvlc_ds_sfilter.TlibvlcSource.Create('udp://@:1234',0)
VideoWin.TGraphHandler.PreopenFile('udp://@:1234',???)
VideoWin.TTimeCtrl.Preopen
VideoWin.TTimeCtrl.Execute
:0042b68b ThreadProc + $37
:004056e2 ThreadWrapper + $2A
:7c80b713 ; C:\SYS\system32\kernel32.dll

but still there are missing calls between

:6a5dfb7c libvlccore.vlc_cond_wait + 0x4c
libvlc_player.TLibVLC_CustomRenderPlayer.Destroy

may be this is because libvlc is linked dinamically

for example this is how looks call to

libvlc_player.pas.269: libvlc_media_player_stop(p_mi);
0056B8D2 52 push edx
0056B8D3 A1EC306000 mov eax,[$006030ec]
0056B8D8 8B00 mov eax,[eax]
0056B8DA FFD0 call eax
0056B8DC 59 pop ecx

in disassembler

Beardless2
Cone that earned his stripes
Cone that earned his stripes
Posts: 125
Joined: 02 Feb 2007 09:53

Re: libvlc_media_player_stop hangs periodically

Postby Beardless2 » 31 Aug 2010 11:42

could you post you entire project of Delphi code in here or on a website somewhere so I can try to assist you?

xdenser
Blank Cone
Blank Cone
Posts: 23
Joined: 30 Aug 2010 23:39
Contact:

Re: libvlc_media_player_stop hangs periodically

Postby xdenser » 31 Aug 2010 12:58

The project is too big to post

so I have created small one for testing
it just detects frame size of udp stream by timer (every 10 s)

here
Last edited by xdenser on 01 Sep 2010 22:04, edited 1 time in total.

Rémi Denis-Courmont
Developer
Developer
Posts: 15215
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: libvlc_media_player_stop hangs periodically

Postby Rémi Denis-Courmont » 01 Sep 2010 03:00

The stack is illegible to me. It goes straight from Delphi code to libvlccore without any libvlc call in the middle. You might be missing the libvlc debug symbols.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

xdenser
Blank Cone
Blank Cone
Posts: 23
Joined: 30 Aug 2010 23:39
Contact:

Re: libvlc_media_player_stop hangs periodically

Postby xdenser » 01 Sep 2010 09:36

What I got using madExcept:

I think I know where is the problem
the program hangs in main thread on vlc_cond_wait
but at the same time in thread $a38 an event is handled
and libvlc_video_get_size called wich locks some mutex
looks like I should not call libvlc_video_get_size when stopping player


here stack traces of all application threads

main thread ($9b0):
7c90df3a +0a ntdll.dll NtWaitForSingleObject
7c8025d5 +85 kernel32.dll WaitForSingleObjectEx
6a5dfb77 +47 libvlccore.dll vlc_cond_wait
6a5d4f67 +37 libvlccore.dll var_DelCallback
6a3092af +2f libvlc.dll libvlc_media_player_stop
004a6962 +12 test_stop.exe libvlc_player 269 +2 TLibVLC_BasePlayer.Stop
004a6a58 +10 test_stop.exe libvlc_player 316 +2 TLibVLC_CustomRenderPlayer.Destroy
004a6cc5 +15 test_stop.exe libvlc_dummy_player 75 +1 Tlibvlc_DummyPlayer.Destroy
004a6de1 +15 test_stop.exe libvlc_dummy_player 115 +1 TSizeGetPlayer.Destroy
004040ec +08 test_stop.exe System 8832 +1 TObject.Free
004a6c41 +75 test_stop.exe libvlc_dummy_player 59 +17 GetVideoSize
004a705a +36 test_stop.exe TestHangU 40 +2 TForm2.Timer1Timer
0047578f +0f test_stop.exe ExtCtrls 2281 +1 TTimer.Timer
00475673 +2b test_stop.exe ExtCtrls 2239 +4 TTimer.WndProc
00467590 +14 test_stop.exe Classes 11583 +8 StdWndProc
7e3696c2 +0a USER32.dll DispatchMessageA
004a0f00 +fc test_stop.exe Forms 8102 +23 TApplication.ProcessMessage
004a0f22 +0a test_stop.exe Forms 8121 +1 TApplication.HandleMessage
004a1233 +b3 test_stop.exe Forms 8219 +20 TApplication.Run
004a8995 +49 test_stop.exe test_stop 18 +4 initialization

thread $348: <priority:15>
7c90df2a +0a ntdll.dll NtWaitForMultipleObjects
7c80956e +00 kernel32.dll WaitForMultipleObjectsEx
7c80a100 +13 kernel32.dll WaitForMultipleObjects
0044ed89 +0d test_stop.exe madExcept CallThreadProcSafe
0044edf3 +37 test_stop.exe madExcept ThreadExceptFrame
>> created by thread $530 at:
72ce328c +00 wdmaud.drv

thread $a08:
7c90df3a +0a ntdll.dll NtWaitForSingleObject
7c8025d5 +85 kernel32.dll WaitForSingleObjectEx
6a5dfb77 +47 libvlccore.dll vlc_cond_wait
77c2a3ad +a6 msvcrt.dll _endthreadex
0044ed89 +0d test_stop.exe madExcept CallThreadProcSafe
0044edf3 +37 test_stop.exe madExcept ThreadExceptFrame
>> created by main thread ($9b0) at:
77c2a43d +62 msvcrt.dll _beginthreadex

thread $a38: <priority:1>
7c90df3a +00a ntdll.dll NtWaitForSingleObject
7c91b226 +087 ntdll.dll RtlpWaitForCriticalSection
7c901041 +041 ntdll.dll RtlEnterCriticalSection
6a5dfcba +07a libvlccore.dll vlc_mutex_lock
6a309f05 +015 libvlc.dll libvlc_get_input_thread
6a30442b +00b libvlc.dll libvlc_video_get_size
004a6843 +01b test_stop.exe libvlc_player 212 +1 TLibVLC_BasePlayer.GetVideoSize
004a6e14 +014 test_stop.exe libvlc_dummy_player 121 +1 TSizeGetPlayer.Event
004a6822 +012 test_stop.exe libvlc_player 207 +1 TLibVLC_BasePlayer.DispatchEvent
004a6247 +00f test_stop.exe libvlc_player 68 +2 lib_vlc_player_event_hdlr
6a3072ff +1bf libvlc.dll libvlc_event_send
6a5d5500 +150 libvlccore.dll var_AddCallback
6a5d5811 +0a1 libvlccore.dll var_SetChecked
77c2a3ad +0a6 msvcrt.dll _endthreadex
0044ed89 +00d test_stop.exe madExcept CallThreadProcSafe
0044edf3 +037 test_stop.exe madExcept ThreadExceptFrame
>> created by main thread ($9b0) at:
77c2a43d +062 msvcrt.dll _beginthreadex

thread $b44:
7c90df3a +0a ntdll.dll NtWaitForSingleObject
7c8025d5 +85 kernel32.dll WaitForSingleObjectEx
6a5dfb77 +47 libvlccore.dll vlc_cond_wait
6a5bb91f +5f libvlccore.dll block_FifoGet
77c2a3ad +a6 msvcrt.dll _endthreadex
0044ed89 +0d test_stop.exe madExcept CallThreadProcSafe
0044edf3 +37 test_stop.exe madExcept ThreadExceptFrame
>> created by thread $a38 at:
77c2a43d +62 msvcrt.dll _beginthreadex

thread $de8: <priority:2>
7c90df3a +0a ntdll.dll NtWaitForSingleObject
7c8025d5 +85 kernel32.dll WaitForSingleObjectEx
6a5dfb77 +47 libvlccore.dll vlc_cond_wait
6a5bb91f +5f libvlccore.dll block_FifoGet
77c2a3ad +a6 msvcrt.dll _endthreadex
0044ed89 +0d test_stop.exe madExcept CallThreadProcSafe
0044edf3 +37 test_stop.exe madExcept ThreadExceptFrame
>> created by thread $a38 at:
77c2a43d +62 msvcrt.dll _beginthreadex

thread $448: <priority:15>
7c90df2a +0a ntdll.dll NtWaitForMultipleObjects
7c80956e +00 kernel32.dll WaitForMultipleObjectsEx
7c80a100 +13 kernel32.dll WaitForMultipleObjects
0044ed89 +0d test_stop.exe madExcept CallThreadProcSafe
0044edf3 +37 test_stop.exe madExcept ThreadExceptFrame
>> created by thread $de8 at:
73eda31f +00 dsound.dll

thread $e28: <priority:15>
7c90df2a +0a ntdll.dll NtWaitForMultipleObjects
7c80956e +00 kernel32.dll WaitForMultipleObjectsEx
7c80a100 +13 kernel32.dll WaitForMultipleObjects
0044ed89 +0d test_stop.exe madExcept CallThreadProcSafe
0044edf3 +37 test_stop.exe madExcept ThreadExceptFrame
>> created by thread $de8 at:
73eda31f +00 dsound.dll

thread $d88: <priority:15>
7c90d1fa +0a ntdll.dll NtDelayExecution
7c8023eb +4b kernel32.dll SleepEx
6a5bb477 +67 libvlccore.dll mwait
77c2a3ad +a6 msvcrt.dll _endthreadex
0044ed89 +0d test_stop.exe madExcept CallThreadProcSafe
0044edf3 +37 test_stop.exe madExcept ThreadExceptFrame
>> created by thread $de8 at:
77c2a43d +62 msvcrt.dll _beginthreadex

thread $c48: <priority:1>
7c90df3a +0a ntdll.dll NtWaitForSingleObject
7c8025d5 +85 kernel32.dll WaitForSingleObjectEx
6a5dfa91 +c1 libvlccore.dll vlc_cond_timedwait
77c2a3ad +a6 msvcrt.dll _endthreadex
0044ed89 +0d test_stop.exe madExcept CallThreadProcSafe
0044edf3 +37 test_stop.exe madExcept ThreadExceptFrame
>> created by thread $b44 at:
77c2a43d +62 msvcrt.dll _beginthreadex

xdenser
Blank Cone
Blank Cone
Posts: 23
Joined: 30 Aug 2010 23:39
Contact:

Re: libvlc_media_player_stop hangs periodically

Postby xdenser » 01 Sep 2010 17:38

ok
i do not call libvlc_video_get_size
while in libvlc_media_player_stop
and it works now

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: libvlc_media_player_stop hangs periodically

Postby Jean-Baptiste Kempf » 04 Sep 2010 11:08

Hmm, you were calling libvlc_video_get_size when stopping???
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

xdenser
Blank Cone
Blank Cone
Posts: 23
Joined: 30 Aug 2010 23:39
Contact:

Re: libvlc_media_player_stop hangs periodically

Postby xdenser » 04 Sep 2010 15:05

yes. it was called from event handler


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 17 guests