fix: preserve audio sample continuity across timestamp rounding
This commit is contained in:
@@ -17,6 +17,11 @@ extern "C" {
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
#ifdef PLAYER_AUDIO_CHECK
|
||||
// Check builds observe the actual callback samples; release builds have no hook.
|
||||
extern void player_check_audio(const float *samples, size_t frames);
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
constexpr size_t capacity = 48000;
|
||||
double host_seconds(uint64_t ticks) {
|
||||
@@ -258,6 +263,9 @@ struct Output::Impl {
|
||||
size_t first = std::min(frames, capacity - size_t(r % capacity));
|
||||
std::memcpy(destination, self.samples.data() + (r % capacity) * 2, first * 2 * sizeof(float));
|
||||
std::memcpy(destination + first * 2, self.samples.data(), (frames - first) * 2 * sizeof(float));
|
||||
#ifdef PLAYER_AUDIO_CHECK
|
||||
player_check_audio(destination, count);
|
||||
#endif
|
||||
if (frames) {
|
||||
self.clockVersion.fetch_add(1, std::memory_order_acq_rel);
|
||||
self.anchorPTS.store(self.origin + double(r) / 48000, std::memory_order_relaxed);
|
||||
|
||||
Reference in New Issue
Block a user