Fix problem setting pan to -1

This commit is contained in:
Marcus Wu 2021-03-30 09:42:50 -04:00
parent c7df7506bc
commit e9e13a3056
4 changed files with 8 additions and 8 deletions

View file

@ -36,7 +36,7 @@
bgmMenu:(NSMenu*)inMenu
appVolumeView:(NSView*)inView;
// Pass -1 for initialVolume or initialPan to leave the volume/pan at its default level.
// Pass -1 for initialVolume or INT_MAX for initialPan to leave the volume/pan at its default level.
- (void) insertMenuItemForApp:(NSRunningApplication*)app
initialVolume:(int)volume
initialPan:(int)pan;

View file

@ -153,7 +153,7 @@ static NSString* const kMoreAppsMenuTitle = @"More Apps";
- (BGMAppVolumeAndPan) getVolumeAndPanForApp:(NSRunningApplication*)app {
BGMAppVolumeAndPan result = {
.volume = -1,
.pan = -1
.pan = INT_MIN
};
NSMenuItem *item = [self getMenuItemForApp:app];
@ -191,7 +191,7 @@ static NSString* const kMoreAppsMenuTitle = @"More Apps";
}
// Set the pan position.
if (volumeAndPan.pan != -1 && [subview isKindOfClass:[BGMAVM_PanSlider class]]) {
if (volumeAndPan.pan != INT_MIN && [subview isKindOfClass:[BGMAVM_PanSlider class]]) {
[(BGMAVM_PanSlider*)subview setPanPosition:volumeAndPan.pan];
}
}
@ -217,7 +217,7 @@ static NSString* const kMoreAppsMenuTitle = @"More Apps";
}
// Set the pan position.
if (pan != -1 && [subview isKindOfClass:[BGMAVM_PanSlider class]]) {
if (pan != INT_MIN && [subview isKindOfClass:[BGMAVM_PanSlider class]]) {
[(BGMAVM_PanSlider*)subview setPanPosition:pan];
}
}

View file

@ -106,10 +106,10 @@
- (void) setVolumeAndPan:(BGMAppVolumeAndPan)volumeAndPan forApp:(NSRunningApplication*)app {
[appVolumes setVolumeAndPan:volumeAndPan forApp:app];
if (volumeAndPan.volume != -1) {
if (volumeAndPan.volume != -1 {
[self setVolume:volumeAndPan.volume forAppWithProcessID:app.processIdentifier bundleID:app.bundleIdentifier];
}
if (volumeAndPan.pan != -1) {
if (volumeAndPan.pan != INT_MIN) {
[self setPanPosition:volumeAndPan.pan forAppWithProcessID:app.processIdentifier bundleID:app.bundleIdentifier];
}
}
@ -118,7 +118,7 @@
fromVolumes:(const CACFArray&)volumes {
BGMAppVolumeAndPan volumeAndPan = {
.volume = -1,
.pan = -1
.pan = INT_MIN
};
for (UInt32 i = 0; i < volumes.GetNumberItems(); i++) {

View file

@ -60,7 +60,7 @@
- (void) setVolume:(int)vol {
BGMAppVolumeAndPan volume = {
.volume = vol,
.pan = -1
.pan = INT_MIN
};
[appVolumesController setVolumeAndPan:volume forApp:application];
}