Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From d987fc88103f5623b504785b9ee0f53921fa61de Mon Sep 17 00:00:00 2001
- From: gocha <gochaism@gmail.com>
- Date: Sun, 30 Jan 2011 15:52:07 +0900
- Subject: [PATCH] windows: improved AVI sound sync
- ---
- win32/win32.cpp | 19 +++++++++++++------
- 1 files changed, 13 insertions(+), 6 deletions(-)
- diff --git a/win32/win32.cpp b/win32/win32.cpp
- index 8672d5a..1f1dad1 100644
- --- a/win32/win32.cpp
- +++ b/win32/win32.cpp
- @@ -201,6 +201,7 @@
- #include <io.h>
- //#define DEBUGGER
- +#include <math.h>
- #ifndef max
- #define max(a, b) (((a) > (b)) ? (a) : (b))
- #endif
- @@ -219,7 +220,8 @@ bool8 do_frame_adjust=false;
- static uint8* avi_buffer = NULL;
- static uint8* avi_sound_buffer = NULL;
- static int avi_sound_bytes_per_sample = 0;
- -static int avi_sound_samples_per_update = 0;
- +static double avi_sound_samples_per_update = 0;
- +static double avi_sound_samples_error = 0;
- static int avi_width = 0;
- static int avi_height = 0;
- static int avi_pitch = 0;
- @@ -1415,12 +1417,13 @@ void DoAVIOpen(const TCHAR* filename)
- return;
- }
- - avi_sound_samples_per_update = (wfx.nSamplesPerSec * frameskip) / framerate;
- + avi_sound_samples_per_update = (double) (wfx.nSamplesPerSec * frameskip) / framerate;
- avi_sound_bytes_per_sample = wfx.nBlockAlign;
- + avi_sound_samples_error = 0;
- // init buffers
- avi_buffer = new uint8[avi_image_size];
- - avi_sound_buffer = new uint8[avi_sound_samples_per_update * avi_sound_bytes_per_sample];
- + avi_sound_buffer = new uint8[(int) ceil(avi_sound_samples_per_update) * avi_sound_bytes_per_sample];
- }
- void DoAVIClose(int reason)
- @@ -1520,9 +1523,13 @@ void DoAVIVideoFrame(SSurface* source_surface)
- if(pwfex)
- {
- const int stereo_multiplier = (Settings.Stereo) ? 2 : 1;
- -
- - S9xMixSamples(avi_sound_buffer, avi_sound_samples_per_update*stereo_multiplier);
- - AVIAddSoundSamples(avi_sound_buffer, avi_sound_samples_per_update, GUI.AVIOut);
- + avi_sound_samples_error += avi_sound_samples_per_update;
- + int samples = (int) avi_sound_samples_error;
- + avi_sound_samples_error -= samples;
- +
- + S9xMixSamples(avi_sound_buffer, samples*stereo_multiplier);
- +
- + AVIAddSoundSamples(avi_sound_buffer, samples, GUI.AVIOut);
- }
- }
- --
- 1.7.3.1.msysgit.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement