Skip to content

Commit

Permalink
feat(audio): replace OpenAL audio device for Miniaudio backend (#1005)
Browse files Browse the repository at this point in the history
  • Loading branch information
diogomsmiranda committed Sep 24, 2024
1 parent baaa941 commit 362bfac
Show file tree
Hide file tree
Showing 5 changed files with 301 additions and 41 deletions.
4 changes: 2 additions & 2 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ set(CUBOS_CORE_SOURCE
"src/gl/util.cpp"

"src/al/audio_device.cpp"
"src/al/oal_audio_device.cpp"
"src/al/oal_audio_device.hpp"
"src/al/miniaudio_device.cpp"
"src/al/miniaudio_device.hpp"

"src/ecs/entity/entity.cpp"
"src/ecs/entity/hash.cpp"
Expand Down
55 changes: 20 additions & 35 deletions core/include/cubos/core/al/audio_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <vector>

#include <glm/glm.hpp>
#include <miniaudio.h>

#include <cubos/core/api.hpp>

Expand All @@ -32,15 +33,6 @@ namespace cubos::core::al
/// @ingroup core-al
using Source = std::shared_ptr<impl::Source>;

/// @brief Possible audio formats.
enum class Format
{
Mono8,
Mono16,
Stereo8,
Stereo16,
};

/// @brief Audio device interface used to wrap low-level audio rendering APIs.
class CUBOS_CORE_API AudioDevice
{
Expand All @@ -51,36 +43,40 @@ namespace cubos::core::al
/// @brief Forbid copy construction.
AudioDevice(const AudioDevice&) = delete;

/// @brief Creates an audio device from a given device @p specifier.
/// @brief Creates an audio device.
/// @see enumerateDevices()
/// @param specifier Device specifier (empty for default).
/// @return Audio device, or nullptr on failure.
static std::shared_ptr<AudioDevice> create(const std::string& specifier = "");
static std::shared_ptr<AudioDevice> create();

/// @brief Enumerates the available devices.
/// @param[out] devices Vector to fill with the available devices.
static void enumerateDevices(std::vector<std::string>& devices);

/// @brief Creates a new audio buffer
/// @param filePath File path to create buffer from.
/// @return Handle of the new buffer.
virtual Buffer createBuffer() = 0;
virtual Buffer createBuffer(const std::string& filePath) = 0;

/// @brief Creates a new audio source.
/// @return Handle of the new source.
virtual Source createSource() = 0;

/// @brief Sets the position of the listener.
/// @param position Position.
virtual void setListenerPosition(const glm::vec3& position) = 0;
/// @param listenerIndex Index of the listener
virtual void setListenerPosition(const glm::vec3& position, unsigned int listenerIndex = 0) = 0;

/// @brief Sets the orientation of the listener.
/// @param forward Forward direction of the listener.
/// @param up Up direction of the listener.
virtual void setListenerOrientation(const glm::vec3& forward, const glm::vec3& up) = 0;
/// @param listenerIndex Index of the listener
virtual void setListenerOrientation(const glm::vec3& forward, const glm::vec3& up,
unsigned int listenerIndex = 0) = 0;

/// @brief Sets the velocity of the listener. Used to implement the doppler effect.
/// @param velocity Velocity of the listener.
virtual void setListenerVelocity(const glm::vec3& velocity) = 0;
/// @param listenerIndex Index of the listener
virtual void setListenerVelocity(const glm::vec3& velocity, unsigned int listenerIndex = 0) = 0;
};

/// @brief Namespace to store the abstract types implemented by the audio device implementations.
Expand All @@ -92,13 +88,6 @@ namespace cubos::core::al
public:
virtual ~Buffer() = default;

/// @brief Fills the buffer with data.
/// @param format Audio format of the data.
/// @param size Size of the buffer in bytes.
/// @param data Buffer data.
/// @param frequency Audio frequency.
virtual void fill(Format format, std::size_t size, const void* data, std::size_t frequency) = 0;

protected:
Buffer() = default;
};
Expand Down Expand Up @@ -141,26 +130,22 @@ namespace cubos::core::al

/// @brief Sets the maximum distance at which the source is audible.
/// @param maxDistance Maximum distance.
virtual void setDistance(float maxDistance) = 0;
virtual void setMaxDistance(float maxDistance) = 0;

/// @brief Sets the cone angle of the source, in degrees. By default, 360.
/// @param coneAngle Angle, in degrees.
virtual void setConeAngle(float coneAngle) = 0;
/// @brief Sets the minimum distance at which the source starts to attenuate.
/// @param minDistance Minimum distance.
virtual void setMinDistance(float minDistance) = 0;

/// @brief Sets the cone gain of the source.
/// @todo Find out what this is.
/// @brief Sets the cone angle, in degrees. While also setting the outerGain.
/// @param innerAngle Outer angle, in degrees.
/// @param outerAngle Inner angle, in degrees.
/// @param coneGain Gain.
virtual void setConeGain(float coneGain) = 0;
virtual void setCone(float innerAngle, float outerAngle, float outerGain) = 0;

/// @brief Sets the cone direction of the source.
/// @param direction Direction.
virtual void setConeDirection(const glm::vec3& direction) = 0;

/// @brief Sets the distance under which the volume for the source would normally drop
/// by half.
/// @param referenceDistance Distance.
virtual void setReferenceDistance(float referenceDistance) = 0;

/// @brief Plays the source.
virtual void play() = 0;

Expand Down
8 changes: 4 additions & 4 deletions core/src/al/audio_device.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include "oal_audio_device.hpp"
#include "miniaudio_device.hpp"

using namespace cubos::core::al;

std::shared_ptr<AudioDevice> AudioDevice::create(const std::string& specifier)
std::shared_ptr<AudioDevice> AudioDevice::create()

Check warning on line 5 in core/src/al/audio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/audio_device.cpp#L5

Added line #L5 was not covered by tests
{
return std::make_shared<OALAudioDevice>(specifier);
return std::make_shared<MiniaudioDevice>();

Check warning on line 7 in core/src/al/audio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/audio_device.cpp#L7

Added line #L7 was not covered by tests
}

void AudioDevice::enumerateDevices(std::vector<std::string>& devices)
{
OALAudioDevice::enumerateDevices(devices);
MiniaudioDevice::enumerateDevices(devices);
}

Check warning on line 13 in core/src/al/audio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/audio_device.cpp#L12-L13

Added lines #L12 - L13 were not covered by tests
244 changes: 244 additions & 0 deletions core/src/al/miniaudio_device.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
#include "miniaudio_device.hpp"

#include <cubos/core/log.hpp>
#include <cubos/core/reflection/external/string.hpp>

using namespace cubos::core::al;

class MiniaudioBuffer : public impl::Buffer
{
public:
std::string path;

MiniaudioBuffer(const std::string& filePath)
{
if (ma_decoder_init_file(filePath.c_str(), NULL, &decoder) != MA_SUCCESS)

Check warning on line 15 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L15

Added line #L15 was not covered by tests
{
CUBOS_CRITICAL("Failed to load audio file: {}", filePath);
abort();

Check warning on line 18 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L17-L18

Added lines #L17 - L18 were not covered by tests
}

path = filePath;

Check warning on line 21 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L21

Added line #L21 was not covered by tests
}

~MiniaudioBuffer()

Check warning on line 24 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L24

Added line #L24 was not covered by tests
{
ma_decoder_uninit(&decoder);

Check warning on line 26 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L26

Added line #L26 was not covered by tests
}

private:
ma_decoder decoder;
};

class MiniaudioSource : public impl::Source
{
public:
MiniaudioSource()

Check warning on line 36 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L36

Added line #L36 was not covered by tests
{
if (ma_engine_init(NULL, &engine) != MA_SUCCESS)

Check warning on line 38 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L38

Added line #L38 was not covered by tests
{
CUBOS_CRITICAL("Failed to initialize miniaudio engine.");
abort();

Check warning on line 41 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L40-L41

Added lines #L40 - L41 were not covered by tests
}
}

~MiniaudioSource()

Check warning on line 45 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L45

Added line #L45 was not covered by tests
{
ma_sound_uninit(&sound);
ma_engine_uninit(&engine);

Check warning on line 48 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L47-L48

Added lines #L47 - L48 were not covered by tests
}

void setBuffer(cubos::core::al::Buffer buffer)

Check warning on line 51 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L51

Added line #L51 was not covered by tests
{
auto miniaudioBuffer = std::dynamic_pointer_cast<MiniaudioBuffer>(buffer);
if (ma_sound_init_from_file(&engine, miniaudioBuffer->path.c_str(), MA_SOUND_FLAG_STREAM, NULL, NULL, &sound) !=

Check warning on line 54 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L53-L54

Added lines #L53 - L54 were not covered by tests
MA_SUCCESS)
{
CUBOS_CRITICAL("Failed while initating sound from buffer file.");
abort();

Check warning on line 58 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L57-L58

Added lines #L57 - L58 were not covered by tests
}
}

void setPosition(const glm::vec3& position)

Check warning on line 62 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L62

Added line #L62 was not covered by tests
{
ma_sound_set_position(&sound, position.x, position.y, position.z);

Check warning on line 64 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L64

Added line #L64 was not covered by tests
}

void setVelocity(const glm::vec3& velocity)

Check warning on line 67 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L67

Added line #L67 was not covered by tests
{
ma_sound_set_velocity(&sound, velocity.x, velocity.y, velocity.z);

Check warning on line 69 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L69

Added line #L69 was not covered by tests
}

void setGain(float gain)

Check warning on line 72 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L72

Added line #L72 was not covered by tests
{
ma_sound_set_volume(&sound, gain);

Check warning on line 74 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L74

Added line #L74 was not covered by tests
}

void setPitch(float pitch)

Check warning on line 77 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L77

Added line #L77 was not covered by tests
{
ma_sound_set_pitch(&sound, pitch);

Check warning on line 79 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L79

Added line #L79 was not covered by tests
}

void setLooping(bool looping)

Check warning on line 82 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L82

Added line #L82 was not covered by tests
{
ma_sound_set_looping(&sound, looping);

Check warning on line 84 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L84

Added line #L84 was not covered by tests
}

void setRelative(bool relative)

Check warning on line 87 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L87

Added line #L87 was not covered by tests
{
relative ? ma_sound_set_positioning(&sound, ma_positioning_relative)
: ma_sound_set_positioning(&sound, ma_positioning_absolute);

Check warning on line 90 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L89-L90

Added lines #L89 - L90 were not covered by tests
}

void setMaxDistance(float maxDistance)

Check warning on line 93 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L93

Added line #L93 was not covered by tests
{
ma_sound_set_max_distance(&sound, maxDistance);

Check warning on line 95 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L95

Added line #L95 was not covered by tests
}

void setMinDistance(float minDistance)

Check warning on line 98 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L98

Added line #L98 was not covered by tests
{
ma_sound_set_min_distance(&sound, minDistance);

Check warning on line 100 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L100

Added line #L100 was not covered by tests
}

void setCone(float innerAngle, float outerAngle, float outerGain = 1.0f)

Check warning on line 103 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L103

Added line #L103 was not covered by tests
{
ma_sound_set_cone(&sound, innerAngle, outerAngle, outerGain);

Check warning on line 105 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L105

Added line #L105 was not covered by tests
}

void setConeDirection(const glm::vec3& direction)

Check warning on line 108 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L108

Added line #L108 was not covered by tests
{
ma_sound_set_direction(&sound, direction.x, direction.y, direction.z);

Check warning on line 110 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L110

Added line #L110 was not covered by tests
}

void play()

Check warning on line 113 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L113

Added line #L113 was not covered by tests
{
if (ma_sound_start(&sound) != MA_SUCCESS)

Check warning on line 115 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L115

Added line #L115 was not covered by tests
{
CUBOS_CRITICAL("Failed to start sound.");
abort();

Check warning on line 118 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L117-L118

Added lines #L117 - L118 were not covered by tests
}
}

private:
ma_sound sound;
ma_engine engine;
};

MiniaudioDevice::MiniaudioDevice()

Check warning on line 127 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L127

Added line #L127 was not covered by tests
{
// Initialize miniaudio context.
if (ma_context_init(NULL, 0, NULL, &context) != MA_SUCCESS)

Check warning on line 130 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L130

Added line #L130 was not covered by tests
{
CUBOS_CRITICAL("Failed to initialize miniaudio context.");
abort();

Check warning on line 133 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L132-L133

Added lines #L132 - L133 were not covered by tests
}

// Initialize miniaudio engine
if (ma_engine_init(NULL, &engine) != MA_SUCCESS)

Check warning on line 137 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L137

Added line #L137 was not covered by tests
{
CUBOS_CRITICAL("Failed to initialize miniaudio engine.");
abort();

Check warning on line 140 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L139-L140

Added lines #L139 - L140 were not covered by tests
}

// Configure the device.
ma_device_config deviceConfig = ma_device_config_init(ma_device_type_playback);
deviceConfig.playback.format = ma_format_f32; // Set to ma_format_unknown to use the device's native format.
deviceConfig.playback.channels = 2; // Set to 0 to use the device's native channel count.
deviceConfig.sampleRate = 48000; // Set to 0 to use the device's native sample rate.

Check warning on line 147 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L144-L147

Added lines #L144 - L147 were not covered by tests

// Initialize the audio device.
if (ma_device_init(&context, &deviceConfig, &device) != MA_SUCCESS)

Check warning on line 150 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L150

Added line #L150 was not covered by tests
{
CUBOS_CRITICAL("Failed to initialize audio device.");
ma_context_uninit(&context);
abort();

Check warning on line 154 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L152-L154

Added lines #L152 - L154 were not covered by tests
}

ma_device_start(&device);

Check warning on line 157 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L157

Added line #L157 was not covered by tests
}

MiniaudioDevice::~MiniaudioDevice()

Check warning on line 160 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L160

Added line #L160 was not covered by tests
{

ma_device_uninit(&device);
ma_context_uninit(&context);

Check warning on line 164 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L163-L164

Added lines #L163 - L164 were not covered by tests
}

void MiniaudioDevice::enumerateDevices(std::vector<std::string>& devices)

Check warning on line 167 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L167

Added line #L167 was not covered by tests
{
ma_context context;
if (ma_context_init(NULL, 0, NULL, &context) != MA_SUCCESS)

Check warning on line 170 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L170

Added line #L170 was not covered by tests
{
CUBOS_CRITICAL("Failed to initialize audio context.");
abort();

Check warning on line 173 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L172-L173

Added lines #L172 - L173 were not covered by tests
}

ma_device_info* pPlaybackDeviceInfos;
ma_uint32 playbackDeviceCount;
if (ma_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, NULL, NULL) != MA_SUCCESS)

Check warning on line 178 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L178

Added line #L178 was not covered by tests
{
CUBOS_CRITICAL("Failed to enumerate devices.");
ma_context_uninit(&context); // Uninitialize context before aborting
abort();

Check warning on line 182 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L180-L182

Added lines #L180 - L182 were not covered by tests
}

for (ma_uint32 i = 0; i < playbackDeviceCount; i++)

Check warning on line 185 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L185

Added line #L185 was not covered by tests
{
devices.push_back(pPlaybackDeviceInfos[i].name);

Check warning on line 187 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L187

Added line #L187 was not covered by tests
}

ma_context_uninit(&context);

Check warning on line 190 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L190

Added line #L190 was not covered by tests
}

std::string MiniaudioDevice::getDefaultDevice()

Check warning on line 193 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L193

Added line #L193 was not covered by tests
{
ma_context context;
if (ma_context_init(NULL, 0, NULL, &context) != MA_SUCCESS)

Check warning on line 196 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L196

Added line #L196 was not covered by tests
{
CUBOS_CRITICAL("Failed to initialize audio context.");
abort();

Check warning on line 199 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L198-L199

Added lines #L198 - L199 were not covered by tests
}

std::string defaultDeviceName;
ma_context_enumerate_devices(

Check warning on line 203 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L202-L203

Added lines #L202 - L203 were not covered by tests
&context,
[](ma_context*, ma_device_type deviceType, const ma_device_info* pDeviceInfo, void* pUserData) -> ma_bool32 {
std::string* pDefaultDeviceName = static_cast<std::string*>(pUserData);
if (deviceType == ma_device_type_playback && pDeviceInfo->isDefault)

Check warning on line 207 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L205-L207

Added lines #L205 - L207 were not covered by tests
{
*pDefaultDeviceName = pDeviceInfo->name; // Set the default device name
return MA_FALSE;

Check warning on line 210 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L209-L210

Added lines #L209 - L210 were not covered by tests
}
return MA_TRUE;

Check warning on line 212 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L212

Added line #L212 was not covered by tests
},
&defaultDeviceName); // Pass defaultDeviceName as pUserData

ma_context_uninit(&context);
return defaultDeviceName;

Check warning on line 217 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L216-L217

Added lines #L216 - L217 were not covered by tests
}

Buffer MiniaudioDevice::createBuffer(const std::string& filePath)

Check warning on line 220 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L220

Added line #L220 was not covered by tests
{
return std::make_shared<MiniaudioBuffer>(filePath);

Check warning on line 222 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L222

Added line #L222 was not covered by tests
}

Source MiniaudioDevice::createSource()

Check warning on line 225 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L225

Added line #L225 was not covered by tests
{
return std::make_shared<MiniaudioSource>();

Check warning on line 227 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L227

Added line #L227 was not covered by tests
}

void MiniaudioDevice::setListenerPosition(const glm::vec3& position, ma_uint32 listenerIndex)

Check warning on line 230 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L230

Added line #L230 was not covered by tests
{
ma_engine_listener_set_position(&engine, listenerIndex, position.x, position.y, position.z);

Check warning on line 232 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L232

Added line #L232 was not covered by tests
}

void MiniaudioDevice::setListenerOrientation(const glm::vec3& forward, const glm::vec3& up, ma_uint32 listenerIndex)

Check warning on line 235 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L235

Added line #L235 was not covered by tests
{
ma_engine_listener_set_direction(&engine, listenerIndex, forward.x, forward.y, forward.z);
ma_engine_listener_set_world_up(&engine, listenerIndex, up.x, up.y, up.z);

Check warning on line 238 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L237-L238

Added lines #L237 - L238 were not covered by tests
}

void MiniaudioDevice::setListenerVelocity(const glm::vec3& velocity, ma_uint32 listenerIndex)

Check warning on line 241 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L241

Added line #L241 was not covered by tests
{
ma_engine_listener_set_velocity(&engine, listenerIndex, velocity.x, velocity.y, velocity.z);

Check warning on line 243 in core/src/al/miniaudio_device.cpp

View check run for this annotation

Codecov / codecov/patch

core/src/al/miniaudio_device.cpp#L243

Added line #L243 was not covered by tests
}
Loading

0 comments on commit 362bfac

Please sign in to comment.