|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef POCKET_TTS_ACCELERATOR_CORE_HPP |
|
|
#define POCKET_TTS_ACCELERATOR_CORE_HPP |
|
|
|
|
|
#include "audio_processor.hpp" |
|
|
#include "ipc_handler.hpp" |
|
|
#include "memory_pool.hpp" |
|
|
#include "thread_pool.hpp" |
|
|
#include <atomic> |
|
|
#include <memory> |
|
|
#include <string> |
|
|
|
|
|
namespace pocket_tts_accelerator { |
|
|
|
|
|
struct AcceleratorConfiguration { |
|
|
std::size_t number_of_worker_threads; |
|
|
std::size_t memory_pool_size_bytes; |
|
|
std::string ipc_socket_path; |
|
|
bool enable_verbose_logging; |
|
|
}; |
|
|
|
|
|
class AcceleratorCore { |
|
|
public: |
|
|
explicit AcceleratorCore(const AcceleratorConfiguration& configuration); |
|
|
~AcceleratorCore(); |
|
|
|
|
|
AcceleratorCore(const AcceleratorCore&) = delete; |
|
|
AcceleratorCore& operator=(const AcceleratorCore&) = delete; |
|
|
|
|
|
bool initialize(); |
|
|
void run(); |
|
|
void shutdown(); |
|
|
|
|
|
bool is_running() const; |
|
|
std::string get_status_string() const; |
|
|
|
|
|
static AcceleratorConfiguration get_default_configuration(); |
|
|
|
|
|
private: |
|
|
void register_all_command_handlers(); |
|
|
void setup_signal_handlers(); |
|
|
|
|
|
std::vector<std::uint8_t> handle_ping_command(const std::vector<std::uint8_t>& payload); |
|
|
std::vector<std::uint8_t> handle_process_audio_command(const std::vector<std::uint8_t>& payload); |
|
|
std::vector<std::uint8_t> handle_convert_to_mono_command(const std::vector<std::uint8_t>& payload); |
|
|
std::vector<std::uint8_t> handle_convert_to_pcm_command(const std::vector<std::uint8_t>& payload); |
|
|
std::vector<std::uint8_t> handle_resample_audio_command(const std::vector<std::uint8_t>& payload); |
|
|
std::vector<std::uint8_t> handle_get_memory_stats_command(const std::vector<std::uint8_t>& payload); |
|
|
std::vector<std::uint8_t> handle_clear_memory_pool_command(const std::vector<std::uint8_t>& payload); |
|
|
std::vector<std::uint8_t> handle_shutdown_command(const std::vector<std::uint8_t>& payload); |
|
|
|
|
|
void log_message(const std::string& message) const; |
|
|
|
|
|
AcceleratorConfiguration config; |
|
|
std::unique_ptr<MemoryPool> memory_pool; |
|
|
std::unique_ptr<ThreadPool> thread_pool; |
|
|
std::unique_ptr<AudioProcessor> audio_processor; |
|
|
std::unique_ptr<IpcHandler> ipc_handler; |
|
|
std::atomic<bool> is_initialized; |
|
|
std::atomic<bool> should_shutdown; |
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
#endif |