Bug 106569 - artsd starts using 100% CPU after playing notifications sounds
Summary: artsd starts using 100% CPU after playing notifications sounds
Status: RESOLVED FIXED
Alias: None
Product: arts
Classification: Miscellaneous
Component: artsd (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Stefan Westerfeld
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-31 22:19 UTC by Jure Repinc
Modified: 2005-06-07 18:01 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jure Repinc 2005-05-31 22:19:09 UTC
Version:            (using KDE KDE 3.4.1)
Installed from:    Gentoo Packages
Compiler:          GCC 3.4.3 AMD64
OS:                Linux

It happens very often in KDE (just installed 3.4.1 in hope to see this fixed) that artsd starts using 100% CPU after playing notification sound (like when the dialog shows up in Firefox and then goes away). artsd is also using 100% CPU (about 35% User and 65% System ) every time I start up KDE. The problem is especially frequent if I am compiling something at the time of notification sound or doing something else that is using a lot of CPU.

My system: KDE 3.4.1, Linux Kernel 2.6.11.11, ALSA 1.0.9 (Sound Blaster Audigy 2 ZX), AMD Athlon 64 3000+
Comment 1 Jure Repinc 2005-06-07 17:24:40 UTC
I applied the attached patch from this bug report:
http://bugs.kde.org/show_bug.cgi?id=88474
And the problem is gone. So I guess it would be nice if we could see this patch in the official KDE.
Comment 2 Allan Sandfeld 2005-06-07 18:01:15 UTC
SVN commit 423127 by carewolf:

Commiting fix for checking xrun in pcm_avail_update. 
Commited based on user feedback as I do not have 64bit system.
BUG: 88474, 106569


 M  +27 -2     audioioalsa9.cc  


--- trunk/KDE/arts/flow/audioioalsa9.cc #423126:423127
@@ -260,15 +260,40 @@
 
 int AudioIOALSA::getParam(AudioParam p)
 {
+	snd_pcm_sframes_t avail;
 	switch(p) {
 
         case canRead:
 		if (! m_pcm_capture) return -1;
-		return snd_pcm_frames_to_bytes(m_pcm_capture, snd_pcm_avail_update(m_pcm_capture));
+		while ((avail = snd_pcm_avail_update(m_pcm_capture)) < 0) {
+			if (avail == -EPIPE)
+				avail = xrun(m_pcm_capture);
+#ifdef HAVE_SND_PCM_RESUME
+			else if (avail == -ESTRPIPE)
+				avail = resume(m_pcm_capture);
+#endif
+			if (avail < 0) {
+				arts_info("Capture error: %s", snd_strerror(avail));
+				return -1;
+			}
+		}
+		return snd_pcm_frames_to_bytes(m_pcm_capture, avail);
 
 	case canWrite:
 		if (! m_pcm_playback) return -1;
-		return snd_pcm_frames_to_bytes(m_pcm_playback, snd_pcm_avail_update(m_pcm_playback));
+		while ((avail = snd_pcm_avail_update(m_pcm_playback)) < 0) {
+			if (avail == -EPIPE)
+				avail = xrun(m_pcm_playback);
+#ifdef HAVE_SND_PCM_RESUME
+			else if (avail == -ESTRPIPE)
+				avail = resume(m_pcm_playback);
+#endif
+			if (avail < 0) {
+				arts_info("Playback error: %s", snd_strerror(avail));
+				return -1;
+			}
+		}
+		return snd_pcm_frames_to_bytes(m_pcm_playback, avail);
 
 	case selectReadFD:
 		return -1;