output/recorder: move code to method Commit()
This commit is contained in:
parent
7a2af0fbf4
commit
fe0c4ff3c2
|
@ -86,6 +86,12 @@ struct RecorderOutput {
|
||||||
void SendTag(const Tag &tag);
|
void SendTag(const Tag &tag);
|
||||||
|
|
||||||
size_t Play(const void *chunk, size_t size, Error &error);
|
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");
|
static constexpr Domain recorder_output_domain("recorder_output");
|
||||||
|
@ -223,19 +229,27 @@ RecorderOutput::Open(AudioFormat &audio_format, Error &error)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline bool
|
||||||
RecorderOutput::Close()
|
RecorderOutput::Commit(Error &error)
|
||||||
{
|
{
|
||||||
/* flush the encoder and write the rest to the file */
|
/* flush the encoder and write the rest to the file */
|
||||||
|
|
||||||
if (encoder_end(encoder, IgnoreError()))
|
bool success = encoder_end(encoder, error) &&
|
||||||
EncoderToFile(IgnoreError());
|
EncoderToFile(error);
|
||||||
|
|
||||||
/* now really close everything */
|
/* now really close everything */
|
||||||
|
|
||||||
encoder_close(encoder);
|
encoder_close(encoder);
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
RecorderOutput::Close()
|
||||||
|
{
|
||||||
|
Commit(IgnoreError());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
|
|
Loading…
Reference in New Issue