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