All of lore.kernel.org
 help / color / mirror / Atom feed
* Moving from OSS to ALSA
@ 2004-01-11 18:13 James Wright
  2004-01-11 18:28 ` Paul Davis
  2004-01-11 22:29 ` Lorn Potter
  0 siblings, 2 replies; 11+ messages in thread
From: James Wright @ 2004-01-11 18:13 UTC (permalink / raw)
  To: alsa-devel

Hello,

   I am currently looking into rewriting our current OSS sound routines to native ALSA, as it seems OSS will invariably be phased out now that the ALSA driver is distrubuted with the Linux kernel, plus ALSA seems to have a great number of benefits for us. 

  Our current sound routines perform software sound sample mixing for use in games. All the  mixing and transfers happen in a non-blocking function called update_jsound() which we call every 1/60th of a second in our main game loop. We find the total size of the hardware ring buffer and use MMAP writes to it. We effectively break the ring buffer into 1024 byte "fragments", and always keep one whole fragment ahead to ensure no underruns. We do this by the follwing:



  ioctl(audiofd, SNDCTL_DSP_GETOPTR, &info);  // get position of DSP pointer

  if (info.ptr >= trigger){ // hit a frag boundary, so write another fragment ahead
      trigger += FRAGSIZE;  // move triggering position to next fragment boundary
      if (trigger >= DMA_SIZE) trigger = 0; // wrap around if at end of DMA buffer
      dptr = DMA_PTR + trigger;  // set write ptr to next fragment

      ...
      mix and write all samples playing into the buffer
      ...
 
      //printf("Ptr position: %u\n", info.ptr);
      //printf("Trigger: %u\n", trigger);
  }


   With all the different methods available the ALSA offers i'm finding it hard to determine the best method to use to do the same job as the OSS code. I have started by writing  a standard "write" access with non-blocking, with a buffersize of 500000 usecs and a period time of 100000 usecs, but i want to know how to determine if there is only one period remaning, which is when i would want to mix and write the next one ahead...

Sorry if this has been covered before...


Thanks,
James






-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-01-12 13:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-11 18:13 Moving from OSS to ALSA James Wright
2004-01-11 18:28 ` Paul Davis
2004-01-11 21:39   ` James Wright
2004-01-11 22:29 ` Lorn Potter
2004-01-11 22:48   ` Måns Rullgård
2004-01-11 22:49   ` James Wright
2004-01-11 23:11   ` Kai Vehmanen
2004-01-12  1:15     ` Lorn Potter
2004-01-12  8:42       ` Jaroslav Kysela
2004-01-12 12:54         ` Paul Davis
2004-01-12 13:56           ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.