diff options
author | Max Kellermann <max@duempel.org> | 2014-08-29 13:15:33 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-08-29 13:20:58 +0200 |
commit | 9d3a85d434892055e5a640338a002504a26eabb0 (patch) | |
tree | 0d2c458f0f6719c266d36d0792f4cc6ad54df17a /src | |
parent | 147d301f102512b1a64c85e3896bdd466fb634af (diff) | |
download | mpd-9d3a85d434892055e5a640338a002504a26eabb0.tar.gz mpd-9d3a85d434892055e5a640338a002504a26eabb0.tar.xz mpd-9d3a85d434892055e5a640338a002504a26eabb0.zip |
MusicChunk: use SignedSongTime for the time stamp
Diffstat (limited to 'src')
-rw-r--r-- | src/MusicChunk.cxx | 6 | ||||
-rw-r--r-- | src/MusicChunk.hxx | 6 | ||||
-rw-r--r-- | src/PlayerThread.cxx | 2 | ||||
-rw-r--r-- | src/decoder/DecoderAPI.cxx | 4 | ||||
-rw-r--r-- | src/output/MultipleOutputs.cxx | 4 |
5 files changed, 12 insertions, 10 deletions
diff --git a/src/MusicChunk.cxx b/src/MusicChunk.cxx index 91856709e..07ec1bc19 100644 --- a/src/MusicChunk.cxx +++ b/src/MusicChunk.cxx @@ -41,17 +41,17 @@ MusicChunk::CheckFormat(const AudioFormat other_format) const WritableBuffer<void> MusicChunk::Write(const AudioFormat af, - float data_time, uint16_t _bit_rate) + SongTime data_time, uint16_t _bit_rate) { assert(CheckFormat(af)); assert(length == 0 || audio_format.IsValid()); if (length == 0) { /* if the chunk is empty, nobody has set bitRate and - times yet */ + time yet */ bit_rate = _bit_rate; - times = data_time; + time = data_time; } const size_t frame_size = af.GetFrameSize(); diff --git a/src/MusicChunk.hxx b/src/MusicChunk.hxx index 835221233..805112d02 100644 --- a/src/MusicChunk.hxx +++ b/src/MusicChunk.hxx @@ -20,6 +20,7 @@ #ifndef MPD_MUSIC_CHUNK_HXX #define MPD_MUSIC_CHUNK_HXX +#include "Chrono.hxx" #include "ReplayGainInfo.hxx" #include "util/WritableBuffer.hxx" @@ -62,7 +63,7 @@ struct MusicChunk { uint16_t bit_rate; /** the time stamp within the song */ - float times; + SignedSongTime time; /** * An optional tag associated with this chunk (and the @@ -128,7 +129,8 @@ struct MusicChunk { * @return a writable buffer, or nullptr if the chunk is full */ WritableBuffer<void> Write(AudioFormat af, - float data_time, uint16_t bit_rate); + SongTime data_time, + uint16_t bit_rate); /** * Increases the length of the chunk after the caller has written to diff --git a/src/PlayerThread.cxx b/src/PlayerThread.cxx index 51d6ee0e8..c74fdeba6 100644 --- a/src/PlayerThread.cxx +++ b/src/PlayerThread.cxx @@ -499,7 +499,7 @@ Player::SendSilence() partial frames */ unsigned num_frames = sizeof(chunk->data) / frame_size; - chunk->times = -1.0; /* undefined time stamp */ + chunk->time = SignedSongTime::Negative(); /* undefined time stamp */ chunk->length = num_frames * frame_size; memset(chunk->data, 0, chunk->length); diff --git a/src/decoder/DecoderAPI.cxx b/src/decoder/DecoderAPI.cxx index bccd46b17..354fed9a3 100644 --- a/src/decoder/DecoderAPI.cxx +++ b/src/decoder/DecoderAPI.cxx @@ -512,8 +512,8 @@ decoder_data(Decoder &decoder, const auto dest = chunk->Write(dc.out_audio_format, - decoder.timestamp - - dc.song->GetStartTime().ToDoubleS(), + SongTime::FromS(decoder.timestamp) - + dc.song->GetStartTime(), kbit_rate); if (dest.IsNull()) { /* the chunk is full, flush it */ diff --git a/src/output/MultipleOutputs.cxx b/src/output/MultipleOutputs.cxx index be99d5aa5..33ab57894 100644 --- a/src/output/MultipleOutputs.cxx +++ b/src/output/MultipleOutputs.cxx @@ -341,10 +341,10 @@ MultipleOutputs::Check() this chunk */ return pipe->GetSize(); - if (chunk->length > 0 && chunk->times >= 0.0) + if (chunk->length > 0 && !chunk->time.IsNegative()) /* only update elapsed_time if the chunk provides a defined value */ - elapsed_time = SignedSongTime::FromS(chunk->times); + elapsed_time = chunk->time; is_tail = chunk->next == nullptr; if (is_tail) |