Page 1 of 1

libvlc and Qt 5

Posted: 11 Dec 2013 11:18
by djoulez78
Hi,

I am trying to use VLC inside a Qt 5 application.


Here is the code I use:

Code: Select all

#include "vlcwidget.h" VLCWidget::VLCWidget(QWidget *parent) : QWidget(parent) { holder = new QWidget(this); const char * const vlc_args[] = { "-I", "dummy", /* Don't use any interface */ "--ignore-config", /* Don't use VLC's config */ "--no-video-title", "--vout=macosx" }; _vlcinstance=libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args); //tricky calculation of the char space used QUrl test("Avengers.mov"); qDebug() << "libvlc_new: " << _vlcinstance; /* Create a new LibVLC media descriptor */ _mp = libvlc_media_player_new (_vlcinstance); libvlc_video_set_deinterlace(_mp,QString("linear").toLatin1().data()); libvlc_media_player_set_nsobject(_mp, (void *)holder->winId()); } void VLCWidget::play() { libvlc_media_t *_m = libvlc_media_new_path(_vlcinstance, "Avengers.mov"); libvlc_media_player_set_media (_mp, _m); libvlc_media_release(_m); int play_status = libvlc_media_player_play (_mp); } void VLCWidget::resizeEvent(QResizeEvent *event) { this->QWidget::resizeEvent(event); holder->resize(this->size()); } void VLCWidget::killVLC() { qDebug() << "KILLING APPLICATION"; holder->deleteLater(); libvlc_media_player_stop(_mp); libvlc_media_player_release(_mp); libvlc_release(_vlcinstance); }
Everything (video and sound) is working well until until release of the instances. At that moment I get a set fault (EXC_BAD_ACCESS).

Here is the link to the project sources:

http://91.121.12.77/download/QVLC.zip

This is a simple example that play a video, then after 6 seconds stops it and release instances.

I noticed that the set fault doesn't occurs if I don't call, libvlc_media_release...but the memory won't be freed :(

Did someone already encounter this problem ?

Any help would be very appreciated :)

Thx