Re: Audio skips when RAM is ~full

From: Willy Tarreau (willy_at_w.ods.org)
Date: 11/01/03

  • Next message: Sam Ravnborg: "Re: [2.6] GUI config targets fail with "make O=...""
    Date:	Sat, 1 Nov 2003 08:19:07 +0100
    To: Anthony DiSante <orders@nodivisions.com>
    
    

    On Sat, Nov 01, 2003 at 01:34:12AM -0500, Anthony DiSante wrote:
    > >2) you can try to preload your file into the cache just before playing it :
    > > cp $file /dev/null ; mpg321 $file
    >
    > But wouldn't "cp $file /tmp/ramdisk0; mpg321 /tmp/ramdisk0/$file"
    > accomplish the same thing? (I've done that.)

    It's different because you need to reserve a fixed amount of ram for the
    ramdisk while I was only using the caching features of the kernel as a
    fast read-ahead mechanism. But I agree with you that the result should be
    the same.

    > Actually, I don't scan the disk to find random albums; I have a text file
    > that contains a list of every album's full path, and I pick a random line
    > from that file. So only the selected album's directory gets scanned. And
    > the mp3 partition is mounted read-only (I should have mentioned that
    > before), so the atimes shouldn't be getting written as it is.

    OK, so it's not a disk IO problem at all. It's really related to the sound
    driver it seems. Now that you say it, I remember having noticed skips on
    my laptop with a via 82cxxx chip after tens of minutes playing. At first
    I thought it was related to other activity on the system, but it did exactly
    what you describe, play seconds 1, 2, then 5 without a hole between them.
    There may be a problem with the way the audio buffer gets allocated or freed.

    > So I'm guessing that there isn't actually a way to manually move
    > buffer-data out of RAM?

    Yes, there is. I have a quick'n'dirty program which does exactly that.
    Basically, you tell it how many kB you want to free, then it allocates
    and uses that amount of memory, frees it and exits. Buffered data gets
    flushed very quickly. I sometimes give it a try before starting to work
    on large kernel trees, because it helps the entire directories to fit in
    cache.

    Here it is if you're interested. Don't start it without an argument, it
    will try to allocate 4G !

    Regards,
    Willy

    ---
    #include <stdio.h>
    main(int argc, char **argv) {
      unsigned long int i,k=0, max;
      char *p;
      if (argc>1)
          max=atol(argv[1]);
      else
          max=0xffffffff;
      printf("Freeing %lu kB ram\n",max);
      while (((p=(char *)malloc(1048576))!=NULL) && (k+1024<=max)) {
        for (i=0;i<256;p[4096*i++]=0);
        k+=1024;
        fprintf(stderr,"\r%d kB allocated",k);
      }
      while (((p=(char *)malloc(65536))!=NULL) && (k+64<=max)) {
        for (i=0;i<16;p[4096*i++]=0);
        k+=64;
        fprintf(stderr,"\r%d kB allocated",k);
      }
      while (((p=(char *)malloc(1024))!=NULL) && (k+1<=max)) {
        for (i=0;i<16;p[64*i++]=0);
        k+=1;
        fprintf(stderr,"\r%d kB allocated",k);
      }
      fprintf(stderr,"\nMemory freed.\n");
      exit(0);
    }
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Sam Ravnborg: "Re: [2.6] GUI config targets fail with "make O=...""

    Relevant Pages

    • [DISCUSS] memory allocation method
      ... I have a process who allocates as much as possible of RAM ... This buffer is never released. ... Please read the FAQ at http://www.tux.org/lkml/ ...
      (Linux-Kernel)
    • Re: [DISCUSS] memory allocation method
      ... in 4 G ram 32bit machine. ... This buffer is never released. ... Is it better allocates with many 1MB buffers or allocate it in with ... Please read the FAQ at http://www.tux.org/lkml/ ...
      (Linux-Kernel)
    • Re: not exactly 4GB of RAM
      ... Windows XP allocates 3GB of virtual address space to programs and 1GB to the kernel ... | I have a Dell Precision Workstation 670 with 4GB of ECC RAM. ... In this case the need for I/O space ...
      (microsoft.public.windowsxp.hardware)
    • Re: CPU usage creep in waveIn sample during handling MM_WIM_DATA message
      ... It's the realloc. ... Allocated fixed amount of memory. ... Allocated fixed amount of memory and grow by large fixed increment. ... This is essentially a big circular buffer, ...
      (microsoft.public.win32.programmer.mmedia)
    • Re: Fast memcpy in kernel space
      ... I would like to see a VC managed method of mapping direct access to the video ... hardware frame buffer. ... the RAM copy of the VC being switched to would be copied in. ... the video hardware buffer from the text buffer ... ...
      (comp.os.linux.development.system)