Re: [hatari-devel] Autostart support for more options |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [hatari-devel] Autostart support for more options
- From: Eero Tamminen <oak@xxxxxxxxxxxxxx>
- Date: Thu, 5 Jun 2025 02:00:50 +0300
- Dkim-filter: OpenDKIM Filter v2.11.0 smtp.dnamail.fi E501C2113FF0
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=helsinkinet.fi; s=2025-03; t=1749078050; bh=bljqvi20pY59p6Z79lCunrtwbOq+R1CmVYVAJDfXcAo=; h=Date:Subject:To:References:From:In-Reply-To:From; b=KSqddAFFDUq2kXJjkG2Mb1nb8A5TAP8t5YMt2rkFfdqwC9BW27zgPvZg8YMdJSxRf tMYaN7ED/5rhorJhPC0nb6YwsP359oi6V9PDkdheytb+v27MukJEJb3Ndvi7gzg5kP X8iZ16RTIniQG/KUuImrlqCZxZ4UY6XNqrHG5P9pvxQygsZcV3zKKhgdLZqySXT2aL taZu/Vq9upq1OCuOWnONLT6L6xntFiZ1QOsjbl7CNVDZIU5hu2CLl795eEe9hSW0d6 Qqn69Xx+P9l3Bqgi5jm8OdsaJfncQ+qlHANDfs7uBEO661qXcEttvGpXeu2O+6uB5k F1rXe67URh2FA==
On 2.6.2025 23.46, Eero Tamminen wrote:
Attached is updated first patch for the most relevant autostartable
options, and another patch for adding that support for few additional,
less relevant options.
Btw. I'm thinking that it would make sense also for AVI recording. Re-
recording the same TOS boot sequence is just waste of disk space, when
recording could be enabled just before the program that one is
interested about, is to start...
Draft patches attached also for that, should be applied on top of
previous ones (they build, but otherwise I haven't tested them).
- Eero
From b41ef1dde59509158799f90923fa6a91b23ec058 Mon Sep 17 00:00:00 2001
From: Eero Tamminen <oak@xxxxxxxxxxxxxx>
Date: Thu, 5 Jun 2025 01:52:37 +0300
Subject: [PATCH 2/2] Add autostart option for toggling AVI recording
AVI recording enabling option did not take an argument, so
unfortunately doing it at autostart required separate option.
---
src/includes/inffile.h | 1 +
src/inffile.c | 10 ++++++++++
src/options.c | 11 +++++++++--
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/includes/inffile.h b/src/includes/inffile.h
index ff41ce63..3f4e41c0 100644
--- a/src/includes/inffile.h
+++ b/src/includes/inffile.h
@@ -24,6 +24,7 @@ typedef struct {
int runVBLs;
int conoutDev;
bool fastForward;
+ bool aviRecord;
} autostart_actions_t;
extern autostart_actions_t INF_AutoStartActions;
diff --git a/src/inffile.c b/src/inffile.c
index 6fda77a3..be81999b 100644
--- a/src/inffile.c
+++ b/src/inffile.c
@@ -23,6 +23,7 @@ const char INFFILE_fileid[] = "Hatari inffile.c";
#include "log.h"
#include "str.h"
#include "screen.h"
+#include "avi_record.h"
#include "tos.h"
#include "vdi.h"
@@ -894,6 +895,15 @@ FILE *INF_OpenOverride(const char *filename)
{
autostart_actions_t const *act = &INF_AutoStartActions; /* alias */
+ /* toggle AVI recording */
+ if (act->aviRecord)
+ {
+ if (Avi_AreWeRecording())
+ Avi_StopRecording_WithMsg();
+ else
+ Avi_StartRecording_WithConfig();
+ }
+
/* set fast forwarding? */
if (act->fastForward)
{
diff --git a/src/options.c b/src/options.c
index 1c3bfb44..1ae36524 100644
--- a/src/options.c
+++ b/src/options.c
@@ -50,7 +50,7 @@ const char Options_fileid[] = "Hatari options.c";
bool bLoadAutoSave; /* Load autosave memory snapshot at startup */
bool bLoadMemorySave; /* Load memory snapshot provided via option at startup */
-bool AviRecordOnStartup; /* Start avi recording at startup */
+bool AviRecordOnStartup; /* Whether AVI recording is active or not */
bool BenchmarkMode; /* Start in benchmark mode (try to run at maximum emulation */
/* speed allowed by the CPU). Disable audio/video for best results */
@@ -106,6 +106,7 @@ enum {
OPT_SCREEN_CROP, /* screen capture options */
OPT_AVIRECORD,
+ OPT_AVIRECORD_AUTOSTART,
OPT_AVIRECORD_VCODEC,
OPT_AVI_PNG_LEVEL,
OPT_AVIRECORD_FPS,
@@ -315,7 +316,9 @@ static const opt_t HatariOptions[] = {
{ OPT_SCREEN_CROP, NULL, "--crop",
"<bool>", "Remove statusbar from screen capture" },
{ OPT_AVIRECORD, NULL, "--avirecord",
- NULL, "Start AVI recording" },
+ NULL, "Start AVI recording at boot" },
+ { OPT_AVIRECORD_AUTOSTART, NULL, "--avi-autostart",
+ NULL, "Toggle AVI recording at autostart" },
{ OPT_AVIRECORD_VCODEC, NULL, "--avi-vcodec",
"<x>", "Select AVI video codec (x = bmp/png)" },
{ OPT_AVI_PNG_LEVEL, NULL, "--png-level",
@@ -1372,6 +1375,10 @@ bool Opt_ParseParameters(int argc, const char * const argv[])
AviRecordOnStartup = true;
break;
+ case OPT_AVIRECORD_AUTOSTART:
+ INF_AutoStartActions.aviRecord = enabled;
+ break;
+
case OPT_AVIRECORD_VCODEC:
i += 1;
if (strcasecmp(argv[i], "bmp") == 0)
--
2.39.5
From 1bbd6a7ebcbdda0ddab42d8eb698e993d27fbf82 Mon Sep 17 00:00:00 2001
From: Eero Tamminen <oak@xxxxxxxxxxxxxx>
Date: Thu, 5 Jun 2025 01:50:09 +0300
Subject: [PATCH 1/2] Add helpers to simplify AVI recording start/stop
---
src/avi_record.c | 26 ++++++++++++++++++++++++--
src/gui-osx/SDLMain.m | 8 +-------
src/gui-sdl/dlgScreen.c | 8 +-------
src/includes/avi_record.h | 3 ++-
src/main.c | 19 +++++--------------
src/shortcut.c | 12 +++---------
6 files changed, 36 insertions(+), 40 deletions(-)
diff --git a/src/avi_record.c b/src/avi_record.c
index 6a15a144..09a7a099 100644
--- a/src/avi_record.c
+++ b/src/avi_record.c
@@ -89,12 +89,14 @@ const char AVIRecord_fileid[] = "Hatari avi_record.c";
#include "version.h"
#include "audio.h"
#include "configuration.h"
+#include "clocks_timings.h"
#include "file.h"
#include "log.h"
#include "screen.h"
#include "screenSnapShot.h"
#include "sound.h"
#include "statusbar.h"
+#include "video.h"
#include "avi_record.h"
/* after above that brings in config.h */
@@ -460,6 +462,7 @@ static void Avi_BuildFileHeader ( RECORD_AVI_PARAMS *pAviParams , AVI_FILE_HEADE
static bool Avi_StartRecording_WithParams ( RECORD_AVI_PARAMS *pAviParams , char *AviFileName );
static bool Avi_StopRecording_WithParams ( RECORD_AVI_PARAMS *pAviParams );
+static bool Avi_StartRecording ( char *FileName , bool CropGui , uint32_t Fps , uint32_t Fps_scale , int VideoCodec );
static void Avi_StoreU8 ( uint8_t *p , uint8_t val )
@@ -1453,7 +1456,7 @@ bool Avi_SetCompressionLevel(const char *str)
}
-bool Avi_StartRecording ( char *FileName , bool CropGui , uint32_t Fps , uint32_t Fps_scale , int VideoCodec )
+static bool Avi_StartRecording ( char *FileName , bool CropGui , uint32_t Fps , uint32_t Fps_scale , int VideoCodec )
{
memset ( &AviParams , 0 , sizeof ( AviParams ) );
@@ -1497,6 +1500,17 @@ void Avi_SetSurface(SDL_Surface *surf)
AviParams.Surface = surf;
}
+bool Avi_StartRecording_WithConfig ( void )
+{
+ return Avi_StartRecording( ConfigureParams.Video.AviRecordFile ,
+ ConfigureParams.Screen.bCrop ,
+ ConfigureParams.Video.AviRecordFps == 0 ?
+ ClocksTimings_GetVBLPerSec ( ConfigureParams.System.nMachineType , nScreenRefreshRate ) :
+ ClocksTimings_GetVBLPerSec ( ConfigureParams.System.nMachineType , ConfigureParams.Video.AviRecordFps ) ,
+ 1 << CLOCKS_TIMINGS_SHIFT_VBL ,
+ ConfigureParams.Video.AviRecordVcodec );
+}
+
bool Avi_StopRecording ( void )
{
if (Avi_StopRecording_WithParams ( &AviParams ))
@@ -1507,4 +1521,12 @@ bool Avi_StopRecording ( void )
return false;
}
-
+bool Avi_StopRecording_WithMsg(void)
+{
+ if (!bRecordingAvi)
+ return true;
+ /* cleanly close the AVI file */
+ Statusbar_AddMessage("Finishing AVI file...", 100);
+ Statusbar_Update(sdlscrn, true);
+ return Avi_StopRecording();
+}
diff --git a/src/gui-osx/SDLMain.m b/src/gui-osx/SDLMain.m
index f4c6c4f1..dba7e392 100644
--- a/src/gui-osx/SDLMain.m
+++ b/src/gui-osx/SDLMain.m
@@ -31,7 +31,6 @@
#import "video.h"
#import "avi_record.h"
#import "debugui.h"
-#import "clocks_timings.h"
#import "change.h"
extern void Main_RequestQuit(int exitval) ;
@@ -283,12 +282,7 @@ char szPath[FILENAME_MAX] ; // for general use
if(path) {
GuiOsx_ExportPathString(path, ConfigureParams.Video.AviRecordFile, sizeof(ConfigureParams.Video.AviRecordFile));
- Avi_StartRecording ( ConfigureParams.Video.AviRecordFile , ConfigureParams.Screen.bCrop ,
- ConfigureParams.Video.AviRecordFps == 0 ?
- ClocksTimings_GetVBLPerSec ( ConfigureParams.System.nMachineType , nScreenRefreshRate ) :
- ClocksTimings_GetVBLPerSec ( ConfigureParams.System.nMachineType , ConfigureParams.Video.AviRecordFps ) ,
- 1 << CLOCKS_TIMINGS_SHIFT_VBL ,
- ConfigureParams.Video.AviRecordVcodec );
+ Avi_StartRecording_WithConfig ();
}
} else {
Avi_StopRecording();
diff --git a/src/gui-sdl/dlgScreen.c b/src/gui-sdl/dlgScreen.c
index e1a0ff01..ad73b272 100644
--- a/src/gui-sdl/dlgScreen.c
+++ b/src/gui-sdl/dlgScreen.c
@@ -21,7 +21,6 @@ const char DlgScreen_fileid[] = "Hatari dlgScreen.c";
#include "video.h"
#include "avi_record.h"
#include "statusbar.h"
-#include "clocks_timings.h"
/* how many pixels to increment VDI mode
* width/height on each click
@@ -456,12 +455,7 @@ void Dialog_WindowDlg(void)
else
{
ConfigureParams.Screen.bCrop = (windowdlg[DLGSCRN_CROP].state & SG_SELECTED);
- Avi_StartRecording ( ConfigureParams.Video.AviRecordFile , ConfigureParams.Screen.bCrop ,
- ConfigureParams.Video.AviRecordFps == 0 ?
- ClocksTimings_GetVBLPerSec ( ConfigureParams.System.nMachineType , nScreenRefreshRate ) :
- ClocksTimings_GetVBLPerSec ( ConfigureParams.System.nMachineType , ConfigureParams.Video.AviRecordFps ) ,
- 1 << CLOCKS_TIMINGS_SHIFT_VBL ,
- ConfigureParams.Video.AviRecordVcodec );
+ Avi_StartRecording_WithConfig ();
windowdlg[DLGSCRN_RECANIM].txt = RECORD_STOP;
}
break;
diff --git a/src/includes/avi_record.h b/src/includes/avi_record.h
index 04b41c5a..89ca92e3 100644
--- a/src/includes/avi_record.h
+++ b/src/includes/avi_record.h
@@ -26,8 +26,9 @@ extern bool Avi_RecordAudioStream ( int16_t pSamples[][2] , int SampleIndex , in
extern bool Avi_AreWeRecording ( void );
extern bool Avi_SetCompressionLevel(const char *str);
-extern bool Avi_StartRecording ( char *FileName , bool CropGui , uint32_t Fps , uint32_t Fps_scale , int VideoCodec );
+extern bool Avi_StartRecording_WithConfig ( void );
extern bool Avi_StopRecording ( void );
+extern bool Avi_StopRecording_WithMsg ( void );
extern void Avi_SetSurface(SDL_Surface *surf);
diff --git a/src/main.c b/src/main.c
index cc64f6bd..b51423f5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1034,26 +1034,17 @@ int main(int argc, char *argv[])
/* Check if SDL_Delay is accurate */
Main_CheckForAccurateDelays();
- if ( AviRecordOnStartup ) /* Immediately starts avi recording ? */
- Avi_StartRecording ( ConfigureParams.Video.AviRecordFile , ConfigureParams.Screen.bCrop ,
- ConfigureParams.Video.AviRecordFps == 0 ?
- ClocksTimings_GetVBLPerSec ( ConfigureParams.System.nMachineType , nScreenRefreshRate ) :
- ClocksTimings_GetVBLPerSec ( ConfigureParams.System.nMachineType , ConfigureParams.Video.AviRecordFps ) ,
- 1 << CLOCKS_TIMINGS_SHIFT_VBL ,
- ConfigureParams.Video.AviRecordVcodec );
+ /* Immediately start AVI recording ? */
+ if ( AviRecordOnStartup )
+ Avi_StartRecording_WithConfig();
/* Run emulation */
Main_UnPauseEmulation();
M68000_Start(); /* Start emulation */
Control_RemoveFifo();
- if (bRecordingAvi)
- {
- /* cleanly close the avi file */
- Statusbar_AddMessage("Finishing AVI file...", 100);
- Statusbar_Update(sdlscrn, true);
- Avi_StopRecording();
- }
+ /* cleanly close the AVI file, if needed */
+ Avi_StopRecording_WithMsg();
/* Un-init emulation system */
Main_UnInit();
diff --git a/src/shortcut.c b/src/shortcut.c
index 433c0c29..2b581220 100644
--- a/src/shortcut.c
+++ b/src/shortcut.c
@@ -28,7 +28,6 @@ const char ShortCut_fileid[] = "Hatari shortcut.c";
#include "sdlgui.h"
#include "video.h"
#include "avi_record.h"
-#include "clocks_timings.h"
#include "statusbar.h"
static SHORTCUTKEYIDX ShortCutKey = SHORTCUT_NONE; /* current shortcut key */
@@ -124,17 +123,12 @@ static void ShortCut_RecordAnimation(void)
if (Avi_AreWeRecording())
{
/* Stop */
- Avi_StopRecording();
+ Avi_StopRecording_WithMsg();
}
else
{
- /* Start animation */
- Avi_StartRecording ( ConfigureParams.Video.AviRecordFile , ConfigureParams.Screen.bCrop ,
- ConfigureParams.Video.AviRecordFps == 0 ?
- ClocksTimings_GetVBLPerSec ( ConfigureParams.System.nMachineType , nScreenRefreshRate ) :
- ClocksTimings_GetVBLPerSec ( ConfigureParams.System.nMachineType , ConfigureParams.Video.AviRecordFps ) ,
- 1 << CLOCKS_TIMINGS_SHIFT_VBL ,
- ConfigureParams.Video.AviRecordVcodec );
+ /* Start */
+ Avi_StartRecording_WithConfig();
}
}
--
2.39.5