Unified · Split
| @@ -269,8 +269,7 @@ static void voiceUpdateVolumes(int32_t i, uint8_t status) · 268 unmodified lines | ||
| 269 | 269 | // if destination volume and current volume is the same (and we have no sample trigger), don't do ramp |
| 270 | 270 | if (fVolumeL == v->fVolumeL && fVolumeR == v->fVolumeR && !(status & IS_Trigger)) |
| 271 | 271 | { |
| 272 | − // there is no volume change | |
| 273 | − v->volumeRampLength = 0; | |
| 272 | + v->volumeRampLength = 0; // there is no volume change | |
| 274 | 273 | } |
| 275 | 274 | else |
| 276 | 275 | { |
| @@ -982,41 +981,28 @@ static void SDLCALL audioCallback(void *userdata, Uint8 *stream, int len) · 705 unmodified lines | ||
| 982 | 981 | |
| 983 | 982 | static bool setupAudioBuffers(void) |
| 984 | 983 | { |
| 985 | − const uint32_t sampleSize = sizeof (float); | |
| 986 | − | |
| 987 | − audio.fMixBufferLUnaligned = (float *)MALLOC_PAD(MAX_WAV_RENDER_SAMPLES_PER_TICK * sampleSize, 256); | |
| 988 | − audio.fMixBufferRUnaligned = (float *)MALLOC_PAD(MAX_WAV_RENDER_SAMPLES_PER_TICK * sampleSize, 256); | |
| 984 | + audio.fMixBufferL = (float *)calloc(MAX_WAV_RENDER_SAMPLES_PER_TICK, sizeof (float)); | |
| 985 | + audio.fMixBufferR = (float *)calloc(MAX_WAV_RENDER_SAMPLES_PER_TICK, sizeof (float)); | |
| 989 | 986 | |
| 990 | − if (audio.fMixBufferLUnaligned == NULL || audio.fMixBufferRUnaligned == NULL) | |
| 987 | + if (audio.fMixBufferL == NULL || audio.fMixBufferR == NULL) | |
| 991 | 988 | return false; |
| 992 | 989 | |
| 993 | − // make aligned main pointers | |
| 994 | − audio.fMixBufferL = (float *)ALIGN_PTR(audio.fMixBufferLUnaligned, 256); | |
| 995 | − audio.fMixBufferR = (float *)ALIGN_PTR(audio.fMixBufferRUnaligned, 256); | |
| 996 | − | |
| 997 | − // clear buffers | |
| 998 | − memset(audio.fMixBufferL, 0, MAX_WAV_RENDER_SAMPLES_PER_TICK * sampleSize); | |
| 999 | − memset(audio.fMixBufferR, 0, MAX_WAV_RENDER_SAMPLES_PER_TICK * sampleSize); | |
| 1000 | − | |
| 1001 | 990 | return true; |
| 1002 | 991 | } |
| 1003 | 992 | |
| 1004 | 993 | static void freeAudioBuffers(void) |
| 1005 | 994 | { |
| 1006 | − if (audio.fMixBufferLUnaligned != NULL) | |
| 995 | + if (audio.fMixBufferL != NULL) | |
| 1007 | 996 | { |
| 1008 | − free(audio.fMixBufferLUnaligned); | |
| 1009 | − audio.fMixBufferLUnaligned = NULL; | |
| 997 | + free(audio.fMixBufferL); | |
| 998 | + audio.fMixBufferL = NULL; | |
| 1010 | 999 | } |
| 1011 | 1000 | |
| 1012 | − if (audio.fMixBufferRUnaligned != NULL) | |
| 1001 | + if (audio.fMixBufferR != NULL) | |
| 1013 | 1002 | { |
| 1014 | − free(audio.fMixBufferRUnaligned); | |
| 1015 | − audio.fMixBufferRUnaligned = NULL; | |
| 1003 | + free(audio.fMixBufferR); | |
| 1004 | + audio.fMixBufferR = NULL; | |
| 1016 | 1005 | } |
| 1017 | − | |
| 1018 | − audio.fMixBufferL = NULL; | |
| 1019 | − audio.fMixBufferR = NULL; | |
| 1020 | 1006 | } |
| 1021 | 1007 | |
| 1022 | 1008 | void updateSendAudSamplesRoutine(bool lockMixer) |
| @@ -40,7 +40,7 @@ typedef struct audio_t · 39 unmodified lines | ||
| 40 | 40 | uint32_t freq, audLatencyPerfValInt, audLatencyPerfValFrac, samplesPerTick, samplesPerTickFrac, musicTimeSpeedVal; |
| 41 | 41 | uint64_t tickTime64, tickTime64Frac; |
| 42 | 42 | float fRampQuickVolMul, fRampTickMul, fRampTickMulTab[(MAX_BPM-MIN_BPM)+1]; |
| 43 | − float *fMixBufferL, *fMixBufferR, *fMixBufferLUnaligned, *fMixBufferRUnaligned; | |
| 43 | + float *fMixBufferL, *fMixBufferR; | |
| 44 | 44 | double dHz2MixDeltaMul, dAudioLatencyMs; |
| 45 | 45 | |
| 46 | 46 | SDL_AudioDeviceID dev; |
| @@ -69,9 +69,6 @@ · 68 unmodified lines | ||
| 69 | 69 | // fast 32-bit -> 16-bit clamp |
| 70 | 70 | #define CLAMP16(i) if ((int16_t)(i) != i) i = 0x7FFF ^ (i >> 31) |
| 71 | 71 | |
| 72 | −#define ALIGN_PTR(p, x) (((uintptr_t)(p) + ((x)-1)) & ~((x)-1)) | |
| 73 | −#define MALLOC_PAD(size, pad) (malloc((size) + (pad))) | |
| 74 | − | |
| 75 | 72 | #define SWAP16(x) \ |
| 76 | 73 | ( \ |
| 77 | 74 | (((uint16_t)((x) & 0x00FF)) << 8) | \ |
| @@ -795,13 +795,11 @@ void closeVideo(void) · 794 unmodified lines | ||
| 795 | 795 | video.window = NULL; |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | − if (video.frameBufferUnaligned != NULL) | |
| 798 | + if (video.frameBuffer != NULL) | |
| 799 | 799 | { |
| 800 | − free(video.frameBufferUnaligned); | |
| 801 | − video.frameBufferUnaligned = NULL; | |
| 800 | + free(video.frameBuffer); | |
| 801 | + video.frameBuffer = NULL; | |
| 802 | 802 | } |
| 803 | − | |
| 804 | − video.frameBuffer = NULL; | |
| 805 | 803 | } |
| 806 | 804 | |
| 807 | 805 | void setWindowSizeFromConfig(bool updateRenderer) |
| @@ -1030,16 +1028,13 @@ bool setupRenderer(void) · 222 unmodified lines | ||
| 1030 | 1028 | } |
| 1031 | 1029 | |
| 1032 | 1030 | // framebuffer used by SDL (for texture) |
| 1033 | − video.frameBufferUnaligned = (uint32_t *)MALLOC_PAD(SCREEN_W * SCREEN_H * sizeof (int32_t), 256); | |
| 1034 | − if (video.frameBufferUnaligned == NULL) | |
| 1031 | + video.frameBuffer = (uint32_t *)malloc(SCREEN_W * SCREEN_H * sizeof (int32_t)); | |
| 1032 | + if (video.frameBuffer == NULL) | |
| 1035 | 1033 | { |
| 1036 | 1034 | showErrorMsgBox("Not enough memory!"); |
| 1037 | 1035 | return false; |
| 1038 | 1036 | } |
| 1039 | 1037 | |
| 1040 | − // we want an aligned pointer | |
| 1041 | − video.frameBuffer = (uint32_t *)ALIGN_PTR(video.frameBufferUnaligned, 256); | |
| 1042 | − | |
| 1043 | 1038 | if (!setupSprites()) |
| 1044 | 1039 | return false; |
| 1045 | 1040 | |
| @@ -32,7 +32,6 @@ typedef struct video_t · 31 unmodified lines | ||
| 32 | 32 | uint8_t upscaleFactor; |
| 33 | 33 | bool vsync60HzPresent, windowHidden; |
| 34 | 34 | int32_t renderX, renderY, renderW, renderH, displayW, displayH, windowW, windowH; |
| 35 | − uint32_t *frameBufferUnaligned; | |
| 36 | 35 | SDL_Renderer *renderer; |
| 37 | 36 | SDL_Texture *texture; |
| 38 | 37 | SDL_Surface *iconSurface; |