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>
This commit is contained in:
+4
-27
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
+19
-34
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user