diff --git a/SConstruct b/SConstruct index 328e71df2..2d2d83d51 100644 --- a/SConstruct +++ b/SConstruct @@ -1353,12 +1353,16 @@ static void terminate_handler() # inputs. user_settings.max_axes_per_joystick = user_settings.max_buttons_per_joystick = user_settings.max_hats_per_joystick = 0 successflags['CPPDEFINES'] = CPPDEFINES = successflags.get('CPPDEFINES', [])[:] + # use Redbook if at least one of the following applies + # 1. we are on SDL1 + # 2. we are building for a platform for which we have a custom CD implementation (currently only win32) + use_redbook = int(not sdl2 or user_settings.host_platform == 'win32') CPPDEFINES.extend(( ('DXX_MAX_JOYSTICKS', user_settings.max_joysticks), ('DXX_MAX_AXES_PER_JOYSTICK', user_settings.max_axes_per_joystick), ('DXX_MAX_BUTTONS_PER_JOYSTICK', user_settings.max_buttons_per_joystick), ('DXX_MAX_HATS_PER_JOYSTICK', user_settings.max_hats_per_joystick), - ('DXX_USE_SDL_REDBOOK_AUDIO', int(not sdl2 or sys.platform in ['win32', 'msys'])), # there is a win32 rbaudio now + ('DXX_USE_SDL_REDBOOK_AUDIO', use_redbook), )) context.Display('%s: checking whether to enable joystick support...%s\n' % (self.msgprefix, 'yes' if user_settings.max_joysticks else 'no')) # SDL2 removed CD-rom support. diff --git a/common/arch/win32/rbaudio.cpp b/common/arch/win32/rbaudio.cpp index b3d0fb816..40939f388 100644 --- a/common/arch/win32/rbaudio.cpp +++ b/common/arch/win32/rbaudio.cpp @@ -93,6 +93,7 @@ static unsigned mci_GetTrackOffset(const int track) Warning("RBAudio win32/MCI: cannot determine track %i offset (%lx)", track, mciError); return -1; } + // dwReturn is a 32-bit value in MSF format, so DWORD_PTR > DWORD is not a problem return mci_TotalFramesMsf(mciStatusParms.dwReturn); } @@ -108,6 +109,7 @@ static unsigned mci_GetTrackLength(const int track) Warning("RBAudio win32/MCI: cannot determine track %i length (%lx)", track, mciError); return -1; } + // dwReturn is a 32-bit value in MSF format, so DWORD_PTR > DWORD is not a problem return mci_TotalFramesMsf(mciStatusParms.dwReturn); } @@ -367,12 +369,13 @@ void RBACheckFinishedHook() // and allow a bit of a leeway when checking if so. DWORD checkValue = playEnd; + // dwReturn is a 32-bit value in MSF format, so DWORD_PTR > DWORD is not a problem DWORD thisFrames = mci_TotalFramesMsf(mciStatusParms.dwReturn); if (thisFrames == lastFrames) checkValue = checkValue < 64 ? 0 : checkValue - 64; // prevent underflow - if (redbook_finished_hook && playEnd > 0 && lastFrames >= checkValue) + if (redbook_finished_hook && playEnd > 0 && thisFrames >= checkValue) { con_puts(CON_VERBOSE, "RBAudio win32/MCI: Playback done, calling finished-hook"); redbook_finished_hook();