Skip to contentSkip to conversation

sound is distorted when pulseaudio system timer scheduling is used (tsched=1)

DISCUSSION Raymond Yau 1 participant 1 message Aug 29, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 6 lines

I am having issue with pulseaudiosink,
I used following command to play a wav file
gst-launch filesrc location=<wav file path> ! wavparse ! pulseaudiosink

if tsched is enabled, then play of wav file via pulseaudiosink gives me

lots of Underrun, and the sound is distorted, following is the pulseaudio log when --log-level=3

Quoted 4 lines

I: [pulseaudio] protocol-native.c: Got credentials: uid=0 gid=0 success=1
I: [pulseaudio] sink-input.c: Trying to change sample rate
I: [pulseaudio] alsa-sink.c: Updating rate for device hw:0, new rate is

48000

Quoted 5 lines

I: [pulseaudio] source.c: Changed sampling rate successfully
I: [pulseaudio] sink.c: Changed sampling rate successfully
I: [pulseaudio] sink-input.c: Rate changed to 48000 Hz
I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Trying resume...
I: [alsa-sink-HiFi wm8962-0] alsa-util.c: cannot disable ALSA period

wakeups

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-util.c: ALSA period wakeups were not

disabled

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Time scheduling watermark is

18.38ms

Quoted 3 lines

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Resumed successfully...
I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Starting playback.
I: [pulseaudio] sink-input.c: Created input 0 "pulsesink probe" on

alsa_output.platform-sound.analog-s

Quoted 1 line

tereo with sample spec s16le 2ch 48000Hz and channel map

front-left,front-right

Quoted 3 lines

I: [pulseaudio] sink-input.c: media.name = "pulsesink probe"
I: [pulseaudio] sink-input.c: application.name = "gst-launch-0.10"
I: [pulseaudio] sink-input.c: native-protocol.peer = "UNIX socket

client"

Quoted 5 lines

I: [pulseaudio] sink-input.c: native-protocol.version = "29"
I: [pulseaudio] sink-input.c: application.process.id = "985"
I: [pulseaudio] sink-input.c: application.process.user = "root"
I: [pulseaudio] sink-input.c: application.process.host = "mx6q"
I: [pulseaudio] sink-input.c: application.process.binary =

"gst-launch-0.10"

Quoted 2 lines

I: [pulseaudio] sink-input.c: application.language = "C"
I: [pulseaudio] sink-input.c: application.process.machine_id =

"0aa7a9566c734f608cbd36f187de8645"

Quoted 1 line

I: [pulseaudio] sink-input.c: module-stream-restore.id =

"sink-input-by-application-name:gst-launc

Quoted 2 lines

h-0.10"
I: [pulseaudio] protocol-native.c: Requested tlength=250.00 ms,

minreq=20.00 ms

Quoted 1 line

I: [pulseaudio] protocol-native.c: Final latency 250.00 ms = 105.00 ms +

2*20.00 ms + 105.00 ms

Quoted 2 lines

I: [pulseaudio] sink-input.c: Freeing input 0 "pulsesink probe"
I: [pulseaudio] sink-input.c: Created input 1 "Playback Stream" on

alsa_output.platform-sound.analog-s

Quoted 1 line

tereo with sample spec s16le 2ch 48000Hz and channel map

front-left,front-right

Quoted 3 lines

I: [pulseaudio] sink-input.c: media.name = "Playback Stream"
I: [pulseaudio] sink-input.c: application.name = "gst-launch-0.10"
I: [pulseaudio] sink-input.c: native-protocol.peer = "UNIX socket

client"

Quoted 5 lines

I: [pulseaudio] sink-input.c: native-protocol.version = "29"
I: [pulseaudio] sink-input.c: application.process.id = "985"
I: [pulseaudio] sink-input.c: application.process.user = "root"
I: [pulseaudio] sink-input.c: application.process.host = "mx6q"
I: [pulseaudio] sink-input.c: application.process.binary =

"gst-launch-0.10"

Quoted 2 lines

I: [pulseaudio] sink-input.c: application.language = "C"
I: [pulseaudio] sink-input.c: application.process.machine_id =

"0aa7a9566c734f608cbd36f187de8645"

Quoted 1 line

I: [pulseaudio] sink-input.c: module-stream-restore.id =

"sink-input-by-application-name:gst-launc

Quoted 2 lines

h-0.10"
I: [pulseaudio] protocol-native.c: Requested tlength=200.00 ms,

minreq=10.00 ms

Quoted 1 line

I: [pulseaudio] protocol-native.c: Final latency 200.00 ms = 90.00 ms +

2*10.00 ms + 90.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing wakeup watermark to

28.38 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing wakeup watermark to

38.38 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing wakeup watermark to

48.38 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing wakeup watermark to

58.38 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing wakeup watermark to

68.38 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing wakeup watermark to

78.38 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing wakeup watermark to

80.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

1.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

2.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

4.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

8.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

16.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

26.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

36.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

46.00 ms

Quoted 1 line

E: [alsa-sink-HiFi wm8962-0] alsa-sink.c: ALSA woke us up to write new

data to the device, but there w

Quoted 2 lines

as actually nothing to write!
E: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Most likely this is a bug in

the ALSA driver '(null)'. Pleas

Quoted 2 lines

e report this issue to the ALSA developers.
E: [alsa-sink-HiFi wm8962-0] alsa-sink.c: We were woken up with POLLOUT

set -- however a subsequent sn

Quoted 2 lines

d_pcm_avail() returned 0 or another value < min_avail.
I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

56.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

66.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

76.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

86.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

96.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing wakeup watermark to

86.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

106.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing wakeup watermark to

96.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

116.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing wakeup watermark to

106.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

126.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing wakeup watermark to

116.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

136.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing wakeup watermark to

126.00 ms

Quoted 2 lines

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Underrun!
I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

146.00 ms

Quoted 2 lines

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Underrun!
I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing wakeup watermark to

136.00 ms

Quoted 2 lines

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Underrun!
I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

156.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing wakeup watermark to

146.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

166.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing wakeup watermark to

156.00 ms

Quoted 1 line

I: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Increasing minimal latency to

176.00 ms

Quoted 5 lines

I: [pulseaudio] sink-input.c: Freeing input 1 "Playback Stream"
I: [pulseaudio] client.c: Freed 4 "gst-launch-0.10"
I: [pulseaudio] protocol-native.c: Connection died.

from the log it seems like, when system timer based scheduling is used,

then pulseaudio will try to keep minimum watermark/latency, only when Underrun occurs, it will increase watermark/latency.

Quoted 5 lines

Is this the expected behaviour of pulseaudio 'glict free' feature?

And from the log there is some error message complain about ALSA driver
E: [alsa-sink-HiFi wm8962-0] alsa-sink.c: ALSA woke us up to write new

data to the device, but there w

Quoted 2 lines

as actually nothing to write!
E: [alsa-sink-HiFi wm8962-0] alsa-sink.c: Most likely this is a bug in

the ALSA driver '(null)'. Pleas

Quoted 2 lines

e report this issue to the ALSA developers.
E: [alsa-sink-HiFi wm8962-0] alsa-sink.c: We were woken up with POLLOUT

set -- however a subsequent sn

Quoted 3 lines

d_pcm_avail() returned 0 or another value < min_avail.

does this mean, there is some bug in ALSA driver, or it just indicates

the ALSA driver doesn't support glitch free feature very well

The timer base scheduling require sound card driver provide accurate hw_ptr position at any time.

So far only two sound card drivers snd-hda-intel and snd-oxygen can provide accurate hw_ptr position from hardware register

static snd_pcm_uframes_t dmaengine_pcm_pointer( struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform);

if (pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE) return snd_dmaengine_pcm_pointer_no_residue(substream); else
return snd_dmaengine_pcm_pointer(substream);
}

http://lxr.free-electrons.com/ident?i=dmaengine_tx_status

Seem none of soc sound drivers can report position accurate than period size

Is there any reason to enable timer based scheduling by default ?

http://mailman.alsa-project.org/pipermail/alsa-devel/2014-September/081501.html

You can try alexandra 's program to find out how accuate hw_ptr can your sound card driver can report ?

_______________________________________________
pulseaudio-discuss mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss