Implement fullscreen and add sound
This commit is contained in:
parent
e9352c051a
commit
f6c983c156
@ -27,7 +27,7 @@
|
||||
#include "tsf.h"
|
||||
|
||||
//#define DEBUG_SAMPLE
|
||||
#define DEBUG_OUTPUT
|
||||
// #define DEBUG_OUTPUT
|
||||
//#define DUMP_WAV
|
||||
//#define DUMP_BUFFER
|
||||
|
||||
@ -162,6 +162,7 @@ static unsigned int bufferSampleSize(segaapiContext_t *context)
|
||||
|
||||
static void updateBufferLoop(segaapiContext_t *context)
|
||||
{
|
||||
return;
|
||||
if (context == NULL)
|
||||
return;
|
||||
|
||||
@ -176,16 +177,6 @@ static void updateBufferLoop(segaapiContext_t *context)
|
||||
*/
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@ -236,37 +227,29 @@ static void updateBufferData(segaapiContext_t *context, unsigned int offset, siz
|
||||
abort();
|
||||
}
|
||||
|
||||
ALint position;
|
||||
alGetSourcei(context->alSource, AL_SAMPLE_OFFSET, &position); // TODO: Patch if looping is active
|
||||
|
||||
ALint unsafe[2];
|
||||
alGetSourceiv(context->alSource, AL_BYTE_RW_OFFSETS_SOFT, unsafe); // AL_BYTE_OFFSET
|
||||
|
||||
// We should update the playing buffer
|
||||
// OpenAL doesn't want to let us do this!!
|
||||
if (offset != -1)
|
||||
{
|
||||
|
||||
// alBufferSubSamplesSOFT(context->alBuffer, offset / bufferSampleSize(context), length / bufferSampleSize(context), alChannels, alType, &context->data[offset], context->sampleRate, alFormat);
|
||||
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]);
|
||||
unsigned int sampleSize = bufferSampleSize(context);
|
||||
|
||||
ALint position;
|
||||
alGetSourcei(context->alSource, AL_BYTE_OFFSET, &position);
|
||||
alGetSourcei(context->alSource, AL_SAMPLE_OFFSET, &position);
|
||||
|
||||
alSourcei(context->alSource, AL_BUFFER, AL_NONE);
|
||||
// alBufferData(context->alBuffer, alFormat, context->data + (offset / sampleSize), FramesToBytes(context->size / bufferSampleSize(context), alChannels, alType), context->sampleRate);
|
||||
alBufferData(context->alBuffer, alFormat, context->data, FramesToBytes(context->size / bufferSampleSize(context), alChannels, alType), context->sampleRate);
|
||||
alSourcei(context->alSource, AL_BUFFER, context->alBuffer);
|
||||
alSourcei(context->alSource, AL_BYTE_OFFSET, position);
|
||||
|
||||
|
||||
alSourcei(context->alSource, AL_SAMPLE_OFFSET, position);
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear the buffer and write again
|
||||
alSourcei(context->alSource, AL_BUFFER, AL_NONE);
|
||||
alBufferData(context->alBuffer, alFormat, context->data, FramesToBytes(context->size / bufferSampleSize(context), alChannels, alType), context->sampleRate);
|
||||
alSourcei(context->alSource, AL_BUFFER, context->alBuffer);
|
||||
|
||||
// updateBufferLoop(context);
|
||||
dbgPrint("Hard update in buffer %X (%u bytes) - buffer playing at %u, unsafe region is %u to %u\n", (uintptr_t)context, context->size, position, unsafe[0], unsafe[1]);
|
||||
}
|
||||
|
||||
static void resetBuffer(segaapiContext_t *context)
|
||||
@ -320,7 +303,8 @@ int SEGAAPI_Play(void *hHandle)
|
||||
if (context == NULL)
|
||||
return SEGAERR_BAD_PARAM;
|
||||
|
||||
alSourcei(context->alSource, AL_LOOPING, context->loop ? AL_TRUE : AL_FALSE);
|
||||
// alSourcei(context->alSource, AL_LOOPING, context->loop ? AL_TRUE : AL_FALSE);
|
||||
alSourcei(context->alSource, AL_LOOPING, AL_FALSE);
|
||||
alSourcei(context->alSource, AL_BUFFER, context->alBuffer);
|
||||
alSourcePlay(context->alSource);
|
||||
return SEGA_SUCCESS;
|
||||
|
@ -1,9 +1,11 @@
|
||||
#include <GL/freeglut.h>
|
||||
#include <GL/glx.h>
|
||||
#include <X11/extensions/xf86vmode.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "jvs.h"
|
||||
@ -76,15 +78,20 @@ Window XCreateWindow(Display *display, Window parent, int x, int y, unsigned int
|
||||
width = getConfig()->width;
|
||||
height = getConfig()->height;
|
||||
|
||||
width = 10;
|
||||
height = 10;
|
||||
|
||||
// Ensure that the windows will respond with keyboard and mouse events
|
||||
attributes->event_mask = attributes->event_mask | KeyPressMask | KeyReleaseMask | PointerMotionMask;
|
||||
attributes->override_redirect = 0;
|
||||
// attributes->override_redirect = False;
|
||||
|
||||
Window window = _XCreateWindow(display, parent, x, y, width, height, border_width, depth, class, visual, valueMask, attributes);
|
||||
printf("%d %d %d %d\n", x, y, width, height);
|
||||
|
||||
if (getConfig()->fullscreen)
|
||||
{
|
||||
Atom wm_state = XInternAtom(display, "_NET_WM_STATE", true);
|
||||
Atom wm_fullscreen = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", true);
|
||||
XChangeProperty(display, window, wm_state, XA_ATOM, 32, PropModeReplace, (unsigned char *)&wm_fullscreen, 1);
|
||||
}
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user