Http://mypyg.iteye.com/blog/845954
In the past two daysProgramChange from the OSS interface to the Alsa interface. After the audio output is modified according to the Alsa example, the sound generated during playback is intermittent and there is a great noise. In the beginning, we thought that there was no correct format, but it still didn't work if we set all the formats again. It's okay to convert the sound into PCM Data and play it with aplay.CodeAn error occurred while calling snd_pcm_writei. The original OSS interface directly uses write (device handle, buffer, data_size), but is not modified when it is changed to snd_pcm_writei. The required parameters for snd_pcm_writei are (device handle, buffer, frame_size), and the last one
Frame_size is the number of frames in the buffer. The formula can be used: (buffer_size * 8)/(number of sampling digits * channel). buffer_size * 8 is the number of bits, the sampling bit is usually 16, and the audio channel is 1 or 2. For example, if the typical MP3 data is 16bit or stereo, the frame_size = buffer_size * 8/(16*2). After modification, playing normally.
PS:
Frame_size is actually how many samples the data is.