aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-01-07 19:11:04 +0100
committerMax Kellermann <max@duempel.org>2015-01-07 19:11:04 +0100
commitfe0c4ff3c26c64aea46b8fa49456e8b40ef8dc05 (patch)
treec8deff6bcf4c2d8f107d0f93190ae3ed6dda67d5
parent7a2af0fbf4a0261a47a05b7587d6352ca8d35c7d (diff)
downloadmpd-fe0c4ff3c26c64aea46b8fa49456e8b40ef8dc05.tar.gz
mpd-fe0c4ff3c26c64aea46b8fa49456e8b40ef8dc05.tar.xz
mpd-fe0c4ff3c26c64aea46b8fa49456e8b40ef8dc05.zip
output/recorder: move code to method Commit()
Diffstat (limited to '')
-rw-r--r--src/output/plugins/RecorderOutputPlugin.cxx22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/output/plugins/RecorderOutputPlugin.cxx b/src/output/plugins/RecorderOutputPlugin.cxx
index 52fdb229f..f83a2edbd 100644
--- a/src/output/plugins/RecorderOutputPlugin.cxx
+++ b/src/output/plugins/RecorderOutputPlugin.cxx
@@ -86,6 +86,12 @@ struct RecorderOutput {
void SendTag(const Tag &tag);
size_t Play(const void *chunk, size_t size, Error &error);
+
+private:
+ /**
+ * Finish the encoder and commit the file.
+ */
+ bool Commit(Error &error);
};
static constexpr Domain recorder_output_domain("recorder_output");
@@ -223,19 +229,27 @@ RecorderOutput::Open(AudioFormat &audio_format, Error &error)
return true;
}
-inline void
-RecorderOutput::Close()
+inline bool
+RecorderOutput::Commit(Error &error)
{
/* flush the encoder and write the rest to the file */
- if (encoder_end(encoder, IgnoreError()))
- EncoderToFile(IgnoreError());
+ bool success = encoder_end(encoder, error) &&
+ EncoderToFile(error);
/* now really close everything */
encoder_close(encoder);
close(fd);
+
+ return success;
+}
+
+inline void
+RecorderOutput::Close()
+{
+ Commit(IgnoreError());
}
inline void