libvlc produces unclosed handles
Posted: 18 Aug 2011 14:28
Hi, the following sample code produces unclosed handles due to libvlc calls (running on win64 as 32bit program, info collected with perfmon at specific process/handles). Is there any I miss or it's libvlc's fault?
Code: Select all
void MediaPlayerEventHandler(const libvlc_event_t* pEvt, void* pUserData)
{
switch(pEvt->type)
{
case libvlc_MediaPlayerEncounteredError:
case libvlc_MediaPlayerEndReached:
case libvlc_MediaPlayerStopped:
printf("Media end\n");
break;
case libvlc_MediaPlayerPlaying:
printf("Media begin\n");
break;
}
}
void *Lock(void *opaque, void **plane)
{
*plane = opaque;
return NULL;
}
void Unlock(void *opaque, void *picture, void *const *plane)
{
}
void Display(void *opaque, void *picture)
{
printf("Display frame\n");
}
int main()
{
const char * const vlc_args[] = {
"-I",
"--ignore-config",
"--plugin-path=./plugins",
"--rtsp-caching=150",
"--http-caching=150",
"--no-osd"
};
libvlc_instance_t* m_pVLCInstance = libvlc_new (sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
libvlc_media_player_t* m_pMediaPlayer = libvlc_media_player_new(m_pVLCInstance);
libvlc_event_manager_t* m_pEvtManager = libvlc_media_player_event_manager(m_pMediaPlayer);
libvlc_event_attach(m_pEvtManager, libvlc_MediaPlayerEncounteredError , MediaPlayerEventHandler, NULL);
libvlc_event_attach(m_pEvtManager, libvlc_MediaPlayerEndReached, MediaPlayerEventHandler, NULL);
libvlc_event_attach(m_pEvtManager, libvlc_MediaPlayerPlaying, MediaPlayerEventHandler, NULL);
libvlc_event_attach(m_pEvtManager, libvlc_MediaPlayerStopped, MediaPlayerEventHandler, NULL);
libvlc_media_t* m_pMedia = libvlc_media_new_path(m_pVLCInstance, "rtsp://192.168.0.18/fake_server");
libvlc_media_player_set_media (m_pMediaPlayer, m_pMedia);
libvlc_video_set_callbacks(m_pMediaPlayer, Lock, Unlock, Display, NULL);
libvlc_video_set_format(m_pMediaPlayer, "RGBA", usWidth, usHeight, usWidth * 4);
while (true)
{
libvlc_media_player_play (m_pMediaPlayer);
Sleep(1000);
libvlc_media_player_stop (m_pMediaPlayer);
Sleep(1000);
}
return 0;
}