MusicChunk: use SignedSongTime for the time stamp
This commit is contained in:
parent
147d301f10
commit
9d3a85d434
@ -41,17 +41,17 @@ MusicChunk::CheckFormat(const AudioFormat other_format) const
|
|||||||
|
|
||||||
WritableBuffer<void>
|
WritableBuffer<void>
|
||||||
MusicChunk::Write(const AudioFormat af,
|
MusicChunk::Write(const AudioFormat af,
|
||||||
float data_time, uint16_t _bit_rate)
|
SongTime data_time, uint16_t _bit_rate)
|
||||||
{
|
{
|
||||||
assert(CheckFormat(af));
|
assert(CheckFormat(af));
|
||||||
assert(length == 0 || audio_format.IsValid());
|
assert(length == 0 || audio_format.IsValid());
|
||||||
|
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
/* if the chunk is empty, nobody has set bitRate and
|
/* if the chunk is empty, nobody has set bitRate and
|
||||||
times yet */
|
time yet */
|
||||||
|
|
||||||
bit_rate = _bit_rate;
|
bit_rate = _bit_rate;
|
||||||
times = data_time;
|
time = data_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t frame_size = af.GetFrameSize();
|
const size_t frame_size = af.GetFrameSize();
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#ifndef MPD_MUSIC_CHUNK_HXX
|
#ifndef MPD_MUSIC_CHUNK_HXX
|
||||||
#define MPD_MUSIC_CHUNK_HXX
|
#define MPD_MUSIC_CHUNK_HXX
|
||||||
|
|
||||||
|
#include "Chrono.hxx"
|
||||||
#include "ReplayGainInfo.hxx"
|
#include "ReplayGainInfo.hxx"
|
||||||
#include "util/WritableBuffer.hxx"
|
#include "util/WritableBuffer.hxx"
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ struct MusicChunk {
|
|||||||
uint16_t bit_rate;
|
uint16_t bit_rate;
|
||||||
|
|
||||||
/** the time stamp within the song */
|
/** the time stamp within the song */
|
||||||
float times;
|
SignedSongTime time;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An optional tag associated with this chunk (and the
|
* 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
|
* @return a writable buffer, or nullptr if the chunk is full
|
||||||
*/
|
*/
|
||||||
WritableBuffer<void> Write(AudioFormat af,
|
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
|
* Increases the length of the chunk after the caller has written to
|
||||||
|
@ -499,7 +499,7 @@ Player::SendSilence()
|
|||||||
partial frames */
|
partial frames */
|
||||||
unsigned num_frames = sizeof(chunk->data) / frame_size;
|
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;
|
chunk->length = num_frames * frame_size;
|
||||||
memset(chunk->data, 0, chunk->length);
|
memset(chunk->data, 0, chunk->length);
|
||||||
|
|
||||||
|
@ -512,8 +512,8 @@ decoder_data(Decoder &decoder,
|
|||||||
|
|
||||||
const auto dest =
|
const auto dest =
|
||||||
chunk->Write(dc.out_audio_format,
|
chunk->Write(dc.out_audio_format,
|
||||||
decoder.timestamp -
|
SongTime::FromS(decoder.timestamp) -
|
||||||
dc.song->GetStartTime().ToDoubleS(),
|
dc.song->GetStartTime(),
|
||||||
kbit_rate);
|
kbit_rate);
|
||||||
if (dest.IsNull()) {
|
if (dest.IsNull()) {
|
||||||
/* the chunk is full, flush it */
|
/* the chunk is full, flush it */
|
||||||
|
@ -341,10 +341,10 @@ MultipleOutputs::Check()
|
|||||||
this chunk */
|
this chunk */
|
||||||
return pipe->GetSize();
|
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
|
/* only update elapsed_time if the chunk
|
||||||
provides a defined value */
|
provides a defined value */
|
||||||
elapsed_time = SignedSongTime::FromS(chunk->times);
|
elapsed_time = chunk->time;
|
||||||
|
|
||||||
is_tail = chunk->next == nullptr;
|
is_tail = chunk->next == nullptr;
|
||||||
if (is_tail)
|
if (is_tail)
|
||||||
|
Loading…
Reference in New Issue
Block a user