Add audio enable and vsync settings

This commit is contained in:
wheremyfoodat 2024-02-23 22:31:45 +02:00
parent e0c1d4511b
commit 8cba0405b9
12 changed files with 102 additions and 22 deletions

View file

@ -32,6 +32,7 @@ namespace Audio {
DSPService& dspService;
Samples sampleBuffer;
bool audioEnabled = false;
MAKE_LOG_FUNCTION(log, dspLogger)
@ -55,7 +56,9 @@ namespace Audio {
static Audio::DSPCore::Type typeFromString(std::string inString);
static const char* typeToString(Audio::DSPCore::Type type);
Samples& getSamples() { return sampleBuffer; }
virtual void setAudioEnabled(bool enable) { audioEnabled = enable; }
};
std::unique_ptr<DSPCore> makeDSPCore(DSPCore::Type type, Memory& mem, Scheduler& scheduler, DSPService& dspService);

View file

@ -1,4 +1,5 @@
#pragma once
#include <atomic>
#include <string>
#include <vector>
@ -7,8 +8,8 @@
class MiniAudioDevice {
using Samples = Common::RingBuffer<ma_int16, 1024>;
// static constexpr ma_uint32 sampleRateIn = 32768; // 3DS sample rate
// static constexpr ma_uint32 sampleRateOut = 44100; // Output sample rate
static constexpr ma_uint32 sampleRate = 32768; // 3DS sample rate
static constexpr ma_uint32 channelCount = 2; // Audio output is stereo
ma_context context;
ma_device_config deviceConfig;
@ -24,5 +25,7 @@ class MiniAudioDevice {
MiniAudioDevice();
// If safe is on, we create a null audio device
void init(Samples& samples, bool safe = false);
void start();
void stop();
};

View file

@ -84,6 +84,7 @@ namespace Audio {
scheduler.addEvent(Scheduler::EventType::RunDSP, scheduler.currentTimestamp + Audio::lleSlice * 2);
}
void setAudioEnabled(bool enable) override;
u8* getDspMemory() override { return teakra.GetDspMemory().data(); }
u16 recvData(u32 regId) override { return teakra.RecvData(regId); }