Bug 80710

Summary: Pulseaudio 5.0 uses 100% CPU time after system resumes from hibernation.
Product: PulseAudio Reporter: Dimitrios Semitsoglou-Tsiapos <kmhzsem>
Component: daemonAssignee: pulseaudio-bugs
Status: RESOLVED MOVED QA Contact: pulseaudio-bugs
Severity: normal    
Priority: medium CC: lennart, main.haarp
Version: unspecified   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: pulseaudio --log-time -vvvvv
more /etc/pulse/*
full gdb backtrace
asound.conf
pulseaudio with dmixer as default
pcm_rewindable.c output

Description Dimitrios Semitsoglou-Tsiapos 2014-06-30 12:13:29 UTC
Created attachment 102010 [details]
pulseaudio --log-time -vvvvv

As described in the title.

Could be related to Bug 71078.
Comment 1 Dimitrios Semitsoglou-Tsiapos 2014-06-30 12:14:10 UTC
Created attachment 102011 [details]
more /etc/pulse/*
Comment 2 Dimitrios Semitsoglou-Tsiapos 2014-06-30 12:14:34 UTC
Created attachment 102012 [details]
full gdb backtrace
Comment 3 Dimitrios Semitsoglou-Tsiapos 2014-06-30 12:15:09 UTC
Created attachment 102013 [details]
asound.conf
Comment 4 Raymond 2014-06-30 16:18:10 UTC
as you are customize pulseaudio to use dmix as default sink



http://mailman.alsa-project.org/pipermail/alsa-devel/2014-May/076475.html

you may need to use Alexander 's program whether dmix plugin should return zero for snd_pcm_rewindable and should alsa lib should return error when disable period wake-up when using dmix

strange that stop threshold is zero when pulseaudio using dmix


aplay -v -D plug:dmix Foo.wav
Comment 5 Dimitrios Semitsoglou-Tsiapos 2014-06-30 17:40:12 UTC
(In reply to comment #4)

As the configuration is now, and while pulseaudio is running `aplay -v -D plug:dmix Foo.wav` plays.
> as you are customize pulseaudio to use dmix as default sink

I added the following block and changed device="default" to device="dmixer",
pcm.dmixer {
    type dmix
        ipc_key 1024
        ipc_key_add_uid false
        ipc_perm 0660
        slave {
            pcm "hw:0,0"
            period_time 0
                period_size 1024
                buffer_size 8192
                rate 44100
                channels 2
        }
}

Now I get:
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.27.2/work/alsa-lib-1.0.27.2/src/pcm/pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
aplay: main:722: audio open error: Device or resource busy

> http://mailman.alsa-project.org/pipermail/alsa-devel/2014-May/076475.html
> 
> you may need to use Alexander 's program whether dmix plugin should return
> zero for snd_pcm_rewindable and should alsa lib should return error when
> disable period wake-up when using dmix

I am not sure how to obtain Alexander's program or how to check for these values.
Comment 6 Dimitrios Semitsoglou-Tsiapos 2014-06-30 17:41:00 UTC
Created attachment 102024 [details]
pulseaudio with dmixer as default
Comment 7 Raymond 2014-07-01 02:34:41 UTC
http://mailman.alsa-project.org/pipermail/alsa-devel/2014-May/076480.html

does your sound card suspend and resume normally when not using pulseaudio ?

aplay -D hw:0,0 stereo.wav

aplay -D plughw:0,0 stereo.wav

aplay -D plug:dmix stereo.wav

refer to your log

dmix usually set stop threshold to boundary 


(   0.189|   0.000) D: [pulseaudio] alsa-util.c:   start_threshold  : 1
(   0.189|   0.000) D: [pulseaudio] alsa-util.c:   stop_threshold   : 0
(   0.189|   0.000) D: [pulseaudio] alsa-util.c:   silence_threshold: 0
(   0.189|   0.000) D: [pulseaudio] alsa-util.c:   silence_size : 0

(   0.189|   0.000) D: [pulseaudio] alsa-util.c:   boundary     : 4611686018427387904
(   0.189|   0.000) D: [pulseaudio] alsa-util.c:   appl_ptr     : 0
(   0.189|   0.000) D: [pulseaudio] alsa-util.c:   hw_ptr       : 8138786
(   0.189|   0.000) D: [alsa-sink-ALC887 Analog] alsa-sink.c: Thread starting up
(   0.197|   0.007) I: [alsa-sink-ALC887 Analog] core-util.c: Failed to acquire real-time scheduling: No such file or directory
(   0.198|   0.000) I: [alsa-sink-ALC887 Analog] alsa-sink.c: Starting playback.


hwptr already ahead of appl_ptr before pulseaudio call snd_pcm_start






his program pcm_rewindable.c want to check when did hw ptr update  by writing square wave and rewind in periods
Comment 8 Dimitrios Semitsoglou-Tsiapos 2014-07-01 08:10:12 UTC
(In reply to comment #7)
> does your sound card suspend and resume normally when not using pulseaudio ?
> 
> aplay -D hw:0,0 stereo.wav
> 
> aplay -D plughw:0,0 stereo.wav
> 
> aplay -D plug:dmix stereo.wav

These commands work fine.

> his program pcm_rewindable.c want to check when did hw ptr update  by
> writing square wave and rewind in periods

I ran it with the above devices and I'm attaching the output.
Comment 9 Dimitrios Semitsoglou-Tsiapos 2014-07-01 08:10:35 UTC
Created attachment 102059 [details]
pcm_rewindable.c output
Comment 10 Raymond 2014-07-01 15:35:08 UTC
 
you can change dmix format to use S16_LE instead of 32 bits 

http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=src/conf/alsa.conf;hb=HEAD

defaults.pcm.dmix.format 


http://git.alsa-project.org/?p=alsa-lib.git;a=commit;h=614a66bb2a94ee64e37935fed7a0adc1e822dc2e

http://git.alsa-project.org/?p=alsa-lib.git;a=commit;h=5256e150eb34cf599e79839feaff7398ed67a499

there are patches which remove support of rewind from rate plugin
Comment 11 Raymond 2014-07-02 02:01:17 UTC
(   0.187|   0.000) I: [pulseaudio] alsa-util.c: Trying to disable ALSA period wakeups, using timers only
(   0.187|   0.000) D: [pulseaudio] alsa-util.c: snd_pcm_hw_params_set_format(Signed 16 bit Little Endian) failed: Invalid argument
(   0.187|   0.000) D: [pulseaudio] alsa-util.c: snd_pcm_hw_params_set_format(Signed 16 bit Big Endian) failed: Invalid argument
(   0.188|   0.000) D: [pulseaudio] alsa-util.c: snd_pcm_hw_params_set_format(Float 32 bit Little Endian) failed: Invalid argument
(   0.188|   0.000) D: [pulseaudio] alsa-util.c: snd_pcm_hw_params_set_format(Float 32 bit Big Endian) failed: Invalid argument
(   0.188|   0.000) D: [pulseaudio] alsa-util.c: Maximum hw buffer size is 341 ms
(   0.188|   0.000) D: [pulseaudio] alsa-util.c: Set buffer size first (to 96000 samples), period size second (to 96000 samples).
(   0.188|   0.000) I: [pulseaudio] alsa-util.c: Device default doesn't support 44100 Hz, changed to 48000 Hz.
(   0.188|   0.000) I: [pulseaudio] alsa-util.c: Device default doesn't support sample format s16le, changed to s32le.
(   0.188|   0.000) I: [pulseaudio] alsa-util.c: ALSA period wakeups disabled

you can change dmix default rate and format to reduce the coversion
Comment 13 Raymond 2014-07-03 03:23:37 UTC
340|   0.021) D: [alsa-sink-ALC887 Analog] alsa-sink.c: Cutting sleep time for the initial iterations by half.
(   0.361|   0.021) D: [alsa-sink-ALC887 Analog] alsa-sink.c: Cutting sleep time for the initial iterations by half.
(  49.612|  49.250) D: [alsa-source-USB Audio] alsa-util.c: Got POLLERR from ALSA
(  49.612|   0.000) W: [alsa-source-USB Audio] alsa-util.c: Got POLLNVAL from ALSA
(  49.612|   0.000) D: [alsa-source-USB Audio] alsa-util.c: PCM state is DISCONNECTED
(  49.612|   0.000) W: [alsa-source-USB Audio] alsa-util.c: Could not recover from POLLERR|POLLNVAL|POLLHUP with snd_pcm_prepare(): No such device
(  49.612|   0.000) I: [alsa-sink-ALC887 Analog] alsa-sink.c: Scheduling delay of 39174.92 ms > 9.21 ms, you might want to investigate this to improve latency...
(  49.612|   0.000) D: [alsa-sink-ALC887 Analog] alsa-util.c: Got POLLERR from ALSA
(  49.612|   0.000) D: [alsa-sink-ALC887 Analog] alsa-util.c: Got POLLOUT from ALSA
(  49.612|   0.000) D: [alsa-sink-ALC887 Analog] alsa-util.c: PCM state is SUSPENDED

seem USB audio disconnect
Comment 14 GitLab Migration User 2018-07-30 10:00:04 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/160.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.