]> git.ipfire.org Git - thirdparty/qemu.git/commit
coreaudio: Lock only the buffer
authorAkihiko Odaki <akihiko.odaki@gmail.com>
Tue, 22 Jun 2021 20:17:40 +0000 (05:17 +0900)
committerGerd Hoffmann <kraxel@redhat.com>
Wed, 23 Jun 2021 12:16:48 +0000 (14:16 +0200)
commiteb1a35e47aff9bda70d74874241e7966f800f4e3
treee8e191190ba9cde13fb9586576fc613b796ac111
parentb22726abdfa54592d6ad88f65b0297c0e8b363e2
coreaudio: Lock only the buffer

On macOS 11.3.1, Core Audio calls AudioDeviceIOProc after calling an
internal function named HALB_Mutex::Lock(), which locks a mutex in
HALB_IOThread::Entry(void*). HALB_Mutex::Lock() is also called in
AudioObjectGetPropertyData, which is called by coreaudio driver.
Therefore, a deadlock will occur if coreaudio driver calls
AudioObjectGetPropertyData while holding a lock for a mutex and tries
to lock the same mutex in AudioDeviceIOProc.

audioDeviceIOProc, which implements AudioDeviceIOProc in coreaudio
driver, requires an exclusive access for the device configuration and
the buffer. Fortunately, a mutex is necessary only for the buffer in
audioDeviceIOProc because a change for the device configuration occurs
only before setting up AudioDeviceIOProc or after stopping the playback
with AudioDeviceStop.

With this change, the mutex owned by the driver will only be used for
the buffer, and the device configuration change will be protected with
the implicit iothread mutex.

Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Message-id: 20210622201740.38005-1-akihiko.odaki@gmail.com
Message-Id: <20210622201740.38005-1-akihiko.odaki@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
audio/coreaudio.c