Some small project cleanups

This commit is contained in:
WolverinDEV 2021-03-29 14:18:46 +02:00
parent 22c8c32bd0
commit a604cdf77d
5 changed files with 6 additions and 69 deletions

View File

@ -1,9 +1,10 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.16)
project(TeaClient-Natives VERSION 1.0.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
# set(CMAKE_VERBOSE_MAKEFILE ON)
if (CMAKE_INCLUDE_FILE AND NOT CMAKE_INCLUDE_FILE STREQUAL "")
@ -102,24 +103,11 @@ endfunction()
#Setup the compiler (Cant be done within a function!)
if (MSVC)
set(CompilerFlags
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
string(REGEX REPLACE "/O\\S+($| )" "/02" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
#add_compile_options("/MTd")
add_compile_options("/EHsc") #We require exception handling
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
add_compile_options(/EHsc) #We require exception handling
add_compile_options(/wd4275) # needs to have dll-interface to be used by clients of class
add_compile_options(/wd4251) # needs to have dll-interface to be used by clients of class
add_compile_options(/std:c++17)
else()
#This is a bad thing here!
function(resolve_library VARIABLE FALLBACK PATHS)

View File

@ -10,41 +10,13 @@
#include "./AudioOutput.h"
#include "./AudioLevelMeter.h"
#include "./processing/AudioProcessor.h"
#include "./AudioEventLoop.h"
#include "../logger.h"
#include "AudioEventLoop.h"
using namespace std;
using namespace tc;
using namespace tc::audio;
AudioConsumer::AudioConsumer(size_t channel_count, size_t sample_rate, size_t frame_size) :
channel_count{channel_count},
sample_rate{sample_rate},
frame_size{frame_size} {
if(this->frame_size > 0) {
this->reframer = std::make_unique<AudioReframer>(channel_count, frame_size);
this->reframer->on_frame = [&](const void* buffer) { this->handle_framed_data(buffer, this->frame_size); };
}
}
void AudioConsumer::handle_framed_data(const void *buffer, size_t samples) {
std::unique_lock read_callback_lock(this->on_read_lock);
auto function = this->on_read; /* copy */
read_callback_lock.unlock();
if(!function)
return;
function(buffer, samples);
}
void AudioConsumer::process_data(const void *buffer, size_t samples) {
if(this->reframer) {
this->reframer->process(buffer, samples);
} else {
this->handle_framed_data(buffer, samples);
}
}
extern tc::audio::AudioOutput* global_audio_output;
AudioInput::AudioInput(size_t channels, size_t sample_rate) :
channel_count_{channels},

View File

@ -18,25 +18,6 @@ namespace tc::audio {
class AudioProcessor;
class AudioInputAudioLevelMeter;
class AudioConsumer {
friend class AudioInput;
public:
size_t const channel_count;
size_t const sample_rate;
size_t const frame_size;
std::mutex on_read_lock{}; /* locked to access the function */
std::function<void(const void* /* buffer */, size_t /* samples */)> on_read;
private:
AudioConsumer(size_t channel_count, size_t sample_rate, size_t frame_size);
std::unique_ptr<AudioReframer> reframer;
void process_data(const void* /* buffer */, size_t /* samples */);
void handle_framed_data(const void* /* buffer */, size_t /* samples */);
};
struct AudioInputBufferInfo {
size_t sample_count{0};
std::optional<bool> vad_detected{};

View File

@ -101,9 +101,6 @@ namespace tc::audio::codec {
case AudioCodec::OpusMusic:
return "opus music";
case AudioCodec::Flac:
return "flac";
case AudioCodec::Unknown:
return "unknown";

View File

@ -9,7 +9,6 @@
namespace tc::audio {
class AudioInput;
class AudioConsumer;
namespace filter {
class Filter;