1740{
1741 enum class State { eUndefined, eOnce, eLoopRunning, eDoNothing, eMonitoring } lastState = State::eUndefined;
1742
1746 {
1747 using Clock = std::chrono::steady_clock;
1748 auto loopPassStart = Clock::now();
1751
1752
1754 .store(true, std::memory_order_relaxed);
1756 .load(std::memory_order_acquire) )
1757 {
1760 .store(false, std::memory_order_release);
1761
1762 lastState = State::eOnce;
1763 }
1765 .load(std::memory_order_relaxed))
1766 {
1767 if (lastState != State::eLoopRunning)
1768 {
1769
1771 std::memory_order::memory_order_release);
1772 }
1773 lastState = State::eLoopRunning;
1774
1775
1776
1777
1778
1779
1780
1782 }
1783 else
1784 {
1785 if ( (lastState == State::eLoopRunning)
1786 || (lastState == State::eMonitoring ) )
1787 {
1788
1789
1791 std::memory_order::memory_order_release);
1792 }
1793 lastState = State::eDoNothing;
1794
1796 {
1797 lastState = State::eMonitoring;
1798 }
1799 }
1800
1802 .store(false, std::memory_order_relaxed);
1803
1804 std::this_thread::sleep_until( loopPassStart + interval );
1805 }
1806
1807 return 0;
1808}
std::chrono::system_clock Clock
bool IsMonitoring() const
Returns true if we're monitoring input (but not recording or playing actual audio)
AudioIO uses the PortAudio library to play and record sound.
void TrackBufferExchange()
PlaybackSchedule mPlaybackSchedule
std::atomic< Acknowledge > mAudioThreadAcknowledge
std::atomic< bool > mAudioThreadTrackBufferExchangeLoopRunning
std::atomic< bool > mAudioThreadTrackBufferExchangeLoopActive
std::atomic< bool > mAudioThreadShouldCallTrackBufferExchangeOnce
virtual std::chrono::milliseconds SleepInterval(PlaybackSchedule &schedule)
How long to wait between calls to AudioIO::TrackBufferExchange.
PlaybackPolicy & GetPolicy()