e74fec9a | 15-Nov-2022 |
Marc-André Lureau <marcandre.lureau@redhat.com> |
audio/dbus: there are no sender for p2p mode
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> |
2f886a34 | 24-Feb-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio: remove sw->ratio
Simplify the resample buffer size calculation.
For audio playback we have sw->ratio = ((int64_t)sw->hw->info.freq << 32) / sw->info.freq; samples = ((int64_t)sw->HWBUF.size
audio: remove sw->ratio
Simplify the resample buffer size calculation.
For audio playback we have sw->ratio = ((int64_t)sw->hw->info.freq << 32) / sw->info.freq; samples = ((int64_t)sw->HWBUF.size << 32) / sw->ratio;
This can be simplified to samples = muldiv64(sw->HWBUF.size, sw->info.freq, sw->hw->info.freq);
For audio recording we have sw->ratio = ((int64_t)sw->info.freq << 32) / sw->hw->info.freq; samples = (int64_t)sw->HWBUF.size * sw->ratio >> 32;
This can be simplified to samples = muldiv64(sw->HWBUF.size, sw->info.freq, sw->hw->info.freq);
With hw = sw->hw this becomes in both cases samples = muldiv64(HWBUF.size, sw->info.freq, hw->info.freq);
Now that sw->ratio is no longer needed, remove sw->ratio.
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20230224190555.7409-15-vr_qemu@t-online.de>
show more ...
|
148392ab | 24-Feb-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio/audio_template: substitute sw->hw with hw
Substitute sw->hw with hw in the audio_pcm_sw_alloc_resources_* functions.
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Ma
audio/audio_template: substitute sw->hw with hw
Substitute sw->hw with hw in the audio_pcm_sw_alloc_resources_* functions.
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20230224190555.7409-14-vr_qemu@t-online.de>
show more ...
|
e1e6a6fc | 24-Feb-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio: handle leftover audio frame from upsampling
Upsampling may leave one remaining audio frame in the input buffer. The emulated audio playback devices are currently resposible to write this audi
audio: handle leftover audio frame from upsampling
Upsampling may leave one remaining audio frame in the input buffer. The emulated audio playback devices are currently resposible to write this audio frame again in the next write cycle. Push that task down to audio_pcm_sw_write.
This is another step towards an audio callback interface that guarantees that when audio frontends are told they can write n audio frames, they can actually do so.
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20230224190555.7409-13-vr_qemu@t-online.de>
show more ...
|
a9ea5678 | 24-Feb-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio: make recording packet length calculation exact
Introduce the new function st_rate_frames_out() to calculate the exact number of audio output frames the resampling code can generate from a giv
audio: make recording packet length calculation exact
Introduce the new function st_rate_frames_out() to calculate the exact number of audio output frames the resampling code can generate from a given number of audio input frames. When upsampling, this function returns the maximum number of output frames.
This new function replaces the audio_frontend_frames_in() function, which calculated the average number of output frames rounded down to the nearest integer. The audio_frontend_frames_in() function was additionally used to limit the number of output frames to the resample buffer size. In audio_pcm_sw_read() the variable resample_buf.size replaces the open coded audio_frontend_frames_in() function. In audio_run_in() an additional MIN() function is necessary.
After this patch the audio packet length calculation for audio recording is exact.
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20230224190555.7409-12-vr_qemu@t-online.de>
show more ...
|
fbde1edf | 24-Feb-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio: rename variables in audio_pcm_sw_read()
The audio_pcm_sw_read() function uses a few very unspecific variable names. Rename them for better readability.
ret => total_out total => total_in siz
audio: rename variables in audio_pcm_sw_read()
The audio_pcm_sw_read() function uses a few very unspecific variable names. Rename them for better readability.
ret => total_out total => total_in size => buf_len samples => frames_out_max
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20230224190555.7409-11-vr_qemu@t-online.de>
show more ...
|
1c49c5f1 | 24-Feb-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio: replace the resampling loop in audio_pcm_sw_read()
Replace the resampling loop in audio_pcm_sw_read() with the new function audio_pcm_sw_resample_in(). Unlike the old resample loop the new fu
audio: replace the resampling loop in audio_pcm_sw_read()
Replace the resampling loop in audio_pcm_sw_read() with the new function audio_pcm_sw_resample_in(). Unlike the old resample loop the new function will try to consume input frames even if the output buffer is full. This is necessary when downsampling to avoid reading less audio frames than calculated in advance. The loop was unrolled to avoid complicated loop control conditions in this case.
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20230224190555.7409-10-vr_qemu@t-online.de>
show more ...
|
1a01df3d | 24-Feb-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio: make playback packet length calculation exact
Introduce the new function st_rate_frames_in() to calculate the exact number of audio input frames needed to get a given number of audio output f
audio: make playback packet length calculation exact
Introduce the new function st_rate_frames_in() to calculate the exact number of audio input frames needed to get a given number of audio output frames. The exact number of frames depends only on the difference of opos - ipos and the number of output frames. When downsampling, this function returns the maximum number of input frames needed.
This new function replaces the audio_frontend_frames_out() function, which calculated the average number of input frames rounded down to the nearest integer. Because audio_frontend_frames_out() also limited the number of input frames to the size of the resample buffer, st_rate_frames_in() is not a direct replacement and two additional MIN() functions are needed. One to prevent resample buffer overflows and one to limit the available bytes for the audio frontends.
After this patch the audio packet length calculation for playback is exact. When upsampling, it's still possible that the audio frontends can't write the last audio frame. This will be fixed later.
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20230224190555.7409-9-vr_qemu@t-online.de>
show more ...
|
1fe3cae3 | 24-Feb-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio: remove unused noop_conv() function
The function audio_capture_mix_and_clear() no longer uses audio_pcm_sw_write() to resample audio frames from one internal buffer to another. For this reason
audio: remove unused noop_conv() function
The function audio_capture_mix_and_clear() no longer uses audio_pcm_sw_write() to resample audio frames from one internal buffer to another. For this reason, the noop_conv() function is now unused. Remove it.
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20230224190555.7409-8-vr_qemu@t-online.de>
show more ...
|
671cca35 | 24-Feb-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio: don't misuse audio_pcm_sw_write()
The audio_pcm_sw_write() function is intended to convert a PCM audio stream to the internal representation, adjust the volume, and then mix it with the other
audio: don't misuse audio_pcm_sw_write()
The audio_pcm_sw_write() function is intended to convert a PCM audio stream to the internal representation, adjust the volume, and then mix it with the other audio streams with a possibly changed sample rate in mix_buf. In order for the audio_capture_mix_and_clear() function to use audio_pcm_sw_write(), it must bypass the first two tasks of audio_pcm_sw_write().
Since patch "audio: split out the resampling loop in audio_pcm_sw_write()" this is no longer necessary, because now the audio_pcm_sw_resample_out() function can be used instead of audio_pcm_sw_write().
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20230224190555.7409-7-vr_qemu@t-online.de>
show more ...
|
d5647bd9 | 24-Feb-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio: rename variables in audio_pcm_sw_write()
The audio_pcm_sw_write() function uses a lot of very unspecific variable names. Rename them for better readability.
ret => total_in total => total_ou
audio: rename variables in audio_pcm_sw_write()
The audio_pcm_sw_write() function uses a lot of very unspecific variable names. Rename them for better readability.
ret => total_in total => total_out size => buf_len hwsamples => hw->mix_buf.size samples => frames_in_max
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20230224190555.7409-6-vr_qemu@t-online.de>
show more ...
|
b8fc5638 | 24-Feb-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio: remove sw == NULL check
All call sites of audio_pcm_sw_write() guarantee that sw is not NULL. Remove the unnecessary NULL check.
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Re
audio: remove sw == NULL check
All call sites of audio_pcm_sw_write() guarantee that sw is not NULL. Remove the unnecessary NULL check.
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20230224190555.7409-5-vr_qemu@t-online.de>
show more ...
|
8a81abee | 24-Feb-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio: replace the resampling loop in audio_pcm_sw_write()
Replace the resampling loop in audio_pcm_sw_write() with the new function audio_pcm_sw_resample_out(). Unlike the old resample loop the new
audio: replace the resampling loop in audio_pcm_sw_write()
Replace the resampling loop in audio_pcm_sw_write() with the new function audio_pcm_sw_resample_out(). Unlike the old resample loop the new function will try to consume input frames even if the output buffer is full. This is necessary when downsampling to avoid reading less audio frames than calculated in advance. The loop was unrolled to avoid complicated loop control conditions in this case.
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20230224190555.7409-4-vr_qemu@t-online.de>
show more ...
|
8933882d | 24-Feb-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio: make the resampling code greedy
Read the maximum possible number of audio frames instead of the minimum necessary number of frames when the audio stream is downsampled and the output buffer i
audio: make the resampling code greedy
Read the maximum possible number of audio frames instead of the minimum necessary number of frames when the audio stream is downsampled and the output buffer is limited. This makes the function symmetrical to upsampling when the input buffer is limited. The maximum possible number of frames is written here.
With this change it's easier to calculate the exact number of audio frames the resample function will read or write. These two functions will be introduced later.
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20230224190555.7409-3-vr_qemu@t-online.de>
show more ...
|
2c3f9a0a | 24-Feb-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio: change type and name of the resample buffer
Change the type of the resample buffer from struct st_sample * to STSampleBuffer. Also change the name from buf to resample_buf for better readabil
audio: change type and name of the resample buffer
Change the type of the resample buffer from struct st_sample * to STSampleBuffer. Also change the name from buf to resample_buf for better readability.
The new variables resample_buf.size and resample_buf.pos will be used after the next patches. There is no functional change.
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20230224190555.7409-2-vr_qemu@t-online.de>
show more ...
|
8dbd3d17 | 24-Feb-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio: change type of mix_buf and conv_buf
Change the type of mix_buf in struct HWVoiceOut and conv_buf in struct HWVoiceIn from STSampleBuffer * to STSampleBuffer. However, a buffer pointer is stil
audio: change type of mix_buf and conv_buf
Change the type of mix_buf in struct HWVoiceOut and conv_buf in struct HWVoiceIn from STSampleBuffer * to STSampleBuffer. However, a buffer pointer is still needed. For this reason in struct STSampleBuffer samples[] is changed to *buffer.
This is a preparation for the next patch. The next patch will add this line, which is not possible with the current struct STSampleBuffer definition.
+ sw->resample_buf.buffer = hw->mix_buf.buffer + rpos2;
There are no functional changes.
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20230224190555.7409-1-vr_qemu@t-online.de>
show more ...
|
5140ad82 | 21-Jan-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
alsaaudio: reintroduce default recording settings
Audio recording with ALSA default settings currently doesn't work. The debug log shows updates every 0.75s and 1.5s.
audio: Elapsed since last alsa
alsaaudio: reintroduce default recording settings
Audio recording with ALSA default settings currently doesn't work. The debug log shows updates every 0.75s and 1.5s.
audio: Elapsed since last alsa run (running): 0.743030 audio: Elapsed since last alsa run (running): 1.486048 audio: Elapsed since last alsa run (running): 0.743008 audio: Elapsed since last alsa run (running): 1.485878 audio: Elapsed since last alsa run (running): 1.486040 audio: Elapsed since last alsa run (running): 1.485886
The time between updates should be in the 10ms range. Audio recording with ALSA has the same timing contraints as playback. Reintroduce the default recording settings and use the same default settings for recording as for playback.
The term "reintroduce" is correct because commit a93f328177 ("alsaaudio: port to -audiodev config") removed the default settings for recording.
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20230121094735.11644-11-vr_qemu@t-online.de>
show more ...
|
46744732 | 21-Jan-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
alsaaudio: change default playback settings
The currently used default playback settings in the ALSA audio backend are a bit unfortunate. With a few emulated audio devices, audio playback does not w
alsaaudio: change default playback settings
The currently used default playback settings in the ALSA audio backend are a bit unfortunate. With a few emulated audio devices, audio playback does not work properly. Here is a short part of the debug log while audio is playing (elapsed time in seconds).
audio: Elapsed since last alsa run (running): 0.046244 audio: Elapsed since last alsa run (running): 0.023137 audio: Elapsed since last alsa run (running): 0.023170 audio: Elapsed since last alsa run (running): 0.023650 audio: Elapsed since last alsa run (running): 0.060802 audio: Elapsed since last alsa run (running): 0.031931
For some audio devices the time of more than 23ms between updates is too long.
Set the period time to 5.8ms so that the maximum time between two updates typically does not exceed 11ms. This roughly matches the 10ms period time when doing playback with the audio timer. After this patch the debug log looks like this.
audio: Elapsed since last alsa run (running): 0.011919 audio: Elapsed since last alsa run (running): 0.005788 audio: Elapsed since last alsa run (running): 0.005995 audio: Elapsed since last alsa run (running): 0.011069 audio: Elapsed since last alsa run (running): 0.005901 audio: Elapsed since last alsa run (running): 0.006084
Acked-by: Christian Schoenebeck <qemu_oss@crudebyte.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20230121094735.11644-10-vr_qemu@t-online.de>
show more ...
|
2d2ccb60 | 21-Jan-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio: remove audio_calloc() function
Now that the last call site of audio_calloc() was removed, remove the unused audio_calloc() function.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> S
audio: remove audio_calloc() function
Now that the last call site of audio_calloc() was removed, remove the unused audio_calloc() function.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20230121094735.11644-9-vr_qemu@t-online.de>
show more ...
|
c6b69a81 | 21-Jan-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio/audio_template: use g_new0() to replace audio_calloc()
Replace audio_calloc() with the equivalent g_new0().
With a n_structs argument >= 1, g_new0() never returns NULL. Also remove the unnece
audio/audio_template: use g_new0() to replace audio_calloc()
Replace audio_calloc() with the equivalent g_new0().
With a n_structs argument >= 1, g_new0() never returns NULL. Also remove the unnecessary NULL checks.
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20230121094735.11644-8-vr_qemu@t-online.de>
show more ...
|
3724ab3b | 21-Jan-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio/audio_template: use g_malloc0() to replace audio_calloc()
Use g_malloc0() as a direct replacement for audio_calloc().
Since the type of the parameter n_bytes of the function g_malloc0() is un
audio/audio_template: use g_malloc0() to replace audio_calloc()
Use g_malloc0() as a direct replacement for audio_calloc().
Since the type of the parameter n_bytes of the function g_malloc0() is unsigned, the type of the variables voice_size_out and voice_size_in has been changed to size_t. This means that the function argument no longer has to be checked for negative values.
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20230121094735.11644-7-vr_qemu@t-online.de>
show more ...
|
d1def19f | 21-Jan-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio/alsaaudio: use g_new0() instead of audio_calloc()
Replace audio_calloc() with the equivalent g_new0().
The value of the g_new0() argument count is >= 1, which means g_new0() will never return
audio/alsaaudio: use g_new0() instead of audio_calloc()
Replace audio_calloc() with the equivalent g_new0().
The value of the g_new0() argument count is >= 1, which means g_new0() will never return NULL. Also remove the unnecessary NULL check.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20230121094735.11644-6-vr_qemu@t-online.de>
show more ...
|
25bf0c2d | 21-Jan-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio/mixeng: use g_new0() instead of audio_calloc()
Replace audio_calloc() with the equivalent g_new0().
With a n_structs argument of 1, g_new0() never returns NULL. Also remove the unnecessary NU
audio/mixeng: use g_new0() instead of audio_calloc()
Replace audio_calloc() with the equivalent g_new0().
With a n_structs argument of 1, g_new0() never returns NULL. Also remove the unnecessary NULL checks.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20230121094735.11644-5-vr_qemu@t-online.de>
show more ...
|
f8f8a8ac | 21-Jan-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio: remove unused #define AUDIO_STRINGIFY
Remove the unused #define AUDIO_STRINGIFY. It was last used before commit 470bcabd8f ("audio: Replace AUDIO_FUNC with __func__").
Reviewed-by: Philippe
audio: remove unused #define AUDIO_STRINGIFY
Remove the unused #define AUDIO_STRINGIFY. It was last used before commit 470bcabd8f ("audio: Replace AUDIO_FUNC with __func__").
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20230121094735.11644-4-vr_qemu@t-online.de>
show more ...
|
b637a61c | 21-Jan-2023 |
Volker Rümelin <vr_qemu@t-online.de> |
audio: rename hardware store to backend
Use a consistent friendly name for the HWVoiceOut and HWVoiceIn structures.
Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Volker Rümelin <vr_qem
audio: rename hardware store to backend
Use a consistent friendly name for the HWVoiceOut and HWVoiceIn structures.
Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20230121094735.11644-3-vr_qemu@t-online.de>
show more ...
|