Skip to content
Snippets Groups Projects
Commit 23193485 authored by Tristan Matthews's avatar Tristan Matthews
Browse files
parents 0175f799 c97a170d
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <sstream> // for stringstream #include <sstream> // for stringstream
#include <cstdio> #include <cstdio>
#include "logger.h" #include "logger.h"
#include "fileutils.h"
// structure for the wave header // structure for the wave header
...@@ -76,10 +77,22 @@ void AudioRecord::setSndSamplingRate(int smplRate) ...@@ -76,10 +77,22 @@ void AudioRecord::setSndSamplingRate(int smplRate)
void AudioRecord::setRecordingOption(FILE_TYPE type, int sndSmplRate, const std::string &path) void AudioRecord::setRecordingOption(FILE_TYPE type, int sndSmplRate, const std::string &path)
{ {
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())) {
s << getenv("HOME");
filePath = s.str();
}
else {
filePath = path;
}
fileType_ = type; fileType_ = type;
channels_ = 1; channels_ = 1;
sndSmplRate_ = sndSmplRate; sndSmplRate_ = sndSmplRate;
savePath_ = path + "/"; savePath_ = (*filePath.rbegin() == '/') ? filePath : filePath + "/";
} }
void AudioRecord::initFilename(const std::string &peerNumber) void AudioRecord::initFilename(const std::string &peerNumber)
...@@ -230,7 +243,7 @@ void AudioRecord::createFilename() ...@@ -230,7 +243,7 @@ void AudioRecord::createFilename()
out << timeinfo->tm_sec; out << timeinfo->tm_sec;
filename_ = out.str(); filename_ = out.str();
DEBUG("AudioRecord: create filename for this call %s ", filename_.c_str()); DEBUG("AudioRecord: Generate filename for this call %s ", filename_.c_str());
} }
bool AudioRecord::setRawFile() bool AudioRecord::setRawFile()
......
...@@ -29,9 +29,11 @@ ...@@ -29,9 +29,11 @@
#include "recordable.h" #include "recordable.h"
#include "manager.h" #include "manager.h"
#include "logger.h"
Recordable::Recordable() : recAudio_(), recorder_(&recAudio_, Manager::instance().getMainBuffer()) Recordable::Recordable() : recAudio_(), recorder_(&recAudio_, Manager::instance().getMainBuffer())
{ {
DEBUG("=================== Set recornding options: %s", Manager::instance().audioPreference.getRecordpath().c_str());
recAudio_.setRecordingOption(AudioRecord::FILE_WAV, 8000, Manager::instance().audioPreference.getRecordpath()); recAudio_.setRecordingOption(AudioRecord::FILE_WAV, 8000, Manager::instance().audioPreference.getRecordpath());
} }
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include <iostream> #include <iostream>
#include "fileutils.h" #include "fileutils.h"
namespace { namespace fileutils {
// returns true if directory exists // returns true if directory exists
bool check_dir(const char *path) bool check_dir(const char *path)
{ {
...@@ -55,9 +55,7 @@ bool check_dir(const char *path) ...@@ -55,9 +55,7 @@ bool check_dir(const char *path)
return true; return true;
} }
}
namespace fileutils {
static char *program_dir = NULL; static char *program_dir = NULL;
void set_program_dir(char *program_path) void set_program_dir(char *program_path)
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#define DIR_SEPARATOR_CH = '/' // Directory separator string #define DIR_SEPARATOR_CH = '/' // Directory separator string
namespace fileutils { namespace fileutils {
bool check_dir(const char *path);
void set_program_dir(char *program_path); void set_program_dir(char *program_path);
const char *get_program_dir(); const char *get_program_dir();
bool create_pidfile(); bool create_pidfile();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment