2
votes

I work on an embedded Linux board (based on Eukrea iMx25). Application is a game playing notes of music or other songs. I get events from radio equipment and then playing wav files.

  1. Homemade player : First solution for playing is using open/write system function to the output /dev/dsp. The latency is very good, launching song quickly and stopping quickly. However, there are some bugs and sometimes song is replaced by noise or noise appear at the end of the song. (This is probably due to problem of syncing playing with hardware since this program application work well alone as minimalist program test).

  2. Aplay (monophonic) : Second solution is to use "aplay" provided in the linux distribution. Problem is latency, some kernell error appears when a play is stopped just after launching (from the tlv320aic23 device). Waiting 100 or 200 ms before stop playing is not acceptable since my radio sensor have 100 ms latency.

  3. Aplay with dmix (polyphonic) : I think in both solution, limitations are due to tlv320aic23 device. I wonder if using a sound server could be best. I could play a new song just after receiving event and stop songs when I want. I tested aplay -D plug:dmix /home/root/mysong.wav but I get plugging crashed after different tests. Problem is there is no error returned by aplay concerning the crash of the plugging and aplay without dmix still works.

Should I use an other sound server ? For example "Jack" ?

Here is test program :

 for(i=50; i>0; i--){
    periode = 23 * i;
    // Display in log
    msg(USER, MSG_CONTROLE, "declenchement dalle %d et attente %f", 
              choixDalle, periode);
    // Send event to audio task
    signalerAppuiDalleCtrl(&ctrlInstances, Hw.xmlParams, &Hw, choixDalle+100, 0);
    // Waiting with arg in second
    attendre(periode/1000.0);
 }
1
It is unlikely that any other API will be able to do more than ALSA, as the driver/kernel is based on ALSA. So any 3rd party solution like JACK is based on ALSA. There are many different ALSA playback options. See: Alsa lib docs and PCM overview. Make sure you have the FIQ support turned on. You can reduce sample rates. You might need to alter the source to fit the FIQ model; I am not sure what rates/formats it supports. You don't want software conversion of samples. - artless noise
I expected Jack is just like plug in dmix without crash. - vincenet
I have to do some research about FIQ model to understand your warning. I hope FIQ is enabled, because I used a script from Eukrea to compile the kernell and rootfs but maybe I am wrong. - vincenet

1 Answers

1
votes

I do not know more about FIQ feature and today I am still using third solution but with asound.conf file (not -D plug:dmix parameter) and it seems working well. my asound.conf file :

pcm.dmixed {
    type dmix
    ipc_key 1024
    ipc_key_add_uid 0
    slave.pcm "hw:0,0"
}
pcm.dsnooped {
    type dsnoop
    ipc_key 1026 
    slave.pcm "hw:0,0"
}

pcm.duplex {
    type asym
    playback.pcm "dmixed"
    capture.pcm "dsnooped"
}

# Instruct ALSA to use pcm.duplex as the default device
pcm.!default {
    type plug
    slave.pcm "duplex"
}
ctl.!default {
    type hw
    card 0
}