[vlc-commits] macosx: implement 120% volume limit
Felix Paul Kühne
git at videolan.org
Tue Jul 23 20:19:12 CEST 2013
vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Fri Jun 21 01:06:22 2013 +0200| [66bf1c6ef19eb62e24a05780ff876c4e1aa282f1] | committer: 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
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=66bf1c6ef19eb62e24a05780ff876c4e1aa282f1
---
modules/gui/macosx/ControlsBar.h | 3 ++-
modules/gui/macosx/ControlsBar.m | 4 +++-
modules/gui/macosx/CoreInteraction.h | 1 +
modules/gui/macosx/CoreInteraction.m | 10 ++++++++++
modules/gui/macosx/misc.h | 1 +
modules/gui/macosx/misc.m | 7 ++++++-
6 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/modules/gui/macosx/ControlsBar.h b/modules/gui/macosx/ControlsBar.h
index a62cfb0..d7637c2 100644
--- a/modules/gui/macosx/ControlsBar.h
+++ b/modules/gui/macosx/ControlsBar.h
@@ -24,6 +24,7 @@
#import <Cocoa/Cocoa.h>
#import "CompatibilityFixes.h"
+#import "misc.h"
@class VLCFSPanel;
@@ -103,7 +104,7 @@
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;
diff --git a/modules/gui/macosx/ControlsBar.m b/modules/gui/macosx/ControlsBar.m
index d310b1d..8fec32a 100644
--- a/modules/gui/macosx/ControlsBar.m
+++ b/modules/gui/macosx/ControlsBar.m
@@ -483,6 +483,7 @@
[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"]];
@@ -514,6 +515,7 @@
[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"]];
@@ -533,9 +535,9 @@
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;
diff --git a/modules/gui/macosx/CoreInteraction.h b/modules/gui/macosx/CoreInteraction.h
index 2db0a04..ff67327 100644
--- a/modules/gui/macosx/CoreInteraction.h
+++ b/modules/gui/macosx/CoreInteraction.h
@@ -31,6 +31,7 @@
}
+ (VLCCoreInteraction *)sharedInstance;
@property (readwrite) int volume;
+ at property (readonly, nonatomic) float maxVolume;
@property (readwrite) int playbackRate;
@property (nonatomic, readwrite) BOOL aspectRatioIsLocked;
@property (readonly) int durationOfCurrentPlaylistItem;
diff --git a/modules/gui/macosx/CoreInteraction.m b/modules/gui/macosx/CoreInteraction.m
index ff2155a..561c255 100644
--- a/modules/gui/macosx/CoreInteraction.m
+++ b/modules/gui/macosx/CoreInteraction.m
@@ -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
diff --git a/modules/gui/macosx/misc.h b/modules/gui/macosx/misc.h
index 366d0e9..81c81ab 100644
--- a/modules/gui/macosx/misc.h
+++ b/modules/gui/macosx/misc.h
@@ -123,6 +123,7 @@
@interface VLCVolumeSliderCommon : NSSlider
{
BOOL _usesBrightArtwork;
+ CGFloat _maximumVolume;
}
@property (readwrite, nonatomic) BOOL usesBrightArtwork;
diff --git a/modules/gui/macosx/misc.m b/modules/gui/macosx/misc.m
index 832f7d7..a24d8f6 100644
--- a/modules/gui/macosx/misc.m
+++ b/modules/gui/macosx/misc.m
@@ -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];
More information about the vlc-commits
mailing list