[vlc] libvlc_new() was trapped and never return‏

tingustar at hotmail.com tingustar at hotmail.com
Thu Apr 23 15:52:49 CEST 2009


Hi all,
 
I met a problem when using libvlc.dll to do a simple test under Visual Studio 2005.
Sometimes the program was trapped into libvlc_new() during startup and never returned
so the thread hang (my main dialog UI is still alive). If libvlc_new() returned correctly
then the playback window pop up and playing started, and then I can control the playing
(pause or resume) smoothly by my main dialog UI. But I don't understand why sometimes
libvlc_new() was trapped and never returned? (it looks to me as if it had deadlock inside)
Does anyone meet similar problem and or anyone can give me some advices? Thank you very much.
My test codes are attached below.
(I spawned a new thread, otherwise my main dialog UI will be blocked)
 
Thanks,
Tingustar
 
 
libvlc_exception_t ex;
libvlc_instance_t * inst;
libvlc_media_player_t *mp;
libvlc_media_t *m;
 
static unsigned WINAPI start_player(void *data)
{  
    const char * const vlc_args[] = {
        "-I", "dummy", /* Don't use any interface */
        "--ignore-config", /* Don't use VLC's config */
        "--plugin-path=C:\\Local\\installed\\VLC\\plugins"
    };    
    
    libvlc_exception_init (&ex);
    inst = libvlc_new (sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args, &ex);
    raise (&ex);
 
    /* Create a new item */
    m = libvlc_media_new (inst, "C:\\Local\\misc\\test\\jofy.wmv", &ex);
    raise (&ex);
   
    /* Create a media player playing environement */
    mp = libvlc_media_player_new_from_media (m, &ex);
    raise (&ex);
    
    /* No need to keep the media now */
    libvlc_media_release (m);
 
    /* play the media_player */
    libvlc_media_player_play (mp, &ex);
    raise (&ex);
    
    while (1)
        Sleep(2000);
 
    return 0;
 
}
 
void Ctest2Dlg::OnBnClickedButtonStop()
{
    /* Stop playing */
 
    libvlc_media_player_stop (mp, &ex);
 
 
 
    /* Free the media_player */
 
    libvlc_media_player_release (mp);
 
 
 
    libvlc_release (inst);
 
    raise (&ex);
}
 
void Ctest2Dlg::OnBnClickedButtonStart()
{
    static int started = 0;
    static int toggle = 0;
 
    unsigned threadID;
    if (started == 0)
    {
        _beginthreadex( NULL, 0, start_player, NULL, 0, &threadID );
        started = 1;
        return;
    }
    if (toggle == 0) {
        libvlc_media_player_pause(mp, &ex);
        toggle = 1;
    } else {
        libvlc_media_player_play(mp, &ex);
        toggle = 0;
    }
}
_________________________________________________________________
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/



More information about the vlc mailing list