Fix frame count bug
This commit is contained in:
11
ffmini.cpp
11
ffmini.cpp
@@ -3,6 +3,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <ranges>
|
||||
#include <chrono>
|
||||
|
||||
#include "fmt/format.h"
|
||||
#include "miniaudio.h"
|
||||
@@ -93,7 +94,6 @@ public:
|
||||
private:
|
||||
std::size_t m_frame_count{0};
|
||||
};
|
||||
using audio_track_ref_t = std::shared_ptr<audio_track>;
|
||||
|
||||
auto ffmpeg_error_str(int err) {
|
||||
static char str[AV_ERROR_MAX_STRING_SIZE]{};
|
||||
@@ -162,7 +162,7 @@ public:
|
||||
while (frame_read < frame_count) {
|
||||
auto track = std::static_pointer_cast<audio_track>(m_tracks[0]);
|
||||
if (track->empty()) read(track);
|
||||
frame_read += track->read_pcm_frame(output, frame_count);
|
||||
frame_read += track->read_pcm_frame(output, frame_count - frame_read);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,9 +225,12 @@ auto callback([[maybe_unused]]ma_device* device, [[maybe_unused]]void* output, [
|
||||
|
||||
auto entry() -> void {
|
||||
media decoder{};
|
||||
decoder.load("C:/Users/miku/Downloads/Porter Robinson - Trying to Feel Alive (Official Audio).webm");
|
||||
fmt::print("{}\n", decoder.str());
|
||||
decoder.load("/Users/k/Downloads/tryingtofeelalive.mp4");
|
||||
fmt::print("{}", decoder.str());
|
||||
if (decoder.tracks().empty())
|
||||
throw std::runtime_error("There are no tracks readable.");
|
||||
|
||||
// TODO: Deocde and cache it in the background.
|
||||
auto track = std::static_pointer_cast<audio_track>(decoder.tracks()[0]);
|
||||
|
||||
ma_device device;
|
||||
|
||||
Reference in New Issue
Block a user