Video recording file select inputevent

This commit is contained in:
Toni Wilen 2022-08-18 21:09:15 +03:00
parent 3de902db01
commit 308f088495
8 changed files with 106 additions and 67 deletions

View File

@ -27,6 +27,7 @@ AKS(STATEREWIND)
AKS(STATECURRENT)
AKS(STATECAPTURE)
AKS(VIDEORECORD)
AKS(VIDEORECORDFILE)
AKS(VOLDOWN)
AKS(VOLUP)
AKS(VOLMUTE)

View File

@ -1972,7 +1972,7 @@ void check_prefs_changed_audio (void)
ch = sound_prefs_changed ();
if (ch > 0) {
#ifdef AVIOUTPUT
AVIOutput_Restart ();
AVIOutput_Restart(true);
#endif
clear_sound_buffers ();
}

View File

@ -4346,7 +4346,17 @@ static bool inputdevice_handle_inputcode2(int monid, int code, int state, const
break;
#ifdef AVIOUTPUT
case AKS_VIDEORECORD:
AVIOutput_Toggle (newstate, true);
AVIOutput_Toggle(newstate, true);
break;
case AKS_VIDEORECORDFILE:
if (s) {
_tcsncpy(avioutput_filename_gui, s, MAX_DPATH);
avioutput_filename_gui[MAX_DPATH - 1] = 0;
set_config_changed();
} else {
gui_display (7);
setsystime ();
}
break;
#endif
#ifdef ACTION_REPLAY

View File

@ -336,6 +336,7 @@ DEFEVENT(SPC_ENTERGUI,_T("Enter GUI"),AM_K,0,0,AKS_ENTERGUI)
DEFEVENT(SPC_SCREENSHOT,_T("Screenshot (file)"),AM_K,0,0,AKS_SCREENSHOT_FILE)
DEFEVENT(SPC_SCREENSHOT_CLIPBOARD,_T("Screenshot (clipboard)"),AM_K,0,0,AKS_SCREENSHOT_CLIPBOARD)
DEFEVENT(SPC_VIDEORECORD, _T("Audio/Video recording"),AM_KT,0,0,AKS_VIDEORECORD)
DEFEVENT(SPC_VIDEORECORDFILE, _T("Change audio/video recording file"),AM_KT,0,0,AKS_VIDEORECORDFILE)
DEFEVENT(SPC_FREEZEBUTTON,_T("Activate Cartridge"),AM_K,0,0,AKS_FREEZEBUTTON)
DEFEVENT(SPC_FLOPPY0,_T("Change disk in DF0:"),AM_K,0,0,AKS_FLOPPY0)
DEFEVENT(SPC_FLOPPY1,_T("Change disk in DF1:"),AM_K,0,0,AKS_FLOPPY1)

View File

@ -758,7 +758,7 @@ static void AVIOutput_End2(bool);
uae_s64 max_avi_size = MAX_AVI_SIZE;
static void checkAVIsize(int force)
static void checkAVIsize(bool force, bool split)
{
int tmp_avioutput_video = avioutput_video;
int tmp_avioutput_audio = avioutput_audio;
@ -768,13 +768,16 @@ static void checkAVIsize(int force)
return;
if (total_avi_size == 0)
return;
if (!avioutput_split_files)
return;
partcnt++;
_tcscpy (fn, avioutput_filename_tmp);
_stprintf (avioutput_filename_inuse, _T("%s_%d.avi"), fn, partcnt);
write_log (_T("AVI split %d at %lld bytes, %d frames\n"),
partcnt, total_avi_size, frame_count);
if (split) {
if (!avioutput_split_files)
return;
partcnt++;
_tcscpy(fn, avioutput_filename_tmp);
_stprintf(avioutput_filename_inuse, _T("%s_%d.avi"), fn, partcnt);
write_log(_T("AVI split %d at %lld bytes, %d frames\n"), partcnt, total_avi_size, frame_count);
} else {
write_log(_T("AVI restart at %lld bytes, %d frames\n"), total_avi_size, frame_count);
}
AVIOutput_End2(false);
total_avi_size = 0;
avioutput_video = tmp_avioutput_video;
@ -783,11 +786,11 @@ static void checkAVIsize(int force)
_tcscpy (avioutput_filename_tmp, fn);
}
static void dorestart (void)
static void dorestart(void)
{
write_log (_T("AVIOutput: parameters changed, restarting..\n"));
checkAVIsize(true, avioutput_needs_restart > 0);
avioutput_needs_restart = 0;
checkAVIsize (1);
}
static void AVIOuput_AVIWriteAudio (uae_u8 *sndbuffer, int sndbufsize, int expectedsize)
@ -800,7 +803,7 @@ static void AVIOuput_AVIWriteAudio (uae_u8 *sndbuffer, int sndbufsize, int expec
}
if (!sndbufsize)
return;
checkAVIsize (0);
checkAVIsize(false, true);
if (avioutput_needs_restart)
dorestart ();
waitqueuefull ();
@ -1202,7 +1205,7 @@ static void AVIOutput_WriteVideo(void)
return;
}
checkAVIsize (0);
checkAVIsize(false, true);
if (avioutput_needs_restart)
dorestart ();
waitqueuefull ();
@ -1311,11 +1314,11 @@ static void writewavheader (uae_u32 size)
fwrite (&tl, 1, 4, wavfile);
}
void AVIOutput_Restart (void)
void AVIOutput_Restart(bool split)
{
if (first_frame)
return;
avioutput_needs_restart = 1;
avioutput_needs_restart = split ? 1 : -1;
}
static void AVIOutput_End2(bool fullrestart)

View File

@ -19,22 +19,22 @@ extern TCHAR avioutput_filename_gui[MAX_DPATH];
extern TCHAR avioutput_filename_auto[MAX_DPATH];
extern TCHAR avioutput_filename_inuse[MAX_DPATH];
extern void AVIOutput_Toggle (int mode, bool immediate);
extern bool AVIOutput_WriteAudio (uae_u8 *sndbuffer, int sndbufsize);
extern int AVIOutput_ChooseAudioCodec (HWND hwnd, TCHAR*, int);
extern int AVIOutput_GetAudioCodec (TCHAR*, int);
extern int AVIOutput_ChooseVideoCodec (HWND hwnd, TCHAR*, int);
extern int AVIOutput_GetVideoCodec (TCHAR*, int);
extern void AVIOutput_Restart (void);
extern void AVIOutput_End (void);
extern void AVIOutput_Begin (bool);
extern void AVIOutput_Release (void);
extern void AVIOutput_Initialize (void);
extern void AVIOutput_RGBinfo (int,int,int,int,int,int,int,int);
extern void AVIOutput_GetSettings (void);
extern void AVIOutput_SetSettings (void);
extern void AVIOutput_Toggle(int mode, bool immediate);
extern bool AVIOutput_WriteAudio(uae_u8 *sndbuffer, int sndbufsize);
extern int AVIOutput_ChooseAudioCodec(HWND hwnd, TCHAR*, int);
extern int AVIOutput_GetAudioCodec(TCHAR*, int);
extern int AVIOutput_ChooseVideoCodec(HWND hwnd, TCHAR*, int);
extern int AVIOutput_GetVideoCodec(TCHAR*, int);
extern void AVIOutput_Restart(bool);
extern void AVIOutput_End(void);
extern void AVIOutput_Begin(bool);
extern void AVIOutput_Release(void);
extern void AVIOutput_Initialize(void);
extern void AVIOutput_RGBinfo(int,int,int,int,int,int,int,int);
extern void AVIOutput_GetSettings(void);
extern void AVIOutput_SetSettings(void);
extern void Screenshot_RGBinfo (int,int,int,int,int,int,int,int);
extern void Screenshot_RGBinfo(int,int,int,int,int,int,int,int);
#define AVIAUDIO_AVI 1
#define AVIAUDIO_WAV 2

View File

@ -1758,7 +1758,7 @@ static void close_hwnds(struct AmigaMonitor *mon)
if (!mon->monitor_id) {
display_vblank_thread_kill();
#ifdef AVIOUTPUT
AVIOutput_Restart();
AVIOutput_Restart(true);
#endif
#ifdef RETROPLATFORM
rp_set_hwnd(NULL);

View File

@ -2319,6 +2319,7 @@ static void flipgui(int opengui)
}
}
static bool get_avioutput_file(HWND);
static int GetSettings (int all_options, HWND hwnd);
/* if drive is -1, show the full GUI, otherwise file-requester for DF[drive] */
void gui_display (int shortcut)
@ -2374,6 +2375,21 @@ void gui_display (int shortcut)
savestate_state = STATE_DORESTORE;
} else if (shortcut == 6) {
DiskSelection(mon->hAmigaWnd, IDC_CD_SELECT, 17, &changed_prefs, NULL, NULL);
} else if (shortcut == 7) {
if (get_avioutput_file(mon->hAmigaWnd)) {
_tcscpy(avioutput_filename_inuse, avioutput_filename_gui);
AVIOutput_SetSettings();
if (!avioutput_requested) {
AVIOutput_Toggle(true, false);
if (avioutput_audio != AVIAUDIO_WAV) {
TCHAR tmp[MAX_DPATH];
avioutput_audio = AVIOutput_GetAudioCodec(tmp, sizeof tmp / sizeof(TCHAR));
avioutput_video = AVIOutput_GetVideoCodec(tmp, sizeof tmp / sizeof(TCHAR));
}
} else {
AVIOutput_Restart(false);
}
}
}
mon->manual_painting_needed--; /* So that WM_PAINT doesn't need to use custom refreshing */
reset_sound ();
@ -20830,6 +20846,47 @@ static void enable_for_avioutputdlg (HWND hDlg)
ew (hDlg, IDC_STATEREC_PLAY, input_record != INPREC_RECORD_RERECORD);
}
static bool get_avioutput_file(HWND hDlg)
{
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hDlg;
ofn.hInstance = hInst;
ofn.Flags = OFN_EXTENSIONDIFFERENT | OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = avioutput_audio == AVIAUDIO_WAV ? 2 : 0;
ofn.lpstrFile = avioutput_filename_gui;
ofn.nMaxFile = MAX_DPATH;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
ofn.lCustData = 0;
ofn.lpstrFilter = _T("Video Clip (*.avi)\0*.avi\0Wave Sound (*.wav)\0");
if (!GetSaveFileName(&ofn))
return false;
if (ofn.nFilterIndex == 2) {
avioutput_audio = AVIAUDIO_WAV;
avioutput_video = 0;
if (_tcslen(avioutput_filename_gui) > 4 && !_tcsicmp(avioutput_filename_gui + _tcslen(avioutput_filename_gui) - 4, _T(".avi")))
_tcscpy(avioutput_filename_gui + _tcslen(avioutput_filename_gui) - 4, _T(".wav"));
_tcscpy(avioutput_filename_auto, avioutput_filename_gui);
} else if (avioutput_audio == AVIAUDIO_WAV) {
avioutput_audio = 0;
avioutput_video = 0;
if (_tcslen(avioutput_filename_gui) > 4 && !_tcsicmp(avioutput_filename_gui + _tcslen(avioutput_filename_gui) - 4, _T(".wav")))
_tcscpy(avioutput_filename_gui + _tcslen(avioutput_filename_gui) - 4, _T(".avi"));
_tcscpy(avioutput_filename_auto, avioutput_filename_gui);
}
return true;
}
static INT_PTR CALLBACK AVIOutputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static int recursive = 0;
@ -21013,42 +21070,9 @@ static INT_PTR CALLBACK AVIOutputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
}
case IDC_AVIOUTPUT_FILE:
{
OPENFILENAME ofn;
ZeroMemory (&ofn, sizeof (OPENFILENAME));
ofn.lStructSize = sizeof (OPENFILENAME);
ofn.hwndOwner = hDlg;
ofn.hInstance = hInst;
ofn.Flags = OFN_EXTENSIONDIFFERENT | OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = avioutput_audio == AVIAUDIO_WAV ? 2 : 0;
ofn.lpstrFile = avioutput_filename_gui;
ofn.nMaxFile = MAX_DPATH;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
ofn.lCustData = 0;
ofn.lpstrFilter = _T("Video Clip (*.avi)\0*.avi\0Wave Sound (*.wav)\0");
if(!GetSaveFileName (&ofn))
break;
if (ofn.nFilterIndex == 2) {
avioutput_audio = AVIAUDIO_WAV;
avioutput_video = 0;
if (_tcslen (avioutput_filename_gui) > 4 && !_tcsicmp (avioutput_filename_gui + _tcslen (avioutput_filename_gui) - 4, _T(".avi")))
_tcscpy (avioutput_filename_gui + _tcslen (avioutput_filename_gui) - 4, _T(".wav"));
_tcscpy (avioutput_filename_auto, avioutput_filename_gui);
} else if (avioutput_audio == AVIAUDIO_WAV) {
avioutput_audio = 0;
avioutput_video = 0;
if (_tcslen(avioutput_filename_gui) > 4 && !_tcsicmp(avioutput_filename_gui + _tcslen(avioutput_filename_gui) - 4, _T(".wav")))
_tcscpy(avioutput_filename_gui + _tcslen(avioutput_filename_gui) - 4, _T(".avi"));
_tcscpy(avioutput_filename_auto, avioutput_filename_gui);
if (get_avioutput_file(hDlg)) {
AVIOutput_SetSettings();
}
AVIOutput_SetSettings();
break;
}
}