fix: fix freeze upon closing Music app
This commit is contained in:
@@ -327,10 +327,18 @@ namespace Drivers::Audio::Mixer {
|
|||||||
if (bitsPerSample != 16) return -1;
|
if (bitsPerSample != 16) return -1;
|
||||||
if (sampleRate < 8000 || sampleRate > 192000) return -1;
|
if (sampleRate < 8000 || sampleRate > 192000) return -1;
|
||||||
|
|
||||||
|
// Allocate the input ring before taking g_lock. Walking the PFA free
|
||||||
|
// list for 16 contiguous pages and zeroing 64 KiB is long enough that
|
||||||
|
// doing it under the lock (with IRQs disabled) lets HDA BCIS IRQs
|
||||||
|
// spin on g_lock on other CPUs — the same hazard that wedged Close().
|
||||||
|
int16_t* ring = AllocRing();
|
||||||
|
if (!ring) return -1;
|
||||||
|
|
||||||
g_lock.Acquire();
|
g_lock.Acquire();
|
||||||
|
|
||||||
if (!EnsureHdaOpen()) {
|
if (!EnsureHdaOpen()) {
|
||||||
g_lock.Release();
|
g_lock.Release();
|
||||||
|
FreeRing(ring);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,16 +348,11 @@ namespace Drivers::Audio::Mixer {
|
|||||||
}
|
}
|
||||||
if (slot < 0) {
|
if (slot < 0) {
|
||||||
g_lock.Release();
|
g_lock.Release();
|
||||||
|
FreeRing(ring);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
VirtualStream& s = g_streams[slot];
|
VirtualStream& s = g_streams[slot];
|
||||||
int16_t* ring = AllocRing();
|
|
||||||
if (!ring) {
|
|
||||||
g_lock.Release();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
s.active = true;
|
s.active = true;
|
||||||
s.ownerPid = ownerPid;
|
s.ownerPid = ownerPid;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user