frame refactoring, add audio frame and sdl default device input

This commit is contained in:
2024-05-02 12:10:31 +02:00
parent 165e80c456
commit b3e5e4c950
7 changed files with 210 additions and 11 deletions

View File

@ -0,0 +1,37 @@
#pragma once
#include "./frame_stream2.hpp"
#include "./audio_stream.hpp"
#include <SDL3/SDL.h>
#include <cstdint>
#include <variant>
#include <vector>
#include <thread>
// we dont have to multiplex ourself, because sdl streams and virtual devices already do this, but we do it anyway
using SDLAudioInputFrameStream2Multiplexer = QueuedFrameStream2Multiplexer<AudioFrame>;
using SDLAudioInputFrameStream2 = SDLAudioInputFrameStream2Multiplexer::reader_type_t; // just use the default for now
// object components?
struct SDLAudioInputDevice : protected SDLAudioInputFrameStream2Multiplexer {
std::unique_ptr<SDL_AudioStream, decltype(&SDL_DestroyAudioStream)> _stream;
std::atomic<bool> _thread_should_quit {false};
std::thread _thread;
// construct source and start thread
// TODO: optimize so the thread is not always running
SDLAudioInputDevice(void);
// stops the thread and closes the device?
~SDLAudioInputDevice(void);
using SDLAudioInputFrameStream2Multiplexer::aquireReader;
using SDLAudioInputFrameStream2Multiplexer::releaseReader;
};
struct SDLAudioOutputDevice {
};