mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-12 09:09:47 +12:00
More audio device
This commit is contained in:
parent
4b7fedb65c
commit
08b9e49269
6 changed files with 45 additions and 39 deletions
|
@ -403,7 +403,7 @@ set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/termcolor.hpp
|
||||||
include/audio/audio_interpolation.hpp include/audio/hle_mixer.hpp include/audio/dsp_simd.hpp
|
include/audio/audio_interpolation.hpp include/audio/hle_mixer.hpp include/audio/dsp_simd.hpp
|
||||||
include/services/dsp_firmware_db.hpp include/frontend_settings.hpp include/fs/archive_twl_photo.hpp
|
include/services/dsp_firmware_db.hpp include/frontend_settings.hpp include/fs/archive_twl_photo.hpp
|
||||||
include/fs/archive_twl_sound.hpp include/fs/archive_card_spi.hpp include/services/ns.hpp include/audio/audio_device.hpp
|
include/fs/archive_twl_sound.hpp include/fs/archive_card_spi.hpp include/services/ns.hpp include/audio/audio_device.hpp
|
||||||
include/audio/libretro_audio_device.hpp
|
include/audio/audio_device_interface.hpp include/audio/libretro_audio_device.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
cmrc_add_resource_library(
|
cmrc_add_resource_library(
|
||||||
|
|
|
@ -1,34 +1,7 @@
|
||||||
#pragma once
|
#ifndef __LIBRETRO__
|
||||||
#include <array>
|
#include "audio/miniaudio_device.hpp"
|
||||||
|
using AudioDevice = MiniAudioDevice;
|
||||||
#include "config.hpp"
|
#else
|
||||||
#include "helpers.hpp"
|
#include "audio/libretro_audio_device.hpp"
|
||||||
#include "ring_buffer.hpp"
|
using AudioDevice = LibretroAudioDevice;
|
||||||
|
#endif
|
||||||
class AudioDeviceInterface {
|
|
||||||
protected:
|
|
||||||
using Samples = Common::RingBuffer<s16, 0x2000 * 2>;
|
|
||||||
using RenderBatchCallback = usize (*)(const s16*, usize);
|
|
||||||
|
|
||||||
Samples* samples = nullptr;
|
|
||||||
|
|
||||||
const AudioDeviceConfig& audioSettings;
|
|
||||||
// Store the last stereo sample we output. We play this when underruning to avoid pops.
|
|
||||||
std::array<s16, 2> lastStereoSample{};
|
|
||||||
|
|
||||||
public:
|
|
||||||
AudioDeviceInterface(Samples* samples, const AudioDeviceConfig& audioSettings) : samples(samples), audioSettings(audioSettings) {}
|
|
||||||
|
|
||||||
bool running = false;
|
|
||||||
Samples* getSamples() { return samples; }
|
|
||||||
|
|
||||||
// If safe is on, we create a null audio device
|
|
||||||
virtual void init(Samples& samples, bool safe = false) = 0;
|
|
||||||
virtual void close() = 0;
|
|
||||||
|
|
||||||
virtual void start() = 0;
|
|
||||||
virtual void stop() = 0;
|
|
||||||
|
|
||||||
// Only used for audio devices that render multiple audio frames in one go, eg the libretro audio device.
|
|
||||||
virtual void renderBatch(RenderBatchCallback callback) {}
|
|
||||||
};
|
|
34
include/audio/audio_device_interface.hpp
Normal file
34
include/audio/audio_device_interface.hpp
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#pragma once
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
#include "config.hpp"
|
||||||
|
#include "helpers.hpp"
|
||||||
|
#include "ring_buffer.hpp"
|
||||||
|
|
||||||
|
class AudioDeviceInterface {
|
||||||
|
protected:
|
||||||
|
using Samples = Common::RingBuffer<s16, 0x2000 * 2>;
|
||||||
|
using RenderBatchCallback = usize (*)(const s16*, usize);
|
||||||
|
|
||||||
|
Samples* samples = nullptr;
|
||||||
|
|
||||||
|
const AudioDeviceConfig& audioSettings;
|
||||||
|
// Store the last stereo sample we output. We play this when underruning to avoid pops.
|
||||||
|
std::array<s16, 2> lastStereoSample{};
|
||||||
|
|
||||||
|
public:
|
||||||
|
AudioDeviceInterface(Samples* samples, const AudioDeviceConfig& audioSettings) : samples(samples), audioSettings(audioSettings) {}
|
||||||
|
|
||||||
|
bool running = false;
|
||||||
|
Samples* getSamples() { return samples; }
|
||||||
|
|
||||||
|
// If safe is on, we create a null audio device
|
||||||
|
virtual void init(Samples& samples, bool safe = false) = 0;
|
||||||
|
virtual void close() = 0;
|
||||||
|
|
||||||
|
virtual void start() = 0;
|
||||||
|
virtual void stop() = 0;
|
||||||
|
|
||||||
|
// Only used for audio devices that render multiple audio frames in one go, eg the libretro audio device.
|
||||||
|
virtual void renderBatch(RenderBatchCallback callback) {}
|
||||||
|
};
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "audio/audio_device.hpp"
|
#include "audio/audio_device_interface.hpp"
|
||||||
|
|
||||||
class LibretroAudioDevice : public AudioDeviceInterface {
|
class LibretroAudioDevice : public AudioDeviceInterface {
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "audio/audio_device.hpp"
|
#include "audio/audio_device_interface.hpp"
|
||||||
#include "miniaudio.h"
|
#include "miniaudio.h"
|
||||||
|
|
||||||
class MiniAudioDevice : public AudioDeviceInterface {
|
class MiniAudioDevice : public AudioDeviceInterface {
|
||||||
|
|
|
@ -7,9 +7,8 @@
|
||||||
#include <span>
|
#include <span>
|
||||||
|
|
||||||
#include "PICA/gpu.hpp"
|
#include "PICA/gpu.hpp"
|
||||||
|
#include "audio/audio_device.hpp"
|
||||||
#include "audio/dsp_core.hpp"
|
#include "audio/dsp_core.hpp"
|
||||||
#include "audio/libretro_audio_device.hpp"
|
|
||||||
#include "audio/miniaudio_device.hpp"
|
|
||||||
#include "cheats.hpp"
|
#include "cheats.hpp"
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "cpu.hpp"
|
#include "cpu.hpp"
|
||||||
|
|
Loading…
Add table
Reference in a new issue