cleanup
This commit is contained in:
parent
6c558eb3d5
commit
ab7bf9c709
@ -625,37 +625,6 @@ void ALAudio::freeBuffer(uint buffer) {
|
||||
freebuffers.push_back(buffer);
|
||||
}
|
||||
|
||||
void ALAudio::setOutputDevice(const std::string& deviceName) {
|
||||
ALCdevice* newDevice = alcOpenDevice(deviceName.c_str());
|
||||
if (newDevice == nullptr) {
|
||||
logger.error() << "failed to open output device: " << deviceName;
|
||||
return;
|
||||
}
|
||||
|
||||
ALCcontext* newContext = alcCreateContext(newDevice, nullptr);
|
||||
if (!alcMakeContextCurrent(newContext)) {
|
||||
logger.error() << "failed to make context current for device: "
|
||||
<< deviceName;
|
||||
alcCloseDevice(newDevice);
|
||||
return;
|
||||
}
|
||||
|
||||
// Clean up old device and context
|
||||
alcMakeContextCurrent(nullptr);
|
||||
check_alc_errors(device, "alcMakeContextCurrent");
|
||||
alcDestroyContext(context);
|
||||
check_alc_errors(device, "alcDestroyContext");
|
||||
if (!alcCloseDevice(device)) {
|
||||
logger.error() << "old device not closed";
|
||||
}
|
||||
|
||||
// Update to new device and context
|
||||
device = newDevice;
|
||||
context = newContext;
|
||||
|
||||
logger.info() << "switched output device to: " << deviceName;
|
||||
}
|
||||
|
||||
void ALAudio::setListener(
|
||||
glm::vec3 position, glm::vec3 velocity, glm::vec3 at, glm::vec3 up
|
||||
) {
|
||||
|
||||
@ -197,8 +197,6 @@ namespace audio {
|
||||
std::vector<std::string> getOutputDeviceNames() override;
|
||||
std::vector<std::string> getInputDeviceNames() override;
|
||||
|
||||
void setOutputDevice(const std::string& deviceName) override;
|
||||
|
||||
void setListener(
|
||||
glm::vec3 position,
|
||||
glm::vec3 velocity,
|
||||
|
||||
@ -89,9 +89,6 @@ namespace audio {
|
||||
return {};
|
||||
}
|
||||
|
||||
void setOutputDevice(const std::string& deviceName) override {
|
||||
}
|
||||
|
||||
void setListener(
|
||||
glm::vec3 position, glm::vec3 velocity, glm::vec3 at, glm::vec3 up
|
||||
) override {
|
||||
|
||||
@ -285,10 +285,6 @@ void audio::set_input_device(const std::string& deviceName) {
|
||||
}
|
||||
}
|
||||
|
||||
void audio::set_output_device(const std::string& deviceName) {
|
||||
backend->setOutputDevice(deviceName);
|
||||
}
|
||||
|
||||
void audio::set_listener(
|
||||
glm::vec3 position, glm::vec3 velocity, glm::vec3 lookAt, glm::vec3 up
|
||||
) {
|
||||
|
||||
@ -381,7 +381,6 @@ namespace audio {
|
||||
) = 0;
|
||||
virtual std::vector<std::string> getInputDeviceNames() = 0;
|
||||
virtual std::vector<std::string> getOutputDeviceNames() = 0;
|
||||
virtual void setOutputDevice(const std::string& deviceName) = 0;
|
||||
virtual void update(double delta) = 0;
|
||||
|
||||
/// @brief Check if backend is an abstraction that does not internally
|
||||
@ -458,7 +457,6 @@ namespace audio {
|
||||
std::vector<std::string> get_output_devices_names();
|
||||
|
||||
void set_input_device(const std::string& deviceName);
|
||||
void set_output_device(const std::string& deviceName);
|
||||
|
||||
/// @brief Configure 3D listener
|
||||
/// @param position listener position
|
||||
|
||||
@ -436,12 +436,6 @@ static int l_audio_set_input_device(lua::State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_audio_set_output_device(lua::State* L) {
|
||||
auto device_name = lua::tostring(L, 1);
|
||||
audio::set_output_device(device_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_audio_get_input_info(lua::State* L) {
|
||||
auto device = audio::get_input_device();
|
||||
if (device == nullptr) {
|
||||
@ -486,7 +480,6 @@ const luaL_Reg audiolib[] = {
|
||||
{"get_input_devices_names", lua::wrap<l_audio_get_input_devices_names>},
|
||||
{"get_output_devices_names", lua::wrap<l_audio_get_output_devices_names>},
|
||||
{"set_input_device", lua::wrap<l_audio_set_input_device>},
|
||||
{"set_output_device", lua::wrap<l_audio_set_output_device>},
|
||||
{"get_input_info", lua::wrap<l_audio_get_input_info>},
|
||||
{nullptr, nullptr}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user