Merge branch 'master' into more-dsp

This commit is contained in:
wheremyfoodat 2024-11-20 02:40:20 +02:00
commit 33f45cf1f5
13 changed files with 83 additions and 42 deletions

View file

@ -27,8 +27,8 @@ void MiniAudioDevice::init(Samples& samples, bool safe) {
// TODO: Make backend selectable here
found = true;
//count = 1;
//backends[0] = backend;
// count = 1;
// backends[0] = backend;
}
if (!found) {
@ -81,8 +81,8 @@ void MiniAudioDevice::init(Samples& samples, bool safe) {
deviceConfig.playback.format = ma_format_s16;
deviceConfig.playback.channels = channelCount;
deviceConfig.sampleRate = sampleRate;
//deviceConfig.periodSizeInFrames = 64;
//deviceConfig.periods = 16;
// deviceConfig.periodSizeInFrames = 64;
// deviceConfig.periods = 16;
deviceConfig.pUserData = this;
deviceConfig.aaudio.usage = ma_aaudio_usage_game;
deviceConfig.wasapi.noAutoConvertSRC = true;
@ -130,7 +130,7 @@ void MiniAudioDevice::start() {
void MiniAudioDevice::stop() {
if (!initialized) {
Helpers::warn("MiniAudio device not initialized, can't start");
Helpers::warn("MiniAudio device not initialized, can't stop");
return;
}
@ -139,6 +139,17 @@ void MiniAudioDevice::stop() {
if (ma_device_stop(&device) != MA_SUCCESS) {
Helpers::warn("Failed to stop audio device");
}
}
}
}
void MiniAudioDevice::close() {
stop();
if (initialized) {
initialized = false;
ma_device_uninit(&device);
ma_context_uninit(&context);
}
}

View file

@ -2,7 +2,10 @@
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
#include "helpers.hpp"
@ -15,6 +18,19 @@ namespace Crypto {
return;
}
auto splitString = [](const std::string& s, const char c) -> std::vector<std::string> {
std::istringstream tmp(s);
std::vector<std::string> result(1);
while (std::getline(tmp, *result.rbegin(), c)) {
result.emplace_back();
}
// Remove temporary slot
result.pop_back();
return result;
};
while (!file.eof()) {
std::string line;
std::getline(file, line);
@ -24,7 +40,7 @@ namespace Crypto {
continue;
}
const auto parts = Helpers::split(line, '=');
const auto parts = splitString(line, '=');
if (parts.size() != 2) {
Helpers::warn("Keys: Failed to parse %s", line.c_str());
continue;