Skip to content

Commit

Permalink
Revert "FIX : Make jack detection more stable"
Browse files Browse the repository at this point in the history
This reverts commit 0f8023d.
  • Loading branch information
Lorys89 committed May 31, 2024
1 parent fe9175e commit aa1a833
Showing 1 changed file with 10 additions and 31 deletions.
41 changes: 10 additions & 31 deletions Combo Jack/hda-verb.m
Original file line number Diff line number Diff line change
Expand Up @@ -345,27 +345,15 @@ static uint32_t headset(void)

void JackBehavior(void)
{
int counter = 4;

while (run) // Poll headphone jack state
while(run && ((GetJackStatus() & 0x80000000) == 0x80000000)) // Poll headphone jack state
{
usleep(250000); // Polling frequency (seconds): use usleep for microseconds if finer-grained control is needed

sleep(1); // Polling frequency (seconds): use usleep for microseconds if finer-grained control is needed
if (awake)
{
awake = false;
break;
}

if ((GetJackStatus() & 0x80000000) != 0x80000000)
{
if (--counter < 0)
break;
}
else
counter = 4;
}

if (run) // If process is killed, maintain current state
{
if (!isSleeping) {
Expand Down Expand Up @@ -672,39 +660,30 @@ int main(void)
@"Cancel", @"btnCancel",
nil];

int counter = 4;

while(run) // Poll headphone jack state
{
if (!isSleeping){
jackstat = GetJackStatus();
if (jackstat == -1) // 0xFFFFFFFF means jack not ready yet
{
fprintf(stderr, "Jack not ready. Checking again in 1 second...\n");
counter = 4;
}
else if ((jackstat & 0x80000000) == 0x80000000)
{
if (--counter < 0)
fprintf(stderr, "Jack sense detected! Displaying menu...\n");
if (CFPopUpMenu() == 0)
{
fprintf(stderr, "Jack sense detected! Displaying menu...\n");
counter = 4;
if (CFPopUpMenu() == 0)
{
JackBehavior();
}
else
{
break;
}
JackBehavior();
}
else
{
break;
}
}
else
counter = 4;
}

//if (awake) awake = false;
usleep(250000); // Sleep delay (seconds): use usleep for microseconds if fine-grained control is needed
sleep(1); // Sleep delay (seconds): use usleep for microseconds if fine-grained control is needed
}

sem_unlink("ComboJack_Watcher");
Expand Down

0 comments on commit aa1a833

Please sign in to comment.