mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-28 08:26:16 +02:00
Log chunk age
This commit is contained in:
parent
2b894c8b07
commit
ecd5f57b0c
3 changed files with 27 additions and 2 deletions
|
@ -102,7 +102,7 @@ void Stream::addChunk(unique_ptr<msg::PcmChunk> chunk)
|
|||
if (age > 5s + bufferMs_)
|
||||
return;
|
||||
|
||||
LOG(DEBUG, LOG_TAG) << "new chunk: " << chunk->durationMs() << " ms, age: " << age.count() << " ms, Chunks: " << chunks_.size() << "\n";
|
||||
LOG(TRACE, LOG_TAG) << "new chunk: " << chunk->durationMs() << " ms, age: " << age.count() << " ms, Chunks: " << chunks_.size() << "\n";
|
||||
|
||||
auto resampled = resampler_->resample(std::move(chunk));
|
||||
if (resampled)
|
||||
|
@ -240,6 +240,21 @@ bool Stream::getPlayerChunk(void* outputBuffer, const cs::usec& outputBufferDacT
|
|||
return false;
|
||||
}
|
||||
|
||||
static int64_t min_buffer = 0;
|
||||
std::shared_ptr<msg::PcmChunk> recent_;
|
||||
if (chunks_.back_copy(recent_))
|
||||
{
|
||||
cs::nsec req_chunk_duration = cs::nsec(static_cast<cs::nsec::rep>(frames / format_.nsRate()));
|
||||
auto youngest = recent_->end() - req_chunk_duration;
|
||||
cs::msec age = std::chrono::duration_cast<cs::msec>(TimeProvider::serverNow() - youngest + outputBufferDacTime);
|
||||
min_buffer = std::max(min_buffer, age.count());
|
||||
if (now != lastUpdate_)
|
||||
{
|
||||
LOG(TRACE, LOG_TAG) << "getPlayerChunk duration: " << std::chrono::duration_cast<std::chrono::milliseconds>(req_chunk_duration).count() << ", min buffer: " << min_buffer << "\n";
|
||||
min_buffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// we have a chunk
|
||||
/// age = chunk age (server now - rec time: some positive value) - buffer (e.g. 1000ms) + time to DAC
|
||||
/// age = 0 => play now
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue