Skip to content

darwinvlc: fix libvlc termination and SIGTERM/SIGINT handling

Two issues were present with the previous implementation for interface handling.

  • Contrary to bin/vlc.c, darwinvlc.m needs to handle the CFRunLoop in the main thread, but libvlc was released only after the runloop was terminated, meaning that interfaces could not use the runloop on close.

  • Some application-specific runloop stop code was present to stop the NSApp for the main macosx.m interface, with conditionals to check whether the NSApp was started or not. darwinvlc.m shouldn't need to know whether it needs to do that and should only handle the termination of its own CFRunLoopRun() call, even if an interface nests the runloop afterwards. As with the point above, the interface should terminate its NSApp before darwinvlc terminates its runloop.

This commit reorder the resource deallocation to first remove the interfaces, by releasing the libvlc instance, and only then destroy the runloop. It uses previous changes in the macosx interface to handle the stopping through libvlc_Quit.

By reordering this way, it's now possible to use SIGINT to stop the Qt interface also.

After that, it adapts the exit code in Qt, which is using libvlc_Quit(), to fix a crash on Darwin.

The Abort() function was set as a handler for the libvlc_Quit() callback, through libvlc_SetExitHandler, and was used to provide Qt runloop termination when the application was exiting.

But terminating the runloop and Qt resources was not correct since it didn't account for the internal resource reference counting. Instead, now that darwinvlc.m correctly handles libvlc termination by releasing the interfaces before killing the runloop, we can just use the normal code path for interfaces, which in the case of Qt already handles the reference counting, and wait for the Qt runloop to exit.

Fix #28917 (closed)

Merge request reports

Loading