Skip to content
Snippets Groups Projects
Commit f18f7d6c authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #9897: audiorecord cleanup

parent fb2671d0
No related branches found
No related tags found
No related merge requests found
......@@ -392,7 +392,7 @@ void AudioRecord::closeWavFile()
WARN("AudioRecord: Error: can't close file");
}
void AudioRecord::recData(SFLDataFormat* buffer, int nSamples)
void AudioRecord::recData(SFLDataFormat* buffer, size_t nSamples)
{
if (recordingEnabled_) {
if (fileHandle_ == 0) {
......@@ -400,11 +400,11 @@ void AudioRecord::recData(SFLDataFormat* buffer, int nSamples)
return;
}
if (fwrite(buffer, sizeof(SFLDataFormat), nSamples, fileHandle_) != (unsigned int) nSamples)
if (fwrite(buffer, sizeof(SFLDataFormat), nSamples, fileHandle_) != nSamples)
WARN("AudioRecord: Could not record data! ");
else {
fflush(fileHandle_);
byteCounter_ += (unsigned long)(nSamples*sizeof(SFLDataFormat));
byteCounter_ += nSamples * sizeof(SFLDataFormat);
}
}
}
......@@ -102,7 +102,7 @@ class AudioRecord {
* @param buffer The data chunk to be recorded
* @param nSamples Number of samples (number of bytes) to be recorded
*/
void recData(SFLDataFormat* buffer, int nSamples);
void recData(SFLDataFormat* buffer, size_t nSamples);
protected:
......
......@@ -58,14 +58,13 @@ AudioRecorder::AudioRecorder(AudioRecord *arec, MainBuffer *mb) : ost::Thread()
*/
void AudioRecorder::run()
{
int bufferLength = 10000;
SFLDataFormat buffer[bufferLength];
const size_t BUFFER_LENGTH = 10000;
SFLDataFormat buffer[BUFFER_LENGTH];
while (isRunning()) {
int availBytes = mbuffer_->availForGet(recorderId_);
int toGet = (availBytes < bufferLength) ? availBytes : bufferLength;
size_t availBytes = mbuffer_->availForGet(recorderId_);
mbuffer_->getData(buffer, toGet, recorderId_);
mbuffer_->getData(buffer, std::min(availBytes, BUFFER_LENGTH), recorderId_);
if (availBytes > 0)
arecord_->recData(buffer, availBytes / sizeof(SFLDataFormat));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment