diff --git a/commonLibs/attachmentSupport/stimulusBuffer.cpp b/commonLibs/attachmentSupport/stimulusBuffer.cpp index 2ebdfba..7388cd3 100644 --- a/commonLibs/attachmentSupport/stimulusBuffer.cpp +++ b/commonLibs/attachmentSupport/stimulusBuffer.cpp @@ -86,16 +86,21 @@ void StimulusBuffer::onTimeout(const boost::system::error_code& error) */ int nextWakeupDelayMs; if (frameAssemblyRateLimiter.tryAcquire()) - { nextWakeupDelayMs = CONFIG_STIMBUFF_FRAME_PERIOD_MS; } - else - { + { + nextWakeupDelayMs = CONFIG_STIMBUFF_FRAME_PERIOD_MS; + + /** EXPLANATION: + * Call the derived class's frame production handler + * Note: The derived class's frame production handler (aka + * its implementation of stimFrameProductionTimesliceInd()) must + * release the lock when frame production completes + */ + stimFrameProductionTimesliceInd(); + } + else { std::cout << __func__ << ": Deferring frame production due to rate limit." << std::endl; nextWakeupDelayMs = CONFIG_STIMBUFF_FRAME_RETRY_DELAY_MS; - } - - // Call the derived class's frame production handler - stimFrameProductionTimesliceInd(); - // Note: The lock should be released when frame production completes + } // Schedule next timeout with the pre-determined duration scheduleNextTimeout(nextWakeupDelayMs);