mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 22:41:49 +00:00
audio fixes
This commit is contained in:
parent
2440d852d3
commit
d1b145e7a4
4 changed files with 5 additions and 11 deletions
|
|
@ -188,7 +188,7 @@ uint ALAudio::getFreeSource(){
|
||||||
}
|
}
|
||||||
ALuint id;
|
ALuint id;
|
||||||
alGenSources(1, &id);
|
alGenSources(1, &id);
|
||||||
if (!AL_GET_ERORR())
|
if (!AL_GET_ERROR())
|
||||||
return 0;
|
return 0;
|
||||||
allsources.push_back(id);
|
allsources.push_back(id);
|
||||||
return id;
|
return id;
|
||||||
|
|
@ -200,13 +200,9 @@ uint ALAudio::getFreeBuffer(){
|
||||||
freebuffers.pop_back();
|
freebuffers.pop_back();
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
if (allbuffers.size() == maxBuffers){
|
|
||||||
std::cerr << "attempted to create new ALbuffer, but limit is " << maxBuffers << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
ALuint id;
|
ALuint id;
|
||||||
alGenBuffers(1, &id);
|
alGenBuffers(1, &id);
|
||||||
if (!AL_GET_ERORR()) {
|
if (!AL_GET_ERROR()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -227,7 +223,7 @@ std::vector<std::string> ALAudio::getAvailableDevices() const {
|
||||||
|
|
||||||
const ALCchar* devices;
|
const ALCchar* devices;
|
||||||
devices = alcGetString(device, ALC_DEVICE_SPECIFIER);
|
devices = alcGetString(device, ALC_DEVICE_SPECIFIER);
|
||||||
if (!AL_GET_ERORR()) {
|
if (!AL_GET_ERROR()) {
|
||||||
return devicesVec;
|
return devicesVec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,6 @@ namespace audio {
|
||||||
std::vector<uint> freebuffers;
|
std::vector<uint> freebuffers;
|
||||||
|
|
||||||
uint maxSources;
|
uint maxSources;
|
||||||
uint maxBuffers;
|
|
||||||
|
|
||||||
ALAudio(ALCdevice* device, ALCcontext* context);
|
ALAudio(ALCdevice* device, ALCcontext* context);
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
|
|
||||||
#define AL_CHECK(STATEMENT) STATEMENT; AL::check_errors(__FILE__, __LINE__)
|
#define AL_CHECK(STATEMENT) STATEMENT; AL::check_errors(__FILE__, __LINE__)
|
||||||
#define AL_GET_ERORR() AL::check_errors(__FILE__, __LINE__)
|
#define AL_GET_ERROR() AL::check_errors(__FILE__, __LINE__)
|
||||||
|
|
||||||
namespace AL {
|
namespace AL {
|
||||||
bool check_errors(const std::string& filename, const std::uint_fast32_t line);
|
bool check_errors(const std::string& filename, const std::uint_fast32_t line);
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ audio::PCM* ogg::load_pcm(const std::filesystem::path& file, bool headerOnly) {
|
||||||
if ((code = ov_fopen(file.u8string().c_str(), &vf))) {
|
if ((code = ov_fopen(file.u8string().c_str(), &vf))) {
|
||||||
throw std::runtime_error(vorbis_error_message(code));
|
throw std::runtime_error(vorbis_error_message(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<char> data;
|
std::vector<char> data;
|
||||||
|
|
||||||
vorbis_info* info = ov_info(&vf, -1);
|
vorbis_info* info = ov_info(&vf, -1);
|
||||||
|
|
@ -52,5 +51,5 @@ audio::PCM* ogg::load_pcm(const std::filesystem::path& file, bool headerOnly) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ov_clear(&vf);
|
ov_clear(&vf);
|
||||||
return new audio::PCM(data, channels, 16, sampleRate);
|
return new audio::PCM(std::move(data), channels, 16, sampleRate);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue