Problems encountered when migrating OSS programs to ALSA

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.