Skip to contentSkip to conversation

pulseaudio: process audio data in smaller chunks

PATCH In review Gerd Hoffmann 3 participants 8 messages Nov 9, 2018 – Nov 12, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 pulseaudio: process audio data in smaller chunks

The rate of pulseaudio absorbing the audio stream is used to control the the rate of the guests audio stream. When the emulated hardware uses small chunks (like intel-hda does) we need small chunks on the audio backend side too, otherwise that feedback loop doesn't work very well.

---
 audio/paaudio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
audio/paaudio.c +2 -2
index 949769774d..4c100bc318 100644
@@ -227,7 +227,7 @@ static void *qpa_thread_out (void *arg)
             }
         }
 
-        decr = to_mix = audio_MIN (pa->live, pa->g->conf.samples >> 2);
+        decr = to_mix = audio_MIN(pa->live, pa->g->conf.samples >> 5);
         rpos = pa->rpos;
 
         if (audio_pt_unlock(&pa->pt, __func__)) {
@@ -319,7 +319,7 @@ static void *qpa_thread_in (void *arg)
             }
         }
 
-        incr = to_grab = audio_MIN (pa->dead, pa->g->conf.samples >> 2);
+        incr = to_grab = audio_MIN(pa->dead, pa->g->conf.samples >> 5);
         wpos = pa->wpos;
 
         if (audio_pt_unlock(&pa->pt, __func__)) {
Signature · 1 line
2.9.3
#1 lore raw

Hi Gerd,

Quoted 4 lines · Gerd Hoffmann

The rate of pulseaudio absorbing the audio stream is used to control the the rate of the guests audio stream. When the emulated hardware uses small chunks (like intel-hda does) we need small chunks on the audio backend side too, otherwise that feedback loop doesn't work very well.

Shouldn't this be user-configurable?

Quoted 32 lines
---
 audio/paaudio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
audio/paaudio.c +2 -2
index 949769774d..4c100bc318 100644
@@ -227,7 +227,7 @@ static void *qpa_thread_out (void *arg)
             }
         }
 
-        decr = to_mix = audio_MIN (pa->live, pa->g->conf.samples >> 2);
+        decr = to_mix = audio_MIN(pa->live, pa->g->conf.samples >> 5);
         rpos = pa->rpos;
 
         if (audio_pt_unlock(&pa->pt, __func__)) {
@@ -319,7 +319,7 @@ static void *qpa_thread_in (void *arg)
             }
         }
 
-        incr = to_grab = audio_MIN (pa->dead, pa->g->conf.samples >> 2);
+        incr = to_grab = audio_MIN(pa->dead, pa->g->conf.samples >> 5);
         wpos = pa->wpos;
 
         if (audio_pt_unlock(&pa->pt, __func__)) {
#2 lore raw
Quoted 9 lines · Philippe Mathieu-Daudé

Hi Gerd,

Quoted 4 lines · Gerd Hoffmann

The rate of pulseaudio absorbing the audio stream is used to control the the rate of the guests audio stream. When the emulated hardware uses small chunks (like intel-hda does) we need small chunks on the audio backend side too, otherwise that feedback loop doesn't work very well.

Shouldn't this be user-configurable?

Why?

cheers,
Gerd

#3 lore raw
Quoted 4 lines · Gerd Hoffmann
Quoted 3 lines · Philippe Mathieu-Daudé

Hi Gerd,

On 11/9/18 3:20 PM, Gerd Hoffmann wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

The rate of pulseaudio absorbing the audio stream is used to control the the rate of the guests audio stream. When the emulated hardware uses small chunks (like intel-hda does) we need small chunks on the audio backend side too, otherwise that feedback loop doesn't work very well.

Shouldn't this be user-configurable?

Why?

When emulated hardware is not intel-hda?

#4 lore raw
Quoted 10 lines · Philippe Mathieu-Daudé
Quoted 9 lines · Gerd Hoffmann
Quoted 8 lines · Philippe Mathieu-Daudé

Hi Gerd,

Quoted 4 lines · Gerd Hoffmann

The rate of pulseaudio absorbing the audio stream is used to control the the rate of the guests audio stream. When the emulated hardware uses small chunks (like intel-hda does) we need small chunks on the audio backend side too, otherwise that feedback loop doesn't work very well.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Shouldn't this be user-configurable?

Why?

When emulated hardware is not intel-hda?

Ok, maybe it is not required then, but it also doesn't hurt.

Also, when making chunk size configurable we should not leave that to the confused user but pick a working value automatically, probably depending on the emulated device. I can't see what the benefit would be though, especially given that intel-hda is probably used in most configurations these days.

cheers,
Gerd

#5 lore raw
Quoted 17 lines · Gerd Hoffmann
Quoted 10 lines · Philippe Mathieu-Daudé
Quoted 9 lines · Gerd Hoffmann
Quoted 8 lines · Philippe Mathieu-Daudé

Hi Gerd,

Quoted 4 lines · Gerd Hoffmann

The rate of pulseaudio absorbing the audio stream is used to control the the rate of the guests audio stream. When the emulated hardware uses small chunks (like intel-hda does) we need small chunks on the audio backend side too, otherwise that feedback loop doesn't work very well.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Shouldn't this be user-configurable?

Why?

When emulated hardware is not intel-hda?

Quoted 7 lines

Ok, maybe it is not required then, but it also doesn't hurt.

Also, when making chunk size configurable we should not leave that to the confused user but pick a working value automatically, probably depending on the emulated device. I can't see what the benefit would be though, especially given that intel-hda is probably used in most configurations these days.

For nowadays uses I agree with your patch.
For retrocomputing and other weird stuffs, if we don't have this user-configurable, I think we need a comment in the code about this change, else it might be hard for other people to figure this change in the git history.

With a such comment:

Regards,

Phil.

#6 lore raw
Quoted 11 lines
Quoted 5 lines

Also, when making chunk size configurable we should not leave that to the confused user but pick a working value automatically, probably depending on the emulated device. I can't see what the benefit would be though, especially given that intel-hda is probably used in most configurations these days.

For nowadays uses I agree with your patch.
For retrocomputing and other weird stuffs, if we don't have this user-configurable, I think we need a comment in the code about this change, else it might be hard for other people to figure this change in the git history.

Again, why? The pulse audio threads might wake up more often than needed. This should have no negative effect on the functionality of the emulated sound cards though. Worst case is we need a few more cpu cycles due to the higher wakeup rate (didn't measure that though).

cheers,
Gerd

#7 lore raw
Quoted 13 lines · Gerd Hoffmann
Quoted 7 lines
Quoted 6 lines

Also, when making chunk size configurable we should not leave that to the confused user but pick a working value automatically, probably depending on the emulated device. I can't see what the benefit would be though, especially given that intel-hda is probably used in most configurations these days.

Quoted 5 lines

For nowadays uses I agree with your patch.
For retrocomputing and other weird stuffs, if we don't have this user-configurable, I think we need a comment in the code about this change, else it might be hard for other people to figure this change in the git history.

Quoted 4 lines

Again, why? The pulse audio threads might wake up more often than needed. This should have no negative effect on the functionality of the emulated sound cards though. Worst case is we need a few more cpu cycles due to the higher wakeup rate (didn't measure that though).

OK, fine then!

Thanks,

Phil.