Solved Unexpected CDB Exit when including libvlc
-
Hi everyone! I'm new, but I have already searched in the forum and I cannot find anything useful to solve my problem. I'm actually developing an opensource torrent app that will include a stream preview implemented using libvlc, but I have been stuck for the past two days trying to figure out what is happening. I'm using QT and I'm compiling using MSVC 2015 x64 with x64 CDB debugger. As soon as I compile something that require the libvlc to be used and I start the debug I receive a messageBox "Unexpected CDB Exit - The CDB process terminated" without even arrive to the debug of the application (I don't even reach the main). I've tried varius versions of the library from different sources, but the result is always the same. The code I'm using is "inspired" by the documentation taken from VideoLAN wiki page and here it is
#include "previewplayer.h" PreviewPlayer::PreviewPlayer(QObject *parent) : QObject(parent) { const char * const vlc_args[] = { "--verbose=2", //be much more verbose then normal for debugging purpose }; vlcInstance = libvlc_new(1, vlc_args); mediaPlayer = libvlc_media_player_new(vlcInstance); } PreviewPlayer::~PreviewPlayer() { libvlc_media_player_stop(mediaPlayer); libvlc_media_player_release(mediaPlayer); libvlc_release(vlcInstance); } void PreviewPlayer::playFile(QString file, WId windowId) { media = libvlc_media_new_path(vlcInstance, file.toLocal8Bit().constData()); libvlc_media_player_set_media(mediaPlayer, media); #if defined(Q_OS_WIN) libvlc_media_player_set_nsobject(mediaPlayer, &windowId); //libvlc_media_player_set_drawable(_mp, reinterpret_cast<unsigned int>(_videoWidget->winId()), &_vlcexcep ); // [20101215 JG] Used for versions prior to VLC 1.2.0. //libvlc_media_player_set_hwnd(_mp, _videoWidget->winId(), &_vlcexcep ); // for vlc 1.0 #elif defined(Q_OS_MAC) libvlc_media_player_set_drawable(mediaPlayer, windowId); //libvlc_media_player_set_drawable(_mp, _videoWidget->winId(), &_vlcexcep ); // [20101215 JG] Used for versions prior to VLC 1.2.0. //libvlc_media_player_set_agl (_mp, _videoWidget->winId(), &_vlcexcep); // for vlc 1.0 #else //Linux //[20101201 Ondrej Spilka] obsolete call on libVLC >=1.1.5 //libvlc_media_player_set_drawable(_mp, _videoWidget->winId(), &_vlcexcep ); //libvlc_media_player_set_xwindow(_mp, _videoWidget->winId(), &_vlcexcep ); // for vlc 1.0 //again note X11 handle on Linux is needed // winID() returns X11 handle when QX11EmbedContainer us used //int windid = _videoWidget->winId(); libvlc_media_player_set_xwindow (mediaPlayer, windowId ); #endif libvlc_media_player_play(mediaPlayer); isPlaying = true; } void PreviewPlayer::changeVolume(int newVolume) { libvlc_audio_set_volume (mediaPlayer, newVolume); } void PreviewPlayer::changeTimelinePosition(int newPosition, unsigned int positionResolution) { //libvlc_exception_clear(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. // It's possible that the vlc doesn't play anything // so check before libvlc_media_t *curMedia = libvlc_media_player_get_media (mediaPlayer); //libvlc_media_t *curMedia = libvlc_media_player_get_media (_mp, &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. //libvlc_exception_clear(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. if (curMedia == NULL) return; float pos=(float)(newPosition)/(float)positionResolution; libvlc_media_player_set_position (mediaPlayer, pos); //libvlc_media_player_set_position (_mp, pos, &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. //raise(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. } int PreviewPlayer::GetVolume() { if(!isPlaying) return -1; // It's possible that the vlc doesn't play anything // so check before libvlc_media_t *curMedia = libvlc_media_player_get_media (mediaPlayer); //libvlc_media_t *curMedia = libvlc_media_player_get_media (_mp, &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. //libvlc_exception_clear(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. if (curMedia == NULL) return -1; return libvlc_audio_get_volume(mediaPlayer); // return 0; } float PreviewPlayer::GetTimelinePosition() { if(!isPlaying) return -1.0; // It's possible that the vlc doesn't play anything // so check before libvlc_media_t *curMedia = libvlc_media_player_get_media (mediaPlayer); //libvlc_media_t *curMedia = libvlc_media_player_get_media (_mp, &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. //libvlc_exception_clear(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. if (curMedia == NULL) return -1.0; return libvlc_media_player_get_position (mediaPlayer); // return 0; }
This code is actually not used in any point of the software yet, therefore these functions are never called. Consider that everything works fine if I comment out everything related to libvlc, so I think that the problem is related to the library.
If I try to run the debug exe I run in a 0xC000007B error (I think it's related to VC++ Redistributable libraries)I'm now running Windows 10 build 15063.502 and CDB version is 10.0.15063.468.
Thank you for your support, is higly appreciated.
-
Hi and welcome to devnet,
Might be a silly question but do you have the libVLC .dll files in folder that can be found when you start your application ?
If not then and using Qt Creator, go to the Run part of the Project panel and modify there the PATH environment variable (do not do it system wide).
-
Hi SGaist,
thank you for your answer. I checked and yes, the folder of the project that contains libvlc dll files is inserted in the path under the Run section. Might it be the plugins folder? I have read online that should be sufficient to insert it together with the other DLLs
-
AFAIR, you should also have the plugins along.
Are you using VLC-Qt ?
-
The plugin folder is inserted and it doesn't work anyway. No, I'm not using VLC-QT because I had an hard time to make them compile even in the example project
-
I- have tried again VLC-Qt libraries and I got them working. Now I can build and compile. I guess we can close the post. Thank you for your support
-
Great !
What was the problem building VLC-Qt ?