52 lines
961 B
C++
52 lines
961 B
C++
#ifndef AUDIO_H
|
|
#define AUDIO_H
|
|
|
|
#include "pch.hpp"
|
|
|
|
#include <SDL3/SDL.h>
|
|
#include <SDL3/SDL_audio.h>
|
|
|
|
namespace Archimedes {
|
|
|
|
class Audio {
|
|
|
|
public:
|
|
|
|
Audio() {
|
|
if(!SDL_Init(SDL_INIT_AUDIO)) {
|
|
|
|
std::abort();
|
|
}
|
|
|
|
pDevices = SDL_GetAudioPlaybackDevices(&pDeviceCount);
|
|
rDevices = SDL_GetAudioPlaybackDevices(&rDeviceCount);
|
|
}
|
|
|
|
~Audio() {
|
|
|
|
for(SDL_AudioStream* s : streams) {
|
|
DestroyAudioStream(s);
|
|
}
|
|
|
|
SDL_QuitSubsystem(SDL_INIT_AUDIO);
|
|
}
|
|
|
|
|
|
private:
|
|
|
|
SDL_AudioDeviceID* pDevices;
|
|
|
|
int pDeviceCount = 0;
|
|
|
|
SDL_AudioDeviceID* rDevices;
|
|
|
|
int rDeviceCount = 0;
|
|
|
|
std::vector<SDL_AudioStream*> streams;
|
|
std::vector<SDL_AudioSpec> specs;
|
|
|
|
};
|
|
}
|
|
|
|
#endif
|