]> git.sesse.net Git - vlc/commitdiff
macosx: implement 120% volume limit
authorFelix Paul Kühne <fkuehne@videolan.org>
Thu, 20 Jun 2013 23:06:22 +0000 (01:06 +0200)
committerDavid Fuhrmann <david.fuhrmann@googlemail.com>
Tue, 23 Jul 2013 18:17:00 +0000 (20:17 +0200)
This patch doesn't stop you from going above the limit using the hotkeys or the Apple Remote

modules/gui/macosx/ControlsBar.h
modules/gui/macosx/ControlsBar.m
modules/gui/macosx/CoreInteraction.h
modules/gui/macosx/CoreInteraction.m
modules/gui/macosx/misc.h
modules/gui/macosx/misc.m

index a62cfb01f9d467c2bd7b1f085d0b2a195015c902..d7637c2ed6525c2d701f921238ef936cc45b002d 100644 (file)
@@ -24,6 +24,7 @@
 
 #import <Cocoa/Cocoa.h>
 #import "CompatibilityFixes.h"
+#import "misc.h"
 
 @class VLCFSPanel;
 
     IBOutlet id o_repeat_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_down_btn;
     IBOutlet id o_volume_up_btn;
index d310b1db98c6cda5a9fbd2a7d04de7d726672c11..8fec32af017e356d2886954b888b7f298659dca0 100644 (file)
         [o_volume_down_btn setImage: [NSImage imageNamed:@"volume-low"]];
         [o_volume_track_view setImage: [NSImage imageNamed:@"volume-slider-track"]];
         [o_volume_up_btn setImage: [NSImage imageNamed:@"volume-high"]];
+        [o_volume_sld setUsesBrightArtwork: YES];
 
         if (b_nativeFullscreenMode) {
             [o_effects_btn setImage: [NSImage imageNamed:@"effects-one-button"]];
         [o_volume_down_btn setImage: [NSImage imageNamed:@"volume-low_dark"]];
         [o_volume_track_view setImage: [NSImage imageNamed:@"volume-slider-track_dark"]];
         [o_volume_up_btn setImage: [NSImage imageNamed:@"volume-high_dark"]];
+        [o_volume_sld setUsesBrightArtwork: NO];
 
         if (b_nativeFullscreenMode) {
             [o_effects_btn setImage: [NSImage imageNamed:@"effects-one-button_dark"]];
 
     BOOL b_mute = ![[VLCCoreInteraction sharedInstance] mute];
     [o_volume_sld setEnabled: b_mute];
+    [o_volume_sld setMaxValue: [[VLCCoreInteraction sharedInstance] maxVolume]];
     [o_volume_up_btn setEnabled: b_mute];
 
-
     // remove fullscreen button for lion fullscreen
     if (b_nativeFullscreenMode) {
         NSRect frame;
index 2db0a04c2d7f3ac569b07121570f5feacf84c452..ff67327e06f079506c9efc31205596e1d84aa231 100644 (file)
@@ -31,6 +31,7 @@
 }
 + (VLCCoreInteraction *)sharedInstance;
 @property (readwrite) int volume;
+@property (readonly, nonatomic) float maxVolume;
 @property (readwrite) int playbackRate;
 @property (nonatomic, readwrite) BOOL aspectRatioIsLocked;
 @property (readonly) int durationOfCurrentPlaylistItem;
index ff2155aa0f98ac3f5b64ab6e9a1de4af392723db..561c2558e11a57fe62383ead8a85c099c7d97c7b 100644 (file)
@@ -538,6 +538,7 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
         return 0;
 
     float volume = playlist_VolumeGet(pl_Get(p_intf));
+    NSLog(@"return vol %f", volume);
 
     return lroundf(volume * AOUT_VOLUME_DEFAULT);
 }
@@ -548,11 +549,20 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
     if (!p_intf)
         return;
 
+    if (i_value >= self.maxVolume)
+        i_value = self.maxVolume;
+
     float f_value = i_value / (float)AOUT_VOLUME_DEFAULT;
+    NSLog( @"set vol %f", f_value);
 
     playlist_VolumeSet(pl_Get(p_intf), f_value);
 }
 
+- (float)maxVolume
+{
+    return 1.2 * AOUT_VOLUME_DEFAULT;
+}
+
 #pragma mark -
 #pragma mark drag and drop support for VLCVoutView, VLBrushedMetalImageView and VLCThreePartDropView
 - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
index 366d0e9e28b89639e1e0bf75b97ee2ce6b5f4901..81c81ab21734257f3fba9cdbd7d20015475cae1d 100644 (file)
 @interface VLCVolumeSliderCommon : NSSlider
 {
     BOOL _usesBrightArtwork;
+    CGFloat _maximumVolume;
 }
 @property (readwrite, nonatomic) BOOL usesBrightArtwork;
 
index 832f7d7b40abfe8c234b9e56506c1dbd68e6112a..a24d8f64615ff0d713e6ec394f051593d76606e5 100644 (file)
@@ -556,8 +556,13 @@ void _drawFrameInRect(NSRect frameRect)
         drawingColor = [[NSColor blackColor] colorWithAlphaComponent:.6];
 
     NSBezierPath* bezierPath = [NSBezierPath bezierPath];
-
     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 lineToPoint:NSMakePoint(fullVolPos, 3.)];
     [bezierPath closePath];