Commit 66bf1c6e authored by Felix Paul Kühne's avatar Felix Paul Kühne Committed by David Fuhrmann

macosx: implement 120% volume limit

This patch doesn't stop you from going above the limit using the hotkeys or the Apple Remote
parent ba8cad3a
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "CompatibilityFixes.h" #import "CompatibilityFixes.h"
#import "misc.h"
@class VLCFSPanel; @class VLCFSPanel;
...@@ -103,7 +104,7 @@ ...@@ -103,7 +104,7 @@
IBOutlet id o_repeat_btn; IBOutlet id o_repeat_btn;
IBOutlet id o_shuffle_btn; IBOutlet id o_shuffle_btn;
IBOutlet id o_volume_sld; IBOutlet VLCVolumeSliderCommon * o_volume_sld;
IBOutlet id o_volume_track_view; IBOutlet id o_volume_track_view;
IBOutlet id o_volume_down_btn; IBOutlet id o_volume_down_btn;
IBOutlet id o_volume_up_btn; IBOutlet id o_volume_up_btn;
......
...@@ -483,6 +483,7 @@ ...@@ -483,6 +483,7 @@
[o_volume_down_btn setImage: [NSImage imageNamed:@"volume-low"]]; [o_volume_down_btn setImage: [NSImage imageNamed:@"volume-low"]];
[o_volume_track_view setImage: [NSImage imageNamed:@"volume-slider-track"]]; [o_volume_track_view setImage: [NSImage imageNamed:@"volume-slider-track"]];
[o_volume_up_btn setImage: [NSImage imageNamed:@"volume-high"]]; [o_volume_up_btn setImage: [NSImage imageNamed:@"volume-high"]];
[o_volume_sld setUsesBrightArtwork: YES];
if (b_nativeFullscreenMode) { if (b_nativeFullscreenMode) {
[o_effects_btn setImage: [NSImage imageNamed:@"effects-one-button"]]; [o_effects_btn setImage: [NSImage imageNamed:@"effects-one-button"]];
...@@ -514,6 +515,7 @@ ...@@ -514,6 +515,7 @@
[o_volume_down_btn setImage: [NSImage imageNamed:@"volume-low_dark"]]; [o_volume_down_btn setImage: [NSImage imageNamed:@"volume-low_dark"]];
[o_volume_track_view setImage: [NSImage imageNamed:@"volume-slider-track_dark"]]; [o_volume_track_view setImage: [NSImage imageNamed:@"volume-slider-track_dark"]];
[o_volume_up_btn setImage: [NSImage imageNamed:@"volume-high_dark"]]; [o_volume_up_btn setImage: [NSImage imageNamed:@"volume-high_dark"]];
[o_volume_sld setUsesBrightArtwork: NO];
if (b_nativeFullscreenMode) { if (b_nativeFullscreenMode) {
[o_effects_btn setImage: [NSImage imageNamed:@"effects-one-button_dark"]]; [o_effects_btn setImage: [NSImage imageNamed:@"effects-one-button_dark"]];
...@@ -533,9 +535,9 @@ ...@@ -533,9 +535,9 @@
BOOL b_mute = ![[VLCCoreInteraction sharedInstance] mute]; BOOL b_mute = ![[VLCCoreInteraction sharedInstance] mute];
[o_volume_sld setEnabled: b_mute]; [o_volume_sld setEnabled: b_mute];
[o_volume_sld setMaxValue: [[VLCCoreInteraction sharedInstance] maxVolume]];
[o_volume_up_btn setEnabled: b_mute]; [o_volume_up_btn setEnabled: b_mute];
// remove fullscreen button for lion fullscreen // remove fullscreen button for lion fullscreen
if (b_nativeFullscreenMode) { if (b_nativeFullscreenMode) {
NSRect frame; NSRect frame;
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
} }
+ (VLCCoreInteraction *)sharedInstance; + (VLCCoreInteraction *)sharedInstance;
@property (readwrite) int volume; @property (readwrite) int volume;
@property (readonly, nonatomic) float maxVolume;
@property (readwrite) int playbackRate; @property (readwrite) int playbackRate;
@property (nonatomic, readwrite) BOOL aspectRatioIsLocked; @property (nonatomic, readwrite) BOOL aspectRatioIsLocked;
@property (readonly) int durationOfCurrentPlaylistItem; @property (readonly) int durationOfCurrentPlaylistItem;
......
...@@ -538,6 +538,7 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -538,6 +538,7 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
return 0; return 0;
float volume = playlist_VolumeGet(pl_Get(p_intf)); float volume = playlist_VolumeGet(pl_Get(p_intf));
NSLog(@"return vol %f", volume);
return lroundf(volume * AOUT_VOLUME_DEFAULT); return lroundf(volume * AOUT_VOLUME_DEFAULT);
} }
...@@ -548,11 +549,20 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -548,11 +549,20 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
if (!p_intf) if (!p_intf)
return; return;
if (i_value >= self.maxVolume)
i_value = self.maxVolume;
float f_value = i_value / (float)AOUT_VOLUME_DEFAULT; float f_value = i_value / (float)AOUT_VOLUME_DEFAULT;
NSLog( @"set vol %f", f_value);
playlist_VolumeSet(pl_Get(p_intf), f_value); playlist_VolumeSet(pl_Get(p_intf), f_value);
} }
- (float)maxVolume
{
return 1.2 * AOUT_VOLUME_DEFAULT;
}
#pragma mark - #pragma mark -
#pragma mark drag and drop support for VLCVoutView, VLBrushedMetalImageView and VLCThreePartDropView #pragma mark drag and drop support for VLCVoutView, VLBrushedMetalImageView and VLCThreePartDropView
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
......
...@@ -123,6 +123,7 @@ ...@@ -123,6 +123,7 @@
@interface VLCVolumeSliderCommon : NSSlider @interface VLCVolumeSliderCommon : NSSlider
{ {
BOOL _usesBrightArtwork; BOOL _usesBrightArtwork;
CGFloat _maximumVolume;
} }
@property (readwrite, nonatomic) BOOL usesBrightArtwork; @property (readwrite, nonatomic) BOOL usesBrightArtwork;
......
...@@ -556,8 +556,13 @@ void _drawFrameInRect(NSRect frameRect) ...@@ -556,8 +556,13 @@ void _drawFrameInRect(NSRect frameRect)
drawingColor = [[NSColor blackColor] colorWithAlphaComponent:.6]; drawingColor = [[NSColor blackColor] colorWithAlphaComponent:.6];
NSBezierPath* bezierPath = [NSBezierPath bezierPath]; NSBezierPath* bezierPath = [NSBezierPath bezierPath];
float fullVolPos = frame.size.width / 2.; float fullVolPos = frame.size.width / 2.;
CGFloat maxAudioVol = self.maxValue / AOUT_VOLUME_DEFAULT;
if ((maxAudioVol - 1.) > 0)
fullVolPos += ((maxAudioVol - 1.) * 2000) / fullVolPos;
[bezierPath moveToPoint:NSMakePoint(fullVolPos, frame.size.height - 3.)]; [bezierPath moveToPoint:NSMakePoint(fullVolPos, frame.size.height - 3.)];
[bezierPath lineToPoint:NSMakePoint(fullVolPos, 3.)]; [bezierPath lineToPoint:NSMakePoint(fullVolPos, 3.)];
[bezierPath closePath]; [bezierPath closePath];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment