From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: "Gerd Hoffmann" <kraxel@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"BALATON Zoltan" <balaton@eik.bme.hu>,
qemu-devel@nongnu.org
Cc: qemu-devel@nongnu.org, devel@daynix.com,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Akihiko Odaki" <odaki@rsg.ci.i.u-tokyo.ac.jp>,
"Phil Dennis-Jordan" <phil@philjordan.eu>,
"Akihiko Odaki" <odaki@rsg.ci.i.u-tokyo.ac.jp>
Subject: Re: [PATCH v8 5/6] audio: Add functions to initialize buffers
Date: Wed, 04 Mar 2026 09:36:42 +0100 [thread overview]
Message-ID: <12848166.O9o76ZdvQC@weasel> (raw)
In-Reply-To: <20260304-coreaudio-v8-5-bf1d40731e73@rsg.ci.i.u-tokyo.ac.jp>
On Wednesday, 4 March 2026 07:16:58 CET Akihiko Odaki wrote:
> These functions can be used to re-initialize buffers when hardware
> parameters change due to device hotplug, for example.
>
> Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
> Reviewed-by: Phil Dennis-Jordan <phil@philjordan.eu>
> Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> ---
> audio/audio_int.h | 2 ++
> audio/audio-mixeng-be.c | 24 ++++++++++++++++++------
> 2 files changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/audio/audio_int.h b/audio/audio_int.h
> index 06f79ade6b0a..290cf373b49f 100644
> --- a/audio/audio_int.h
> +++ b/audio/audio_int.h
> @@ -141,9 +141,11 @@ static inline void *advance(void *p, size_t incr)
> int wav_start_capture(AudioBackend *state, CaptureState *s, const char
> *path, int freq, int bits, int nchannels);
>
> +void audio_generic_initialize_buffer_in(HWVoiceIn *hw);
> void audio_generic_run_buffer_in(HWVoiceIn *hw);
> void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size);
> void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size);
> +void audio_generic_initialize_buffer_out(HWVoiceOut *hw);
> void audio_generic_run_buffer_out(HWVoiceOut *hw);
> size_t audio_generic_buffer_get_free(HWVoiceOut *hw);
> void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size);
> diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c
> index 370404505111..1419e7521503 100644
> --- a/audio/audio-mixeng-be.c
> +++ b/audio/audio-mixeng-be.c
> @@ -1187,14 +1187,20 @@ void audio_run(AudioMixengBackend *s, const char
> *msg) }
> }
>
> +void audio_generic_initialize_buffer_in(HWVoiceIn *hw)
> +{
> + g_free(hw->buf_emul);
> + hw->size_emul = hw->samples * hw->info.bytes_per_frame;
> + hw->buf_emul = g_malloc(hw->size_emul);
> + hw->pos_emul = hw->pending_emul = 0;
> +}
> +
> void audio_generic_run_buffer_in(HWVoiceIn *hw)
> {
> AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_GET_CLASS(hw->s);
>
> if (unlikely(!hw->buf_emul)) {
> - hw->size_emul = hw->samples * hw->info.bytes_per_frame;
> - hw->buf_emul = g_malloc(hw->size_emul);
> - hw->pos_emul = hw->pending_emul = 0;
> + audio_generic_initialize_buffer_in(hw);
> }
It would be cleaner having split this patch over 2 patches. One for pure
refactoring (no behaviour change), and one that adds g_free(hw->buf_emul);
> while (hw->pending_emul < hw->size_emul) {
> @@ -1227,6 +1233,14 @@ void audio_generic_put_buffer_in(HWVoiceIn *hw, void
> *buf, size_t size) hw->pending_emul -= size;
> }
>
> +void audio_generic_initialize_buffer_out(HWVoiceOut *hw)
> +{
> + g_free(hw->buf_emul);
> + hw->size_emul = hw->samples * hw->info.bytes_per_frame;
> + hw->buf_emul = g_malloc(hw->size_emul);
> + hw->pos_emul = hw->pending_emul = 0;
> +}
> +
> size_t audio_generic_buffer_get_free(HWVoiceOut *hw)
> {
> if (hw->buf_emul) {
> @@ -1260,9 +1274,7 @@ void audio_generic_run_buffer_out(HWVoiceOut *hw)
> void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size)
> {
> if (unlikely(!hw->buf_emul)) {
> - hw->size_emul = hw->samples * hw->info.bytes_per_frame;
> - hw->buf_emul = g_malloc(hw->size_emul);
> - hw->pos_emul = hw->pending_emul = 0;
> + audio_generic_initialize_buffer_out(hw);
> }
>
> *size = MIN(hw->size_emul - hw->pending_emul,
next prev parent reply other threads:[~2026-03-04 8:37 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-04 6:16 [PATCH v8 0/6] coreaudio fixes Akihiko Odaki
2026-03-04 6:16 ` [PATCH v8 1/6] coreaudio: Remove unnecessary explicit casts Akihiko Odaki
2026-03-04 8:07 ` Marc-André Lureau
2026-03-04 6:16 ` [PATCH v8 2/6] coreaudio: Remove extra whitespaces Akihiko Odaki
2026-03-04 8:06 ` Marc-André Lureau
2026-03-04 6:16 ` [PATCH v8 3/6] coreaudio: Improve naming Akihiko Odaki
2026-03-04 8:07 ` Marc-André Lureau
2026-03-04 9:25 ` Christian Schoenebeck
2026-03-04 10:42 ` Akihiko Odaki
2026-03-04 10:52 ` Christian Schoenebeck
2026-03-04 12:00 ` BALATON Zoltan
2026-03-04 6:16 ` [PATCH v8 4/6] coreaudio: Commit the result of init in the end Akihiko Odaki
2026-03-04 11:56 ` Christian Schoenebeck
2026-03-07 4:10 ` Akihiko Odaki
2026-03-04 6:16 ` [PATCH v8 5/6] audio: Add functions to initialize buffers Akihiko Odaki
2026-03-04 8:11 ` Marc-André Lureau
2026-03-04 8:36 ` Christian Schoenebeck [this message]
2026-03-04 10:47 ` Akihiko Odaki
2026-03-04 11:17 ` Christian Schoenebeck
2026-03-07 4:17 ` Akihiko Odaki
2026-03-04 6:16 ` [PATCH v8 6/6] coreaudio: Initialize the buffer for device change Akihiko Odaki
2026-03-04 8:11 ` Marc-André Lureau
2026-03-04 11:39 ` Christian Schoenebeck
2026-03-07 5:29 ` Akihiko Odaki
2026-03-04 8:42 ` [PATCH v8 0/6] coreaudio fixes Christian Schoenebeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=12848166.O9o76ZdvQC@weasel \
--to=qemu_oss@crudebyte.com \
--cc=balaton@eik.bme.hu \
--cc=devel@daynix.com \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
--cc=phil@philjordan.eu \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.