1
0
mirror of synced 2024-11-30 20:24:27 +01:00

Make it slightly better

This commit is contained in:
Bobby Dilley 2022-08-02 12:12:27 +01:00
parent 2dab9f406f
commit 20599f5946

View File

@ -93,9 +93,9 @@ typedef struct
struct tsf_region *region; struct tsf_region *region;
} segaapiContext_t; } segaapiContext_t;
LPALBUFFERSAMPLESSOFT alBufferSamplesSOFT = NULL; // LPALBUFFERSAMPLESSOFT alBufferSamplesSOFT = NULL;
LPALBUFFERSUBSAMPLESSOFT alBufferSubSamplesSOFT = NULL; // LPALBUFFERSUBSAMPLESSOFT alBufferSubSamplesSOFT = NULL;
LPALGETBUFFERSAMPLESSOFT alGetBufferSamplesSOFT = NULL; // LPALGETBUFFERSAMPLESSOFT alGetBufferSamplesSOFT = NULL;
#ifdef DEBUG_OUTPUT #ifdef DEBUG_OUTPUT
void dbgPrint(const char *format, ...) void dbgPrint(const char *format, ...)
@ -292,14 +292,19 @@ static void updateBufferLoop(segaapiContext_t *context)
return; return;
} }
void AL_APIENTRY wrap_BufferSamples(ALuint buffer, ALuint samplerate, void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer, ALuint samplerate, ALenum internalformat, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data)
ALenum internalformat, ALsizei samples,
ALenum channels, ALenum type,
const ALvoid *data)
{ {
alBufferData(buffer, internalformat, data, alBufferData(buffer, internalformat, data, FramesToBytes(samples, channels, type), samplerate);
FramesToBytes(samples, channels, type), }
samplerate);
AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data, ALuint samplerate, ALenum internalformat)
{
ALsizei FrameSize = FramesToBytes(samples, channels, type);
offset *= FrameSize;
alBufferData(buffer + offset, internalformat, data, FrameSize, samplerate);
} }
static void updateBufferData(segaapiContext_t *context, unsigned int offset, size_t length) static void updateBufferData(segaapiContext_t *context, unsigned int offset, size_t length)
@ -359,11 +364,8 @@ static void updateBufferData(segaapiContext_t *context, unsigned int offset, siz
// CHECK(); // CHECK();
if (offset != -1) if (offset != -1)
{ {
// printf("CANNOT DO IT\n");
// exit(1);
wrap_BufferSamples(context->alBuffer, context->sampleRate, alFormat, context->size / bufferSampleSize(context), alChannels, alType, &(context->data[offset]));
// alBufferSubSamplesSOFT(context->alBuffer, offset / bufferSampleSize(context), length / bufferSampleSize(context), alChannels, alType, &context->data[offset]); alBufferSubSamplesSOFT(context->alBuffer, offset / bufferSampleSize(context), length / bufferSampleSize(context), alChannels, alType, &context->data[offset], context->sampleRate, alFormat);
// CHECK(); // CHECK();
dbgPrint("Soft update in buffer %X at %u (%u bytes) - buffer playing at %u, unsafe region is %u to %u\n", (uintptr_t)context, offset, length, position, unsafe[0], unsafe[1]); dbgPrint("Soft update in buffer %X at %u (%u bytes) - buffer playing at %u, unsafe region is %u to %u\n", (uintptr_t)context, offset, length, position, unsafe[0], unsafe[1]);
} }
@ -372,7 +374,7 @@ static void updateBufferData(segaapiContext_t *context, unsigned int offset, siz
alSourcei(context->alSource, AL_BUFFER, AL_NONE); alSourcei(context->alSource, AL_BUFFER, AL_NONE);
// CHECK(); // CHECK();
wrap_BufferSamples(context->alBuffer, context->sampleRate, alFormat, context->size / bufferSampleSize(context), alChannels, alType, context->data); alBufferSamplesSOFT(context->alBuffer, context->sampleRate, alFormat, context->size / bufferSampleSize(context), alChannels, alType, context->data);
// CHECK(); // CHECK();
alSourcei(context->alSource, AL_BUFFER, context->alBuffer); alSourcei(context->alSource, AL_BUFFER, context->alBuffer);
// CHECK(); // CHECK();
@ -1135,7 +1137,7 @@ int SEGAAPI_Init(void)
dbgPrint("SEGAAPI_Init() alutInit failed"); dbgPrint("SEGAAPI_Init() alutInit failed");
return SEGAERR_FAIL; return SEGAERR_FAIL;
} }
/*
alBufferSamplesSOFT = alGetProcAddress("alBufferSamplesSOFT"); alBufferSamplesSOFT = alGetProcAddress("alBufferSamplesSOFT");
if (alBufferSamplesSOFT == NULL) if (alBufferSamplesSOFT == NULL)
{ {
@ -1155,7 +1157,7 @@ int SEGAAPI_Init(void)
dbgPrint("Warning: Could not resolve AL extension!\n"); dbgPrint("Warning: Could not resolve AL extension!\n");
// exit(1); // exit(1);
} }
*/
SEGAAPI_SetGlobalEAXProperty((GUID *)&EAXPROPERTYID_EAX40_FXSlot2, 0, (void *)&EAX_NULL_GUID, 16); SEGAAPI_SetGlobalEAXProperty((GUID *)&EAXPROPERTYID_EAX40_FXSlot2, 0, (void *)&EAX_NULL_GUID, 16);
SEGAAPI_SetSPDIFOutChannelRouting(0, 0); SEGAAPI_SetSPDIFOutChannelRouting(0, 0);