#include #include #include #include #include "BellTask.h" #include "CentralAudioBuffer.h" #include "PortAudioSink.h" #include "StreamInfo.h" #define DEBUG_LEVEL 4 #include #include std::shared_ptr audioBuffer; std::atomic isPaused = false; class AudioPlayer : bell::Task { public: std::unique_ptr audioSink; std::unique_ptr dsp; AudioPlayer() : bell::Task("player", 1024, 0, 0) { this->audioSink = std::make_unique(); this->audioSink->setParams(44100, 2, 16); this->dsp = std::make_unique(audioBuffer); startTask(); } void runTask() override { while (true) { if (audioBuffer->hasAtLeast(64) || isPaused) { auto chunk = audioBuffer->readChunk(); if (chunk != nullptr && chunk->pcmSize > 0) { this->dsp->process(chunk->pcmData, chunk->pcmSize, 2, 44100, bell::BitWidth::BW_16); this->audioSink->feedPCMFrames(chunk->pcmData, chunk->pcmSize); } } } } }; int main() { bell::setDefaultLogger(); BELL_LOG(info, "cock", "Published?"); return 0; }