diff --git a/VBA.vcproj b/VBA.vcproj
index 1ba400a0..8be787e6 100644
--- a/VBA.vcproj
+++ b/VBA.vcproj
@@ -1,7 +1,7 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -548,6 +538,16 @@
Outputs=""$(IntDir)\$(InputName).obj""
/>
+
+
+
@@ -623,16 +623,6 @@
Outputs=""$(IntDir)\$(InputName).obj""
/>
-
-
-
@@ -643,6 +633,16 @@
Outputs=""$(IntDir)\$(InputName).obj""
/>
+
+
+
@@ -667,16 +667,6 @@
Outputs=""$(IntDir)\$(InputName).obj""
/>
-
-
-
@@ -687,6 +677,16 @@
Outputs=""$(IntDir)\$(InputName).obj""
/>
+
+
+
@@ -711,16 +711,6 @@
Outputs=""$(IntDir)\$(InputName).obj""
/>
-
-
-
@@ -731,6 +721,16 @@
Outputs=""$(IntDir)\$(InputName).obj""
/>
+
+
+
@@ -755,16 +755,6 @@
Outputs=""$(IntDir)\$(InputName).obj""
/>
-
-
-
@@ -775,6 +765,16 @@
Outputs=""$(IntDir)\$(InputName).obj""
/>
+
+
+
@@ -1175,30 +1175,6 @@
RelativePath=".\src\win32\Logging.cpp"
>
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1223,6 +1199,10 @@
RelativePath=".\src\win32\ModeConfirm.cpp"
>
+
+
@@ -1331,6 +1311,34 @@
>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/win32/MainWnd.cpp b/src/win32/MainWnd.cpp
index 0bb23604..f9db5f1c 100644
--- a/src/win32/MainWnd.cpp
+++ b/src/win32/MainWnd.cpp
@@ -456,6 +456,7 @@ BEGIN_MESSAGE_MAP(MainWnd, CWnd)
ON_UPDATE_COMMAND_UI(ID_OUTPUTAPI_DIRECTSOUND, &MainWnd::OnUpdateOutputapiDirectsound)
ON_COMMAND(ID_OUTPUTAPI_OPENAL, &MainWnd::OnOutputapiOpenal)
ON_UPDATE_COMMAND_UI(ID_OUTPUTAPI_OPENAL, &MainWnd::OnUpdateOutputapiOpenal)
+ ON_COMMAND(ID_OUTPUTAPI_OALCONFIGURATION, &MainWnd::OnOutputapiOalconfiguration)
END_MESSAGE_MAP()
diff --git a/src/win32/MainWnd.h b/src/win32/MainWnd.h
index 43605e43..3cf22f43 100644
--- a/src/win32/MainWnd.h
+++ b/src/win32/MainWnd.h
@@ -456,6 +456,7 @@ public:
afx_msg void OnUpdateOutputapiDirectsound(CCmdUI *pCmdUI);
afx_msg void OnOutputapiOpenal();
afx_msg void OnUpdateOutputapiOpenal(CCmdUI *pCmdUI);
+ afx_msg void OnOutputapiOalconfiguration();
};
/////////////////////////////////////////////////////////////////////////////
diff --git a/src/win32/MainWndOptions.cpp b/src/win32/MainWndOptions.cpp
index e3df7f08..59c34091 100644
--- a/src/win32/MainWndOptions.cpp
+++ b/src/win32/MainWndOptions.cpp
@@ -34,6 +34,7 @@
#include "Throttle.h"
#include "WinResUtil.h"
#include "SelectPlugin.h"
+#include "OALConfig.h"
#include "../System.h"
#include "../agbprint.h"
@@ -1990,3 +1991,24 @@ void MainWnd::OnUpdateOutputapiOpenal(CCmdUI *pCmdUI)
#endif
}
+void MainWnd::OnOutputapiOalconfiguration()
+{
+#ifndef NO_OAL
+ OALConfig dlg;
+
+ dlg.selectedDevice = theApp.oalDevice;
+
+ if( dlg.DoModal() == IDOK ) {
+ if( theApp.oalDevice ) {
+ free( theApp.oalDevice );
+ theApp.oalDevice = NULL;
+ }
+
+ theApp.oalDevice = (TCHAR*)malloc( (dlg.selectedDevice.GetLength() + 1) * sizeof( TCHAR ) );
+ _tcscpy( theApp.oalDevice, dlg.selectedDevice.GetBuffer() );
+
+ systemSoundShutdown();
+ systemSoundInit();
+ }
+#endif
+}
diff --git a/src/win32/OALConfig.cpp b/src/win32/OALConfig.cpp
new file mode 100644
index 00000000..c82fa1df
--- /dev/null
+++ b/src/win32/OALConfig.cpp
@@ -0,0 +1,67 @@
+// src/win32/OALConfig.cpp : implementation file
+//
+
+#ifndef NO_OAL
+
+#include "stdafx.h"
+#include "OALConfig.h"
+
+// OpenAL
+#include
+#include
+#pragma comment( lib, "OpenAL32.lib" )
+
+
+// OALConfig dialog
+
+IMPLEMENT_DYNAMIC(OALConfig, CDialog)
+
+OALConfig::OALConfig(CWnd* pParent /*=NULL*/)
+ : CDialog(OALConfig::IDD, pParent)
+ , selectedDevice(_T(""))
+{
+
+}
+
+OALConfig::~OALConfig()
+{
+}
+
+void OALConfig::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_DEVICE, cbDevice);
+
+ if( !pDX->m_bSaveAndValidate ) {
+ // enumerate devices
+ const ALchar *devices = NULL;
+ devices = alcGetString( NULL, ALC_DEVICE_SPECIFIER );
+ if( strlen( devices ) ) {
+ while( *devices ) {
+ cbDevice.AddString( devices );
+ devices += strlen( devices ) + 1;
+ }
+ } else {
+ systemMessage( IDS_OAL_NODEVICE, "There are no sound devices present on this system." );
+ }
+ }
+ DDX_CBString(pDX, IDC_DEVICE, selectedDevice);
+
+}
+
+
+BOOL OALConfig::OnInitDialog()
+{
+ CDialog::OnInitDialog();
+
+ return TRUE;
+}
+
+
+BEGIN_MESSAGE_MAP(OALConfig, CDialog)
+END_MESSAGE_MAP()
+
+
+// OALConfig message handlers
+
+#endif
diff --git a/src/win32/OALConfig.h b/src/win32/OALConfig.h
new file mode 100644
index 00000000..7dd522b3
--- /dev/null
+++ b/src/win32/OALConfig.h
@@ -0,0 +1,31 @@
+#ifndef NO_OAL
+
+#pragma once
+#include "afxwin.h"
+
+
+// OALConfig dialog
+
+class OALConfig : public CDialog
+{
+ DECLARE_DYNAMIC(OALConfig)
+
+public:
+ OALConfig(CWnd* pParent = NULL); // standard constructor
+ virtual ~OALConfig();
+
+// Dialog Data
+ enum { IDD = IDD_OAL_CONFIG };
+
+protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+
+ DECLARE_MESSAGE_MAP()
+private:
+ CComboBox cbDevice;
+public:
+ CString selectedDevice;
+};
+
+#endif
diff --git a/src/win32/OpenAL.cpp b/src/win32/OpenAL.cpp
index 65a6aefe..8ba592d0 100644
--- a/src/win32/OpenAL.cpp
+++ b/src/win32/OpenAL.cpp
@@ -62,7 +62,6 @@ public:
private:
bool initialized;
bool buffersLoaded;
- bool playing;
ALCdevice *device;
ALCcontext *context;
ALuint buffer[NBUFFERS];
@@ -80,7 +79,6 @@ OpenAL::OpenAL()
{
initialized = false;
buffersLoaded = false;
- playing = false;
device = NULL;
context = NULL;
memset( buffer, 0, NBUFFERS * sizeof( ALuint ) );
@@ -121,7 +119,7 @@ void OpenAL::debugState()
alGetSourcei( source, AL_SOURCE_STATE, &value );
assert( AL_NO_ERROR == alGetError() );
- winlog( " playing = %i\n", playing );
+ winlog( " soundPaused = %i\n", soundPaused );
winlog( " Source:\n" );
winlog( " State: " );
switch( value )
@@ -160,7 +158,11 @@ bool OpenAL::init()
winlog( "OpenAL::init\n" );
assert( initialized == false );
- device = alcOpenDevice( theApp.OpenALAudiomixing ? "Generic Software" : NULL );
+ if( theApp.oalDevice ) {
+ device = alcOpenDevice( theApp.oalDevice );
+ } else {
+ device = alcOpenDevice( NULL );
+ }
assert( device != NULL );
context = alcCreateContext( device, NULL );
@@ -175,20 +177,7 @@ bool OpenAL::init()
alGenSources( 1, &source );
assert( AL_NO_ERROR == alGetError() );
- switch( soundQuality )
- {
- case 4:
- freq = 11025;
- break;
- case 2:
- freq = 22050;
- break;
- default:
- soundQuality = 1;
- case 1:
- freq = 44100;
- break;
- }
+ freq = 44100 / soundQuality;
soundBufferLen = freq * 2 * 2 / 60;
// 16bit stereo, buffer can store the sound for 1 frame in 60Hz
@@ -204,7 +193,6 @@ void OpenAL::resume()
{
winlog( "OpenAL::resume\n" );
assert( initialized );
- playing = true;
if( !buffersLoaded ) return;
debugState();
@@ -224,7 +212,6 @@ void OpenAL::pause()
{
winlog( "OpenAL::pause\n" );
assert( initialized );
- playing = false;
if( !buffersLoaded ) return;
debugState();
@@ -244,7 +231,6 @@ void OpenAL::reset()
{
winlog( "OpenAL::reset\n" );
assert( initialized );
- playing = false;
if( !buffersLoaded ) return;
debugState();
@@ -319,7 +305,7 @@ void OpenAL::write()
// start playing the source if necessary
alGetSourcei( source, AL_SOURCE_STATE, &sourceState );
assert( AL_NO_ERROR == alGetError() );
- if( playing && ( sourceState != AL_PLAYING ) ) {
+ if( !soundPaused && ( sourceState != AL_PLAYING ) ) {
alSourcePlay( source );
assert( AL_NO_ERROR == alGetError() );
}
diff --git a/src/win32/VBA.cpp b/src/win32/VBA.cpp
index 361a744c..410c17ee 100644
--- a/src/win32/VBA.cpp
+++ b/src/win32/VBA.cpp
@@ -278,6 +278,9 @@ VBA::VBA()
pVideoDriverGUID = NULL;
renderMethod = DIRECT_DRAW;
audioAPI = DIRECTSOUND;
+#ifndef NO_OAL
+ oalDevice = NULL;
+#endif
iconic = false;
ddrawEmulationOnly = false;
ddrawUsingEmulationOnly = false;
@@ -304,7 +307,6 @@ VBA::VBA()
input = NULL;
joypadDefault = 0;
autoFire = 0;
- OpenALAudiomixing = false;
autoFireToggle = false;
winPauseNextFrame = false;
soundRecording = false;
@@ -418,6 +420,12 @@ VBA::~VBA()
if(rewindMemory)
free(rewindMemory);
+
+#ifndef NO_OAL
+ if( oalDevice ) {
+ free( oalDevice );
+ }
+#endif
}
/////////////////////////////////////////////////////////////////////////////
@@ -1421,7 +1429,6 @@ void VBA::loadSettings()
audioAPI = DIRECTSOUND;
}
- OpenALAudiomixing = regQueryDwordValue( "OpenALAudiomixing", 0 );
windowPositionX = regQueryDwordValue("windowX", 0);
if(windowPositionX < 0)
windowPositionX = 0;
@@ -1649,6 +1656,15 @@ void VBA::loadSettings()
}
Sm60FPS::bSaveMoreCPU = regQueryDwordValue("saveMoreCPU", 0);
+
+#ifndef NO_OAL
+ buffer = regQueryStringValue( "oalDevice", "" );
+ if( oalDevice ) {
+ free( oalDevice );
+ }
+ oalDevice = (TCHAR*)malloc( ( buffer.GetLength() + 1 ) * sizeof( TCHAR ) );
+ _tcscpy( oalDevice, buffer.GetBuffer() );
+#endif
}
void VBA::updateFrameSkip()
@@ -2484,8 +2500,6 @@ void VBA::saveSettings()
regSetDwordValue("autoFrameSkip", autoFrameSkip);
- regSetDwordValue( "OpenALAudiomixing", OpenALAudiomixing);
-
regSetDwordValue("vsync", vsync);
regSetDwordValue("synchronize", synchronize);
regSetDwordValue("stretch", fullScreenStretch);
@@ -2620,6 +2634,10 @@ void VBA::saveSettings()
regSetDwordValue("Linklog", linklog);
regSetDwordValue("RFU", adapter);
regSetDwordValue("linkEnabled", linkenable);
+
+#ifndef NO_OAL
+ regSetStringValue( "oalDevice", oalDevice );
+#endif
}
void winSignal(int, int)
diff --git a/src/win32/VBA.h b/src/win32/VBA.h
index f67402c5..977a083a 100644
--- a/src/win32/VBA.h
+++ b/src/win32/VBA.h
@@ -148,12 +148,14 @@ class VBA : public CWinApp
u32 autoFrameSkipLastTime;
bool autoFrameSkip;
bool vsync;
- bool OpenALAudiomixing;
bool changingVideoSize;
GUID videoDriverGUID;
GUID *pVideoDriverGUID;
DISPLAY_TYPE renderMethod;
AUDIO_API audioAPI;
+#ifndef NO_OAL
+ TCHAR *oalDevice;
+#endif
bool iconic;
bool ddrawEmulationOnly;
bool ddrawUsingEmulationOnly;
diff --git a/src/win32/VBA.rc b/src/win32/VBA.rc
index 04d9d0b1..570d0683 100644
--- a/src/win32/VBA.rc
+++ b/src/win32/VBA.rc
@@ -12,6 +12,54 @@
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+// German (Germany) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
+#ifdef _WIN32
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_OAL_CONFIG DIALOGEX 0, 0, 167, 53
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "OpenAL configuration"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,66,36,48,12
+ PUSHBUTTON "Cancel",IDCANCEL,114,36,48,12
+ COMBOBOX IDC_DEVICE,6,18,156,36,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Select device:",IDC_STATIC,6,6,156,12
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_OAL_CONFIG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 160
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 46
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // German (Germany) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
@@ -1660,6 +1708,7 @@ BEGIN
MENUITEM " Use &old synchronization", ID_OPTIONS_SOUND_USEOLDSYNCHRONIZATION
MENUITEM SEPARATOR
MENUITEM "OpenAL", ID_OUTPUTAPI_OPENAL
+ MENUITEM " Configuration...", ID_OUTPUTAPI_OALCONFIGURATION
MENUITEM SEPARATOR
MENUITEM "&Sync game to audio", ID_OPTIONS_EMULATOR_SYNCHRONIZE
END
@@ -2151,6 +2200,7 @@ BEGIN
"Invalid rewind interval value. Please enter a number between 0 and 600 seconds."
IDS_REGISTRY "VisualBoyAdvance no longer uses the registry to store its settings. Your previous settings have been exported into the file: %s"
IDS_MOVIE_PLAY "Playing a movie will load a save state which may erase your previous battery saves. Please be sure to have a saved state if you don't want to loose any previous data."
+ IDS_OAL_NODEVICE "There are no sound devices present on this system."
END
#endif // English (U.S.) resources
diff --git a/src/win32/resource.h b/src/win32/resource.h
index a46d8254..354ac4c7 100644
--- a/src/win32/resource.h
+++ b/src/win32/resource.h
@@ -97,6 +97,7 @@
#define IDD_GAME_OVERRIDES 156
#define IDD_SELECT 159
#define IDD_SELECT_PLUGIN 159
+#define IDD_OAL_CONFIG 160
#define IDC_R0 1000
#define IDC_EDIT_UP 1000
#define IDC_R1 1001
@@ -379,6 +380,7 @@
#define IDC_SAVE_OBJ 1138
#define IDC_MAP_VIEW_ZOOM 1138
#define IDS_MOVIE_PLAY 1138
+#define IDS_OAL_NODEVICE 1139
#define IDC_VIEWER 1140
#define IDC_ADDRESSES 1141
#define IDC_GO 1143
@@ -508,6 +510,7 @@
#define IDC_MIRRORING 1266
#define IDC_LY 1267
#define IDC_APPENDMODE 1268
+#define IDC_DEVICE 1269
#define ID_HELP_ABOUT 40001
#define ID_FILE_EXIT 40002
#define ID_OPTIONS_VIDEO_FRAMESKIP_0 40003
@@ -807,14 +810,16 @@
#define ID_OUTPUTAPI_DIRECTSOUND 40346
#define ID_OUTPUTAPI_OPENAL 40347
#define ID_OUTPUTAPI_SOFTWAREMIXING 40348
+#define ID_OUTPUTAPI_CONFIGURATION 40349
+#define ID_OUTPUTAPI_OALCONFIGURATION 40350
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 159
-#define _APS_NEXT_COMMAND_VALUE 40349
-#define _APS_NEXT_CONTROL_VALUE 1269
+#define _APS_NEXT_RESOURCE_VALUE 161
+#define _APS_NEXT_COMMAND_VALUE 40351
+#define _APS_NEXT_CONTROL_VALUE 1270
#define _APS_NEXT_SYMED_VALUE 103
#endif
#endif