what will happen when the number of data which is sampled through audio exceed the “bufferSizeInBytes” which is set in AudioRecord constructor?

坚强是说给别人听的谎言 提交于 2019-12-12 15:54:03

问题


public AudioRecord (int audioSource, int sampleRateInHz, int channelConfig, int audioFormat, int bufferSizeInBytes)

This is the Public Constructor of AudioRecord, you can find the last parameter called bufferSizeInBytes , and it means "the total size (in bytes) of the buffer where audio data is written to during the recording." in android docs.

I thought this is a buffer for storing all data which is sampled from audio hardware. i have a question :

If the number of data which is sampled through audio exceed the "bufferSizeInBytes" , what will happen, stop sampling or else?

I did some test , and found that nothing happened (it kept recording)even if the number of the sample data has exceeded. why?

So  can anyone tell me what's the meaning about  "bufferSizeInBytes"

回答1:


It's the amount of audiodata which is buffered during recording. It determines how often you have to pull the AudioRecord object via read(), and not the total amount which can get recorded during the Audiorecord object's lifetime.

If you don't read out of the AudioRecord object, recorded data is lost. It keeps recording, but audioframes which exceed the buffer-level are dropped.

If you read audio data from the object, the buffer fill-level is decreased.



来源:https://stackoverflow.com/questions/12002031/what-will-happen-when-the-number-of-data-which-is-sampled-through-audio-exceed-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!