fix audio sleep -> superb perf
This commit is contained in:
parent
3a98e10007
commit
e149873673
@ -18,8 +18,8 @@ SDLAudioInputDeviceDefault::SDLAudioInputDeviceDefault(void) : _stream{nullptr,
|
|||||||
const auto audio_device_id = SDL_GetAudioStreamDevice(_stream.get());
|
const auto audio_device_id = SDL_GetAudioStreamDevice(_stream.get());
|
||||||
SDL_ResumeAudioDevice(audio_device_id);
|
SDL_ResumeAudioDevice(audio_device_id);
|
||||||
|
|
||||||
static constexpr size_t buffer_size {512}; // in samples
|
static constexpr size_t buffer_size {512*2}; // in samples
|
||||||
const auto interval_ms {buffer_size/(spec.freq * 1000)};
|
const auto interval_ms {(buffer_size * 1000) / spec.freq};
|
||||||
|
|
||||||
_thread = std::thread([this, interval_ms, spec](void) {
|
_thread = std::thread([this, interval_ms, spec](void) {
|
||||||
while (!_thread_should_quit) {
|
while (!_thread_should_quit) {
|
||||||
|
@ -83,7 +83,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
auto writer = SDLAudioOutputDeviceDefaultFactory{}.create();
|
auto writer = SDLAudioOutputDeviceDefaultFactory{}.create();
|
||||||
|
|
||||||
for (size_t i = 0; i < 2000; i++) {
|
for (size_t i = 0; i < 20; i++) {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
auto new_frame_opt = reader->pop();
|
auto new_frame_opt = reader->pop();
|
||||||
if (new_frame_opt.has_value()) {
|
if (new_frame_opt.has_value()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user