Skip to contentSkip to conversation

Small patch for alsa-lib

PATCH Adam Tla/lka 2 participants 2 messages Jan 20, 2004

lore
Share & tools
lore
#0 lore raw

Welcome

I observe that while using xmms with ALSA output plugin
and alsa-20040120 compiled lib we get shared memory usage growing.
Any opening of new sound source (sound file etc.) adds a new shm segment while old segments stay in memory until xmms exits. Sometimes they stay even after application closing and must be removed manually.
I am sending a small patch which should remove this behaviour.

Regards

Signature · 3 lines
Adam Tla/lka      mailto:[email protected]    ^v^ ^v^ ^v^
Computer Center,  Technical University of Gdansk, Poland
PGP public key:   finger [email protected]
alsa-lib/src/pcm/pcm_mmap.c renamed from alsa-lib/src/pcm/pcm_mmap_old.c +10 -5
@@ -462,11 +462,16 @@
 			if (i->u.shm.area) {
 				snd_shm_area_destroy(i->u.shm.area);
 				i->u.shm.area = NULL;
-			} else {
-				err = shmdt(i->addr);
-				if (err < 0) {
-					SYSERR("shmdt failed");
-					return -errno;
+				if (pcm->access == SND_PCM_ACCESS_MMAP_INTERLEAVED ||
+				    pcm->access == SND_PCM_ACCESS_RW_INTERLEAVED) {
+					unsigned int c1;
+					for (c1 = c + 1; c1 < pcm->channels; c1++) {
+						snd_pcm_channel_info_t *i1 = &pcm->mmap_channels[c1];
+						if (i1->u.shm.area) {
+							snd_shm_area_destroy(i1->u.shm.area);
+							i1->u.shm.area = NULL;
+						}
+					}
 				}
 			}
 			break;
#1 lore raw
Quoted 9 lines · Adam Tla/lka

Welcome

I observe that while using xmms with ALSA output plugin
and alsa-20040120 compiled lib we get shared memory usage growing. Any opening of new sound source (sound file etc.) adds a new shm segment while old segments stay in memory until xmms exits. Sometimes they stay even after application closing and must be removed manually.
I am sending a small patch which should remove this behaviour.

Thanks for this patch. It's in CVS now.

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn