[PATCH v8 6/6] coreaudio: Initialize the buffer for device change

Akihiko Odaki posted 6 patches 1 month, 1 week ago
Maintainers: Gerd Hoffmann <kraxel@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Christian Schoenebeck <qemu_oss@crudebyte.com>, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
[PATCH v8 6/6] coreaudio: Initialize the buffer for device change
Posted by Akihiko Odaki 1 month, 1 week ago
Reallocate buffers when the active device change as the required buffer
size may differ.

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Phil Dennis-Jordan <phil@philjordan.eu>
Acked-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
 audio/coreaudio.m | 1 +
 1 file changed, 1 insertion(+)

diff --git a/audio/coreaudio.m b/audio/coreaudio.m
index 23c3d1f80ac5..e4ec1df971c8 100644
--- a/audio/coreaudio.m
+++ b/audio/coreaudio.m
@@ -471,6 +471,7 @@ static OSStatus init_out_device(CoreaudioVoiceOut *core)
     core->device_id = device_id;
     core->device_frame_size = device_frame_size;
     core->hw.samples = core->buffer_count * core->device_frame_size;
+    audio_generic_initialize_buffer_out(&core->hw);
     core->ioprocid = ioprocid;
 
     return 0;

-- 
2.53.0
Re: [PATCH v8 6/6] coreaudio: Initialize the buffer for device change
Posted by Christian Schoenebeck 1 month, 1 week ago
On Wednesday, 4 March 2026 07:16:59 CET Akihiko Odaki wrote:
> Reallocate buffers when the active device change as the required buffer
> size may differ.
> 
> Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
> Reviewed-by: Phil Dennis-Jordan <phil@philjordan.eu>
> Acked-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> ---
>  audio/coreaudio.m | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/audio/coreaudio.m b/audio/coreaudio.m
> index 23c3d1f80ac5..e4ec1df971c8 100644
> --- a/audio/coreaudio.m
> +++ b/audio/coreaudio.m
> @@ -471,6 +471,7 @@ static OSStatus init_out_device(CoreaudioVoiceOut *core)
> core->device_id = device_id;
>      core->device_frame_size = device_frame_size;
>      core->hw.samples = core->buffer_count * core->device_frame_size;
> +    audio_generic_initialize_buffer_out(&core->hw);
>      core->ioprocid = ioprocid;
> 
>      return 0;

There is no specific reason to insert that call between the struct
initializers here, or is there? I mean the device is suspended at this point,
so it should not matter. Just looks a bit weird.

But in general, LGTM:

Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Re: [PATCH v8 6/6] coreaudio: Initialize the buffer for device change
Posted by Akihiko Odaki 1 month ago
On 2026/03/04 20:39, Christian Schoenebeck wrote:
> On Wednesday, 4 March 2026 07:16:59 CET Akihiko Odaki wrote:
>> Reallocate buffers when the active device change as the required buffer
>> size may differ.
>>
>> Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
>> Reviewed-by: Phil Dennis-Jordan <phil@philjordan.eu>
>> Acked-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
>> ---
>>   audio/coreaudio.m | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/audio/coreaudio.m b/audio/coreaudio.m
>> index 23c3d1f80ac5..e4ec1df971c8 100644
>> --- a/audio/coreaudio.m
>> +++ b/audio/coreaudio.m
>> @@ -471,6 +471,7 @@ static OSStatus init_out_device(CoreaudioVoiceOut *core)
>> core->device_id = device_id;
>>       core->device_frame_size = device_frame_size;
>>       core->hw.samples = core->buffer_count * core->device_frame_size;
>> +    audio_generic_initialize_buffer_out(&core->hw);
>>       core->ioprocid = ioprocid;
>>
>>       return 0;
> 
> There is no specific reason to insert that call between the struct
> initializers here, or is there? I mean the device is suspended at this point,
> so it should not matter. Just looks a bit weird.

I will move it after core->ioprocid = ioprocid.

Regards,
Akihiko Odaki

> 
> But in general, LGTM:
> 
> Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> 
> 
>
Re: [PATCH v8 6/6] coreaudio: Initialize the buffer for device change
Posted by Marc-André Lureau 1 month, 1 week ago
On Wed, Mar 4, 2026 at 7:17 AM Akihiko Odaki
<odaki@rsg.ci.i.u-tokyo.ac.jp> wrote:
>
> Reallocate buffers when the active device change as the required buffer
> size may differ.
>
> Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
> Reviewed-by: Phil Dennis-Jordan <phil@philjordan.eu>
> Acked-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> ---
>  audio/coreaudio.m | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/audio/coreaudio.m b/audio/coreaudio.m
> index 23c3d1f80ac5..e4ec1df971c8 100644
> --- a/audio/coreaudio.m
> +++ b/audio/coreaudio.m
> @@ -471,6 +471,7 @@ static OSStatus init_out_device(CoreaudioVoiceOut *core)
>      core->device_id = device_id;
>      core->device_frame_size = device_frame_size;
>      core->hw.samples = core->buffer_count * core->device_frame_size;
> +    audio_generic_initialize_buffer_out(&core->hw);

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

>      core->ioprocid = ioprocid;
>
>      return 0;
>
> --
> 2.53.0
>