aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2020-12-15 13:58:18 +0000
committerPeter Maydell <peter.maydell@linaro.org>2020-12-15 13:58:18 +0000
commitffb1e2ed7cd76df7537562f7e0b2bd5bf8b0842d (patch)
tree22a5e232f302cdc34f87f5d8c304878b646fb6f8
parent5bfbd8170ce7acb98a1834ff49ed7340b0837144 (diff)
parent06c8c375389a54d8e4457d967f4f0896caecefb2 (diff)
Merge remote-tracking branch 'remotes/kraxel/tags/audio-20201215-pull-request' into staging
audio: coreaudio playback state fixes. audio: misc cleanups. # gpg: Signature made Tue 15 Dec 2020 13:47:57 GMT # gpg: using RSA key 4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full] # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" [full] # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full] # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/audio-20201215-pull-request: audio: add sanity check audio: Simplify audio_bug() removing old code cs4231: Get rid of empty property array audio: remove unused function audio_is_cleaning_up() coreaudio: always stop audio playback on shut down coreaudio: don't start playback in init routine coreaudio: rename misnamed variable fake_as Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--audio/audio.c31
-rw-r--r--audio/audio.h1
-rw-r--r--audio/coreaudio.c53
-rw-r--r--hw/audio/cs4231.c5
4 files changed, 23 insertions, 67 deletions
diff --git a/audio/audio.c b/audio/audio.c
index 46578e4a58..b48471bb3f 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -104,9 +104,6 @@ const struct mixeng_volume nominal_volume = {
static bool legacy_config = true;
-#ifdef AUDIO_IS_FLAWLESS_AND_NO_CHECKS_ARE_REQURIED
-#error No its not
-#else
int audio_bug (const char *funcname, int cond)
{
if (cond) {
@@ -119,25 +116,11 @@ int audio_bug (const char *funcname, int cond)
AUD_log (NULL, "I am sorry\n");
}
AUD_log (NULL, "Context:\n");
-
-#if defined AUDIO_BREAKPOINT_ON_BUG
-# if defined HOST_I386
-# if defined __GNUC__
- __asm__ ("int3");
-# elif defined _MSC_VER
- _asm _emit 0xcc;
-# else
- abort ();
-# endif
-# else
- abort ();
-# endif
-#endif
+ abort();
}
return cond;
}
-#endif
static inline int audio_bits_to_index (int bits)
{
@@ -1588,13 +1571,6 @@ static void audio_vm_change_state_handler (void *opaque, int running,
audio_reset_timer (s);
}
-static bool is_cleaning_up;
-
-bool audio_is_cleaning_up(void)
-{
- return is_cleaning_up;
-}
-
static void free_audio_state(AudioState *s)
{
HWVoiceOut *hwo, *hwon;
@@ -1647,7 +1623,6 @@ static void free_audio_state(AudioState *s)
void audio_cleanup(void)
{
- is_cleaning_up = true;
while (!QTAILQ_EMPTY(&audio_states)) {
AudioState *s = QTAILQ_FIRST(&audio_states);
QTAILQ_REMOVE(&audio_states, s, list);
@@ -1709,7 +1684,9 @@ static AudioState *audio_init(Audiodev *dev, const char *name)
* backend and this can go away.
*/
driver = audio_driver_lookup("spice");
- driver->can_be_default = 1;
+ if (driver) {
+ driver->can_be_default = 1;
+ }
}
if (dev) {
diff --git a/audio/audio.h b/audio/audio.h
index b883ebfb1f..41b3ef04ea 100644
--- a/audio/audio.h
+++ b/audio/audio.h
@@ -160,7 +160,6 @@ static inline void *advance (void *p, int incr)
int wav_start_capture(AudioState *state, CaptureState *s, const char *path,
int freq, int bits, int nchannels);
-bool audio_is_cleaning_up(void);
void audio_cleanup(void);
void audio_sample_to_uint64(const void *samples, int pos,
diff --git a/audio/coreaudio.c b/audio/coreaudio.c
index 4b4365660f..79a9d40bf8 100644
--- a/audio/coreaudio.c
+++ b/audio/coreaudio.c
@@ -482,7 +482,7 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as,
Audiodev *dev = drv_opaque;
AudiodevCoreaudioPerDirectionOptions *cpdo = dev->u.coreaudio.out;
int frames;
- struct audsettings fake_as;
+ struct audsettings obt_as;
/* create mutex */
err = pthread_mutex_init(&core->mutex, NULL);
@@ -491,8 +491,8 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as,
return -1;
}
- fake_as = *as;
- as = &fake_as;
+ obt_as = *as;
+ as = &obt_as;
as->fmt = AUDIO_FORMAT_F32;
audio_pcm_init_info (&hw->info, as);
@@ -584,17 +584,6 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as,
return -1;
}
- /* start Playback */
- if (!isPlaying(core->outputDeviceID)) {
- status = AudioDeviceStart(core->outputDeviceID, core->ioprocid);
- if (status != kAudioHardwareNoError) {
- coreaudio_logerr2 (status, typ, "Could not start playback\n");
- AudioDeviceDestroyIOProcID(core->outputDeviceID, core->ioprocid);
- core->outputDeviceID = kAudioDeviceUnknown;
- return -1;
- }
- }
-
return 0;
}
@@ -604,22 +593,20 @@ static void coreaudio_fini_out (HWVoiceOut *hw)
int err;
coreaudioVoiceOut *core = (coreaudioVoiceOut *) hw;
- if (!audio_is_cleaning_up()) {
- /* stop playback */
- if (isPlaying(core->outputDeviceID)) {
- status = AudioDeviceStop(core->outputDeviceID, core->ioprocid);
- if (status != kAudioHardwareNoError) {
- coreaudio_logerr (status, "Could not stop playback\n");
- }
- }
-
- /* remove callback */
- status = AudioDeviceDestroyIOProcID(core->outputDeviceID,
- core->ioprocid);
+ /* stop playback */
+ if (isPlaying(core->outputDeviceID)) {
+ status = AudioDeviceStop(core->outputDeviceID, core->ioprocid);
if (status != kAudioHardwareNoError) {
- coreaudio_logerr (status, "Could not remove IOProc\n");
+ coreaudio_logerr(status, "Could not stop playback\n");
}
}
+
+ /* remove callback */
+ status = AudioDeviceDestroyIOProcID(core->outputDeviceID,
+ core->ioprocid);
+ if (status != kAudioHardwareNoError) {
+ coreaudio_logerr(status, "Could not remove IOProc\n");
+ }
core->outputDeviceID = kAudioDeviceUnknown;
/* destroy mutex */
@@ -644,13 +631,11 @@ static void coreaudio_enable_out(HWVoiceOut *hw, bool enable)
}
} else {
/* stop playback */
- if (!audio_is_cleaning_up()) {
- if (isPlaying(core->outputDeviceID)) {
- status = AudioDeviceStop(core->outputDeviceID,
- core->ioprocid);
- if (status != kAudioHardwareNoError) {
- coreaudio_logerr (status, "Could not pause playback\n");
- }
+ if (isPlaying(core->outputDeviceID)) {
+ status = AudioDeviceStop(core->outputDeviceID,
+ core->ioprocid);
+ if (status != kAudioHardwareNoError) {
+ coreaudio_logerr(status, "Could not pause playback\n");
}
}
}
diff --git a/hw/audio/cs4231.c b/hw/audio/cs4231.c
index 8e9554ce9b..209c05a0a0 100644
--- a/hw/audio/cs4231.c
+++ b/hw/audio/cs4231.c
@@ -160,17 +160,12 @@ static void cs4231_init(Object *obj)
sysbus_init_irq(dev, &s->irq);
}
-static Property cs4231_properties[] = {
- {.name = NULL},
-};
-
static void cs4231_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->reset = cs_reset;
dc->vmsd = &vmstate_cs4231;
- device_class_set_props(dc, cs4231_properties);
}
static const TypeInfo cs4231_info = {