[vlc-devel] [PATCH 3/3] macosx: remove NSSound+VLCAdditions

Felix Paul Kühne fkuehne at videolan.org
Thu Aug 13 21:49:44 CEST 2020


LGTM for the entire set.

Nice!

> On 5. Aug 2020, at 22:07, Marvin Scholz <epirat07 at gmail.com> wrote:
> 
> ---
> .../macosx/VLC.xcodeproj/project.pbxproj      |   6 -
> modules/gui/macosx/Makefile.am                |   2 -
> .../macosx/extensions/NSSound+VLCAdditions.h  |  39 ------
> .../macosx/extensions/NSSound+VLCAdditions.m  | 113 ------------------
> po/POTFILES.in                                |   2 -
> 5 files changed, 162 deletions(-)
> delete mode 100644 modules/gui/macosx/extensions/NSSound+VLCAdditions.h
> delete mode 100644 modules/gui/macosx/extensions/NSSound+VLCAdditions.m
> 
> diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
> index c92f32226b3..5b51beeb3cd 100644
> --- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj
> +++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
> @@ -86,7 +86,6 @@
> 		6B3BE42C1E6217CB008D098A /* VLCImageButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3BE42B1E6217CB008D098A /* VLCImageButton.m */; };
> 		6B4D50901E79781F004479B5 /* VLCHotkeyChangeWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B4D508F1E79781F004479B5 /* VLCHotkeyChangeWindow.m */; };
> 		6B4D50931E7979CB004479B5 /* VLCSimplePrefsWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B4D50921E7979CB004479B5 /* VLCSimplePrefsWindow.m */; };
> -		6B4D50961E7A7D16004479B5 /* NSSound+VLCAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B4D50951E7A7D16004479B5 /* NSSound+VLCAdditions.m */; };
> 		6B4D50A71E7AB52C004479B5 /* NSScreen+VLCAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B4D50A61E7AB52C004479B5 /* NSScreen+VLCAdditions.m */; };
> 		6B6FFF701EF9EC350001CEB1 /* CompatibilityFixes.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B6FFF6F1EF9EC350001CEB1 /* CompatibilityFixes.m */; };
> 		6B7F1FDF1F07DA920002BDD8 /* VLCHexNumberFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B7F1FDE1F07DA920002BDD8 /* VLCHexNumberFormatter.m */; };
> @@ -244,8 +243,6 @@
> 		6B4D508F1E79781F004479B5 /* VLCHotkeyChangeWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCHotkeyChangeWindow.m; sourceTree = "<group>"; };
> 		6B4D50911E7979CB004479B5 /* VLCSimplePrefsWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCSimplePrefsWindow.h; sourceTree = "<group>"; };
> 		6B4D50921E7979CB004479B5 /* VLCSimplePrefsWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCSimplePrefsWindow.m; sourceTree = "<group>"; };
> -		6B4D50941E7A7D16004479B5 /* NSSound+VLCAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSSound+VLCAdditions.h"; sourceTree = "<group>"; };
> -		6B4D50951E7A7D16004479B5 /* NSSound+VLCAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSSound+VLCAdditions.m"; sourceTree = "<group>"; };
> 		6B4D50A51E7AB52C004479B5 /* NSScreen+VLCAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSScreen+VLCAdditions.h"; sourceTree = "<group>"; };
> 		6B4D50A61E7AB52C004479B5 /* NSScreen+VLCAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSScreen+VLCAdditions.m"; sourceTree = "<group>"; };
> 		6B6A499A1DFD9B23009128AC /* VLCDefaultValueSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCDefaultValueSlider.h; sourceTree = "<group>"; };
> @@ -1012,8 +1009,6 @@
> 			children = (
> 				6B4D50A51E7AB52C004479B5 /* NSScreen+VLCAdditions.h */,
> 				6B4D50A61E7AB52C004479B5 /* NSScreen+VLCAdditions.m */,
> -				6B4D50941E7A7D16004479B5 /* NSSound+VLCAdditions.h */,
> -				6B4D50951E7A7D16004479B5 /* NSSound+VLCAdditions.m */,
> 				6B397C4D216C8EB200403ED0 /* NSString+Helpers.h */,
> 				6B397C4E216C8EB200403ED0 /* NSString+Helpers.m */,
> 				7DE7232C22A51F8C00D72616 /* VLCPositionFormatter.h */,
> @@ -1733,7 +1728,6 @@
> 				6B4D50901E79781F004479B5 /* VLCHotkeyChangeWindow.m in Sources */,
> 				1C3114031E508C8800D4DD76 /* AppleRemote.m in Sources */,
> 				1CFE8D591EA0D42A00E94451 /* VLCErrorWindowController.m in Sources */,
> -				6B4D50961E7A7D16004479B5 /* NSSound+VLCAdditions.m in Sources */,
> 				6BF093F91EE0182B0049D8B0 /* VLCTimeField.m in Sources */,
> 				1C31140D1E508C8800D4DD76 /* SPMediaKeyTap.m in Sources */,
> 				1C3113EF1E508C7600D4DD76 /* VLCRendererDiscovery.m in Sources */,
> diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am
> index 0f7f25b7893..900f09a1ec7 100644
> --- a/modules/gui/macosx/Makefile.am
> +++ b/modules/gui/macosx/Makefile.am
> @@ -40,8 +40,6 @@ libmacosx_plugin_la_SOURCES = \
> 	gui/macosx/extensions/NSMenu+VLCAdditions.m \
> 	gui/macosx/extensions/NSScreen+VLCAdditions.h \
> 	gui/macosx/extensions/NSScreen+VLCAdditions.m \
> -	gui/macosx/extensions/NSSound+VLCAdditions.h \
> -	gui/macosx/extensions/NSSound+VLCAdditions.m \
> 	gui/macosx/extensions/NSString+Helpers.h \
> 	gui/macosx/extensions/NSString+Helpers.m \
> 	gui/macosx/extensions/NSView+VLCAdditions.h \
> diff --git a/modules/gui/macosx/extensions/NSSound+VLCAdditions.h b/modules/gui/macosx/extensions/NSSound+VLCAdditions.h
> deleted file mode 100644
> index fc874bf431c..00000000000
> --- a/modules/gui/macosx/extensions/NSSound+VLCAdditions.h
> +++ /dev/null
> @@ -1,39 +0,0 @@
> -/*****************************************************************************
> - * NSSound+VLCAdditions.h: Category that adds system volume control
> - *****************************************************************************
> - * Copyright (C) 2003-2014 VLC authors and VideoLAN
> - *
> - * Authors: Jon Lech Johansen <jon-vl at nanocrew.net>
> - *          Felix Paul Kühne <fkuehne at videolan dot org>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write to the Free Software
> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
> - *****************************************************************************/
> -
> -#import <Cocoa/Cocoa.h>
> -
> -/* Adds methods to change the system volume, needed for the apple remote code.
> - *
> - * This is simplified code, which won't let you set the exact volume
> - * (that's what the audio output is for after all), but just the system volume
> - * in steps of 1/16 (matching the default AR or volume key implementation).
> - */
> - at interface NSSound (VLCAdditions)
> -
> -+ (float)systemVolumeForChannel:(int)channel;
> -+ (bool)setSystemVolume:(float)volume forChannel:(int)channel;
> -+ (void)increaseSystemVolume;
> -+ (void)decreaseSystemVolume;
> -
> - at end
> diff --git a/modules/gui/macosx/extensions/NSSound+VLCAdditions.m b/modules/gui/macosx/extensions/NSSound+VLCAdditions.m
> deleted file mode 100644
> index 188f11b06d4..00000000000
> --- a/modules/gui/macosx/extensions/NSSound+VLCAdditions.m
> +++ /dev/null
> @@ -1,113 +0,0 @@
> -/*****************************************************************************
> - * NSSound+VLCAdditions.m: Category that adds system volume control
> - *****************************************************************************
> - * Copyright (C) 2003-2014 VLC authors and VideoLAN
> - *
> - * Authors: Jon Lech Johansen <jon-vl at nanocrew.net>
> - *          Felix Paul Kühne <fkuehne at videolan dot org>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write to the Free Software
> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
> - *****************************************************************************/
> -
> -#import "NSSound+VLCAdditions.h"
> -
> -#import <CoreAudio/CoreAudio.h>
> -
> -#import "main/VLCMain.h"
> -
> - at implementation NSSound (VLCAdditions)
> -
> -+ (float)systemVolumeForChannel:(int)channel
> -{
> -    AudioDeviceID i_device;
> -    float f_volume;
> -    OSStatus err;
> -    UInt32 i_size;
> -
> -    i_size = sizeof( i_device );
> -    AudioObjectPropertyAddress deviceAddress = { kAudioHardwarePropertyDefaultOutputDevice, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster };
> -    err = AudioObjectGetPropertyData( kAudioObjectSystemObject, &deviceAddress, 0, NULL, &i_size, &i_device );
> -    if (err != noErr) {
> -        msg_Warn( getIntf(), "couldn't get main audio output device" );
> -        return .0;
> -    }
> -
> -    AudioObjectPropertyAddress propertyAddress = { kAudioDevicePropertyVolumeScalar, kAudioDevicePropertyScopeOutput, channel };
> -    i_size = sizeof( f_volume );
> -    err = AudioObjectGetPropertyData(i_device, &propertyAddress, 0, NULL, &i_size, &f_volume);
> -    if (err != noErr) {
> -        msg_Warn( getIntf(), "couldn't get volume value" );
> -        return .0;
> -    }
> -
> -    return f_volume;
> -}
> -
> -+ (bool)setSystemVolume:(float)f_volume forChannel:(int)i_channel
> -{
> -    /* the following code will fail on S/PDIF devices. there is an easy work-around, but we'd like to match the OS behavior */
> -
> -    AudioDeviceID i_device;
> -    OSStatus err;
> -    UInt32 i_size;
> -    Boolean b_writeable;
> -
> -    i_size = sizeof( i_device );
> -    AudioObjectPropertyAddress deviceAddress = { kAudioHardwarePropertyDefaultOutputDevice, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster };
> -    err = AudioObjectGetPropertyData( kAudioObjectSystemObject, &deviceAddress, 0, NULL, &i_size, &i_device );
> -    if (err != noErr) {
> -        msg_Warn( getIntf(), "couldn't get main audio output device" );
> -        return NO;
> -    }
> -
> -    AudioObjectPropertyAddress propertyAddress = { kAudioDevicePropertyVolumeScalar, kAudioDevicePropertyScopeOutput, i_channel };
> -    i_size = sizeof( f_volume );
> -    err = AudioObjectIsPropertySettable( i_device, &propertyAddress, &b_writeable );
> -    if (err != noErr || !b_writeable ) {
> -        msg_Warn( getIntf(), "we can't set the main audio devices' volume" );
> -        return NO;
> -    }
> -    err = AudioObjectSetPropertyData(i_device, &propertyAddress, 0, NULL, i_size, &f_volume);
> -    if (err != noErr ) {
> -        msg_Warn( getIntf(), "failed to set the main device volume" );
> -        return NO;
> -    }
> -
> -    return YES;
> -}
> -
> -+ (void)increaseSystemVolume
> -{
> -    float f_volume = [NSSound systemVolumeForChannel:1]; // we trust that mono is always available and that all channels got the same volume
> -    f_volume += .0625; // 1/16 to match the OS
> -    bool b_returned = YES;
> -
> -    /* since core audio doesn't provide a reasonable way to see how many channels we got, let's see how long we can do this */
> -    for (int x = 1; b_returned ; x++)
> -        b_returned = [NSSound setSystemVolume: f_volume forChannel:x];
> -}
> -
> -+ (void)decreaseSystemVolume
> -{
> -    float f_volume = [NSSound systemVolumeForChannel:1]; // we trust that mono is always available and that all channels got the same volume
> -    f_volume -= .0625; // 1/16 to match the OS
> -    bool b_returned = YES;
> -
> -    /* since core audio doesn't provide a reasonable way to see how many channels we got, let's see how long we can do this */
> -    for (int x = 1; b_returned ; x++)
> -        b_returned = [NSSound setSystemVolume: f_volume forChannel:x];
> -}
> -
> - at end
> diff --git a/po/POTFILES.in b/po/POTFILES.in
> index 5a39007f798..d5ce9334088 100644
> --- a/po/POTFILES.in
> +++ b/po/POTFILES.in
> @@ -447,8 +447,6 @@ modules/gui/macosx/extensions/NSMenu+VLCAdditions.h
> modules/gui/macosx/extensions/NSMenu+VLCAdditions.m
> modules/gui/macosx/extensions/NSScreen+VLCAdditions.h
> modules/gui/macosx/extensions/NSScreen+VLCAdditions.m
> -modules/gui/macosx/extensions/NSSound+VLCAdditions.h
> -modules/gui/macosx/extensions/NSSound+VLCAdditions.m
> modules/gui/macosx/extensions/NSString+Helpers.h
> modules/gui/macosx/extensions/NSString+Helpers.m
> modules/gui/macosx/extensions/NSView+VLCAdditions.h
> -- 
> 2.24.3 (Apple Git-128)
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list