Commit fb2671d0 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #9897: audiorecord: cleanup, removed unused methods

parent 23193485
......@@ -80,8 +80,8 @@ void AudioRecord::setRecordingOption(FILE_TYPE type, int sndSmplRate, const std:
std::stringstream s;
std::string filePath;
// use HOME directory if path is empty, nor does not exist
if(path.empty() || !fileutils::check_dir(path.c_str())) {
// use HOME directory if path is empty, or if path does not exist
if (path.empty() || !fileutils::check_dir(path.c_str())) {
s << getenv("HOME");
filePath = s.str();
}
......@@ -124,8 +124,6 @@ bool AudioRecord::openFile()
{
bool result = false;
DEBUG("AudioRecord: Open file()");
if (not fileExists()) {
DEBUG("AudioRecord: Filename does not exist, creating one");
byteCounter_ = 0;
......@@ -170,24 +168,14 @@ bool AudioRecord::isRecording() const
return recordingEnabled_;
}
bool AudioRecord::setRecording()
void AudioRecord::setRecording()
{
if (isOpenFile()) {
if (!recordingEnabled_) {
DEBUG("AudioRecording: Start recording");
recordingEnabled_ = true;
} else {
DEBUG("AudioRecording: Stop recording");
recordingEnabled_ = false;
}
recordingEnabled_ = !recordingEnabled_;
} else {
openFile();
recordingEnabled_ = true; // once opend file, start recording
}
// WARNING: Unused return value
return true;
}
void AudioRecord::stopRecording()
......@@ -198,12 +186,8 @@ void AudioRecord::stopRecording()
void AudioRecord::createFilename()
{
time_t rawtime;
struct tm * timeinfo;
rawtime = time(NULL);
timeinfo = localtime(&rawtime);
time_t rawtime = time(NULL);
struct tm * timeinfo = localtime(&rawtime);
std::stringstream out;
......@@ -408,27 +392,6 @@ void AudioRecord::closeWavFile()
WARN("AudioRecord: Error: can't close file");
}
void AudioRecord::recSpkrData(SFLDataFormat* buffer, int nSamples)
{
if (recordingEnabled_) {
nbSamplesMic_ = nSamples;
for (int i = 0; i < nbSamplesMic_; i++)
micBuffer_[i] = buffer[i];
}
}
void AudioRecord::recMicData(SFLDataFormat* buffer, int nSamples)
{
if (recordingEnabled_) {
nbSamplesSpk_ = nSamples;
for (int i = 0; i < nbSamplesSpk_; i++)
spkBuffer_[i] = buffer[i];
}
}
void AudioRecord::recData(SFLDataFormat* buffer, int nSamples)
{
if (recordingEnabled_) {
......@@ -445,26 +408,3 @@ void AudioRecord::recData(SFLDataFormat* buffer, int nSamples)
}
}
}
void AudioRecord::recData(SFLDataFormat* buffer_1, SFLDataFormat* buffer_2,
int nSamples_1, int /*nSamples_2*/)
{
if (recordingEnabled_) {
if (fileHandle_ == 0) {
DEBUG("AudioRecord: Can't record data, a file has not yet been opened!");
return;
}
for (int k = 0; k < nSamples_1; k++) {
mixBuffer_[k] = (buffer_1[k]+buffer_2[k]);
if (fwrite(&mixBuffer_[k], 2, 1, fileHandle_) != 1)
WARN("AudioRecord: Could not record data!");
else
fflush(fileHandle_);
}
byteCounter_ += (unsigned long)(nSamples_1 * sizeof(SFLDataFormat));
}
}
......@@ -90,28 +90,13 @@ class AudioRecord {
/**
* Set recording flag
*/
bool setRecording();
void setRecording();
/**
* Stop recording flag
*/
void stopRecording();
/**
* Record a chunk of data in an internal buffer
* @param buffer The data chunk to be recorded
* @param nSamples Number of samples (number of bytes) to be recorded
*/
void recSpkrData(SFLDataFormat* buffer, int nSamples);
/**
* Record a chunk of data in an internal buffer
* @param buffer The data chunk to be recorded
* @param nSamples Number of samples (number of bytes) to be recorded
*/
void recMicData(SFLDataFormat* buffer, int nSamples);
/**
* Record a chunk of data in an openend file
* @param buffer The data chunk to be recorded
......@@ -119,16 +104,6 @@ class AudioRecord {
*/
void recData(SFLDataFormat* buffer, int nSamples);
/**
* Record a chunk of data in an openend file, Mix two differnet buffer
* @param buffer_1 The first data chunk to be recorded
* @param buffer_2 The second data chunk to be recorded
* @param nSamples_1 Number of samples (number of bytes) of buffer_1
* @param nSamples_2 Number of samples (number of bytes) of buffer_2
*/
void recData(SFLDataFormat* buffer_1, SFLDataFormat* buffer_2, int nSamples_1, int nSamples_2);
protected:
/**
......
......@@ -45,7 +45,7 @@ bool check_dir(const char *path)
{
DIR *dir = opendir(path);
if (!dir) { // doesn't exist
if (!dir) { // doesn't exist
if (mkdir(path, 0755) != 0) { // couldn't create the dir
perror(path);
return false;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment