Commit cad2f6e2 authored by Stefan Westerfeld's avatar Stefan Westerfeld

Use Error object as result for SFOutputStream open().

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent b046b704
......@@ -1287,9 +1287,10 @@ add_watermark (const string& infile, const string& outfile, const string& bits)
{
SFOutputStream *sfostream = new SFOutputStream();
out_stream.reset (sfostream);
if (!sfostream->open (outfile, in_stream->n_channels(), in_stream->sample_rate(), out_bit_depth, in_stream->n_frames()))
Error err = sfostream->open (outfile, in_stream->n_channels(), in_stream->sample_rate(), out_bit_depth, in_stream->n_frames());
if (err)
{
error ("audiowmark: error writing to %s\n", outfile.c_str()); // FIXME, sfostream->error_blurb());
error ("audiowmark: error writing to %s: %s\n", outfile.c_str(), err.message());
return 1;
}
}
......
......@@ -12,7 +12,7 @@ SFOutputStream::~SFOutputStream()
close();
}
bool
Error
SFOutputStream::open (const string& filename, int n_channels, int sample_rate, int bit_depth, size_t n_frames)
{
assert (m_state == State::NEW);
......@@ -39,14 +39,14 @@ SFOutputStream::open (const string& filename, int n_channels, int sample_rate, i
int error = sf_error (m_sndfile);
if (error)
{
m_error_blurb = sf_strerror (m_sndfile);
string msg = sf_strerror (m_sndfile);
if (m_sndfile)
sf_close (m_sndfile);
return false;
return Error (msg);
}
m_state = State::OPEN;
return true;
return Error::Code::NONE;
}
void
......
......@@ -10,7 +10,6 @@
class SFOutputStream : public AudioOutputStream
{
SNDFILE *m_sndfile = nullptr;
std::string m_error_blurb;
int m_bit_depth = 0;
int m_sample_rate = 0;
int m_n_channels = 0;
......@@ -25,7 +24,7 @@ class SFOutputStream : public AudioOutputStream
public:
~SFOutputStream();
bool open (const std::string& filename, int n_channels, int sample_rate, int bit_depth, size_t n_frames);
Error open (const std::string& filename, int n_channels, int sample_rate, int bit_depth, size_t n_frames);
Error write_frames (const std::vector<float>& frames) override;
void close();
int bit_depth() const override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment