aboutsummaryrefslogtreecommitdiff
path: root/audio/coreaudio.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-08-01 15:23:43 +0400
committerMarkus Armbruster <armbru@redhat.com>2016-08-08 14:17:00 +0200
commita384c205acaa4b6fe6d4d392af47b49b2c448eb4 (patch)
treee4169ed10e099e09ce4fa4209ac29fb9afa36a0d /audio/coreaudio.c
parent2ef45716e1d4820f10a90ee2f17a9cb4fe5a8806 (diff)
audio: clean up before monitor clean up
Since aa5cb7f5e, the chardevs are being cleaned up when leaving qemu, before the atexit() handlers. audio_cleanup() may use the monitor to notify of changes. For compatibility reasons, let's clean up audio before the monitor so it keeps emitting monitor events. The audio_atexit() function is made idempotent (so it can be called multiple times), and renamed to audio_cleanup(). Since coreaudio backend is using a 'isAtexit' code path, change it to check audio_is_cleaning_up() instead, so the path is taken during normal exit. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20160801112343.29082-3-marcandre.lureau@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'audio/coreaudio.c')
-rw-r--r--audio/coreaudio.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/audio/coreaudio.c b/audio/coreaudio.c
index d4ad224590..c75142084f 100644
--- a/audio/coreaudio.c
+++ b/audio/coreaudio.c
@@ -36,8 +36,6 @@
#define MAC_OS_X_VERSION_10_6 1060
#endif
-static int isAtexit;
-
typedef struct {
int buffer_frames;
int nbuffers;
@@ -378,11 +376,6 @@ static inline UInt32 isPlaying (AudioDeviceID outputDeviceID)
return result;
}
-static void coreaudio_atexit (void)
-{
- isAtexit = 1;
-}
-
static int coreaudio_lock (coreaudioVoiceOut *core, const char *fn_name)
{
int err;
@@ -630,7 +623,7 @@ static void coreaudio_fini_out (HWVoiceOut *hw)
int err;
coreaudioVoiceOut *core = (coreaudioVoiceOut *) hw;
- if (!isAtexit) {
+ if (!audio_is_cleaning_up()) {
/* stop playback */
if (isPlaying(core->outputDeviceID)) {
status = AudioDeviceStop(core->outputDeviceID, core->ioprocid);
@@ -673,7 +666,7 @@ static int coreaudio_ctl_out (HWVoiceOut *hw, int cmd, ...)
case VOICE_DISABLE:
/* stop playback */
- if (!isAtexit) {
+ if (!audio_is_cleaning_up()) {
if (isPlaying(core->outputDeviceID)) {
status = AudioDeviceStop(core->outputDeviceID,
core->ioprocid);
@@ -697,7 +690,6 @@ static void *coreaudio_audio_init (void)
CoreaudioConf *conf = g_malloc(sizeof(CoreaudioConf));
*conf = glob_conf;
- atexit(coreaudio_atexit);
return conf;
}