mirror of
https://github.com/bitgapp/eqMac.git
synced 2024-11-22 22:32:17 +03:00
Merge pull request #25 from romankisil/SleepFix
Now EQ will resume as normal after waking up from sleep
This commit is contained in:
commit
c9f05a2b0f
@ -23,6 +23,7 @@ NSPopover *settingsPopover;
|
||||
NSPopover *eqPopover;
|
||||
NSEvent *eqPopoverTransiencyMonitor;
|
||||
NSEvent *settingsPopoverTransiencyMonitor;
|
||||
NSTimer *deviceWatcher;
|
||||
|
||||
|
||||
@implementation AppDelegate
|
||||
@ -96,7 +97,14 @@ NSEvent *settingsPopoverTransiencyMonitor;
|
||||
[API startPinging];
|
||||
[API sendPresets];
|
||||
|
||||
[Utilities executeBlock:^{
|
||||
[self startWatchingDevices];
|
||||
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(goToSleep) name:NSWorkspaceWillSleepNotification object:NULL];
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(wakeUpFromSleep) name:NSWorkspaceDidWakeNotification object:NULL];
|
||||
}
|
||||
|
||||
-(void)startWatchingDevices{
|
||||
deviceWatcher = [Utilities executeBlock:^{
|
||||
AudioDeviceID selectedDeviceID = [Devices getCurrentDeviceID];
|
||||
if(selectedDeviceID != [EQHost getPassthroughDeviceID]){
|
||||
[EQHost createEQEngineWithOutputDevice: selectedDeviceID];
|
||||
@ -104,6 +112,23 @@ NSEvent *settingsPopoverTransiencyMonitor;
|
||||
} every:1];
|
||||
}
|
||||
|
||||
-(void)goToSleep{
|
||||
[deviceWatcher invalidate];
|
||||
deviceWatcher = nil;
|
||||
[EQHost deleteEQEngine];
|
||||
[Devices switchToDeviceWithID:[EQHost getSelectedOutputDeviceID]];
|
||||
[EQHost detectAndRemoveRoguePassthroughDevice];
|
||||
}
|
||||
|
||||
-(void)wakeUpFromSleep{
|
||||
[self goToSleep]; //just in case
|
||||
|
||||
//delay the start a little so os has time to catchup with the Audio Processing
|
||||
[Utilities executeBlock:^{
|
||||
[self startWatchingDevices];
|
||||
} after:3];
|
||||
}
|
||||
|
||||
-(void)checkAndInstallDriver{
|
||||
if([Devices legacyDriverInstalled]){
|
||||
if(![Devices eqMacDriverInstalled]){
|
||||
|
@ -198,7 +198,7 @@ static NSDate *runStart;
|
||||
AudioObjectGetPropertyDataSize(pluginID, &pluginAOPA, 0, NULL, &outDataSize);
|
||||
|
||||
AudioObjectGetPropertyData(pluginID, &pluginAOPA, 0, NULL, &outDataSize, &ID);
|
||||
|
||||
passthroughDeviceID = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user