diff --git a/daemon/src/audio/audiorecord.cpp b/daemon/src/audio/audiorecord.cpp index af1f94ef161628194cdf32758e934acf33df402f..9df38a352409dccfff3f20e20041fbcf043f8faf 100644 --- a/daemon/src/audio/audiorecord.cpp +++ b/daemon/src/audio/audiorecord.cpp @@ -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)); - } -} - diff --git a/daemon/src/audio/audiorecord.h b/daemon/src/audio/audiorecord.h index 83143255b49a5c108f8f798b1f5f962a2c0b497b..efbe7f281d490c14cdf3f06c21fa0074297a3c45 100644 --- a/daemon/src/audio/audiorecord.h +++ b/daemon/src/audio/audiorecord.h @@ -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: /** diff --git a/daemon/src/fileutils.cpp b/daemon/src/fileutils.cpp index 29376115950b5a2634ca44cd285c1a8af71b40c4..7a7240abd2c8cce14e1fd14a95f15d872f11762f 100644 --- a/daemon/src/fileutils.cpp +++ b/daemon/src/fileutils.cpp @@ -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;