* [PATCH] audio: fix audio recording
@ 2019-11-19 6:58 Volker Rümelin
2019-11-19 8:01 ` Philippe Mathieu-Daudé
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Volker Rümelin @ 2019-11-19 6:58 UTC (permalink / raw)
To: Gerd Hoffmann, qemu-devel
With current code audio recording with all audio backends
except PulseAudio and DirectSound is broken. The generic audio
recording buffer management forgot to update the current read
position after a read.
Fixes: ff095e5231 "audio: api for mixeng code free backends"
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
audio/audio.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/audio/audio.c b/audio/audio.c
index 7fc3aa9d16..56fae55047 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1390,6 +1390,7 @@ void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size)
size_t read = hw->pcm_ops->read(hw, hw->buf_emul + hw->pos_emul,
read_len);
hw->pending_emul += read;
+ hw->pos_emul = (hw->pos_emul + read) % hw->size_emul;
if (read < read_len) {
break;
}
--
2.16.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] audio: fix audio recording
2019-11-19 6:58 [PATCH] audio: fix audio recording Volker Rümelin
@ 2019-11-19 8:01 ` Philippe Mathieu-Daudé
2019-11-19 19:43 ` Richard Henderson
2019-11-20 0:36 ` Zoltán Kővágó
2019-11-20 8:12 ` Gerd Hoffmann
2 siblings, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-11-19 8:01 UTC (permalink / raw)
To: Volker Rümelin, Gerd Hoffmann, Kővágó, Zoltán
Cc: qemu-devel
Cc'ing Zoltán.
On 11/19/19 7:58 AM, Volker Rümelin wrote:
> With current code audio recording with all audio backends
> except PulseAudio and DirectSound is broken. The generic audio
> recording buffer management forgot to update the current read
> position after a read.
>
> Fixes: ff095e5231 "audio: api for mixeng code free backends"
>
> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
> ---
> audio/audio.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/audio/audio.c b/audio/audio.c
> index 7fc3aa9d16..56fae55047 100644
> --- a/audio/audio.c
> +++ b/audio/audio.c
> @@ -1390,6 +1390,7 @@ void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size)
> size_t read = hw->pcm_ops->read(hw, hw->buf_emul + hw->pos_emul,
> read_len);
> hw->pending_emul += read;
> + hw->pos_emul = (hw->pos_emul + read) % hw->size_emul;
Anyway since read() can return a negative value, both previous
assignments should go after this if/break check...
> if (read < read_len) {
> break;
> }
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] audio: fix audio recording
2019-11-19 8:01 ` Philippe Mathieu-Daudé
@ 2019-11-19 19:43 ` Richard Henderson
2019-11-20 0:40 ` Zoltán Kővágó
0 siblings, 1 reply; 6+ messages in thread
From: Richard Henderson @ 2019-11-19 19:43 UTC (permalink / raw)
To: Philippe Mathieu-Daudé,
Volker Rümelin, Gerd Hoffmann, Kővágó,
Zoltán
Cc: qemu-devel
On 11/19/19 9:01 AM, Philippe Mathieu-Daudé wrote:
> Cc'ing Zoltán.
>
> On 11/19/19 7:58 AM, Volker Rümelin wrote:
>> With current code audio recording with all audio backends
>> except PulseAudio and DirectSound is broken. The generic audio
>> recording buffer management forgot to update the current read
>> position after a read.
>>
>> Fixes: ff095e5231 "audio: api for mixeng code free backends"
>>
>> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
>> ---
>> audio/audio.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/audio/audio.c b/audio/audio.c
>> index 7fc3aa9d16..56fae55047 100644
>> --- a/audio/audio.c
>> +++ b/audio/audio.c
>> @@ -1390,6 +1390,7 @@ void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t
>> *size)
>> size_t read = hw->pcm_ops->read(hw, hw->buf_emul + hw->pos_emul,
>> read_len);
>> hw->pending_emul += read;
>> + hw->pos_emul = (hw->pos_emul + read) % hw->size_emul;
>
> Anyway since read() can return a negative value, both previous assignments
> should go after this if/break check...
This isn't read(2).
size_t (*read) (HWVoiceIn *hw, void *buf, size_t size);
Since this isn't ssize_t, no negative return value possible.
r~
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] audio: fix audio recording
2019-11-19 6:58 [PATCH] audio: fix audio recording Volker Rümelin
2019-11-19 8:01 ` Philippe Mathieu-Daudé
@ 2019-11-20 0:36 ` Zoltán Kővágó
2019-11-20 8:12 ` Gerd Hoffmann
2 siblings, 0 replies; 6+ messages in thread
From: Zoltán Kővágó @ 2019-11-20 0:36 UTC (permalink / raw)
To: Volker Rümelin, Gerd Hoffmann, qemu-devel
On 2019-11-19 07:58, Volker Rümelin wrote:
> With current code audio recording with all audio backends
> except PulseAudio and DirectSound is broken. The generic audio
> recording buffer management forgot to update the current read
> position after a read.
Indeed, pos_emul is updated in audio_generic_put_buffer_out_nowrite but
it's never updated on the capture end. I tested it with alsa and
hda-micro and it fixes the problem (that is, if I add in.try-poll=off,
but I need that for output too).
Thanks.
>
> Fixes: ff095e5231 "audio: api for mixeng code free backends"
>
> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Reviewed-by: Zoltán Kővágó <DirtY.iCE.hu@gmail.com>
> ---
> audio/audio.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/audio/audio.c b/audio/audio.c
> index 7fc3aa9d16..56fae55047 100644
> --- a/audio/audio.c
> +++ b/audio/audio.c
> @@ -1390,6 +1390,7 @@ void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size)
> size_t read = hw->pcm_ops->read(hw, hw->buf_emul + hw->pos_emul,
> read_len);
> hw->pending_emul += read;
> + hw->pos_emul = (hw->pos_emul + read) % hw->size_emul;
> if (read < read_len) {
> break;
> }
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] audio: fix audio recording
2019-11-19 19:43 ` Richard Henderson
@ 2019-11-20 0:40 ` Zoltán Kővágó
0 siblings, 0 replies; 6+ messages in thread
From: Zoltán Kővágó @ 2019-11-20 0:40 UTC (permalink / raw)
To: Richard Henderson, Philippe Mathieu-Daudé,
Volker Rümelin, Gerd Hoffmann
Cc: qemu-devel
On 2019-11-19 20:43, Richard Henderson wrote:
> On 11/19/19 9:01 AM, Philippe Mathieu-Daudé wrote:
>> Cc'ing Zoltán.
>>
>> On 11/19/19 7:58 AM, Volker Rümelin wrote:
>>> With current code audio recording with all audio backends
>>> except PulseAudio and DirectSound is broken. The generic audio
>>> recording buffer management forgot to update the current read
>>> position after a read.
>>>
>>> Fixes: ff095e5231 "audio: api for mixeng code free backends"
>>>
>>> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
>>> ---
>>> audio/audio.c | 1 +
>>> 1 file changed, 1 insertion(+)
>>>
>>> diff --git a/audio/audio.c b/audio/audio.c
>>> index 7fc3aa9d16..56fae55047 100644
>>> --- a/audio/audio.c
>>> +++ b/audio/audio.c
>>> @@ -1390,6 +1390,7 @@ void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t
>>> *size)
>>> size_t read = hw->pcm_ops->read(hw, hw->buf_emul + hw->pos_emul,
>>> read_len);
>>> hw->pending_emul += read;
>>> + hw->pos_emul = (hw->pos_emul + read) % hw->size_emul;
>>
>> Anyway since read() can return a negative value, both previous assignments
>> should go after this if/break check...
>
> This isn't read(2).
>
> size_t (*read) (HWVoiceIn *hw, void *buf, size_t size);
>
> Since this isn't ssize_t, no negative return value possible.
Yes, read failures are handled inside the backends. If the backend
really can't read anything, it'll return zero, which is harmless here.
Zoltan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] audio: fix audio recording
2019-11-19 6:58 [PATCH] audio: fix audio recording Volker Rümelin
2019-11-19 8:01 ` Philippe Mathieu-Daudé
2019-11-20 0:36 ` Zoltán Kővágó
@ 2019-11-20 8:12 ` Gerd Hoffmann
2 siblings, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2019-11-20 8:12 UTC (permalink / raw)
To: Volker Rümelin; +Cc: qemu-devel
On Tue, Nov 19, 2019 at 07:58:49AM +0100, Volker Rümelin wrote:
> With current code audio recording with all audio backends
> except PulseAudio and DirectSound is broken. The generic audio
> recording buffer management forgot to update the current read
> position after a read.
>
> Fixes: ff095e5231 "audio: api for mixeng code free backends"
>
> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Queued for 4.2
thanks,
Gerd
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-11-20 8:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-19 6:58 [PATCH] audio: fix audio recording Volker Rümelin
2019-11-19 8:01 ` Philippe Mathieu-Daudé
2019-11-19 19:43 ` Richard Henderson
2019-11-20 0:40 ` Zoltán Kővágó
2019-11-20 0:36 ` Zoltán Kővágó
2019-11-20 8:12 ` Gerd Hoffmann
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.