[hatari-devel] Generalize recording titlebar time showing |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: Hatari Development <hatari-devel@xxxxxxxxxxxxxxxxxxx>
- Subject: [hatari-devel] Generalize recording titlebar time showing
- From: Eero Tamminen <oak@xxxxxxxxxxxxxx>
- Date: Tue, 9 Sep 2025 01:13:33 +0300
- Dkim-filter: OpenDKIM Filter v2.11.0 smtp.dnamail.fi 0DEFB2119C2A
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=helsinkinet.fi; s=2025-03; t=1757369614; bh=W6kIuVNoVQpfpj2tFcpG5xg4tLfSb9pO9JhdJi0hEaE=; h=Date:To:From:Subject:From; b=SdQX0ni+OTYpHLqEKvgMhsO9V9AYQNBOCxyEISfqBYv2DkUoyHicUzBnMBER1pKUT b18qPGzXR/LWpEgw8MI0z7dzIsATIjwm3bG8iip7X1qxYk1Uz6X+2ibNx+2+UXRYIb zlZ/XYuoWnb27nJP3aMsqjU8MWxdI/8x1KTJpEFGR+nT61F+eG2zauif2zFfh0w9s1 KscNJ6NZcThwfTV72VYY9nmhks1STRaq0bGMfCCT0wLqedh7AXaV8WRZ+RAtxiHSHh kIuUpUsdt7ZrmYza/jwkH/t6d6IsoE98Ly1AA2xNDn2nzR8C1NXv1+6Me9qMFAjuUP QdnQiqL9yuAPg==
Hi,
Andreas, attached patch will show timing info in titlebar also for sound
recording, as you asked. Does it work as expected?
Nicolas, does the patch look OK to push?
(Please CC answers to me as I'm not receiving list mails.)
- Eero
From df9aa171b4bf536a30ef13c14edba63bb732af9c Mon Sep 17 00:00:00 2001
From: Eero Tamminen <oak@xxxxxxxxxxxxxx>
Date: Tue, 9 Sep 2025 01:01:01 +0300
Subject: [PATCH] Show time in titlebar also for sound recording, not just AVI
By changing record time to be calculated more generically,
from VBL instead of recording format specific details.
---
src/avi_record.c | 12 ------------
src/main.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/src/avi_record.c b/src/avi_record.c
index 722471d6..2d6990e2 100644
--- a/src/avi_record.c
+++ b/src/avi_record.c
@@ -1021,18 +1021,6 @@ bool Avi_RecordVideoStream ( void )
if ( Avi_FrameIndex_Add ( &AviParams , &AviFileHeader , 0 , Pos_Start , (uint32_t)( Pos_End - Pos_Start ) ) == false )
return false;
- if (AviParams.TotalVideoFrames % ( AviParams.Fps / AviParams.Fps_scale ) == 0)
- {
- char str[20];
- int secs , hours , mins;
-
- secs = AviParams.TotalVideoFrames / ( AviParams.Fps / AviParams.Fps_scale );
- hours = secs / 3600;
- mins = ( secs % 3600 ) / 60;
- secs = secs % 60;
- snprintf ( str , 20 , "%d:%02d:%02d" , hours , mins , secs );
- Main_SetTitle(str);
- }
return true;
}
diff --git a/src/main.c b/src/main.c
index 30067573..37a2654f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -298,6 +298,50 @@ void Main_SetQuitValue(int exitval)
nQuitValue = exitval;
}
+/*-----------------------------------------------------------------------*/
+/**
+ * When recording, show time in titlebar.
+ */
+static void Main_UpdateTitlebar(int currentVbl)
+{
+ static int startVbl;
+ int vbls, secs, mins, hours;
+ char info[16];
+
+ /* recording started since previous VBL? */
+ if (!startVbl)
+ {
+ if (Sound_AreWeRecording() || Avi_AreWeRecording())
+ {
+ SDL_SetWindowTitle(sdlWindow, "00:00:00");
+ startVbl = currentVbl;
+ }
+ return;
+ }
+
+ /* recording stopped since previous VBL? */
+ if (!(Sound_AreWeRecording() || Avi_AreWeRecording()))
+ {
+ SDL_SetWindowTitle(sdlWindow, PROG_NAME);
+ startVbl = 0;
+ return;
+ }
+
+ vbls = currentVbl - startVbl;
+ /* no need to update titlebar/secs? */
+ if (vbls % nScreenRefreshRate != 0)
+ return;
+
+ secs = vbls / nScreenRefreshRate;
+ hours = secs / 3600;
+ mins = (secs % 3600) / 60;
+ secs = secs % 60;
+
+ /* update recording time to titlebar */
+ snprintf(info, sizeof(info), "%02d:%02d:%02d", hours, mins, secs);
+ SDL_SetWindowTitle(sdlWindow, info);
+}
+
/*-----------------------------------------------------------------------*/
/**
* Set how many VBLs Hatari should run, from the moment this function
@@ -355,6 +399,8 @@ void Main_WaitOnVbl(void)
exit(0);
}
+ Main_UpdateTitlebar(nVBLCount);
+
// FrameDuration_micro = (int64_t) ( 1000000.0 / nScreenRefreshRate + 0.5 ); /* round to closest integer */
FrameDuration_micro = ClocksTimings_GetVBLDuration_micro ( ConfigureParams.System.nMachineType , nScreenRefreshRate );
FrameDuration_micro *= nVBLSlowdown;
--
2.39.5