Skip to content
Snippets Groups Projects
Commit c97a170d authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#9897: Initialize and fallback recording path in home directory if not valid

parent b1fb764c
Branches
Tags
No related merge requests found
......@@ -33,6 +33,7 @@
#include <sstream> // for stringstream
#include <cstdio>
#include "logger.h"
#include "fileutils.h"
// structure for the wave header
......@@ -76,10 +77,22 @@ void AudioRecord::setSndSamplingRate(int smplRate)
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;
channels_ = 1;
sndSmplRate_ = sndSmplRate;
savePath_ = path + "/";
savePath_ = (*filePath.rbegin() == '/') ? filePath : filePath + "/";
}
void AudioRecord::initFilename(const std::string &peerNumber)
......@@ -230,7 +243,7 @@ void AudioRecord::createFilename()
out << timeinfo->tm_sec;
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()
......
......@@ -29,9 +29,11 @@
#include "recordable.h"
#include "manager.h"
#include "logger.h"
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());
}
......
......@@ -39,7 +39,7 @@
#include <iostream>
#include "fileutils.h"
namespace {
namespace fileutils {
// returns true if directory exists
bool check_dir(const char *path)
{
......@@ -55,9 +55,7 @@ bool check_dir(const char *path)
return true;
}
}
namespace fileutils {
static char *program_dir = NULL;
void set_program_dir(char *program_path)
......
......@@ -42,6 +42,7 @@
#define DIR_SEPARATOR_CH = '/' // Directory separator string
namespace fileutils {
bool check_dir(const char *path);
void set_program_dir(char *program_path);
const char *get_program_dir();
bool create_pidfile();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment