Skip to content
Snippets Groups Projects
Commit 70e0af64 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #8968: AudioFile: initialize filepath earlier

parent dda278a2
No related branches found
No related tags found
No related merge requests found
......@@ -45,14 +45,11 @@
#include "manager.h"
RawFile::RawFile(const std::string& name, sfl::AudioCodec *codec, unsigned int sampleRate)
: audioCodec_(codec)
: AudioFile(name), audioCodec_(codec)
{
filepath_ = name;
if (filepath_.empty())
throw AudioFileException("Unable to open audio file: filename is empty");
std::fstream file;
file.open(filepath_.c_str(), std::fstream::in);
......@@ -114,14 +111,13 @@ RawFile::RawFile(const std::string& name, sfl::AudioCodec* codec, unsigned int s
}
WaveFile::WaveFile(const std::string& fileName, int newRate)
WaveFile::WaveFile(const std::string &fileName, int newRate) : AudioFile(fileName)
{
const std::fstream fs(fileName.c_str(), std::ios_base::in);
if (!fs)
throw AudioFileException("File " + fileName + " doesn't exist");
filepath_ = fileName;
std::fstream fileStream;
fileStream.open(fileName.c_str(), std::ios::in | std::ios::binary);
......
......@@ -43,7 +43,7 @@ class AudioCodec;
class AudioFileException : public std::runtime_error {
public:
AudioFileException(const std::string& str = "") :
AudioFileException(const std::string &str) :
std::runtime_error("AudioFile: AudioFileException occured: " + str) {}
};
......@@ -52,7 +52,7 @@ class AudioFileException : public std::runtime_error {
*/
class AudioFile : public AudioLoop {
public:
AudioFile() : filepath_() {}
AudioFile(const std::string &filepath) : filepath_(filepath) {}
std::string getFilePath() const {
return filepath_;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment