MusicChunk: rename struct to MusicChunk
This commit is contained in:
parent
61f9e79ec9
commit
c94b4466d5
@ -30,7 +30,7 @@ MusicBuffer::MusicBuffer(unsigned num_chunks)
|
|||||||
FatalError("Failed to allocate buffer");
|
FatalError("Failed to allocate buffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
music_chunk *
|
MusicChunk *
|
||||||
MusicBuffer::Allocate()
|
MusicBuffer::Allocate()
|
||||||
{
|
{
|
||||||
const ScopeLock protect(mutex);
|
const ScopeLock protect(mutex);
|
||||||
@ -38,7 +38,7 @@ MusicBuffer::Allocate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MusicBuffer::Return(music_chunk *chunk)
|
MusicBuffer::Return(MusicChunk *chunk)
|
||||||
{
|
{
|
||||||
assert(chunk != nullptr);
|
assert(chunk != nullptr);
|
||||||
|
|
||||||
|
@ -23,22 +23,22 @@
|
|||||||
#include "util/SliceBuffer.hxx"
|
#include "util/SliceBuffer.hxx"
|
||||||
#include "thread/Mutex.hxx"
|
#include "thread/Mutex.hxx"
|
||||||
|
|
||||||
struct music_chunk;
|
struct MusicChunk;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An allocator for #music_chunk objects.
|
* An allocator for #MusicChunk objects.
|
||||||
*/
|
*/
|
||||||
class MusicBuffer {
|
class MusicBuffer {
|
||||||
/** a mutex which protects #buffer */
|
/** a mutex which protects #buffer */
|
||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
|
|
||||||
SliceBuffer<music_chunk> buffer;
|
SliceBuffer<MusicChunk> buffer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Creates a new #MusicBuffer object.
|
* Creates a new #MusicBuffer object.
|
||||||
*
|
*
|
||||||
* @param num_chunks the number of #music_chunk reserved in
|
* @param num_chunks the number of #MusicChunk reserved in
|
||||||
* this buffer
|
* this buffer
|
||||||
*/
|
*/
|
||||||
MusicBuffer(unsigned num_chunks);
|
MusicBuffer(unsigned num_chunks);
|
||||||
@ -71,13 +71,13 @@ public:
|
|||||||
* @return an empty chunk or nullptr if there are no chunks
|
* @return an empty chunk or nullptr if there are no chunks
|
||||||
* available
|
* available
|
||||||
*/
|
*/
|
||||||
music_chunk *Allocate();
|
MusicChunk *Allocate();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a chunk to the buffer. It can be reused by
|
* Returns a chunk to the buffer. It can be reused by
|
||||||
* Allocate() then.
|
* Allocate() then.
|
||||||
*/
|
*/
|
||||||
void Return(music_chunk *chunk);
|
void Return(MusicChunk *chunk);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,14 +24,14 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
music_chunk::~music_chunk()
|
MusicChunk::~MusicChunk()
|
||||||
{
|
{
|
||||||
delete tag;
|
delete tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
bool
|
bool
|
||||||
music_chunk::CheckFormat(const AudioFormat other_format) const
|
MusicChunk::CheckFormat(const AudioFormat other_format) const
|
||||||
{
|
{
|
||||||
assert(other_format.IsValid());
|
assert(other_format.IsValid());
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ music_chunk::CheckFormat(const AudioFormat other_format) const
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
WritableBuffer<void>
|
WritableBuffer<void>
|
||||||
music_chunk::Write(const AudioFormat af,
|
MusicChunk::Write(const AudioFormat af,
|
||||||
float data_time, uint16_t _bit_rate)
|
float data_time, uint16_t _bit_rate)
|
||||||
{
|
{
|
||||||
assert(CheckFormat(af));
|
assert(CheckFormat(af));
|
||||||
@ -67,7 +67,7 @@ music_chunk::Write(const AudioFormat af,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
music_chunk::Expand(const AudioFormat af, size_t _length)
|
MusicChunk::Expand(const AudioFormat af, size_t _length)
|
||||||
{
|
{
|
||||||
const size_t frame_size = af.GetFrameSize();
|
const size_t frame_size = af.GetFrameSize();
|
||||||
|
|
||||||
|
@ -39,15 +39,15 @@ struct Tag;
|
|||||||
* A chunk of music data. Its format is defined by the
|
* A chunk of music data. Its format is defined by the
|
||||||
* MusicPipe::Push() caller.
|
* MusicPipe::Push() caller.
|
||||||
*/
|
*/
|
||||||
struct music_chunk {
|
struct MusicChunk {
|
||||||
/** the next chunk in a linked list */
|
/** the next chunk in a linked list */
|
||||||
struct music_chunk *next;
|
MusicChunk *next;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An optional chunk which should be mixed into this chunk.
|
* An optional chunk which should be mixed into this chunk.
|
||||||
* This is used for cross-fading.
|
* This is used for cross-fading.
|
||||||
*/
|
*/
|
||||||
struct music_chunk *other;
|
MusicChunk *other;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current mix ratio for cross-fading: 1.0 means play 100%
|
* The current mix ratio for cross-fading: 1.0 means play 100%
|
||||||
@ -92,13 +92,13 @@ struct music_chunk {
|
|||||||
AudioFormat audio_format;
|
AudioFormat audio_format;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
music_chunk()
|
MusicChunk()
|
||||||
:other(nullptr),
|
:other(nullptr),
|
||||||
length(0),
|
length(0),
|
||||||
tag(nullptr),
|
tag(nullptr),
|
||||||
replay_gain_serial(0) {}
|
replay_gain_serial(0) {}
|
||||||
|
|
||||||
~music_chunk();
|
~MusicChunk();
|
||||||
|
|
||||||
bool IsEmpty() const {
|
bool IsEmpty() const {
|
||||||
return length == 0 && tag == nullptr;
|
return length == 0 && tag == nullptr;
|
||||||
@ -118,7 +118,7 @@ struct music_chunk {
|
|||||||
* where you may write into. After you are finished, call
|
* where you may write into. After you are finished, call
|
||||||
* Expand().
|
* Expand().
|
||||||
*
|
*
|
||||||
* @param chunk the music_chunk object
|
* @param chunk the MusicChunk object
|
||||||
* @param audio_format the audio format for the appended data;
|
* @param audio_format the audio format for the appended data;
|
||||||
* must stay the same for the life cycle of this chunk
|
* must stay the same for the life cycle of this chunk
|
||||||
* @param data_time the time within the song
|
* @param data_time the time within the song
|
||||||
@ -134,7 +134,7 @@ struct music_chunk {
|
|||||||
* Increases the length of the chunk after the caller has written to
|
* Increases the length of the chunk after the caller has written to
|
||||||
* the buffer returned by Write().
|
* the buffer returned by Write().
|
||||||
*
|
*
|
||||||
* @param chunk the music_chunk object
|
* @param chunk the MusicChunk object
|
||||||
* @param audio_format the audio format for the appended data; must
|
* @param audio_format the audio format for the appended data; must
|
||||||
* stay the same for the life cycle of this chunk
|
* stay the same for the life cycle of this chunk
|
||||||
* @param length the number of bytes which were appended
|
* @param length the number of bytes which were appended
|
||||||
|
@ -25,11 +25,11 @@
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MusicPipe::Contains(const music_chunk *chunk) const
|
MusicPipe::Contains(const MusicChunk *chunk) const
|
||||||
{
|
{
|
||||||
const ScopeLock protect(mutex);
|
const ScopeLock protect(mutex);
|
||||||
|
|
||||||
for (const struct music_chunk *i = head; i != nullptr; i = i->next)
|
for (const MusicChunk *i = head; i != nullptr; i = i->next)
|
||||||
if (i == chunk)
|
if (i == chunk)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -38,12 +38,12 @@ MusicPipe::Contains(const music_chunk *chunk) const
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
music_chunk *
|
MusicChunk *
|
||||||
MusicPipe::Shift()
|
MusicPipe::Shift()
|
||||||
{
|
{
|
||||||
const ScopeLock protect(mutex);
|
const ScopeLock protect(mutex);
|
||||||
|
|
||||||
music_chunk *chunk = head;
|
MusicChunk *chunk = head;
|
||||||
if (chunk != nullptr) {
|
if (chunk != nullptr) {
|
||||||
assert(!chunk->IsEmpty());
|
assert(!chunk->IsEmpty());
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ MusicPipe::Shift()
|
|||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
/* poison the "next" reference */
|
/* poison the "next" reference */
|
||||||
chunk->next = (music_chunk *)(void *)0x01010101;
|
chunk->next = (MusicChunk *)(void *)0x01010101;
|
||||||
|
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
audio_format.Clear();
|
audio_format.Clear();
|
||||||
@ -75,14 +75,14 @@ MusicPipe::Shift()
|
|||||||
void
|
void
|
||||||
MusicPipe::Clear(MusicBuffer &buffer)
|
MusicPipe::Clear(MusicBuffer &buffer)
|
||||||
{
|
{
|
||||||
music_chunk *chunk;
|
MusicChunk *chunk;
|
||||||
|
|
||||||
while ((chunk = Shift()) != nullptr)
|
while ((chunk = Shift()) != nullptr)
|
||||||
buffer.Return(chunk);
|
buffer.Return(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MusicPipe::Push(music_chunk *chunk)
|
MusicPipe::Push(MusicChunk *chunk)
|
||||||
{
|
{
|
||||||
assert(!chunk->IsEmpty());
|
assert(!chunk->IsEmpty());
|
||||||
assert(chunk->length == 0 || chunk->audio_format.IsValid());
|
assert(chunk->length == 0 || chunk->audio_format.IsValid());
|
||||||
|
@ -29,19 +29,19 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
struct music_chunk;
|
struct MusicChunk;
|
||||||
class MusicBuffer;
|
class MusicBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A queue of #music_chunk 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 first chunk */
|
/** the first chunk */
|
||||||
music_chunk *head;
|
MusicChunk *head;
|
||||||
|
|
||||||
/** a pointer to the tail of the chunk */
|
/** a pointer to the tail of the chunk */
|
||||||
music_chunk **tail_r;
|
MusicChunk **tail_r;
|
||||||
|
|
||||||
/** the current number of chunks */
|
/** the current number of chunks */
|
||||||
unsigned size;
|
unsigned size;
|
||||||
@ -87,22 +87,22 @@ public:
|
|||||||
* Checks if the specified chunk is enqueued in the music pipe.
|
* Checks if the specified chunk is enqueued in the music pipe.
|
||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
bool Contains(const music_chunk *chunk) const;
|
bool Contains(const MusicChunk *chunk) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the first #music_chunk from the pipe. Returns
|
* Returns the first #MusicChunk from the pipe. Returns
|
||||||
* nullptr if the pipe is empty.
|
* nullptr if the pipe is empty.
|
||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
const music_chunk *Peek() const {
|
const MusicChunk *Peek() const {
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the first chunk from the head, and returns it.
|
* Removes the first chunk from the head, and returns it.
|
||||||
*/
|
*/
|
||||||
music_chunk *Shift();
|
MusicChunk *Shift();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the whole pipe and returns the chunks to the buffer.
|
* Clears the whole pipe and returns the chunks to the buffer.
|
||||||
@ -114,7 +114,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Pushes a chunk to the tail of the pipe.
|
* Pushes a chunk to the tail of the pipe.
|
||||||
*/
|
*/
|
||||||
void Push(music_chunk *chunk);
|
void Push(MusicChunk *chunk);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of chunks currently in this pipe.
|
* Returns the number of chunks currently in this pipe.
|
||||||
|
@ -484,7 +484,7 @@ Player::SendSilence()
|
|||||||
assert(output_open);
|
assert(output_open);
|
||||||
assert(play_audio_format.IsDefined());
|
assert(play_audio_format.IsDefined());
|
||||||
|
|
||||||
struct music_chunk *chunk = buffer.Allocate();
|
MusicChunk *chunk = buffer.Allocate();
|
||||||
if (chunk == nullptr) {
|
if (chunk == nullptr) {
|
||||||
LogError(player_domain, "Failed to allocate silence buffer");
|
LogError(player_domain, "Failed to allocate silence buffer");
|
||||||
return false;
|
return false;
|
||||||
@ -704,7 +704,7 @@ update_song_tag(PlayerControl &pc, DetachedSong &song, const Tag &new_tag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plays a #music_chunk object (after applying software volume). If
|
* Plays a #MusicChunk object (after applying software volume). If
|
||||||
* it contains a (stream) tag, copy it to the current song, so MPD's
|
* it contains a (stream) tag, copy it to the current song, so MPD's
|
||||||
* playlist reflects the new stream tag.
|
* playlist reflects the new stream tag.
|
||||||
*
|
*
|
||||||
@ -712,7 +712,7 @@ update_song_tag(PlayerControl &pc, DetachedSong &song, const Tag &new_tag)
|
|||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
play_chunk(PlayerControl &pc,
|
play_chunk(PlayerControl &pc,
|
||||||
DetachedSong &song, struct music_chunk *chunk,
|
DetachedSong &song, MusicChunk *chunk,
|
||||||
MusicBuffer &buffer,
|
MusicBuffer &buffer,
|
||||||
const AudioFormat format,
|
const AudioFormat format,
|
||||||
Error &error)
|
Error &error)
|
||||||
@ -750,11 +750,11 @@ Player::PlayNextChunk()
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
unsigned cross_fade_position;
|
unsigned cross_fade_position;
|
||||||
struct music_chunk *chunk = nullptr;
|
MusicChunk *chunk = nullptr;
|
||||||
if (xfade_state == CrossFadeState::ENABLED && IsDecoderAtNextSong() &&
|
if (xfade_state == CrossFadeState::ENABLED && IsDecoderAtNextSong() &&
|
||||||
(cross_fade_position = pipe->GetSize()) <= cross_fade_chunks) {
|
(cross_fade_position = pipe->GetSize()) <= cross_fade_chunks) {
|
||||||
/* perform cross fade */
|
/* perform cross fade */
|
||||||
music_chunk *other_chunk = dc.pipe->Shift();
|
MusicChunk *other_chunk = dc.pipe->Shift();
|
||||||
|
|
||||||
if (!cross_fading) {
|
if (!cross_fading) {
|
||||||
/* beginning of the cross fade - adjust
|
/* beginning of the cross fade - adjust
|
||||||
@ -786,7 +786,7 @@ Player::PlayNextChunk()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (other_chunk->IsEmpty()) {
|
if (other_chunk->IsEmpty()) {
|
||||||
/* the "other" chunk was a music_chunk
|
/* the "other" chunk was a MusicChunk
|
||||||
which had only a tag, but no music
|
which had only a tag, but no music
|
||||||
data - we cannot cross-fade that;
|
data - we cannot cross-fade that;
|
||||||
but since this happens only at the
|
but since this happens only at the
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
*
|
*
|
||||||
* The player thread controls the playback. It acts as a bridge
|
* The player thread controls the playback. It acts as a bridge
|
||||||
* between the decoder thread and the output thread(s): it receives
|
* between the decoder thread and the output thread(s): it receives
|
||||||
* #music_chunk objects from the decoder, optionally mixes them
|
* #MusicChunk objects from the decoder, optionally mixes them
|
||||||
* (cross-fading), applies software volume, and sends them to the
|
* (cross-fading), applies software volume, and sends them to the
|
||||||
* audio outputs via audio_output_all_play().
|
* audio outputs via audio_output_all_play().
|
||||||
*
|
*
|
||||||
@ -31,7 +31,7 @@
|
|||||||
*
|
*
|
||||||
* The player thread itself does not do any I/O. It synchronizes with
|
* The player thread itself does not do any I/O. It synchronizes with
|
||||||
* other threads via #GMutex and #GCond objects, and passes
|
* other threads via #GMutex and #GCond objects, and passes
|
||||||
* #music_chunk instances around in #MusicPipe objects.
|
* #MusicChunk instances around in #MusicPipe objects.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MPD_PLAYER_THREAD_HXX
|
#ifndef MPD_PLAYER_THREAD_HXX
|
||||||
|
@ -387,7 +387,7 @@ decoder_timestamp(Decoder &decoder, double t)
|
|||||||
static DecoderCommand
|
static DecoderCommand
|
||||||
do_send_tag(Decoder &decoder, const Tag &tag)
|
do_send_tag(Decoder &decoder, const Tag &tag)
|
||||||
{
|
{
|
||||||
struct music_chunk *chunk;
|
MusicChunk *chunk;
|
||||||
|
|
||||||
if (decoder.chunk != nullptr) {
|
if (decoder.chunk != nullptr) {
|
||||||
/* there is a partial chunk - flush it, we want the
|
/* there is a partial chunk - flush it, we want the
|
||||||
@ -487,7 +487,7 @@ decoder_data(Decoder &decoder,
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (length > 0) {
|
while (length > 0) {
|
||||||
struct music_chunk *chunk;
|
MusicChunk *chunk;
|
||||||
bool full;
|
bool full;
|
||||||
|
|
||||||
chunk = decoder.GetChunk();
|
chunk = decoder.GetChunk();
|
||||||
|
@ -144,7 +144,7 @@ struct DecoderControl {
|
|||||||
|
|
||||||
float total_time;
|
float total_time;
|
||||||
|
|
||||||
/** the #music_chunk allocator */
|
/** the #MusicChunk allocator */
|
||||||
MusicBuffer *buffer;
|
MusicBuffer *buffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +56,7 @@ need_chunks(DecoderControl &dc)
|
|||||||
return dc.command;
|
return dc.command;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct music_chunk *
|
MusicChunk *
|
||||||
Decoder::GetChunk()
|
Decoder::GetChunk()
|
||||||
{
|
{
|
||||||
DecoderCommand cmd;
|
DecoderCommand cmd;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
|
|
||||||
class PcmConvert;
|
class PcmConvert;
|
||||||
|
struct MusicChunk;
|
||||||
struct DecoderControl;
|
struct DecoderControl;
|
||||||
struct Tag;
|
struct Tag;
|
||||||
|
|
||||||
@ -76,7 +77,7 @@ struct Decoder {
|
|||||||
Tag *decoder_tag;
|
Tag *decoder_tag;
|
||||||
|
|
||||||
/** the chunk currently being written to */
|
/** the chunk currently being written to */
|
||||||
struct music_chunk *chunk;
|
MusicChunk *chunk;
|
||||||
|
|
||||||
ReplayGainInfo replay_gain_info;
|
ReplayGainInfo replay_gain_info;
|
||||||
|
|
||||||
@ -112,7 +113,7 @@ struct Decoder {
|
|||||||
*
|
*
|
||||||
* @return the chunk, or NULL if we have received a decoder command
|
* @return the chunk, or NULL if we have received a decoder command
|
||||||
*/
|
*/
|
||||||
music_chunk *GetChunk();
|
MusicChunk *GetChunk();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flushes the current chunk.
|
* Flushes the current chunk.
|
||||||
|
@ -35,7 +35,7 @@ class MusicPipe;
|
|||||||
class EventLoop;
|
class EventLoop;
|
||||||
class Mixer;
|
class Mixer;
|
||||||
class MixerListener;
|
class MixerListener;
|
||||||
struct music_chunk;
|
struct MusicChunk;
|
||||||
struct config_param;
|
struct config_param;
|
||||||
struct PlayerControl;
|
struct PlayerControl;
|
||||||
struct AudioOutputPlugin;
|
struct AudioOutputPlugin;
|
||||||
@ -257,12 +257,12 @@ struct AudioOutput {
|
|||||||
PlayerControl *player_control;
|
PlayerControl *player_control;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The #music_chunk which is currently being played. All
|
* The #MusicChunk which is currently being played. All
|
||||||
* chunks before this one may be returned to the
|
* chunks before this one may be returned to the
|
||||||
* #music_buffer, because they are not going to be used by
|
* #music_buffer, because they are not going to be used by
|
||||||
* this output anymore.
|
* this output anymore.
|
||||||
*/
|
*/
|
||||||
const music_chunk *current_chunk;
|
const MusicChunk *current_chunk;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has the output finished playing #current_chunk?
|
* Has the output finished playing #current_chunk?
|
||||||
@ -395,9 +395,9 @@ private:
|
|||||||
bool WaitForDelay();
|
bool WaitForDelay();
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
const music_chunk *GetNextChunk() const;
|
const MusicChunk *GetNextChunk() const;
|
||||||
|
|
||||||
bool PlayChunk(const music_chunk *chunk);
|
bool PlayChunk(const MusicChunk *chunk);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plays all remaining chunks, until the tail of the pipe has
|
* Plays all remaining chunks, until the tail of the pipe has
|
||||||
|
@ -187,7 +187,7 @@ MultipleOutputs::SetReplayGainMode(ReplayGainMode mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MultipleOutputs::Play(music_chunk *chunk, Error &error)
|
MultipleOutputs::Play(MusicChunk *chunk, Error &error)
|
||||||
{
|
{
|
||||||
assert(buffer != nullptr);
|
assert(buffer != nullptr);
|
||||||
assert(pipe != nullptr);
|
assert(pipe != nullptr);
|
||||||
@ -265,7 +265,7 @@ gcc_pure
|
|||||||
static bool
|
static bool
|
||||||
chunk_is_consumed_in(const AudioOutput *ao,
|
chunk_is_consumed_in(const AudioOutput *ao,
|
||||||
gcc_unused const MusicPipe *pipe,
|
gcc_unused const MusicPipe *pipe,
|
||||||
const struct music_chunk *chunk)
|
const MusicChunk *chunk)
|
||||||
{
|
{
|
||||||
if (!ao->open)
|
if (!ao->open)
|
||||||
return true;
|
return true;
|
||||||
@ -285,7 +285,7 @@ chunk_is_consumed_in(const AudioOutput *ao,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MultipleOutputs::IsChunkConsumed(const music_chunk *chunk) const
|
MultipleOutputs::IsChunkConsumed(const MusicChunk *chunk) const
|
||||||
{
|
{
|
||||||
for (auto ao : outputs) {
|
for (auto ao : outputs) {
|
||||||
const ScopeLock protect(ao->mutex);
|
const ScopeLock protect(ao->mutex);
|
||||||
@ -297,7 +297,7 @@ MultipleOutputs::IsChunkConsumed(const music_chunk *chunk) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
MultipleOutputs::ClearTailChunk(gcc_unused const struct music_chunk *chunk,
|
MultipleOutputs::ClearTailChunk(gcc_unused const MusicChunk *chunk,
|
||||||
bool *locked)
|
bool *locked)
|
||||||
{
|
{
|
||||||
assert(chunk->next == nullptr);
|
assert(chunk->next == nullptr);
|
||||||
@ -325,9 +325,9 @@ MultipleOutputs::ClearTailChunk(gcc_unused const struct music_chunk *chunk,
|
|||||||
unsigned
|
unsigned
|
||||||
MultipleOutputs::Check()
|
MultipleOutputs::Check()
|
||||||
{
|
{
|
||||||
const struct music_chunk *chunk;
|
const MusicChunk *chunk;
|
||||||
bool is_tail;
|
bool is_tail;
|
||||||
struct music_chunk *shifted;
|
MusicChunk *shifted;
|
||||||
bool locked[outputs.size()];
|
bool locked[outputs.size()];
|
||||||
|
|
||||||
assert(buffer != nullptr);
|
assert(buffer != nullptr);
|
||||||
|
@ -39,7 +39,7 @@ class MusicBuffer;
|
|||||||
class MusicPipe;
|
class MusicPipe;
|
||||||
class EventLoop;
|
class EventLoop;
|
||||||
class MixerListener;
|
class MixerListener;
|
||||||
struct music_chunk;
|
struct MusicChunk;
|
||||||
struct PlayerControl;
|
struct PlayerControl;
|
||||||
struct AudioOutput;
|
struct AudioOutput;
|
||||||
class Error;
|
class Error;
|
||||||
@ -119,7 +119,7 @@ public:
|
|||||||
* Opens all audio outputs which are not disabled.
|
* Opens all audio outputs which are not disabled.
|
||||||
*
|
*
|
||||||
* @param audio_format the preferred audio format
|
* @param audio_format the preferred audio format
|
||||||
* @param buffer the #music_buffer where consumed #music_chunk objects
|
* @param buffer the #music_buffer where consumed #MusicChunk objects
|
||||||
* should be returned
|
* should be returned
|
||||||
* @return true on success, false on failure
|
* @return true on success, false on failure
|
||||||
*/
|
*/
|
||||||
@ -140,14 +140,14 @@ public:
|
|||||||
void SetReplayGainMode(ReplayGainMode mode);
|
void SetReplayGainMode(ReplayGainMode mode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enqueue a #music_chunk object for playing, i.e. pushes it to a
|
* Enqueue a #MusicChunk object for playing, i.e. pushes it to a
|
||||||
* #MusicPipe.
|
* #MusicPipe.
|
||||||
*
|
*
|
||||||
* @param chunk the #music_chunk object to be played
|
* @param chunk the #MusicChunk object to be played
|
||||||
* @return true on success, false if no audio output was able to play
|
* @return true on success, false if no audio output was able to play
|
||||||
* (all closed then)
|
* (all closed then)
|
||||||
*/
|
*/
|
||||||
bool Play(music_chunk *chunk, Error &error);
|
bool Play(MusicChunk *chunk, Error &error);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the output devices have drained their music pipe, and
|
* Checks if the output devices have drained their music pipe, and
|
||||||
@ -160,7 +160,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Checks if the size of the #MusicPipe is below the #threshold. If
|
* Checks if the size of the #MusicPipe is below the #threshold. If
|
||||||
* not, it attempts to synchronize with all output threads, and waits
|
* not, it attempts to synchronize with all output threads, and waits
|
||||||
* until another #music_chunk is finished.
|
* until another #MusicChunk is finished.
|
||||||
*
|
*
|
||||||
* @param threshold the maximum number of chunks in the pipe
|
* @param threshold the maximum number of chunks in the pipe
|
||||||
* @return true if there are less than #threshold chunks in the pipe
|
* @return true if there are less than #threshold chunks in the pipe
|
||||||
@ -262,14 +262,14 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Has this chunk been consumed by all audio outputs?
|
* Has this chunk been consumed by all audio outputs?
|
||||||
*/
|
*/
|
||||||
bool IsChunkConsumed(const music_chunk *chunk) const;
|
bool IsChunkConsumed(const MusicChunk *chunk) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* There's only one chunk left in the pipe (#pipe), and all
|
* There's only one chunk left in the pipe (#pipe), and all
|
||||||
* audio outputs have consumed it already. Clear the
|
* audio outputs have consumed it already. Clear the
|
||||||
* reference.
|
* reference.
|
||||||
*/
|
*/
|
||||||
void ClearTailChunk(const struct music_chunk *chunk, bool *locked);
|
void ClearTailChunk(const MusicChunk *chunk, bool *locked);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -307,7 +307,7 @@ AudioOutput::WaitForDelay()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const void *
|
static const void *
|
||||||
ao_chunk_data(AudioOutput *ao, const struct music_chunk *chunk,
|
ao_chunk_data(AudioOutput *ao, const MusicChunk *chunk,
|
||||||
Filter *replay_gain_filter,
|
Filter *replay_gain_filter,
|
||||||
unsigned *replay_gain_serial_p,
|
unsigned *replay_gain_serial_p,
|
||||||
size_t *length_r)
|
size_t *length_r)
|
||||||
@ -347,7 +347,7 @@ ao_chunk_data(AudioOutput *ao, const struct music_chunk *chunk,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const void *
|
static const void *
|
||||||
ao_filter_chunk(AudioOutput *ao, const struct music_chunk *chunk,
|
ao_filter_chunk(AudioOutput *ao, const MusicChunk *chunk,
|
||||||
size_t *length_r)
|
size_t *length_r)
|
||||||
{
|
{
|
||||||
size_t length;
|
size_t length;
|
||||||
@ -417,7 +417,7 @@ ao_filter_chunk(AudioOutput *ao, const struct music_chunk *chunk,
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
AudioOutput::PlayChunk(const music_chunk *chunk)
|
AudioOutput::PlayChunk(const MusicChunk *chunk)
|
||||||
{
|
{
|
||||||
assert(filter != nullptr);
|
assert(filter != nullptr);
|
||||||
|
|
||||||
@ -478,7 +478,7 @@ AudioOutput::PlayChunk(const music_chunk *chunk)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const music_chunk *
|
inline const MusicChunk *
|
||||||
AudioOutput::GetNextChunk() const
|
AudioOutput::GetNextChunk() const
|
||||||
{
|
{
|
||||||
return current_chunk != nullptr
|
return current_chunk != nullptr
|
||||||
@ -493,7 +493,7 @@ AudioOutput::Play()
|
|||||||
{
|
{
|
||||||
assert(pipe != nullptr);
|
assert(pipe != nullptr);
|
||||||
|
|
||||||
const music_chunk *chunk = GetNextChunk();
|
const MusicChunk *chunk = GetNextChunk();
|
||||||
if (chunk == nullptr)
|
if (chunk == nullptr)
|
||||||
/* no chunk available */
|
/* no chunk available */
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user