[vlc-devel] [PATCH] [HACK] bin/darwinvlc: fix issues with premature start of playlist, before intf is up

david.fuhrmann at gmail.com david.fuhrmann at gmail.com
Sun Mar 15 18:38:01 CET 2015

From: David Fuhrmann <dfuhrmann at videolan.org>

The interface needs to be up before the playlist is started, otherwise
events get missing.
For the mac interface, playlist start happens in the
interface itself. For all other interfaces, libvlc_playlist_play is moved after
open again. It is only called when the mac interface is not used, because
otherwise it interferes with the shutdown sequence.

This solution is a hack to keep behaviour as expected for VLC 2.2. Startup
needs to be properly fixed later on. This patch only works if the
modules cache is properly initialized before. I.e. the application bundle
should be started once graphically. But this is needed anyway, to trigger
signature verification of the bundle.

close #11585
close #14046
 bin/darwinvlc.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/bin/darwinvlc.c b/bin/darwinvlc.c
index fbad415..b3b53f1 100644
--- a/bin/darwinvlc.c
+++ b/bin/darwinvlc.c
@@ -43,6 +43,8 @@
 #include <TargetConditionals.h>
 #import <CoreFoundation/CoreFoundation.h>
+#include <mach-o/dyld.h>
 extern void vlc_enable_override (void);
 static bool signal_ignored (int signum)
@@ -221,13 +223,29 @@ int main( int i_argc, const char *ppsz_argv[] )
     libvlc_set_app_id (vlc, "org.VideoLAN.VLC", PACKAGE_VERSION, PACKAGE_NAME);
     libvlc_set_user_agent (vlc, "VLC media player", "VLC/"PACKAGE_VERSION);
-    libvlc_playlist_play (vlc, -1, 0, NULL);
     libvlc_add_intf (vlc, "hotkeys,none");
     if (libvlc_add_intf (vlc, NULL))
         goto out;
+    /* Check if mac interface plugin was loaded. This is an evil hack and only works if the cache
+       was properly generated before! Startup code needs to be properly fixed later on. */
+    bool b_mac_intf_found = false;
+    uint32_t num = _dyld_image_count();
+    for(uint32_t i = 0; i < num; ++i) {
+        const char *library_name = _dyld_get_image_name(i);
+        if (library_name && strstr(library_name, "libmacosx_plugin.dylib")) {
+            b_mac_intf_found = true;
+            break;
+        }
+    }
+    /* libvlc_playlist_play should not be called if mac interface was found */
+    if (!b_mac_intf_found) {
+        libvlc_playlist_play (vlc, -1, 0, NULL);
+    }
     /* Qt4 insists on catching SIGCHLD via signal handler. To work around that,
      * unblock it after all our child threads are created. */
     sigdelset (&set, SIGCHLD);
1.9.5 (Apple Git-50.3)

More information about the vlc-devel mailing list