Create OpenAL device in main() and store in RGSSThreadData
This commit is contained in:
parent
3596fc568d
commit
5974d05380
|
@ -37,6 +37,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
struct RGSSThreadData;
|
struct RGSSThreadData;
|
||||||
|
typedef struct ALCdevice_struct ALCdevice;
|
||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
|
|
||||||
class EventThread
|
class EventThread
|
||||||
|
@ -225,6 +226,7 @@ struct RGSSThreadData
|
||||||
const char *argv0;
|
const char *argv0;
|
||||||
|
|
||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
|
ALCdevice *alcDev;
|
||||||
|
|
||||||
Vec2 sizeResoRatio;
|
Vec2 sizeResoRatio;
|
||||||
Vec2i screenOffset;
|
Vec2i screenOffset;
|
||||||
|
@ -236,10 +238,12 @@ struct RGSSThreadData
|
||||||
RGSSThreadData(EventThread *ethread,
|
RGSSThreadData(EventThread *ethread,
|
||||||
const char *argv0,
|
const char *argv0,
|
||||||
SDL_Window *window,
|
SDL_Window *window,
|
||||||
|
ALCdevice *alcDev,
|
||||||
const Config& newconf)
|
const Config& newconf)
|
||||||
: ethread(ethread),
|
: ethread(ethread),
|
||||||
argv0(argv0),
|
argv0(argv0),
|
||||||
window(window),
|
window(window),
|
||||||
|
alcDev(alcDev),
|
||||||
sizeResoRatio(1, 1),
|
sizeResoRatio(1, 1),
|
||||||
config(newconf)
|
config(newconf)
|
||||||
{}
|
{}
|
||||||
|
|
33
src/main.cpp
33
src/main.cpp
|
@ -108,22 +108,11 @@ int rgssThreadFun(void *userdata)
|
||||||
GLDebugLogger dLogger;
|
GLDebugLogger dLogger;
|
||||||
|
|
||||||
/* Setup AL context */
|
/* Setup AL context */
|
||||||
ALCdevice *alcDev = alcOpenDevice(0);
|
ALCcontext *alcCtx = alcCreateContext(threadData->alcDev, 0);
|
||||||
|
|
||||||
if (!alcDev)
|
|
||||||
{
|
|
||||||
rgssThreadError(threadData, "Error opening OpenAL device");
|
|
||||||
SDL_GL_DeleteContext(glCtx);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ALCcontext *alcCtx = alcCreateContext(alcDev, 0);
|
|
||||||
|
|
||||||
if (!alcCtx)
|
if (!alcCtx)
|
||||||
{
|
{
|
||||||
rgssThreadError(threadData, "Error creating OpenAL context");
|
rgssThreadError(threadData, "Error creating OpenAL context");
|
||||||
alcCloseDevice(alcDev);
|
|
||||||
SDL_GL_DeleteContext(glCtx);
|
SDL_GL_DeleteContext(glCtx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -139,7 +128,6 @@ int rgssThreadFun(void *userdata)
|
||||||
{
|
{
|
||||||
rgssThreadError(threadData, exc.msg);
|
rgssThreadError(threadData, exc.msg);
|
||||||
alcDestroyContext(alcCtx);
|
alcDestroyContext(alcCtx);
|
||||||
alcCloseDevice(alcDev);
|
|
||||||
SDL_GL_DeleteContext(glCtx);
|
SDL_GL_DeleteContext(glCtx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -154,8 +142,6 @@ int rgssThreadFun(void *userdata)
|
||||||
SharedState::finiInstance();
|
SharedState::finiInstance();
|
||||||
|
|
||||||
alcDestroyContext(alcCtx);
|
alcDestroyContext(alcCtx);
|
||||||
alcCloseDevice(alcDev);
|
|
||||||
|
|
||||||
SDL_GL_DeleteContext(glCtx);
|
SDL_GL_DeleteContext(glCtx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -284,8 +270,22 @@ int main(int argc, char *argv[])
|
||||||
SDL_FreeSurface(iconImg);
|
SDL_FreeSurface(iconImg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ALCdevice *alcDev = alcOpenDevice(0);
|
||||||
|
|
||||||
|
if (!alcDev)
|
||||||
|
{
|
||||||
|
showInitError("Error opening OpenAL device");
|
||||||
|
SDL_DestroyWindow(win);
|
||||||
|
TTF_Quit();
|
||||||
|
IMG_Quit();
|
||||||
|
SDL_Quit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
EventThread eventThread;
|
EventThread eventThread;
|
||||||
RGSSThreadData rtData(&eventThread, argv[0], win, conf);
|
RGSSThreadData rtData(&eventThread, argv[0], win,
|
||||||
|
alcDev, conf);
|
||||||
|
|
||||||
int winW, winH;
|
int winW, winH;
|
||||||
SDL_GetWindowSize(win, &winW, &winH);
|
SDL_GetWindowSize(win, &winW, &winH);
|
||||||
|
@ -338,6 +338,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
Debug() << "Shutting down.";
|
Debug() << "Shutting down.";
|
||||||
|
|
||||||
|
alcCloseDevice(alcDev);
|
||||||
SDL_DestroyWindow(win);
|
SDL_DestroyWindow(win);
|
||||||
|
|
||||||
Sound_Quit();
|
Sound_Quit();
|
||||||
|
|
Loading…
Reference in New Issue