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
_______________________________________________
Alsa-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-devel