public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Anthony DiSante <orders@nodivisions.com>
To: linux-kernel@vger.kernel.org
Subject: Audio skips when RAM is ~full
Date: Sat, 01 Nov 2003 00:31:15 -0500	[thread overview]
Message-ID: <3FA34523.30902@nodivisions.com> (raw)

Hello,

I have a memory-related question regarding a Slackware system I'm running 
(kernel 2.4.22, compiled for i386, on a VIA Eden 600MHz processor, with 
256MB RAM).

First, the background info:

This system is primarily an mp3 player.  It boots directly to /bin/bash 
bypassing everything under /etc/rc.d, and just runs a small script that does 
modprobing and a few other miscellaneous things, then starts the main 
control script (which is Perl).

I have about 250 CDs encoded as mp3s on the 40gig drive, laid out in 
directories as /music/band/album/songs.mp3.  I also have a text file which 
contains one line for the full path to each album (so ~250 lines total). 
This file is used by my play-random-album function, which plays a random 
album each time I press the tick key.  When I do that, the songs from the 
randomly-chosen album become the current playlist, and the first song starts 
playing.

Now, the problem/question:

Each time I press the tick key, a new directory is read from the disk (and a 
song is played, and the directory contents are enqueued).  This causes the 
free memory (as reported by free) to drop by 1%, each time I press tick.  I 
often press it 5 or 10 or 20 times in a row until I find something I feel 
like listening to, and the free memory will drop by almost exactly 5 or 10 
or 20 percent by the time I settle on an album.  If the free memory was 
already very low (for example, when I do this after having already listened 
to an album or two), then it will often get down to 2% or 3% at this point, 
and stay there until I reboot.

This system has one of those awful on-board "ac'97" sound chips, which 
(AIUI) uses the system CPU to do much of the audio work instead of using 
dedicated audio chips for it.  When the free memory is less than about 10%, 
each song will "skip" when it first starts playing.  (It sounds like 1/2 or 
1 or 2 seconds of audio was deleted from the song; you don't hear silence, 
you hear the music at seconds 1, 2, and then 4, or just 2, 3, 4, ... 
skipping the very start, etc.  But it's always some portion of the first ~5 
seconds getting skipped.)

When the system is first booted, the free mem is around 90%, and this 
skipping doesn't happen.  As time goes on, the free mem drops, and skipping 
starts happening somewhere along the line; by the time it's down to ~10% 
free, every song skips when it starts.

The disk is a modern one using DMA.  And I even set up a ramdisk to try 
playing the songs from there (copying the "next" track into ramdisk while 
the current track is playing), but it still skips at the beginning of each 
track when the free mem is low enough.

My understanding/analysis/proposed solution:

The kernel is buffering the contents of each directory (album) that it reads 
(and also, mpg321 copies each mp3 file into RAM before playing it?).  I 
understand that the idea is to stuff as much into RAM as possible to reduce 
pagefile usage, and that the kernel will reclaim memory utilized by buffers 
if/when it needs to.  But apparently that isn't happening fast enough to 
allow a realtime process like music-playing to work skip-free on this system 
with this soundcard.  I think that if I could regularly forcibly dump the 
buffered stuff out of the RAM (dropping the used-RAM percentage down to, 
say, 10%, like at boot time) then this would make the skipping stop.

So... do I have a correct understanding of the problem, and a correct 
analysis of the kernel/mem issues that are related to it?  Is it possible to 
clear some of the RAM; if so, would that help?

Thanks,
Anthony

PS - you can see the system at:
http://nodivisions.com/tech/systems/musicbox/

             reply	other threads:[~2003-11-01  5:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-01  5:31 Anthony DiSante [this message]
2003-11-01  6:20 ` Audio skips when RAM is ~full Willy Tarreau
2003-11-01  6:34   ` Anthony DiSante
2003-11-01  7:19     ` Willy Tarreau
2003-11-01 12:48       ` Anthony DiSante
2003-11-01 14:57         ` Jaroslav Kysela
2003-11-01  9:43     ` Maciej Zenczykowski
2003-11-01 18:08 ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3FA34523.30902@nodivisions.com \
    --to=orders@nodivisions.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox