mirror of https://gitee.com/openkylin/qemu.git
audio: Do not check for audio_calloc failure
audio_calloc uses g_malloc0 which never returns in case of memory failure. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Message-id: 20190225154335.11397-2-fziglio@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
71f2874fc1
commit
e8d8544402
|
@ -811,12 +811,7 @@ static int audio_attach_capture (HWVoiceOut *hw)
|
||||||
SWVoiceOut *sw;
|
SWVoiceOut *sw;
|
||||||
HWVoiceOut *hw_cap = &cap->hw;
|
HWVoiceOut *hw_cap = &cap->hw;
|
||||||
|
|
||||||
sc = audio_calloc(__func__, 1, sizeof(*sc));
|
sc = g_malloc0(sizeof(*sc));
|
||||||
if (!sc) {
|
|
||||||
dolog ("Could not allocate soft capture voice (%zu bytes)\n",
|
|
||||||
sizeof (*sc));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
sc->cap = cap;
|
sc->cap = cap;
|
||||||
sw = &sc->sw;
|
sw = &sc->sw;
|
||||||
|
@ -1960,15 +1955,10 @@ CaptureVoiceOut *AUD_add_capture (
|
||||||
if (audio_validate_settings (as)) {
|
if (audio_validate_settings (as)) {
|
||||||
dolog ("Invalid settings were passed when trying to add capture\n");
|
dolog ("Invalid settings were passed when trying to add capture\n");
|
||||||
audio_print_settings (as);
|
audio_print_settings (as);
|
||||||
goto err0;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cb = audio_calloc(__func__, 1, sizeof(*cb));
|
cb = g_malloc0(sizeof(*cb));
|
||||||
if (!cb) {
|
|
||||||
dolog ("Could not allocate capture callback information, size %zu\n",
|
|
||||||
sizeof (*cb));
|
|
||||||
goto err0;
|
|
||||||
}
|
|
||||||
cb->ops = *ops;
|
cb->ops = *ops;
|
||||||
cb->opaque = cb_opaque;
|
cb->opaque = cb_opaque;
|
||||||
|
|
||||||
|
@ -1981,12 +1971,7 @@ CaptureVoiceOut *AUD_add_capture (
|
||||||
HWVoiceOut *hw;
|
HWVoiceOut *hw;
|
||||||
CaptureVoiceOut *cap;
|
CaptureVoiceOut *cap;
|
||||||
|
|
||||||
cap = audio_calloc(__func__, 1, sizeof(*cap));
|
cap = g_malloc0(sizeof(*cap));
|
||||||
if (!cap) {
|
|
||||||
dolog ("Could not allocate capture voice, size %zu\n",
|
|
||||||
sizeof (*cap));
|
|
||||||
goto err1;
|
|
||||||
}
|
|
||||||
|
|
||||||
hw = &cap->hw;
|
hw = &cap->hw;
|
||||||
QLIST_INIT (&hw->sw_head);
|
QLIST_INIT (&hw->sw_head);
|
||||||
|
@ -1994,23 +1979,11 @@ CaptureVoiceOut *AUD_add_capture (
|
||||||
|
|
||||||
/* XXX find a more elegant way */
|
/* XXX find a more elegant way */
|
||||||
hw->samples = 4096 * 4;
|
hw->samples = 4096 * 4;
|
||||||
hw->mix_buf = audio_calloc(__func__, hw->samples,
|
hw->mix_buf = g_new0(struct st_sample, hw->samples);
|
||||||
sizeof(struct st_sample));
|
|
||||||
if (!hw->mix_buf) {
|
|
||||||
dolog ("Could not allocate capture mix buffer (%d samples)\n",
|
|
||||||
hw->samples);
|
|
||||||
goto err2;
|
|
||||||
}
|
|
||||||
|
|
||||||
audio_pcm_init_info (&hw->info, as);
|
audio_pcm_init_info (&hw->info, as);
|
||||||
|
|
||||||
cap->buf = audio_calloc(__func__, hw->samples, 1 << hw->info.shift);
|
cap->buf = g_malloc0_n(hw->samples, 1 << hw->info.shift);
|
||||||
if (!cap->buf) {
|
|
||||||
dolog ("Could not allocate capture buffer "
|
|
||||||
"(%d samples, each %d bytes)\n",
|
|
||||||
hw->samples, 1 << hw->info.shift);
|
|
||||||
goto err3;
|
|
||||||
}
|
|
||||||
|
|
||||||
hw->clip = mixeng_clip
|
hw->clip = mixeng_clip
|
||||||
[hw->info.nchannels == 2]
|
[hw->info.nchannels == 2]
|
||||||
|
@ -2025,15 +1998,6 @@ CaptureVoiceOut *AUD_add_capture (
|
||||||
audio_attach_capture (hw);
|
audio_attach_capture (hw);
|
||||||
}
|
}
|
||||||
return cap;
|
return cap;
|
||||||
|
|
||||||
err3:
|
|
||||||
g_free (cap->hw.mix_buf);
|
|
||||||
err2:
|
|
||||||
g_free (cap);
|
|
||||||
err1:
|
|
||||||
g_free (cb);
|
|
||||||
err0:
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue