A quick lint run
This commit is contained in:
parent
fa5c203cf8
commit
dd16d8be84
@ -38,6 +38,9 @@ namespace audio{
|
||||
int m_out_channels;
|
||||
|
||||
public:
|
||||
//buffersize of 0 means to automatically pick a good size
|
||||
//TODO: if samplerate is 0, use device's default sample rate
|
||||
//TODO: allow choosing device by index
|
||||
template<typename Callback, typename... Args>
|
||||
stream(int in_c, int out_c, double samplerate, size_t buffersize, Callback&& cb, Args&&... cbargs):
|
||||
m_cb(new detail::callback_impl<Callback,Args...>(std::forward<Callback>(cb), std::forward<Args>(cbargs)...)),
|
||||
@ -68,7 +71,7 @@ namespace audio{
|
||||
long unsigned int fmt, double samplerate,
|
||||
size_t bufsize, detail::callback_iface* cb);
|
||||
static int callback(const void* input, void* output, unsigned long framecount,
|
||||
const PaStreamCallbackTimeInfo* /*timeInfo*/, PaStreamCallbackFlags /*statusFlags*/,
|
||||
const PaStreamCallbackTimeInfo* /*timeInfo*/, PaStreamCallbackFlags statusflags,
|
||||
void* userdata);
|
||||
};
|
||||
|
||||
|
||||
@ -105,7 +105,7 @@ namespace util{
|
||||
void mpmc_ring_buffer<T>::resize(size_type newcap){
|
||||
mpmc_ring_buffer tmp(newcap);
|
||||
size_type max = (m_head - m_tail) < newcap ? (m_head - m_tail) : newcap;
|
||||
for(size_type i = m_tail, j = 0;j < max;++i,++j){
|
||||
for(size_type i = m_tail, j = 0;j < max;++i, ++j){
|
||||
tmp.m_slots[j].get() = std::move(m_slots[i % m_slots.capacity()].get());
|
||||
tmp.m_slots[j].turn() |= 1; //in-use bit
|
||||
}
|
||||
@ -141,7 +141,7 @@ namespace util{
|
||||
size_type head = m_head.load(std::memory_order_acquire);
|
||||
while(1){
|
||||
slot& s = m_slots[head % m_slots.capacity()];
|
||||
if(rotation_cnt(head) << 1 == s.turn().load(std::memory_order_acquire)){
|
||||
if((rotation_cnt(head) << 1) == s.turn().load(std::memory_order_acquire)){
|
||||
if(m_head.compare_exchange_strong(head, head+1, std::memory_order_seq_cst)){
|
||||
s.construct(std::forward<Args>(args)...);
|
||||
s.turn().store((rotation_cnt(head) << 1) + 1, std::memory_order_release);
|
||||
|
||||
@ -34,7 +34,7 @@ namespace audio::impl{
|
||||
m_operating(false),
|
||||
m_channels(channel_count),
|
||||
m_lk(m_copy_lock, std::defer_lock),
|
||||
m_output_sink(0, output_channels, 44100, 512, callback, *this)
|
||||
m_output_sink(0, output_channels, 44100, 0, callback, *this)
|
||||
{
|
||||
m_output_sink.start();
|
||||
}
|
||||
@ -160,8 +160,8 @@ namespace audio::impl{
|
||||
//copy data into the output buffer
|
||||
size_t real_floatcount = real_framecount * out_channels;
|
||||
size_t offset_float = offset * data.channels;
|
||||
for(size_t j = 0, k = 0;j < real_floatcount;j += out_channels, k += data.channels){
|
||||
for(size_t l = 0;l < out_channels;++l){
|
||||
for(size_t j = 0, k = 0; j < real_floatcount; j += out_channels, k += data.channels){
|
||||
for(size_t l = 0; l < out_channels; ++l){
|
||||
foutput[j+l] += ((data.data + offset_float)[k + (l % data.channels)] * data.volume);
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include "audio/mixdata.hpp"
|
||||
|
||||
#include <utility> //exchange, swap, move
|
||||
#include <cstring> //mpmcpy, memset
|
||||
#include <cstring> //memcpy, memset
|
||||
|
||||
namespace audio{
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ namespace audio{
|
||||
//first free channel
|
||||
channel mixer::get_channel(){
|
||||
//TODO
|
||||
for(size_t i = 0;i < m_mix->channels().size();++i){
|
||||
for(size_t i = 0; i < m_mix->channels().size(); ++i){
|
||||
if(m_mix->channels()[i].is_playing())
|
||||
return channel(m_mix->channels()[i]);
|
||||
}
|
||||
|
||||
@ -78,10 +78,10 @@ namespace audio{
|
||||
PaStreamParameters in = {Pa_GetDefaultInputDevice(), in_c, fmt, PORTAUDIO_FIXED_LATENCY, nullptr};
|
||||
PaStreamParameters* outp = out_c ? &out : nullptr;
|
||||
PaStreamParameters* inp = in_c ? &in : nullptr;
|
||||
return Pa_OpenStream(stream, inp, outp, samplerate, paFramesPerBufferUnspecified, paNoFlag, callback, cb);
|
||||
return Pa_OpenStream(stream, inp, outp, samplerate, bufsize, paNoFlag, callback, cb);
|
||||
}
|
||||
int stream::callback(const void* input, void* output, unsigned long framecount,
|
||||
const PaStreamCallbackTimeInfo* timeinfo, PaStreamCallbackFlags statusflags,
|
||||
const PaStreamCallbackTimeInfo* /*timeinfo*/, PaStreamCallbackFlags statusflags,
|
||||
void* userdata)
|
||||
{
|
||||
detail::callback_iface* cb = static_cast<detail::callback_iface*>(userdata);
|
||||
|
||||
12
src/main.cpp
12
src/main.cpp
@ -105,7 +105,7 @@ void handle_input_events(GLFWwindow*, int key, int, int, int){
|
||||
}
|
||||
|
||||
audio::mixchunk read_audio_file(const char* filename){
|
||||
debug_print("!!!!filename!!!! %s\n", filename);
|
||||
debug_print("Reading in %s\n", filename);
|
||||
audio::sndrd f(filename, audio::sndrd::mode::r);
|
||||
if(!f.valid()){
|
||||
return {};
|
||||
@ -113,16 +113,18 @@ audio::mixchunk read_audio_file(const char* filename){
|
||||
return f.read_all();
|
||||
}
|
||||
std::string select_audio_file(){
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
size_t filecnt = 0;
|
||||
for(std::filesystem::directory_iterator i("assets/moans");i != std::filesystem::directory_iterator();++i){
|
||||
std::filesystem::directory_entry e = *i;
|
||||
for(fs::directory_iterator i("assets/moans"); i != fs::directory_iterator(); ++i){
|
||||
fs::directory_entry e = *i;
|
||||
if(!e.is_directory())
|
||||
++filecnt;
|
||||
}
|
||||
|
||||
size_t selection = rand() % filecnt;
|
||||
for(std::filesystem::directory_iterator i("assets/moans");i != std::filesystem::directory_iterator();++i){
|
||||
std::filesystem::directory_entry e = *i;
|
||||
for(fs::directory_iterator i("assets/moans");i != fs::directory_iterator();++i){
|
||||
fs::directory_entry e = *i;
|
||||
if(selection == 0){
|
||||
return e.path().native();
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ void render_manager::update(){
|
||||
}
|
||||
|
||||
void render_manager::request_exit(){
|
||||
if (m_window_close_callback)
|
||||
if(m_window_close_callback)
|
||||
m_window_close_callback();
|
||||
glfwSetWindowShouldClose(m_main_window, GLFW_TRUE);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user