mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-21 18:52:49 +00:00
PulseAudio: Make FlushLoop more robust
When PA_CONTEXT_READY is called multiple times, PulseAudio::FlusLoop() would get stuck to to integer underflow. Now there are multiple things preventing that. Possible fix for https://github.com/scorpion-26/gBar/issues/7
This commit is contained in:
parent
60b9355e88
commit
0e4b877654
1 changed files with 8 additions and 3 deletions
|
@ -11,14 +11,15 @@ namespace PulseAudio
|
|||
|
||||
static pa_mainloop* mainLoop;
|
||||
static pa_context* context;
|
||||
static uint32_t pending = 0;
|
||||
static int32_t pending = 0;
|
||||
|
||||
inline void FlushLoop()
|
||||
{
|
||||
while (pending)
|
||||
while (pending > 0)
|
||||
{
|
||||
pa_mainloop_iterate(mainLoop, 0, nullptr);
|
||||
}
|
||||
pending = 0;
|
||||
}
|
||||
|
||||
inline void Init()
|
||||
|
@ -41,7 +42,11 @@ namespace PulseAudio
|
|||
case PA_CONTEXT_CONNECTING:
|
||||
// Don't care
|
||||
break;
|
||||
case PA_CONTEXT_READY: pending--; break;
|
||||
case PA_CONTEXT_READY:
|
||||
// Prevent pending from going negative when PA_CONTEXT_READY is called multiple times
|
||||
if (pending > 0)
|
||||
pending--;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue