mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
audiofile: count samples with resampled format
Change-Id: I451c66a9b9a8f806daa82406ca24936d4345b068
This commit is contained in:
@ -66,9 +66,9 @@ AudioFile::AudioFile(const std::string& fileName, unsigned int sampleRate, AVSam
|
||||
Resampler r {};
|
||||
auto decoder = std::make_unique<MediaDecoder>(
|
||||
[&r, this, &buf, &total_samples](const std::shared_ptr<MediaFrame>& frame) mutable {
|
||||
auto autoFrame = std::static_pointer_cast<AudioFrame>(frame);
|
||||
total_samples += autoFrame->getFrameSize();
|
||||
buf.emplace_back(r.resample(std::move(autoFrame), format_));
|
||||
auto resampled = r.resample(std::move(std::static_pointer_cast<AudioFrame>(frame)), format_);
|
||||
total_samples += resampled->getFrameSize();
|
||||
buf.emplace_back(std::move(resampled));
|
||||
});
|
||||
DeviceParams dev;
|
||||
dev.input = fileName;
|
||||
@ -79,10 +79,10 @@ AudioFile::AudioFile(const std::string& fileName, unsigned int sampleRate, AVSam
|
||||
|
||||
if (decoder->setupAudio() < 0)
|
||||
throw AudioFileException("Decoder setup failed: " + fileName);
|
||||
|
||||
|
||||
while (decoder->decode() != MediaDemuxer::Status::EndOfFile)
|
||||
;
|
||||
|
||||
|
||||
buffer_->nb_samples = total_samples;
|
||||
buffer_->format = format_.sampleFormat;
|
||||
buffer_->sample_rate = format_.sample_rate;
|
||||
|
Reference in New Issue
Block a user