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

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 @@
#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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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
......
......@@ -123,6 +123,7 @@
@interface VLCVolumeSliderCommon : NSSlider
{
BOOL _usesBrightArtwork;
CGFloat _maximumVolume;
}
@property (readwrite, nonatomic) BOOL usesBrightArtwork;
......
......@@ -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];
......
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