Commit a687eb2d authored by Adrien Béraud's avatar Adrien Béraud

audioframeresizer: preserve pts

Change-Id: I89e3096ccdc27a2ca32f58c40e33f3e65fe45405
Reviewed-by: Philippe Gorley's avatarPhilippe Gorley <philippe.gorley@savoirfairelinux.com>
parent a436351a
......@@ -95,7 +95,9 @@ AudioFrameResizer::enqueue(std::shared_ptr<AudioFrame>&& frame)
throw std::runtime_error("Could not write samples to audio queue: input frame is not the right format");
}
if (samples() == 0 && f->nb_samples == frameSize_) {
auto nb_samples = samples();
if (nb_samples == 0 && f->nb_samples == frameSize_) {
nextOutputPts_ = frame->pointer()->pts + frameSize_;
cb_(std::move(frame));
return; // return if frame was just passed through
}
......@@ -106,6 +108,9 @@ AudioFrameResizer::enqueue(std::shared_ptr<AudioFrame>&& frame)
throw std::runtime_error("Failed to add audio to frame resizer");
}
if (nextOutputPts_ == 0)
nextOutputPts_ = frame->pointer()->pts - nb_samples;
if (cb_)
while (auto frame = dequeue())
cb_(std::move(frame));
......@@ -123,6 +128,8 @@ AudioFrameResizer::dequeue()
RING_ERR() << "Could not read samples from queue: " << libav_utils::getError(ret);
return {};
}
frame->pointer()->pts = nextOutputPts_;
nextOutputPts_ += frameSize_;
return frame;
}
......
......@@ -98,6 +98,7 @@ private:
* Audio queue operating on the sample level instead of byte level.
*/
AVAudioFifo* queue_;
int64_t nextOutputPts_ {0};
};
} // namespace ring
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