Commit 9d3a85d4 authored by Max Kellermann's avatar Max Kellermann

MusicChunk: use SignedSongTime for the time stamp

parent 147d301f
......@@ -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();
......
......@@ -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
......
......@@ -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);
......
......@@ -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 */
......
......@@ -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)
......
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