-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace OpenAL by PortAudio #1040
Replace OpenAL by PortAudio #1040
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang-Tidy
found issue(s) with the introduced code (1/1)
@@ -0,0 +1,15 @@ | |||
#include <stdio.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inclusion of deprecated C++ header stdio.h
; consider using cstdio
instead
#include <stdio.h> | |
#include <cstdio> |
auto err = Pa_Initialize(); | ||
if (err != paNoError) | ||
{ | ||
CUBOS_FAIL("PortAudio failed to initialize: {}", Pa_GetErrorText(err)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for global function Pa_GetErrorText
CUBOS_FAIL("PortAudio failed to initialize: {}", Pa_GetErrorText(err)); | |
CUBOS_FAIL("PortAudio failed to initialize: {}", paGetErrorText(err)); |
PortAudioDevice::PortAudioDevice(const std::string& specifier) | ||
{ | ||
#ifdef WITH_PORTAUDIO | ||
auto err = Pa_Initialize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for global function Pa_Initialize
auto err = Pa_Initialize(); | |
auto err = paInitialize(); |
PortAudioDevice::~PortAudioDevice() | ||
{ | ||
#ifdef WITH_PORTAUDIO | ||
Pa_Terminate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for global function Pa_Terminate
Pa_Terminate(); | |
paTerminate(); |
core/src/al/port_audio_device.cpp
Outdated
int PortAudioDevice::getDeviceCount() | ||
{ | ||
#ifdef WITH_PORTAUDIO | ||
return Pa_GetDeviceCount(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for global function Pa_GetDeviceCount
return Pa_GetDeviceCount(); | |
return paGetDeviceCount(); |
core/src/al/port_audio_device.cpp
Outdated
// TODO: should we store PaDeviceInfos instead of strings? | ||
for (int i = 0; i < getDeviceCount(); i++) | ||
{ | ||
devices.push_back(std::string(Pa_GetDeviceInfo(i)->name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for global function Pa_GetDeviceInfo
devices.push_back(std::string(Pa_GetDeviceInfo(i)->name)); | |
devices.push_back(std::string(paGetDeviceInfo(i)->name)); |
core/src/al/port_audio_device.cpp
Outdated
// TODO: should we store PaDeviceInfos instead of strings? | ||
for (int i = 0; i < getDeviceCount(); i++) | ||
{ | ||
devices.push_back(std::string(Pa_GetDeviceInfo(i)->name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use emplace_back instead of push_back
devices.push_back(std::string(Pa_GetDeviceInfo(i)->name)); | |
devices.emplace_back(Pa_GetDeviceInfo(i)->name); |
core/src/al/port_audio_device.cpp
Outdated
#endif // WITH_PORTAUDIO | ||
} | ||
|
||
void PortAudioDevice::setListenerPosition(const glm::vec3&) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all parameters should be named in a function
void PortAudioDevice::setListenerPosition(const glm::vec3&) | |
void PortAudioDevice::setListenerPosition(const glm::vec3& /*position*/) |
core/src/al/port_audio_device.cpp
Outdated
#endif // WITH_PORTAUDIO | ||
} | ||
|
||
void PortAudioDevice::setListenerOrientation(const glm::vec3&, const glm::vec3&) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all parameters should be named in a function
void PortAudioDevice::setListenerOrientation(const glm::vec3&, const glm::vec3&) | |
void PortAudioDevice::setListenerOrientation(const glm::vec3& /*forward*/, const glm::vec3& /*up*/) |
core/src/al/port_audio_device.cpp
Outdated
#endif // WITH_PORTAUDIO | ||
} | ||
|
||
void PortAudioDevice::setListenerVelocity(const glm::vec3&) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all parameters should be named in a function
void PortAudioDevice::setListenerVelocity(const glm::vec3&) | |
void PortAudioDevice::setListenerVelocity(const glm::vec3& /*velocity*/) |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1040 +/- ##
==========================================
- Coverage 37.70% 37.68% -0.03%
==========================================
Files 302 303 +1
Lines 25036 25051 +15
==========================================
Hits 9441 9441
- Misses 15595 15610 +15 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang-Tidy
found issue(s) with the introduced code (1/3)
core/src/al/port_audio_device.hpp
Outdated
PortAudioOutputCallbackFn callback; | ||
|
||
private: | ||
int outputDeviceID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for private member outputDeviceID
int outputDeviceID; | |
int mOutputDeviceId; |
core/src/al/port_audio_device.hpp
Outdated
|
||
private: | ||
int outputDeviceID; | ||
PaStream* stream; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for private member stream
PaStream* stream; | |
PaStream* mStream; |
static int paCallback(const void*, void* outputBuffer, unsigned long framesPerBuffer, | ||
const PaStreamCallbackTimeInfo*, PaStreamCallbackFlags flags, void* userData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all parameters should be named in a function
static int paCallback(const void*, void* outputBuffer, unsigned long framesPerBuffer, | |
const PaStreamCallbackTimeInfo*, PaStreamCallbackFlags flags, void* userData) | |
static int paCallback(const void* /*unused*/, void* outputBuffer, unsigned long framesPerBuffer, | |
const PaStreamCallbackTimeInfo* /*unused*/, PaStreamCallbackFlags flags, void* userData) |
static int paCallback(const void*, void* outputBuffer, unsigned long framesPerBuffer, | ||
const PaStreamCallbackTimeInfo*, PaStreamCallbackFlags flags, void* userData) | ||
{ | ||
PortAudioDevice* portAudioDevice = static_cast<PortAudioDevice*>(userData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use auto when initializing with a cast to avoid duplicating the type name
PortAudioDevice* portAudioDevice = static_cast<PortAudioDevice*>(userData); | |
auto* portAudioDevice = static_cast<PortAudioDevice*>(userData); |
core/src/al/port_audio_device.cpp
Outdated
|
||
PortAudioDevice::~PortAudioDevice() | ||
{ | ||
if (stream) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implicit conversion PaStream *
(aka void *
) -> bool
if (stream) | |
if (stream != nullptr) |
if (stream) | ||
{ | ||
// FIXME: double stop?» | ||
stop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call to virtual method PortAudioDevice::stop
during destruction bypasses virtual dispatch
devices.clear(); | ||
for (int i = 0; i < deviceCount(); i++) | ||
{ | ||
auto deviceInfo = Pa_GetDeviceInfo(i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto deviceInfo
can be declared as const auto *deviceInfo
auto deviceInfo = Pa_GetDeviceInfo(i); | |
const auto *deviceInfo = Pa_GetDeviceInfo(i); |
{ | ||
if (i == deviceIndex) | ||
{ | ||
auto deviceInfo = Pa_GetDeviceInfo(i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto deviceInfo
can be declared as const auto *deviceInfo
auto deviceInfo = Pa_GetDeviceInfo(i); | |
const auto *deviceInfo = Pa_GetDeviceInfo(i); |
{ | ||
if (i == deviceIndex) | ||
{ | ||
auto deviceInfo = Pa_GetDeviceInfo(i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto deviceInfo
can be declared as const auto *deviceInfo
auto deviceInfo = Pa_GetDeviceInfo(i); | |
const auto *deviceInfo = Pa_GetDeviceInfo(i); |
core/src/al/port_audio_device.cpp
Outdated
#ifdef WITH_PORTAUDIO | ||
CUBOS_TODO(); | ||
#else | ||
UNSUPPORTED(); | ||
#endif // WITH_PORTAUDIO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all parameters should be named in a function
#ifdef WITH_PORTAUDIO | |
CUBOS_TODO(); | |
#else | |
UNSUPPORTED(); | |
#endif // WITH_PORTAUDIO | |
#ifdef WITH_PORTAUDIO | |
CUBOS_TODO(); | |
#else | |
UNSUPPORTED(); | |
#endif // WITH_PORTAUDIO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang-Tidy
found issue(s) with the introduced code (2/3)
core/src/al/port_audio_device.hpp
Outdated
PortAudioOutputCallbackFn callback; | ||
|
||
private: | ||
int outputDeviceID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for private member outputDeviceID
int outputDeviceID; | |
int mOutputDeviceId; |
core/src/al/port_audio_device.cpp
Outdated
} | ||
|
||
PortAudioDevice::PortAudioDevice(int deviceIndex) | ||
: outputDeviceID(deviceIndex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for private member outputDeviceID
: outputDeviceID(deviceIndex) | |
: mOutputDeviceId(deviceIndex) |
core/src/al/port_audio_device.cpp
Outdated
|
||
CUBOS_INFO("PortAudio initialized"); | ||
|
||
if (outputDeviceID == -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for private member outputDeviceID
if (outputDeviceID == -1) | |
if (mOutputDeviceId == -1) |
core/src/al/port_audio_device.cpp
Outdated
outputDeviceID = Pa_GetDefaultOutputDevice(); | ||
CUBOS_INFO("PortAudio will use default output device ('{}') :", outputDeviceID); | ||
printDeviceInformation(outputDeviceID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for private member outputDeviceID
outputDeviceID = Pa_GetDefaultOutputDevice(); | |
CUBOS_INFO("PortAudio will use default output device ('{}') :", outputDeviceID); | |
printDeviceInformation(outputDeviceID); | |
mOutputDeviceId = Pa_GetDefaultOutputDevice(); | |
CUBOS_INFO("PortAudio will use default output device ('{}') :", mOutputDeviceId); | |
printDeviceInformation(mOutputDeviceId); |
core/src/al/port_audio_device.cpp
Outdated
CUBOS_INFO("Custom output callback function set"); | ||
|
||
PaStreamParameters outputParameters; | ||
outputParameters.device = outputDeviceID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for private member outputDeviceID
outputParameters.device = outputDeviceID; | |
outputParameters.device = mOutputDeviceId; |
core/src/al/port_audio_device.cpp
Outdated
PaStreamParameters outputParameters; | ||
outputParameters.device = outputDeviceID; | ||
// FIXME: what should be specified by the user? | ||
outputParameters.channelCount = Pa_GetDeviceInfo(outputDeviceID)->maxOutputChannels; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for private member outputDeviceID
outputParameters.channelCount = Pa_GetDeviceInfo(outputDeviceID)->maxOutputChannels; | |
outputParameters.channelCount = Pa_GetDeviceInfo(mOutputDeviceId)->maxOutputChannels; |
core/src/al/port_audio_device.cpp
Outdated
// FIXME: what should be specified by the user? | ||
outputParameters.channelCount = Pa_GetDeviceInfo(outputDeviceID)->maxOutputChannels; | ||
outputParameters.sampleFormat = paFloat32; | ||
outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputDeviceID)->defaultLowOutputLatency; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for private member outputDeviceID
outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputDeviceID)->defaultLowOutputLatency; | |
outputParameters.suggestedLatency = Pa_GetDeviceInfo(mOutputDeviceId)->defaultLowOutputLatency; |
core/src/al/port_audio_device.hpp
Outdated
|
||
private: | ||
int outputDeviceID; | ||
PaStream* stream; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use default member initializer for stream
PaStream* stream; | |
PaStream* stream{nullptr}; |
core/src/al/port_audio_device.cpp
Outdated
|
||
PortAudioDevice::PortAudioDevice(int deviceIndex) | ||
: outputDeviceID(deviceIndex) | ||
, stream(nullptr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use default member initializer for stream
, stream(nullptr) | |
, |
core/src/al/port_audio_device.hpp
Outdated
|
||
private: | ||
int outputDeviceID; | ||
PaStream* stream; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for private member stream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang-Tidy
found issue(s) with the introduced code (3/3)
core/src/al/port_audio_device.hpp
Outdated
PortAudioOutputCallbackFn callback; | ||
|
||
private: | ||
int outputDeviceID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for private member outputDeviceID
int outputDeviceID; | |
int mOutputDeviceId; |
core/src/al/port_audio_device.hpp
Outdated
|
||
private: | ||
int outputDeviceID; | ||
PaStream* stream; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for private member stream
PaStream* stream; | |
PaStream* mStream; |
audio->enumerateDevices(devices, true); | ||
|
||
audio->init([](void* outputBuffer, unsigned long framesPerBuffer, unsigned long, void*) -> int { | ||
float* out = static_cast<float*>(outputBuffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use auto when initializing with a cast to avoid duplicating the type name
float* out = static_cast<float*>(outputBuffer); | |
auto* out = static_cast<float*>(outputBuffer); |
float* out = static_cast<float*>(outputBuffer); | ||
for (unsigned int i = 0; i < framesPerBuffer; i++) | ||
{ | ||
*out++ = 0.5f * static_cast<float>(std::sin(2.0 * 3.141592653589793 * 440.0 * i / 44100.0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
floating point literal has suffix f
, which is not uppercase
*out++ = 0.5f * static_cast<float>(std::sin(2.0 * 3.141592653589793 * 440.0 * i / 44100.0)); | |
*out++ = 0.5F * static_cast<float>(std::sin(2.0 * 3.141592653589793 * 440.0 * i / 44100.0)); |
Closing due to: members already working in another solution |
Description
AudioDevice
AudioDevice
sample (output)Checklist