]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Avioutput updates.
authorToni Wilen <twilen@winuae.net>
Sat, 14 Oct 2017 17:41:51 +0000 (20:41 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 14 Oct 2017 17:41:51 +0000 (20:41 +0300)
drawing.cpp
include/drawing.h
od-win32/avioutput.cpp
od-win32/avioutput.h
od-win32/sounddep/sound.cpp
od-win32/win32gui.cpp

index 7dbb836be736f0f53ef46b99a5c9dde462422006..c5448583fff0e0a876436c8c86bd22acd293b8b0 100644 (file)
@@ -3957,15 +3957,22 @@ void vsync_handle_redraw (int long_field, int lof_changed, uae_u16 bplcon0p, uae
        if (lof_changed || interlace_seen <= 0 || (currprefs.gfx_iscanlines && interlace_seen > 0) || last_redraw_point >= 2 || long_field || doublescan < 0) {
                last_redraw_point = 0;
 
-               if (framecnt == 0)
-                       finish_drawing_frame ();
+               if (framecnt == 0) {
+                       finish_drawing_frame();
+#ifdef AVIOUTPUT
+                       if (!picasso_on) {
+                               frame_drawn();
+                       }
+#endif
+               }
 #if 0
                if (interlace_seen > 0) {
                        interlace_seen = -1;
-               } else if (interlace_seen == -1) {
+               }
+               else if (interlace_seen == -1) {
                        interlace_seen = 0;
                        if (currprefs.gfx_scandoubler && currprefs.gfx_vresolution)
-                               notice_screen_contents_lost ();
+                               notice_screen_contents_lost();
                }
 #endif
 
@@ -3973,33 +3980,31 @@ void vsync_handle_redraw (int long_field, int lof_changed, uae_u16 bplcon0p, uae
 #ifdef SAVESTATE
                        if (!savestate_state) {
                                if (currprefs.quitstatefile[0]) {
-                                       savestate_initsave (currprefs.quitstatefile, 1, 1, true); 
-                                       save_state (currprefs.quitstatefile, _T(""));
+                                       savestate_initsave(currprefs.quitstatefile, 1, 1, true);
+                                       save_state(currprefs.quitstatefile, _T(""));
                                }
                        }
 #endif
                        quit_program = -quit_program;
-                       set_inhibit_frame (IHF_QUIT_PROGRAM);
+                       set_inhibit_frame(IHF_QUIT_PROGRAM);
                        set_special(SPCFLAG_BRK | SPCFLAG_MODE_CHANGE);
                        return;
                }
 
-               count_frame ();
+               count_frame();
 
-               if (framecnt == 0)
-                       init_drawing_frame ();
-               else if (currprefs.cpu_memory_cycle_exact)
-                       init_hardware_for_drawing_frame ();
+               if (framecnt == 0) {
+                       init_drawing_frame();
+               } else if (currprefs.cpu_memory_cycle_exact) {
+                       init_hardware_for_drawing_frame();
+               }
        } else {
-               if (isvsync_chipset ())
-                       flush_screen (gfxvidinfo.inbuffer, 0, 0); /* vsync mode */
+               if (isvsync_chipset()) {
+                       flush_screen(gfxvidinfo.inbuffer, 0, 0); /* vsync mode */
+               }
        }
 
        gui_flicker_led (-1, 0, 0);
-#ifdef AVIOUTPUT
-       if (!picasso_on)
-               frame_drawn ();
-#endif
 }
 
 void hsync_record_line_state (int lineno, enum nln_how how, int changed)
index ce99be0611064f60afdd34d4ab8c2b9199410203..01dfcfe02bfd18abe05b4a6a5ee5e798f0a72a1c 100644 (file)
@@ -318,7 +318,7 @@ extern void reset_drawing (void);
 extern void drawing_init (void);
 extern bool notice_interlace_seen (bool);
 extern void notice_resolution_seen (int, bool);
-extern void frame_drawn (void);
+extern bool frame_drawn (void);
 extern void redraw_frame (void);
 extern bool draw_frame (struct vidbuffer*);
 extern int get_custom_limits (int *pw, int *ph, int *pdx, int *pdy, int *prealh);
index d9a9ea6c32c84aa4170952a1ce8e09680a83e7a9..d01437a7cdbcc21de235d3d37013efd338e8993e 100644 (file)
@@ -42,6 +42,7 @@ Copyright(c) 2001 - 2002; 
 #include "fsdb.h"
 #include "threaddep/thread.h"
 #include "zfile.h"
+#include "savestate.h"
 
 #define MAX_AVI_SIZE (0x80000000 - 0x1000000)
 
@@ -58,7 +59,7 @@ static int frame_count; // current frame
 static int frame_skip;
 static uae_u64 total_avi_size;
 static int partcnt;
-static int first_frame = 1;
+static int first_frame;
 
 int avioutput_audio, avioutput_video, avioutput_enabled, avioutput_requested;
 static int videoallocated;
@@ -633,9 +634,10 @@ static int AVIOutput_GetCOMPVARSFromRegistry (COMPVARS *pcv)
                                        regquerydata(avikey, _T("VideoConfigurationState"), state, &ss);
                                }
                                pcv->hic = ICOpen (pcv->fccType, pcv->fccHandler, ICMODE_COMPRESS);
-                               if (pcv->hic) {
+                               if (pcv->hic || (!pcv->hic && pcv->fccHandler == mmioFOURCC('D', 'I', 'B', ' '))) { // DIB = uncompressed
                                        ok = 1;
-                                       ICSetState (pcv->hic, state, ss);
+                                       if (pcv->hic)
+                                               ICSetState (pcv->hic, state, ss);
                                }
                                xfree (state);
                        }
@@ -724,7 +726,7 @@ int AVIOutput_ChooseVideoCodec (HWND hwnd, TCHAR *s, int len)
                        ss = 0;
                }
                if (ss == 0)
-                       state = xmalloc (uae_u8, 1);
+                       state = xcalloc (uae_u8, 1);
                avikey = openavikey ();
                if (avikey) {
                        regsetdata (avikey, _T("VideoConfigurationState"), state, ss);
@@ -1263,7 +1265,7 @@ void AVIOutput_Restart (void)
 
 static void AVIOutput_End2(bool fullrestart)
 {
-       first_frame = 1;
+       first_frame = 0;
        avioutput_enabled = 0;
 
        if (alive) {
@@ -1372,7 +1374,9 @@ static void AVIOutput_Begin2(bool fullstart, bool immediate)
        if (fullstart) {
                reset_sound();
                init_hz_normal();
-               first_frame = 1;
+               first_frame = 0;
+               if (savestate_state && !avioutput_originalsize)
+                       first_frame = 1;
        } else {
                first_frame = 0;
        }
@@ -1660,14 +1664,33 @@ void AVIOutput_Toggle (int mode, bool immediate)
        }
 }
 
-void AVIOutput_WriteAudio(uae_u8 *sndbuffer, int sndbufsize)
+static void start_if_requested(void)
 {
-       if (!avioutput_audio || !avioutput_enabled)
+       if (!avioutput_requested)
                return;
+       AVIOutput_Begin(true);
+}
+
+static bool can_record(void)
+{
+       if (savestate_state == STATE_DORESTORE || savestate_state == STATE_RESTORE)
+               return false;
+       return true;
+}
+
+bool AVIOutput_WriteAudio(uae_u8 *sndbuffer, int sndbufsize)
+{
+       if (!can_record())
+               return false;
+
+       start_if_requested();
+
+       if (!avioutput_audio || !avioutput_enabled)
+               return false;
        if (!sndbufsize)
-               return;
+               return false;
        if (avioutput_failed)
-               return;
+               return false;
 
        if (!avi_sndbuffer) {
                avi_sndbufsize = sndbufsize * 2;
@@ -1680,10 +1703,16 @@ void AVIOutput_WriteAudio(uae_u8 *sndbuffer, int sndbufsize)
        }
        memcpy(avi_sndbuffer + avi_sndbuffered, sndbuffer, sndbufsize);
        avi_sndbuffered += sndbufsize;
+       return true;
 }
 
-void frame_drawn (void)
+bool frame_drawn (void)
 {
+       if (!can_record())
+               return false;
+
+       start_if_requested();
+
        if (screenshot_multi) {
                screenshot(1, 1);
                if (screenshot_multi > 0)
@@ -1691,9 +1720,9 @@ void frame_drawn (void)
        }
 
        if (!avioutput_enabled)
-               return;
+               return false;
        if (avioutput_failed)
-               return;
+               return false;
 
        if (avioutput_audio == AVIAUDIO_WAV) {
                finish_sound_buffer();
@@ -1702,12 +1731,12 @@ void frame_drawn (void)
                }
                first_frame = 0;
                avi_sndbuffered = 0;
-               return;
+               return true;
        }
 
        if (avioutput_audio) {
                finish_sound_buffer();
-               if (!first_frame) {
+               if (first_frame == 0 || first_frame == -1) {
                        int bytesperframe;
                        bytesperframe = wfxSrc.Format.nChannels * 2;
                        StreamSizeAudioGot += avi_sndbuffered / bytesperframe;
@@ -1731,14 +1760,18 @@ void frame_drawn (void)
        }
 
        if (first_frame) {
-               first_frame = 0;
-               return;
+               if (first_frame > 0)
+                       first_frame--;
+               else
+                       first_frame++;
+               return true;
        }
 
        if (!avioutput_video)
-               return;
+               return false;
 
        AVIOutput_WriteVideo ();
+       return true;
 }
 
 /* Resampler from:
index 696630cef0a5521f60d5f360ac54bdeee2a8d567..f61f6632129769f98148ea08397aeada56f4afc8 100644 (file)
@@ -21,8 +21,7 @@ extern TCHAR avioutput_filename_auto[MAX_DPATH];
 extern TCHAR avioutput_filename_inuse[MAX_DPATH];
 
 extern void AVIOutput_Toggle (int mode, bool immediate);
-extern void AVIOutput_WriteAudio (uae_u8 *sndbuffer, int sndbufsize);
-extern void AVIOutput_WriteVideo (void);
+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);
index d4a49cbd35b73e87220ee572fa6f196f3cedc485..55d1395a302b41f4489a6a13af139e019928dd94 100644 (file)
@@ -2630,10 +2630,11 @@ void finish_sound_buffer (void)
        // must be after driveclick_mix
        paula_sndbufpt = paula_sndbuffer;
 #ifdef AVIOUTPUT
-       if (avioutput_enabled && avioutput_audio) {
-               AVIOutput_WriteAudio((uae_u8*)paula_sndbuffer, bufsize);
-               if (avioutput_nosoundsync)
-                       sound_setadjust(0);
+       if (avioutput_audio) {
+               if (AVIOutput_WriteAudio((uae_u8*)paula_sndbuffer, bufsize)) {
+                       if (avioutput_nosoundsync)
+                               sound_setadjust(0);
+               }
        }
        if (avioutput_enabled && (!avioutput_framelimiter || avioutput_nosoundoutput))
                return;
index 1c15da0a8382f6a294618fc83651e5c2323c5470..0b351fd61181b0f889e0d3add2aad8a270bbee59 100644 (file)
@@ -2266,9 +2266,6 @@ void gui_display (int shortcut)
        if (resumepaused (7)) {
                inputdevice_acquire (TRUE);
                setmouseactive (1);
-#ifdef AVIOUTPUT
-               AVIOutput_Begin (true);
-#endif
        }
        flipgui(false);
        fpscounter_reset ();
@@ -20683,11 +20680,6 @@ int gui_init (void)
                        break;
                restart_requested = 0;
        }
-       if (ret > 0) {
-#ifdef AVIOUTPUT
-               AVIOutput_Begin (true);
-#endif
-       }
        return ret;
 }