Commit 2be905b2 authored by Max Kellermann's avatar Max Kellermann

MusicPipe: eliminate the unused MusicBuffer reference

This requires re-adding the reference to struct DecoderControl, which was removed recently by commit 9f14e7a9
parent 076be809
...@@ -30,18 +30,11 @@ ...@@ -30,18 +30,11 @@
#include <assert.h> #include <assert.h>
class MusicBuffer;
/** /**
* A queue of #MusicChunk objects. One party appends chunks at the * A queue of #MusicChunk objects. One party appends chunks at the
* tail, and the other consumes them from the head. * tail, and the other consumes them from the head.
*/ */
class MusicPipe { class MusicPipe {
/**
* The #MusicBuffer where all chunks must be returned.
*/
MusicBuffer &buffer;
/** the first chunk */ /** the first chunk */
MusicChunkPtr head; MusicChunkPtr head;
...@@ -59,24 +52,10 @@ class MusicPipe { ...@@ -59,24 +52,10 @@ class MusicPipe {
#endif #endif
public: public:
/**
* Creates a new #MusicPipe object. It is empty.
*/
explicit MusicPipe(MusicBuffer &_buffer) noexcept
:buffer(_buffer) {}
MusicPipe(const MusicPipe &) = delete;
~MusicPipe() noexcept { ~MusicPipe() noexcept {
Clear(); Clear();
} }
MusicPipe &operator=(const MusicPipe &) = delete;
MusicBuffer &GetBuffer() noexcept {
return buffer;
}
#ifndef NDEBUG #ifndef NDEBUG
/** /**
* Checks if the audio format if the chunk is equal to the specified * Checks if the audio format if the chunk is equal to the specified
......
...@@ -98,7 +98,7 @@ DecoderBridge::GetChunk() noexcept ...@@ -98,7 +98,7 @@ DecoderBridge::GetChunk() noexcept
return current_chunk.get(); return current_chunk.get();
do { do {
current_chunk = dc.pipe->GetBuffer().Allocate(); current_chunk = dc.buffer->Allocate();
if (current_chunk != nullptr) { if (current_chunk != nullptr) {
current_chunk->replay_gain_serial = replay_gain_serial; current_chunk->replay_gain_serial = replay_gain_serial;
if (replay_gain_serial != 0) if (replay_gain_serial != 0)
......
...@@ -92,7 +92,7 @@ DecoderControl::IsCurrentSong(const DetachedSong &_song) const noexcept ...@@ -92,7 +92,7 @@ DecoderControl::IsCurrentSong(const DetachedSong &_song) const noexcept
void void
DecoderControl::Start(std::unique_ptr<DetachedSong> _song, DecoderControl::Start(std::unique_ptr<DetachedSong> _song,
SongTime _start_time, SongTime _end_time, SongTime _start_time, SongTime _end_time,
MusicPipe &_pipe) noexcept MusicBuffer &_buffer, MusicPipe &_pipe) noexcept
{ {
assert(_song != nullptr); assert(_song != nullptr);
assert(_pipe.IsEmpty()); assert(_pipe.IsEmpty());
...@@ -100,6 +100,7 @@ DecoderControl::Start(std::unique_ptr<DetachedSong> _song, ...@@ -100,6 +100,7 @@ DecoderControl::Start(std::unique_ptr<DetachedSong> _song,
song = std::move(_song); song = std::move(_song);
start_time = _start_time; start_time = _start_time;
end_time = _end_time; end_time = _end_time;
buffer = &_buffer;
pipe = &_pipe; pipe = &_pipe;
ClearError(); ClearError();
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#endif #endif
class DetachedSong; class DetachedSong;
class MusicBuffer;
class MusicPipe; class MusicPipe;
enum class DecoderState : uint8_t { enum class DecoderState : uint8_t {
...@@ -151,6 +152,9 @@ struct DecoderControl final : InputStreamHandler { ...@@ -151,6 +152,9 @@ struct DecoderControl final : InputStreamHandler {
SignedSongTime total_time; SignedSongTime total_time;
/** the #MusicChunk allocator */
MusicBuffer *buffer;
/** /**
* The destination pipe for decoded chunks. The caller thread * The destination pipe for decoded chunks. The caller thread
* owns this object, and is responsible for freeing it. * owns this object, and is responsible for freeing it.
...@@ -379,7 +383,7 @@ public: ...@@ -379,7 +383,7 @@ public:
*/ */
void Start(std::unique_ptr<DetachedSong> song, void Start(std::unique_ptr<DetachedSong> song,
SongTime start_time, SongTime end_time, SongTime start_time, SongTime end_time,
MusicPipe &pipe) noexcept; MusicBuffer &buffer, MusicPipe &pipe) noexcept;
/** /**
* Caller must lock the object. * Caller must lock the object.
......
...@@ -221,19 +221,16 @@ MultipleOutputs::Play(MusicChunkPtr chunk) ...@@ -221,19 +221,16 @@ MultipleOutputs::Play(MusicChunkPtr chunk)
} }
void void
MultipleOutputs::Open(const AudioFormat audio_format, MultipleOutputs::Open(const AudioFormat audio_format)
MusicBuffer &buffer)
{ {
bool ret = false, enabled = false; bool ret = false, enabled = false;
assert(pipe == nullptr || &pipe->GetBuffer() == &buffer);
/* the audio format must be the same as existing chunks in the /* the audio format must be the same as existing chunks in the
pipe */ pipe */
assert(pipe == nullptr || pipe->CheckFormat(audio_format)); assert(pipe == nullptr || pipe->CheckFormat(audio_format));
if (pipe == nullptr) if (pipe == nullptr)
pipe = new MusicPipe(buffer); pipe = new MusicPipe();
else else
/* if the pipe hasn't been cleared, the the audio /* if the pipe hasn't been cleared, the the audio
format must not have changed */ format must not have changed */
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include <assert.h> #include <assert.h>
class MusicBuffer;
class MusicPipe; class MusicPipe;
class EventLoop; class EventLoop;
class MixerListener; class MixerListener;
...@@ -181,8 +180,7 @@ private: ...@@ -181,8 +180,7 @@ private:
/* virtual methods from class PlayerOutputs */ /* virtual methods from class PlayerOutputs */
void EnableDisable() override; void EnableDisable() override;
void Open(const AudioFormat audio_format, void Open(const AudioFormat audio_format) override;
MusicBuffer &_buffer) override;
void Close() noexcept override; void Close() noexcept override;
void Release() noexcept override; void Release() noexcept override;
void Play(MusicChunkPtr chunk) override; void Play(MusicChunkPtr chunk) override;
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
struct AudioFormat; struct AudioFormat;
struct MusicChunk; struct MusicChunk;
class MusicBuffer;
/** /**
* An interface for the player thread to control all outputs. This * An interface for the player thread to control all outputs. This
...@@ -50,11 +49,8 @@ public: ...@@ -50,11 +49,8 @@ public:
* Throws on error. * Throws on error.
* *
* @param audio_format the preferred audio format * @param audio_format the preferred audio format
* @param buffer the #MusicBuffer where consumed #MusicChunk
* objects should be returned
*/ */
virtual void Open(const AudioFormat audio_format, virtual void Open(const AudioFormat audio_format) = 0;
MusicBuffer &buffer) = 0;
/** /**
* Closes all audio outputs. * Closes all audio outputs.
......
...@@ -343,7 +343,7 @@ Player::StartDecoder(MusicPipe &_pipe) noexcept ...@@ -343,7 +343,7 @@ Player::StartDecoder(MusicPipe &_pipe) noexcept
dc.Start(std::make_unique<DetachedSong>(*pc.next_song), dc.Start(std::make_unique<DetachedSong>(*pc.next_song),
start_time, pc.next_song->GetEndTime(), start_time, pc.next_song->GetEndTime(),
_pipe); buffer, _pipe);
} }
void void
...@@ -445,7 +445,7 @@ Player::OpenOutput() noexcept ...@@ -445,7 +445,7 @@ Player::OpenOutput() noexcept
try { try {
const ScopeUnlock unlock(pc.mutex); const ScopeUnlock unlock(pc.mutex);
pc.outputs.Open(play_audio_format, buffer); pc.outputs.Open(play_audio_format);
} catch (...) { } catch (...) {
LogError(std::current_exception()); LogError(std::current_exception());
...@@ -661,7 +661,7 @@ Player::ProcessCommand() noexcept ...@@ -661,7 +661,7 @@ Player::ProcessCommand() noexcept
pc.CommandFinished(); pc.CommandFinished();
if (dc.IsIdle()) if (dc.IsIdle())
StartDecoder(*new MusicPipe(buffer)); StartDecoder(*new MusicPipe());
break; break;
...@@ -932,7 +932,7 @@ Player::SongBorder() noexcept ...@@ -932,7 +932,7 @@ Player::SongBorder() noexcept
inline void inline void
Player::Run() noexcept Player::Run() noexcept
{ {
pipe = new MusicPipe(buffer); pipe = new MusicPipe();
const std::lock_guard<Mutex> lock(pc.mutex); const std::lock_guard<Mutex> lock(pc.mutex);
...@@ -979,7 +979,7 @@ Player::Run() noexcept ...@@ -979,7 +979,7 @@ Player::Run() noexcept
assert(dc.pipe == nullptr || dc.pipe == pipe); assert(dc.pipe == nullptr || dc.pipe == pipe);
StartDecoder(*new MusicPipe(buffer)); StartDecoder(*new MusicPipe());
} }
if (/* no cross-fading if MPD is going to pause at the if (/* no cross-fading if MPD is going to pause at the
......
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