[vlc-devel] [vlc-commits] macosx: clean access to the aout/vout threads
David Fuhrmann
david.fuhrmann at gmail.com
Sat Mar 16 21:35:14 CET 2019
> Am 15.03.2019 um 11:19 schrieb Felix Paul Kühne <git at videolan.org>:
>
> vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Fri Mar 15 11:12:56 2019 +0100| [224b04306d8c6629c0c905fd7ed2bacef65fa7d3] | committer: Felix Paul Kühne
>
> macosx: clean access to the aout/vout threads
>
> Use instance variables more effectively to save selector dispatches (and characters)
>
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=224b04306d8c6629c0c905fd7ed2bacef65fa7d3
> ---
>
> .../macosx/coreinteraction/VLCCoreInteraction.m | 26 ++++++++--------
> modules/gui/macosx/menus/VLCMainMenu.m | 14 ++++-----
> .../panels/VLCAudioEffectsWindowController.m | 36 +++++++++++++---------
> .../panels/VLCVideoEffectsWindowController.m | 6 ++--
> 4 files changed, 46 insertions(+), 36 deletions(-)
>
> diff --git a/modules/gui/macosx/coreinteraction/VLCCoreInteraction.m b/modules/gui/macosx/coreinteraction/VLCCoreInteraction.m
> index 85fb334939..0ec106ef3c 100644
> --- a/modules/gui/macosx/coreinteraction/VLCCoreInteraction.m
> +++ b/modules/gui/macosx/coreinteraction/VLCCoreInteraction.m
> @@ -61,6 +61,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
>
> VLCClickerManager *_clickerManager;
> VLCPlaylistController *_playlistController;
> + VLCPlayerController *_playerController;
> }
> @end
>
> @@ -94,6 +95,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
>
> _clickerManager = [[VLCClickerManager alloc] init];
> _playlistController = [[VLCMain sharedInstance] playlistController];
> + _playerController = [_playlistController playerController];
>
> var_AddCallback(pl_Get(p_intf), "intf-boss", BossCallback, (__bridge void *)self);
> }
> @@ -119,18 +121,16 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
>
> - (void)playOrPause
> {
> - VLCMain *mainInstance = [VLCMain sharedInstance];
> - VLCPlaylistController *playlistController = mainInstance.playlistController;
> - input_item_t *p_input_item = playlistController.currentlyPlayingInputItem;
> + input_item_t *p_input_item = _playlistController.currentlyPlayingInputItem;
>
> if (p_input_item) {
> - [playlistController.playerController togglePlayPause];
> + [_playerController togglePlayPause];
> input_item_Release(p_input_item);
> } else {
> - if (mainInstance.playlistController.playlistModel.numberOfPlaylistItems == 0)
> - [[mainInstance open] openFileGeneric];
> + if (_playlistController.playlistModel.numberOfPlaylistItems == 0)
> + [[[VLCMain sharedInstance] open] openFileGeneric];
> else
> - [playlistController startPlaylist];
> + [_playlistController startPlaylist];
> }
> }
>
> @@ -381,7 +381,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
> }
> config_PutInt("random", on);
>
> - vout_thread_t *p_vout = [[_playlistController playerController] mainVideoOutputThread];
> + vout_thread_t *p_vout = [_playerController mainVideoOutputThread];
> if (!p_vout) {
> return;
> }
> @@ -398,7 +398,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
> {
> _playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_ALL;
>
> - vout_thread_t *p_vout = [[_playlistController playerController] mainVideoOutputThread];
> + vout_thread_t *p_vout = [_playerController mainVideoOutputThread];
> if (p_vout) {
> vout_OSDMessage(p_vout, VOUT_SPU_CHANNEL_OSD, "%s", _("Repeat All"));
> vout_Release(p_vout);
> @@ -409,7 +409,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
> {
> _playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT;
>
> - vout_thread_t *p_vout = [[_playlistController playerController] mainVideoOutputThread];
> + vout_thread_t *p_vout = [_playerController mainVideoOutputThread];
> if (p_vout) {
> vout_OSDMessage(p_vout, VOUT_SPU_CHANNEL_OSD, "%s", _("Repeat One"));
> vout_Release(p_vout);
> @@ -420,7 +420,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
> {
> _playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_NONE;
>
> - vout_thread_t *p_vout = [[_playlistController playerController] mainVideoOutputThread];
> + vout_thread_t *p_vout = [_playerController mainVideoOutputThread];
> if (p_vout) {
> vout_OSDMessage(p_vout, VOUT_SPU_CHANNEL_OSD, "%s", _("Repeat Off"));
> vout_Release(p_vout);
> @@ -574,7 +574,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
>
> - (void)showPosition
> {
> - vout_thread_t *p_vout = [[_playlistController playerController] mainVideoOutputThread];
> + vout_thread_t *p_vout = [_playerController mainVideoOutputThread];
> if (p_vout != NULL) {
> var_SetInteger(vlc_object_instance(getIntf()), "key-action", ACTIONID_POSITION);
> vout_Release(p_vout);
> @@ -678,7 +678,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
> unichar key = [characters characterAtIndex: 0];
>
> if (key) {
> - vout_thread_t *p_vout = [[_playlistController playerController] mainVideoOutputThread];
> + vout_thread_t *p_vout = [_playerController mainVideoOutputThread];
> if (p_vout != NULL) {
> /* Escape */
> if (key == (unichar) 0x1b) {
> diff --git a/modules/gui/macosx/menus/VLCMainMenu.m b/modules/gui/macosx/menus/VLCMainMenu.m
> index 5f91103146..41359c320f 100644
> --- a/modules/gui/macosx/menus/VLCMainMenu.m
> +++ b/modules/gui/macosx/menus/VLCMainMenu.m
> @@ -585,7 +585,7 @@
> [self setupVarMenuItem:_subtitle_track target: (vlc_object_t *)p_input
> var:"spu-es" selector: @selector(toggleVar:)];
>
> - audio_output_t *p_aout = _playlistController.playerController.mainAudioOutput;
> + audio_output_t *p_aout = [_playerController mainAudioOutput];
> if (p_aout != NULL) {
> [self setupVarMenuItem:_channels target: (vlc_object_t *)p_aout
> var:"stereo-mode" selector: @selector(toggleVar:)];
> @@ -595,7 +595,7 @@
> aout_Release(p_aout);
> }
>
> - vout_thread_t *p_vout = [[[[VLCMain sharedInstance] playlistController] playerController] videoOutputThreadForKeyWindow];
> + vout_thread_t *p_vout = [_playerController videoOutputThreadForKeyWindow];
>
> if (p_vout != NULL) {
> [self setupVarMenuItem:_aspect_ratio target: (vlc_object_t *)p_vout
> @@ -886,7 +886,7 @@
>
> [_audioDeviceMenu removeAllItems];
>
> - audio_output_t *p_aout = _playlistController.playerController.mainAudioOutput;
> + audio_output_t *p_aout = [_playerController mainAudioOutput];
> if (!p_aout)
> return;
>
> @@ -923,7 +923,7 @@
>
> - (void)toggleAudioDevice:(id)sender
> {
> - audio_output_t *p_aout = _playlistController.playerController.mainAudioOutput;
> + audio_output_t *p_aout = [_playerController mainAudioOutput];
> if (!p_aout)
> return;
>
> @@ -950,7 +950,7 @@
>
> - (IBAction)resizeVideoWindow:(id)sender
> {
> - vout_thread_t *p_vout = [[[[VLCMain sharedInstance] playlistController] playerController] videoOutputThreadForKeyWindow];
> + vout_thread_t *p_vout = [_playerController videoOutputThreadForKeyWindow];
> if (p_vout) {
> if (sender == _half_window)
> var_SetFloat(p_vout, "zoom", 0.5);
> @@ -971,7 +971,7 @@
> // FIXME re-write using VLCPlayerController
> input_thread_t *p_input = pl_CurrentInput(getIntf());
> if (p_input) {
> - vout_thread_t *p_vout = [[[[VLCMain sharedInstance] playlistController] playerController] videoOutputThreadForKeyWindow];
> + vout_thread_t *p_vout = [_playerController videoOutputThreadForKeyWindow];
> if (p_vout) {
> BOOL b_fs = var_ToggleBool(p_vout, "video-on-top");
> var_SetBool(pl_Get(getIntf()), "video-on-top", b_fs);
> @@ -1664,7 +1664,7 @@
> mi == _floatontop
> ) {
>
> - vout_thread_t *p_vout = [[[[VLCMain sharedInstance] playlistController] playerController] videoOutputThreadForKeyWindow];
> + vout_thread_t *p_vout = [_playerController videoOutputThreadForKeyWindow];
> if (p_vout != NULL) {
> // FIXME: re-write using VLCPlayerController
> if (mi == _floatontop)
> diff --git a/modules/gui/macosx/panels/VLCAudioEffectsWindowController.m b/modules/gui/macosx/panels/VLCAudioEffectsWindowController.m
> index 87ee801b92..010ca22df5 100644
> --- a/modules/gui/macosx/panels/VLCAudioEffectsWindowController.m
> +++ b/modules/gui/macosx/panels/VLCAudioEffectsWindowController.m
> @@ -41,6 +41,11 @@
> #import "playlist/VLCPlaylistController.h"
> #import "playlist/VLCPlayerController.h"
>
> + at interface VLCAudioEffectsWindowController ()
> +{
> + VLCPlayerController *_playerController;
> +}
> + at end
>
> #pragma mark -
> #pragma mark Initialization
> @@ -96,6 +101,8 @@
> {
> self = [super initWithWindowNibName:@"AudioEffects"];
> if (self) {
> + _playerController = [[[VLCMain sharedInstance] playlistController] playerController];
> +
Hi Felix,
Does this actually works for you?
On my machine, now VLC immediately crashes at startup like that:
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [6895]
Application Specific Information:
BUG IN CLIENT OF LIBDISPATCH: trying to lock recursively
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libdispatch.dylib 0x00007fff7c0c08c3 _dispatch_once_wait + 97
1 libmacosx_plugin.dylib 0x00000001068f2be4 +[VLCMain sharedInstance] + 84 (once.h:85)
2 libmacosx_plugin.dylib 0x000000010691a590 -[VLCAudioEffectsWindowController init] + 128 (VLCAudioEffectsWindowController.m:104)
3 libmacosx_plugin.dylib 0x00000001068f30a9 -[VLCMain init] + 1033
4 libmacosx_plugin.dylib 0x00000001068f2c44 __25+[VLCMain sharedInstance]_block_invoke + 52 (VLCMain.m:211)
5 libdispatch.dylib 0x00007fff7c0bfdcf _dispatch_client_callout + 8
6 libdispatch.dylib 0x00007fff7c0c1515 _dispatch_once_callout + 20
7 libmacosx_plugin.dylib 0x00000001068f2be4 +[VLCMain sharedInstance] + 84 (once.h:85)
8 libmacosx_plugin.dylib 0x00000001068f2788 OpenIntf + 184 (VLCMain.m:105)
9 libvlccore.dylib 0x000000010668573b generic_start + 139 (modules.c:258)
10 libvlccore.dylib 0x00000001066853e6 module_load + 166
11 libvlccore.dylib 0x0000000106684fce vlc_module_load + 958 (modules.c:194)
12 libvlccore.dylib 0x000000010668563b module_need + 91 (modules.c:277)
13 libvlccore.dylib 0x000000010668f88e intf_CreateInternal + 782 (interface.c:193)
14 libvlccore.dylib 0x000000010668fd41 libvlc_InternalAddIntf + 257 (interface.c:297)
15 libvlc.dylib 0x0000000106629ef0 libvlc_add_intf + 32 (playlist.c:43)
16 org.videolan.vlc 0x000000010661e667 main + 1767 (darwinvlc.m:285)
17 libdyld.dylib 0x00007fff7c10ded9 start + 1
BR. David
> self.popupPanel = [[VLCPopupPanelController alloc] init];
> self.textfieldPanel = [[VLCTextfieldPanelController alloc] init];
>
> @@ -153,7 +160,7 @@
>
> /* eq preset */
> char const *psz_eq_preset = [B64DecNSStr([items firstObject]) UTF8String];
> - audio_output_t *p_aout = [[[[VLCMain sharedInstance] playlistController] playerController] mainAudioOutput];
> + audio_output_t *p_aout = [_playerController mainAudioOutput];
> if (p_aout)
> var_SetString(p_aout, "equalizer-preset", psz_eq_preset);
> var_SetString(p_playlist, "equalizer-preset", psz_eq_preset);
> @@ -609,10 +616,11 @@
> #pragma mark -
> #pragma mark Equalizer
> static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
> + VLCPlayerController *playerController,
> char *psz_name)
> {
> char *psz_parser, *psz_string = NULL;
> - audio_output_t *p_aout = [[[[VLCMain sharedInstance] playlistController] playerController] mainAudioOutput];
> + audio_output_t *p_aout = [playerController mainAudioOutput];
> if (!p_aout)
> return false;
>
> @@ -654,7 +662,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
> [[_equalizerPresetsPopup lastItem] setAction: @selector(deletePresetAction:)];
> }
>
> - audio_output_t *p_aout = [[[[VLCMain sharedInstance] playlistController] playerController] mainAudioOutput];
> + audio_output_t *p_aout = [_playerController mainAudioOutput];
>
> NSString *currentPreset = nil;
> if (p_aout) {
> @@ -684,7 +692,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
> intf_thread_t *p_intf = getIntf();
> playlist_t *p_playlist = pl_Get(p_intf);
> bool b_2p = var_CreateGetBool(p_playlist, "equalizer-2pass");
> - bool bEnabled = GetEqualizerStatus(p_intf, (char *)"equalizer");
> + bool bEnabled = GetEqualizerStatus(p_intf, _playerController, (char *)"equalizer");
>
> /* Setup sliders */
> var_Create(p_playlist, "equalizer-preset",
> @@ -758,7 +766,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
>
> - (IBAction)equalizerBandSliderUpdated:(id)sender
> {
> - audio_output_t *p_aout = [[[[VLCMain sharedInstance] playlistController] playerController] mainAudioOutput];
> + audio_output_t *p_aout = [_playerController mainAudioOutput];
> char const *psz_preset_values = [[self generatePresetString] UTF8String];
> if (p_aout) {
> var_SetString(p_aout, "equalizer-bands", psz_preset_values);
> @@ -776,7 +784,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
> float f_eq_preamp = [[[defaults objectForKey:@"EQPreampValues"] objectAtIndex:numberOfChosenPreset] floatValue];
> char const *psz_eq_preset = [[[defaults objectForKey:@"EQNames"] objectAtIndex:numberOfChosenPreset] UTF8String];
>
> - audio_output_t *p_aout = [[[[VLCMain sharedInstance] playlistController] playerController] mainAudioOutput];
> + audio_output_t *p_aout = [_playerController mainAudioOutput];
> if (p_aout) {
> var_SetString(p_aout, "equalizer-bands", psz_eq_bands);
> var_SetFloat(p_aout, "equalizer-preamp", f_eq_preamp);
> @@ -796,7 +804,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
> {
> float fPreamp = [sender floatValue] ;
>
> - audio_output_t *p_aout = [[[[VLCMain sharedInstance] playlistController] playerController] mainAudioOutput];
> + audio_output_t *p_aout = [_playerController mainAudioOutput];
> if (p_aout) {
> var_SetFloat(p_aout, "equalizer-preamp", fPreamp);
> aout_Release(p_aout);
> @@ -808,7 +816,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
> {
> bool b_2p = [sender state] ? true : false;
>
> - audio_output_t *p_aout = [[[[VLCMain sharedInstance] playlistController] playerController] mainAudioOutput];
> + audio_output_t *p_aout = [_playerController mainAudioOutput];
> if (p_aout) {
> var_SetBool(p_aout, "equalizer-2pass", b_2p);
> aout_Release(p_aout);
> @@ -850,7 +858,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
>
> /* update VLC internals */
> char const *psz_eq_preset = [decomposedStringWithCanonicalMapping UTF8String];
> - audio_output_t *p_aout = [[[[VLCMain sharedInstance] playlistController] playerController] mainAudioOutput];
> + audio_output_t *p_aout = [self->_playerController mainAudioOutput];
> if (p_aout) {
> var_SetString(p_aout, "equalizer-preset", psz_eq_preset);
> aout_Release(p_aout);
> @@ -943,7 +951,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
> var_SetFloat(p_playlist, "compressor-knee", 2.500000);
> var_SetFloat(p_playlist, "compressor-makeup-gain", 7.000000);
>
> - audio_output_t *p_aout = [[[[VLCMain sharedInstance] playlistController] playerController] mainAudioOutput];
> + audio_output_t *p_aout = [_playerController mainAudioOutput];
> if (p_aout) {
> var_SetFloat(p_aout, "compressor-rms-peak", 0.000000);
> var_SetFloat(p_aout, "compressor-attack", 25.000000);
> @@ -985,7 +993,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
>
> assert(psz_property);
>
> - audio_output_t *p_aout = [[[[VLCMain sharedInstance] playlistController] playerController] mainAudioOutput];
> + audio_output_t *p_aout = [_playerController mainAudioOutput];
> if (p_aout) {
> var_SetFloat(p_aout, psz_property, f_value);
> aout_Release(p_aout);
> @@ -1047,7 +1055,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
> var_SetFloat(p_playlist, "spatializer-dry", .5);
> var_SetFloat(p_playlist, "spatializer-damp", .5);
>
> - audio_output_t *p_aout = [[[[VLCMain sharedInstance] playlistController] playerController] mainAudioOutput];
> + audio_output_t *p_aout = [_playerController mainAudioOutput];
> if (p_aout) {
> var_SetFloat(p_aout, "spatializer-roomsize", .85);
> var_SetFloat(p_aout, "spatializer-width", 1.);
> @@ -1083,7 +1091,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
>
> assert(psz_property);
>
> - audio_output_t *p_aout = [[[[VLCMain sharedInstance] playlistController] playerController] mainAudioOutput];
> + audio_output_t *p_aout = [_playerController mainAudioOutput];
> if (p_aout) {
> var_SetFloat(p_aout, psz_property, f_value / 10.f);
> aout_Release(p_aout);
> @@ -1145,7 +1153,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
>
> - (IBAction)filterVolumeNormSliderUpdated:(id)sender
> {
> - audio_output_t *p_aout = [[[[VLCMain sharedInstance] playlistController] playerController] mainAudioOutput];
> + audio_output_t *p_aout = [_playerController mainAudioOutput];
> float f_value = [_filterNormLevelSlider floatValue];
>
> if (p_aout) {
> diff --git a/modules/gui/macosx/panels/VLCVideoEffectsWindowController.m b/modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
> index 3779afc949..6b2ad1a9a5 100644
> --- a/modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
> +++ b/modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
> @@ -115,21 +115,23 @@
>
> /* enable the new filters */
> var_SetString(p_playlist, "video-filter", [tempString UTF8String]);
> - if (vouts)
> + if (vouts) {
> for (NSValue *ptr in vouts) {
> vout_thread_t *p_vout = [ptr pointerValue];
> var_SetString(p_vout, "video-filter", [tempString UTF8String]);
> }
> + }
>
> tempString = B64DecNSStr([items objectAtIndex:1]);
> /* enable another round of new filters */
> var_SetString(p_playlist, "sub-source", [tempString UTF8String]);
> - if (vouts)
> + if (vouts) {
> for (NSValue *ptr in vouts) {
> vout_thread_t *p_vout = [ptr pointerValue];
> var_SetString(p_vout, "sub-source", [tempString UTF8String]);
> vout_Release(p_vout);
> }
> + }
>
> tempString = B64DecNSStr([items objectAtIndex:2]);
> /* enable another round of new filters */
>
> _______________________________________________
> vlc-commits mailing list
> vlc-commits at videolan.org
> https://mailman.videolan.org/listinfo/vlc-commits
More information about the vlc-devel
mailing list