问题
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