Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 989eb180 authored by hhakim's avatar hhakim
Browse files

Catch exception when Faust.save() fails in dynamic library to avoid python/matlab script to crash.

Just displaying the error message.
parent 744c36ea
No related branches found
No related tags found
No related merge requests found
......@@ -92,7 +92,14 @@ void save(Faust::TransformHelper<SCALAR,Cpu>* core_ptr, int nargs, const mxArray
return;
}
// printf("save: filepath = %s, nargs = %d\n", filepath, nargs);
core_ptr->save_mat_file(filepath/*, mxGetScalar(args[1])*/);
try
{
core_ptr->save_mat_file(filepath/*, mxGetScalar(args[1])*/);
}
catch(exception& e)
{
mexErrMsgTxt("Failed to save the file.");
}
}
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
......
......@@ -91,7 +91,7 @@ class FaustCoreCpp
FaustCoreCpp<FPP>* fancy_idx(unsigned long int* row_ids, unsigned long int
num_rows, unsigned long int* col_ids,
unsigned long int num_cols);
void save_mat_file(const char* filepath) const;
bool save_mat_file(const char* filepath) const;
const bool isTransposed();
FaustCoreCpp<FPP>* transpose();
FaustCoreCpp<FPP>* conjugate();
......
......@@ -294,10 +294,18 @@ FaustCoreCpp<FPP>* FaustCoreCpp<FPP>::fancy_idx(unsigned long int* row_ids, unsi
}
template<typename FPP>
void FaustCoreCpp<FPP>::save_mat_file(const char* filepath) const
bool FaustCoreCpp<FPP>::save_mat_file(const char* filepath) const
{
// std::cout << "FaustCoreCpp::save_mat_file()" << std::endl;
this->transform->save_mat_file(filepath);
try
{
this->transform->save_mat_file(filepath);
return true;
}
catch(exception& e) {
//cerr << e.what() << endl;
return false;
}
}
template<typename FPP>
......
......@@ -81,7 +81,7 @@ cdef extern from "FaustCoreCpp.h" :
FaustCoreCpp[FPP]* fancy_idx(unsigned long int* row_ids, unsigned long int
num_rows, unsigned long int* col_ids,
unsigned long int num_cols)
void save_mat_file(const char* filepath) const
bool save_mat_file(const char* filepath) const
const bool isTransposed()
FaustCoreCpp[FPP]* transpose()
FaustCoreCpp[FPP]* conjugate()
......
......@@ -653,9 +653,11 @@ cdef class FaustCore:
cfilepath[i] = fparr[i]
cfilepath[i+1] = 0
if(self._isReal):
self.core_faust_dbl.save_mat_file(cfilepath)
ret = self.core_faust_dbl.save_mat_file(cfilepath)
else:
self.core_faust_cplx.save_mat_file(cfilepath)
ret = self.core_faust_cplx.save_mat_file(cfilepath)
if(not ret):
raise Exception("Failed to save the file: "+filepath)
PyMem_Free(cfilepath)
def transpose(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment