@@ -473,9 +473,12 @@ FifoMonitor::FifoMonitor(RecordNode* node, uint16 streamId_, String streamName_)
473473 streamId(streamId_),
474474 streamName(streamName_),
475475 fillPercentage(0.0 ),
476- stateChangeSinceLastUpdate(false )
476+ stateChangeSinceLastUpdate(false ),
477+ dataRate(0.0 ),
478+ lastUpdateTime(0.0 ),
479+ lastFreeSpace(0.0 ),
480+ recordingTimeLeftInSeconds(0 )
477481{
478-
479482 startTimer (500 );
480483 setTooltip (streamName);
481484}
@@ -552,9 +555,41 @@ void FifoMonitor::timerCallback()
552555 if (ratio > 0 )
553556 setFillPercentage (1 .0f - ratio);
554557
555- // std::cout << "Setting fill percentage for " << streamId << " to " << 1 - ratio << std::endl;
558+ if (!recordingTimeLeftInSeconds)
559+ setTooltip (String (bytesFree / pow (2 , 30 )) + " GB available" );
560+
561+ float currentTime = Time::getMillisecondCounterHiRes ();
562+
563+ // Update data rate and recording time left every 30 seconds
564+ if (recordNode->getRecordingStatus () && currentTime - lastUpdateTime > 30000 ) {
565+
566+ if (lastUpdateTime == 0.0 ) {
567+ lastUpdateTime = Time::getMillisecondCounterHiRes ();
568+ lastFreeSpace = bytesFree;
569+ }
570+ else
571+ {
572+ dataRate = (lastFreeSpace - bytesFree) / (currentTime - lastUpdateTime); // bytes/ms
573+ lastUpdateTime = currentTime;
574+ lastFreeSpace = bytesFree;
556575
557- setTooltip (String (bytesFree / pow (2 , 30 )) + " GB available" );
576+ recordingTimeLeftInSeconds = (int ) (bytesFree / dataRate / 1000 .0f );
577+
578+ LOGD (" Data rate: " , dataRate, " bytes/ms" );
579+
580+ // Stop recording and show warning when less than 5 minutes of disk space left
581+ if (dataRate > 0 && recordingTimeLeftInSeconds < 60 *5 ) {
582+ CoreServices::setRecordingStatus (false );
583+ String msg = " Recording stopped. Less than 60 seconds of disk space remaining." ;
584+ AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, " WARNING" , msg);
585+ }
586+
587+ String msg = String (bytesFree / pow (2 , 30 )) + " GB available\n " ;
588+ msg += String (recordingTimeLeftInSeconds / 60 ) + " minutes remaining\n " ;
589+ msg += " Data rate: " + String (dataRate * 1000 / pow (2 , 20 ), 2 ) + " MB/s" ;
590+ setTooltip (msg);
591+ }
592+ }
558593 }
559594 else /* Subprocessor monitor */
560595 {
0 commit comments