Page 1 of 1

Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 20 Oct 2012 14:29
by Jo2003
I have a problem with libVLC > 2.0.1 on Mac Mountain Lion (64bit) when using libVLC in a Qt application. Every time I try to display the video the app crashes.

I'm using libVLC from VLC (64bit only), Qt 4.8.3, OSX 10.8.2 64bit

This worked fine with libVLC2.0.1 but since 2.0.3 it always crashes. Almost the same code on Windows / Linux works without a problem also with libVLC 2.0.4.

I wrote a simple test application which shows this behavior.

This is mainwindow.h

Code: Select all

#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <vlc/vlc.h> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_pushPlay_clicked(); void on_pushStop_clicked(); void on_pushGetFile_clicked(); private: Ui::MainWindow *ui; libvlc_media_player_t *_player; libvlc_instance_t *_lib; }; #endif // MAINWINDOW_H
This is mainwindow.cpp

Code: Select all

#include "mainwindow.h" #include "ui_mainwindow.h" #include <QFileDialog> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); _lib = NULL; _player = NULL; // create a new libvlc instance ... const char *vlc_args[] = { "--ignore-config", "--intf=dummy", "--no-media-library", "--no-osd", "--no-stats", "--no-video-title-show", #ifdef Q_WS_MAC // vout as well as opengl-provider MIGHT be "minimal_macosx" ... "--vout=macosx", #endif "--verbose=1" }; int argc = sizeof(vlc_args) / sizeof(vlc_args[0]); const char ** argv = vlc_args; _lib = libvlc_new(argc, argv); _player = libvlc_media_player_new(_lib); #ifdef Q_OS_WIN libvlc_media_player_set_hwnd (_player, (void *)ui->frame->winId()); #elif defined Q_OS_MAC libvlc_media_player_set_nsobject(_player, (void *)ui->frame->winId()); #else libvlc_media_player_set_xwindow(_player, ui->frame->winId()); #endif } MainWindow::~MainWindow() { libvlc_media_player_stop(_player); libvlc_media_player_release (_player); libvlc_release(_lib); delete ui; } void MainWindow::on_pushPlay_clicked() { if (ui->lineFile->text() != "") { libvlc_media_t* video = libvlc_media_new_path(_lib, ui->lineFile->text().toUtf8().constData()); if (video) { libvlc_media_player_set_media (_player, video); libvlc_media_release (video); libvlc_media_player_play (_player); } } } void MainWindow::on_pushStop_clicked() { if (libvlc_media_player_is_playing (_player)) { libvlc_media_player_stop (_player); } } void MainWindow::on_pushGetFile_clicked() { QString file = QFileDialog::getOpenFileName(this, tr("Open Media File"), QString(), tr("Matroshka (*.mkv);;Mpeg4 (*.m4?);;All Files (*.*)")); if (file != "") { ui->lineFile->setText(file); } }
Is this a known limitation? As I told it works until 2.0.1 but any newer version crashes. Do I have a problem in my code or is there a workaround?

Here you can download the whole source code as tgz package. http://rt.coujo.de/qtplay.tgz

Thank you for your help!

Best regards,
Jörg

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 22 Oct 2012 11:26
by Jean-Baptiste Kempf
Does it not crash if you remove libvlc_media_player_set_nsobject(_player, (void *)ui->frame->winId()); ?

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 22 Oct 2012 19:49
by Jo2003
It doesn't crash if not running this function. But of course there is no video display when starting the playback. Sound is there.

When this function is enabled the program only crashes when starting to play a media file. So running this function in constructor itself doesn't lead to the crash.

Best regards,
Jörg

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 24 Oct 2012 16:15
by Jo2003
I can provide 2 app packages (one with 2.0.1, one with 2.0.4) if this helps?!

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 25 Oct 2012 13:21
by Jean-Baptiste Kempf
Because your winId() is not a NSObject. Use QMacCocoaViewContainer

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 25 Oct 2012 14:13
by Jo2003
Actually winId() is a NSView object (which inherits from NSObject). Here is the help entry from Qt:
WId QWidget::winId () const
Returns the window system identifier of the widget.
...
On Mac OS X, the type returned depends on which framework Qt was linked against. ... If Qt is using Cocoa, {WId} is a pointer to an NSView.
...
... and as stated - it works with libVLC2.0.1!

Should I enter a bugreport?!

Best regards,
Jörg

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 25 Oct 2012 14:52
by Jean-Baptiste Kempf
Or find the regression...

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 25 Oct 2012 16:11
by Rémi Denis-Courmont
This is probably an issue in the MacOS video output. I think it expects something else than an NSObject, confusingly enough.

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 01 Nov 2012 13:52
by Jo2003
Has this changed between 2.0.1 and 2.0.3?

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 13 Dec 2012 20:17
by daeq
Hello! Have you been able to fix this problem? I have the same issue with Qt 4.8.8 MacOSX 10.8.2. I tried different versions of libvlc, including latest from git, but error remains.

Or is there alternative way to display video in window?

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 21 Dec 2012 05:50
by geostein8888
Hello,
i have the same problem with the crash when i set the nsobject in 2.05, did somebody found out how the siplay has to be so this works with the newer revs?

Georg

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 21 Dec 2012 16:44
by Jean-Baptiste Kempf
Did you try VLC 2.1.0 nightly build?

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 13 Feb 2013 10:01
by daeq
I've tried 2.1.0 nighly build. Problem remains the same.

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 29 Mar 2013 14:08
by lanamelach
Have the same problem with Qt 4.8.4 + Mac OS X 10.6 + libvlc 2.0.5.

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 29 Mar 2013 19:57
by sherington
I have been looking into a similar problem that affects my own libvlc bindings on MacOSX. I have been told by some of my users that reverting to vlc 2.0.3 works just fine, but any other version does not, including 2.1.0-git. This is clearly at odds with the original poster who states that vlc 2.0.3 does not work for them.

One of my users however states vlc 2.0.3 does not work for him either, so there's maybe some other factor in play here, but I don't know what it is.

I've diffed the code between 2.0.3 and 2.0.4 but I'm not a Mac developer nor am I a vlc developer, and I can't see anything obvious that might have caused this problem.

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 01 Apr 2013 19:37
by Jean-Baptiste Kempf
Hmm, I think the issue is more related to Qt, but I'll have a look.

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 08 Apr 2013 08:38
by lanamelach
Tested with this code. Works fine with vlc 2.0.1, vlc 2.0.2 and vlc 2.0.3, but with vlc 2.0.4 or 2.0.5 it crashes. Qt 4.8.4, Test platform: OSX 10.6.

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 24 May 2013 06:09
by geostein8888
also with the 2.06 this is still an issue, but it looks like nobody is really interested to fix this, so i guess there must be a work around i do not know. I still can't use the versions after 2.01 in my source because of this. So when there is somebody who can give me a hint how to bring newer versions to work on mac i will be very happy.
I'm still confused how there can be such a big change in a .0x version change

Georg

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 05 Jun 2013 07:25
by lanamelach
They don't fix it. Instead admin decided to ban me from this board :)

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 07 Jun 2013 23:35
by Jean-Baptiste Kempf
It was fixed for 2.0.7

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 21 Aug 2013 15:03
by Jo2003
I'll try and report. So far I'm still using 2.01.

Best regards,
Jörg

Re: Qt4.8.3 + MacOSX 10.8 + libVLC > 2.0.1 = crash

Posted: 26 Aug 2013 12:37
by Jo2003
Yes, it works!

Many thanks for this!

Best regards,
Jörg