1
1
mirror of https://github.com/bitgapp/eqMac.git synced 2024-11-22 22:32:17 +03:00

Now EQ will resume as normal after waking up from sleep

This commit is contained in:
Romans Kisils 2017-08-02 19:50:36 +01:00
parent fe6afdf2ab
commit a31e2bc8c9
2 changed files with 27 additions and 2 deletions

View File

@ -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]){

View File

@ -198,7 +198,7 @@ static NSDate *runStart;
AudioObjectGetPropertyDataSize(pluginID, &pluginAOPA, 0, NULL, &outDataSize);
AudioObjectGetPropertyData(pluginID, &pluginAOPA, 0, NULL, &outDataSize, &ID);
passthroughDeviceID = 0;
return;
}