/* ******************************************************************************* * INCLUDE ******************************************************************************* */ #include "AudioOutput.h" #include "Logger.h" namespace Video { namespace Core { /* ******************************************************************************* * CLASS DEFINE ******************************************************************************* */ void AudioOutput::start() { _task.run( [this](std::atomic& isCancelled) -> void { while (!isCancelled) { try { Frame::Ptr pFrame = readFrame(1000); writeFrame(pFrame); } catch (Poco::Exception& e) { logger().error("%s: %s", name(), e.displayText()); Poco::Thread::sleep(1000); } catch (std::exception& e) { logger().error("%s: %s", name(), std::string(e.what())); Poco::Thread::sleep(1000); } } }); } void AudioOutput::stop() { _task.cancel(); } void AudioOutput::onLink(Core::Component::Ptr pPrevious) { if (!frameQueues().empty() && frameQueues().firstComponent() != pPrevious) throw Poco::LogicException(name() + ": Support only one previous component, conflict with: " + pPrevious->name() + ", Current: " + frameQueues().firstComponent()->name()); frameQueues().add(pPrevious, name(), MediaType::AUDIO, 6); } } }