Bug 104884 - sound does not work after suspend to disk
Summary: sound does not work after suspend to disk
Status: RESOLVED FIXED
: 104100 (view as bug list)
Alias: None
Product: SUSE LINUX 10.0
Classification: openSUSE
Component: Sound (show other bugs)
Version: Beta 1
Hardware: i686 All
: P5 - None : Major
Target Milestone: ---
Assignee: Jaroslav Kysela
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on: 104100
Blocks:
  Show dependency treegraph
 
Reported: 2005-08-16 09:14 UTC by László Attila Tóth
Modified: 2005-08-18 12:03 UTC (History)
0 users

See Also:
Found By: Other
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
output of lsmod (3.77 KB, text/plain)
2005-08-16 10:29 UTC, László Attila Tóth
Details
Run aplay using LD_PRELOAD to debug library (127 bytes, application/octet-stream)
2005-08-18 07:28 UTC, Jaroslav Kysela
Details
testcase outputs (12.48 KB, application/x-bzip2)
2005-08-18 10:14 UTC, László Attila Tóth
Details
The official patch solving the resource server problem (it is also commited to ALSA CVS) (939 bytes, text/plain)
2005-08-18 11:01 UTC, Jaroslav Kysela
Details
pcm_direct.c.rej file (959 bytes, application/octet-stream)
2005-08-18 11:18 UTC, László Attila Tóth
Details

Note You need to log in before you can comment on or make changes to this bug.
Description László Attila Tóth 2005-08-16 09:14:24 UTC
before suspend to disk no apps uses sound device (sound module: snd_intel8x0),
but after suspend all applications tell that /dev/dsp: device or resurce busy.
Comment 1 Olaf Kirch 2005-08-16 09:24:32 UTC
Jaroslav, can you look into this please? Thanks! 
Comment 2 Jaroslav Kysela 2005-08-16 09:32:06 UTC
It might be related to bug #104100 . Can you give me output from 'lsmod' and
'fuser -v /dev/dsp' and 'fuser -v /dev/snd/pcmC0D0p' after resume ?
Comment 3 László Attila Tóth 2005-08-16 10:29:39 UTC
Created attachment 46149 [details]
output of lsmod
Comment 4 László Attila Tóth 2005-08-16 10:36:29 UTC
# fuser -v /dev/snd/pcmC0D0p

                     USER        PID ACCESS COMMAND
/dev/snd/pcmC0D0p    panther    6440 f...m  knotify


The output of fuser -v /dev/dsp is empty.
lsmod output is attached to bug report.

It seems related to both bug #104100  and bug #104078. Somehow I didn't see 
Comment 5 László Attila Tóth 2005-08-16 10:43:07 UTC
> It seems related to both bug #104100  and bug #104078. Somehow I didn't see 
also: i saw only artsd in process list. after killing knotify I can write
/dev/dsp but xmms with alsa output does not work, only after restarting of xmms.
Comment 6 Jaroslav Kysela 2005-08-17 09:41:49 UTC
Could you try to compile and test the alsa-lib package from the ALSA's CVS? See
http://www.alsa-project.org - Download link. The changes should be also in
beta3, but I would appreciate faster testing...
Comment 7 László Attila Tóth 2005-08-17 10:31:06 UTC
Fisrt, cvs checkout was at about 12:00 CEST.
Usually when xmms is paused, it can continue playing that song after resume.
When the song ends, next can't be played.
Now i installed the alsa-lib (to /usr/lib + I run ldconfig). After resume xmms
works. (in this case neither artsd nor knotify runs).
Comment 8 László Attila Tóth 2005-08-17 10:40:01 UTC
after resume when nothing using /dev/snd/pcmC0D0p, but only the cvs version of
alsa-lib works. With running knotify it still doesn't work (both xmms and
knotify uses the device, and the next song can't be played).
Comment 9 Jaroslav Kysela 2005-08-17 11:07:57 UTC
Please, attach or include contents from files ~/.kde/share/config/kcmartsrc and
~/.kde/share/config/knotifyrc .
Comment 10 László Attila Tóth 2005-08-17 11:38:39 UTC
Contents:
panther@zeratul:~> cat ~/.kde/share/config/kcmartsrc
[Arts]
AddOptions=
Arguments=\s-F 10 -S 4096 -a alsa -s 60 -m artsmessage -c drkonqi -l 3 -f
AudioIO=alsa
AutoSuspend=true
Bits=0
DeviceName=
FullDuplex=false
Latency=250
NetworkTransparent=false
SamplingRate=0
StartRealtime=true
StartServer=true
SuspendTime=60
panther@zeratul:~> cat ~/.kde/share/config/knotifyrc
[Misc]
LastConfiguredApp=Akregator

[StartProgress]
Arts Init=true
KNotify Init=true
Use Arts=true
Comment 11 Jaroslav Kysela 2005-08-17 13:49:47 UTC
Do you see any error messages from xmms (try run it from a terminal window)?
Please, send me 'fuser -v /dev/snd/pcmC0D0p' and 'ps ax | grep -E
"(arts|knotify|xmms)"' contents after resume when knotify is enabled and CVS
version of alsa-lib is installed.

Also, you might use 'aplay' tool instead xmms from the terminal window.
Comment 12 László Attila Tóth 2005-08-17 14:54:06 UTC
zeratul:~ # ps ax | grep -E "(arts|knotify|xmms)"
31067 pts/2    SL     0:00 knotify
31104 pts/1    SLl+   0:01 xmms
31410 pts/3    S+     0:00 grep -E (arts|knotify|xmms)
zeratul:~ # fuser -v /dev/snd/pcmC0D0p

                     USER        PID ACCESS COMMAND
/dev/snd/pcmC0D0p    panther   31067 f...m  knotify

My Konsole has more tabs, also knotify used when i try to close it. Before
suspend  it writes to output:
"auto_sink: Could not load polyp
Cannot open client
akode: ALSA fragment-size: 940"

after resume it says (when try to close the window):
"auto_sink: Could not load polyp
Cannot open client
ALSA lib pcm_direct.c:218:(make_local_socket) connect failed:
/tmp/alsa-dmix-31067-1124289631-49777: No such file or directory
ALSA lib pcm_dmix.c:850:(snd_pcm_dmix_open) unable to connect client"

XMMS:
at startup:
"/usr/lib/xmms/General/libir.so: undefined symbol: irapp_thread
/usr/lib/xmms/Visualization/libmadspin.so: undefined symbol: config_window"
after resume:
ALSA lib pcm_direct.c:218:(make_local_socket) connect failed:
/tmp/alsa-dmix-31067-1124289631-49777: No such file or directory
ALSA lib pcm_dmix.c:850:(snd_pcm_dmix_open) unable to connect client

** WARNING **: alsa_setup(): Failed to open pcm device (default): Nincs ilyen
fájl vagy könyvtár


Comment 13 Jaroslav Kysela 2005-08-17 16:55:54 UTC
So we are in the really same situation as reported in bug #104100 .
Please, could you kill artsd and knotify and reproduce the 'connect failed' bug
with plain aplay?

1) on first console give 'aplay <some_wav_file>'
2) send output from 'ps ax | grep aplay'
3) suspend
4) resume
5) send output from 'ps ax | grep aplay' after resume
6) try run second 'aplay <some_wav_file>' in another terminal window (and you
should get the 'connect failed bug' here)

If you can reproduce, I will ask you to provide more debug info (with special
alsa-lib).
Comment 14 László Attila Tóth 2005-08-17 17:29:08 UTC
> 2) send output from 'ps ax | grep aplay'
zeratul:~ # ps ax | grep aplay
32715 pts/2    SL+    0:00 aplay music/sc/music/protoss1.wav
32717 ?        Ss     0:00 aplay music/sc/music/protoss1.wav
32719 pts/3    R+     0:00 grep aplay
> 5) send output from 'ps ax | grep aplay' after resume
zeratul:~ # ps ax | grep aplay
32715 pts/2    SL+    0:01 aplay music/sc/music/protoss1.wav
  542 pts/3    S+     0:00 grep aplay
> 6) try run second 'aplay <some_wav_file>' in another terminal window (and you
> should get the 'connect failed bug' here)
panther@zeratul:~> aplay music/sc/music/tvict.wav
ALSA lib pcm_direct.c:218:(make_local_socket) connect failed:
/tmp/alsa-dmix-32715-1124299090-838259: No such file or directory
ALSA lib pcm_dmix.c:850:(snd_pcm_dmix_open) unable to connect client
aplay: main:540: audio open error: No such file or directory

After killing the first aplay, I don't get any error messages.
Comment 15 László Attila Tóth 2005-08-17 17:31:20 UTC
I forget to tell, that knotify is not running.
Comment 16 Jaroslav Kysela 2005-08-18 07:28:47 UTC
Created attachment 46406 [details]
Run aplay using LD_PRELOAD to debug library
Comment 17 Jaroslav Kysela 2005-08-18 07:33:33 UTC
Please, enable SERVER_JOB_DEBUG in pcm_direct.c (alsa-lib) like:

Index: pcm_direct.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_direct.c,v
retrieving revision 1.43
diff -u -r1.43 pcm_direct.c
--- pcm_direct.c        17 Aug 2005 14:00:32 -0000      1.43
+++ pcm_direct.c        18 Aug 2005 07:29:39 -0000
@@ -226,7 +226,7 @@
        return sock;
 }

-#if 0
+#if 1
 #define SERVER_JOB_DEBUG
 #define server_printf(fmt, args...) printf(fmt, ##args)
 #else


Then run the debug library exactly in same way as described in comment #13
(don't attach the ps outputs). I need the output from console/terminal from the
first aplay command (strip duplicate lines, please).

I also attached a small 'go' script to run aplay with the debug library without
installing alsa-lib to system paths. Simply, correct paths in this file for aply
and alsa-lib.
Comment 18 Matthias Hopf 2005-08-18 09:21:26 UTC
*** Bug 104100 has been marked as a duplicate of this bug. ***
Comment 19 László Attila Tóth 2005-08-18 10:14:49 UTC
Created attachment 46450 [details]
testcase outputs

Please read first bug/README in the tar.bz2 file.
Comment 20 Jaroslav Kysela 2005-08-18 10:33:41 UTC
Thanks, please, modify pcm_direct.c in this way (I need to know the errno value)
and retry. Don't enable DBG= lines in your go script. I need only "DIRECT
SERVER: " lines printed to stdout.

--- pcm_direct.c        17 Aug 2005 14:00:32 -0000      1.43
+++ pcm_direct.c        18 Aug 2005 10:30:40 -0000
@@ -226,7 +226,7 @@
        return sock;
 }

-#if 0
+#if 1
 #define SERVER_JOB_DEBUG
 #define server_printf(fmt, args...) printf(fmt, ##args)
 #else
@@ -287,7 +287,7 @@
        server_printf("DIRECT SERVER STARTED\n");
        while (1) {
                ret = poll(pfds, current + 1, 500);
-               server_printf("DIRECT SERVER: poll ret = %i, revents[0] =
0x%x\n", ret, pfds[0].revents);
+               server_printf("DIRECT SERVER: poll ret = %i, revents[0] = 0x%x,
errno = %i\n", ret, pfds[0].revents, errno);
                if (ret < 0)    /* some error */
                        break;
                if (ret == 0 || (pfds[0].revents & (POLLERR | POLLHUP))) {    
/* timeout or error? */
Comment 21 Jaroslav Kysela 2005-08-18 10:38:51 UTC
I think that errno would be EINTR, so bellow patch might fix the resume issue:

diff -u -r1.43 pcm_direct.c
--- pcm_direct.c        17 Aug 2005 14:00:32 -0000      1.43
+++ pcm_direct.c        18 Aug 2005 10:37:50 -0000
@@ -226,7 +226,7 @@
        return sock;
 }

-#if 0
+#if 1
 #define SERVER_JOB_DEBUG
 #define server_printf(fmt, args...) printf(fmt, ##args)
 #else
@@ -287,9 +287,13 @@
        server_printf("DIRECT SERVER STARTED\n");
        while (1) {
                ret = poll(pfds, current + 1, 500);
-               server_printf("DIRECT SERVER: poll ret = %i, revents[0] =
0x%x\n", ret, pfds[0].revents);
-               if (ret < 0)    /* some error */
+               server_printf("DIRECT SERVER: poll ret = %i, revents[0] = 0x%x,
errno = %i\n", ret, pfds[0].revents, errno);
+               if (ret < 0) {
+                       if (errno == EINTR)
+                               continue;
+                       /* some error */
                        break;
+               }
                if (ret == 0 || (pfds[0].revents & (POLLERR | POLLHUP))) {    
/* timeout or error? */
                        struct shmid_ds buf;
                        snd_pcm_direct_semaphore_down(dmix, DIRECT_IPC_SEM_CLIENT);
Comment 22 László Attila Tóth 2005-08-18 10:57:47 UTC
(In reply to comment #20)
DIRECT SERVER: poll ret = 0, revents[0] = 0x0, errno = 9
DIRECT SERVER: nattch = 2
(the same during play)
DIRECT SERVER: poll ret = 0, revents[0] = 0x0, errno = 9
DIRECT SERVER: nattch = 2
DIRECT SERVER: poll ret = -1, revents[0] = 0x0, errno = 4
Suspended. Trying resume. Done.
DIRECT SERVER EXIT

I have a little bit different version of the file. 
#if 1  // is in line number 225 (in mcedit)
server_printf("DIRECT SERVER STARTED\n");  // is in line number 256.
Comment post breaks your copied diff files, also could you attach them?
(now i'll try your next code)

Comment 23 Jaroslav Kysela 2005-08-18 11:01:24 UTC
Created attachment 46461 [details]
The official patch solving the resource server problem (it is also commited to ALSA CVS)
Comment 24 László Attila Tóth 2005-08-18 11:18:24 UTC
Created attachment 46462 [details]
pcm_direct.c.rej file

(In reply to comment #23)

(before suspend:)
DIRECT SERVER: poll ret = 0, revents[0] = 0x0, errno = 9
DIRECT SERVER: nattch = 2
DIRECT SERVER: poll ret = 0, revents[0] = 0x0, errno = 9
DIRECT SERVER: nattch = 2
DIRECT SERVER: poll ret = -1, revents[0] = 0x0, errno = 4
DIRECT SERVER: poll ret = 0, revents[0] = 0x0, errno = 4
DIRECT SERVER: nattch = 2
Suspended. Trying resume. Done.
DIRECT SERVER: poll ret = 0, revents[0] = 0x0, errno = 4
DIRECT SERVER: nattch = 2
DIRECT SERVER: poll ret = 0, revents[0] = 0x0, errno = 4
DIRECT SERVER: nattch = 2
DIRECT SERVER: poll ret = 0, revents[0] = 0x0, errno = 4
DIRECT SERVER: nattch = 2
underrun!!! (at least 0,067 ms long)
DIRECT SERVER: poll ret = 0, revents[0] = 0x0, errno = 4
DIRECT SERVER: nattch = 2
(the same after resume, the .wav file playing works)

The out.txt is still rejected (the original files are not the same). I attach
the .rej file, i hope this also helps.
Comment 25 Jaroslav Kysela 2005-08-18 11:25:53 UTC
It seems that it solved the problem. The ALSA anonymous CVS will sync in some
hours, so you might try the official alsa-lib code then. The changes will be in
SL10-beta3 release.

If you disable the debugging in pcm_direct.c (change #if 1 to #if 0 - reverse
things as in comment #17), then install modified alsa-lib to system directories,
you may test the new alsa-lib immediately with the former testcase (xmms,
knotify, arts).
Comment 26 László Attila Tóth 2005-08-18 11:58:27 UTC
Now sound works as expected (also after resume I can start other aplay-s, xmms,
knotify, etc. and the next song is also playable (after another resume), with
#if 0 but patched with out.txt in comment #23)
Comment 27 Jaroslav Kysela 2005-08-18 12:03:35 UTC
Fine. This issue is solved then. Thank you for your report and tests.