MusicPipe: automatically clear in destructor

We can implement this now that we have a MusicBuffer reference.
This commit is contained in:
Max Kellermann 2018-06-22 23:09:13 +02:00
parent 9f14e7a98d
commit e81b089612
3 changed files with 8 additions and 23 deletions

View File

@ -67,12 +67,8 @@ public:
MusicPipe(const MusicPipe &) = delete;
/**
* Frees the object. It must be empty now.
*/
~MusicPipe() {
assert(head == nullptr);
assert(tail_r == &head);
~MusicPipe() noexcept {
Clear();
}
MusicPipe &operator=(const MusicPipe &) = delete;

View File

@ -407,11 +407,8 @@ MultipleOutputs::Close() noexcept
for (auto *ao : outputs)
ao->LockCloseWait();
if (pipe != nullptr) {
pipe->Clear();
delete pipe;
pipe = nullptr;
}
delete pipe;
pipe = nullptr;
input_audio_format.Clear();
@ -424,11 +421,8 @@ MultipleOutputs::Release() noexcept
for (auto *ao : outputs)
ao->LockRelease();
if (pipe != nullptr) {
pipe->Clear();
delete pipe;
pipe = nullptr;
}
delete pipe;
pipe = nullptr;
input_audio_format.Clear();

View File

@ -169,14 +169,9 @@ private:
xfade_state = CrossFadeState::UNKNOWN;
}
void ClearAndDeletePipe() noexcept {
pipe->Clear();
delete pipe;
}
void ClearAndReplacePipe(MusicPipe *_pipe) noexcept {
ResetCrossFade();
ClearAndDeletePipe();
delete pipe;
pipe = _pipe;
}
@ -1070,7 +1065,7 @@ Player::Run() noexcept
CancelPendingSeek();
StopDecoder();
ClearAndDeletePipe();
delete pipe;
cross_fade_tag.reset();