added buffer count selection to OpenAL config dialog. default is 5
This commit is contained in:
parent
e3f1a33834
commit
7bf80601a1
|
@ -2009,8 +2009,13 @@ void MainWnd::OnOutputapiOalconfiguration()
|
|||
OALConfig dlg;
|
||||
|
||||
dlg.selectedDevice = theApp.oalDevice;
|
||||
dlg.bufferCount = theApp.oalBufferCount;
|
||||
|
||||
if( dlg.DoModal() == IDOK ) {
|
||||
systemSoundShutdown();
|
||||
// do this before changing any values OpenAL
|
||||
// might need for successful cleanup
|
||||
|
||||
if( theApp.oalDevice ) {
|
||||
free( theApp.oalDevice );
|
||||
theApp.oalDevice = NULL;
|
||||
|
@ -2018,8 +2023,8 @@ void MainWnd::OnOutputapiOalconfiguration()
|
|||
|
||||
theApp.oalDevice = (TCHAR*)malloc( (dlg.selectedDevice.GetLength() + 1) * sizeof( TCHAR ) );
|
||||
_tcscpy( theApp.oalDevice, dlg.selectedDevice.GetBuffer() );
|
||||
theApp.oalBufferCount = dlg.bufferCount;
|
||||
|
||||
systemSoundShutdown();
|
||||
systemSoundInit();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -19,6 +19,7 @@ IMPLEMENT_DYNAMIC(OALConfig, CDialog)
|
|||
OALConfig::OALConfig(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(OALConfig::IDD, pParent)
|
||||
, selectedDevice(_T(""))
|
||||
, bufferCount(0)
|
||||
{
|
||||
if( !LoadOAL10Library( NULL, &ALFunction ) ) {
|
||||
systemMessage( IDS_OAL_NODLL, "OpenAL32.dll could not be found on your system. Please install the runtime from http://openal.org" );
|
||||
|
@ -32,7 +33,7 @@ OALConfig::~OALConfig()
|
|||
void OALConfig::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_DEVICE, cbDevice);
|
||||
DDX_Control(pDX, IDC_DEVICE, m_cbDevice);
|
||||
|
||||
if( !pDX->m_bSaveAndValidate ) {
|
||||
// enumerate devices
|
||||
|
@ -40,7 +41,7 @@ void OALConfig::DoDataExchange(CDataExchange* pDX)
|
|||
devices = ALFunction.alcGetString( NULL, ALC_DEVICE_SPECIFIER );
|
||||
if( strlen( devices ) ) {
|
||||
while( *devices ) {
|
||||
cbDevice.AddString( devices );
|
||||
m_cbDevice.AddString( devices );
|
||||
devices += strlen( devices ) + 1;
|
||||
}
|
||||
} else {
|
||||
|
@ -48,23 +49,43 @@ void OALConfig::DoDataExchange(CDataExchange* pDX)
|
|||
}
|
||||
}
|
||||
DDX_CBString(pDX, IDC_DEVICE, selectedDevice);
|
||||
|
||||
DDX_Control(pDX, IDC_SLIDER_BUFFERCOUNT, m_sliderBufferCount);
|
||||
DDX_Slider(pDX, IDC_SLIDER_BUFFERCOUNT, bufferCount);
|
||||
DDX_Control(pDX, IDC_BUFFERINFO, m_bufferInfo);
|
||||
}
|
||||
|
||||
|
||||
BOOL OALConfig::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
m_sliderBufferCount.SetRange( 2, 10, FALSE );
|
||||
m_sliderBufferCount.SetTicFreq( 1 );
|
||||
m_sliderBufferCount.SetPos( bufferCount );
|
||||
|
||||
CString info;
|
||||
int pos = m_sliderBufferCount.GetPos();
|
||||
info.Format( _T("%i frames = %.2f ms"), pos, (float)pos / 60.0f * 1000.0f );
|
||||
m_bufferInfo.SetWindowText( info );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(OALConfig, CDialog)
|
||||
ON_WM_HSCROLL()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// OALConfig message handlers
|
||||
|
||||
#endif
|
||||
|
||||
void OALConfig::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
|
||||
{
|
||||
CString info;
|
||||
int pos = m_sliderBufferCount.GetPos();
|
||||
info.Format( _T("%i frames = %.2f ms"), pos, (float)pos / 60.0f * 1000.0f );
|
||||
m_bufferInfo.SetWindowText( info );
|
||||
|
||||
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <al.h>
|
||||
#include <alc.h>
|
||||
#include "LoadOAL.h"
|
||||
#include "afxcmn.h"
|
||||
|
||||
|
||||
// OALConfig dialog
|
||||
|
@ -28,10 +29,14 @@ protected:
|
|||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
CComboBox cbDevice;
|
||||
OPENALFNTABLE ALFunction;
|
||||
CComboBox m_cbDevice;
|
||||
CSliderCtrl m_sliderBufferCount;
|
||||
CStatic m_bufferInfo;
|
||||
public:
|
||||
CString selectedDevice;
|
||||
int bufferCount;
|
||||
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,6 +17,11 @@
|
|||
|
||||
#ifndef NO_OAL
|
||||
|
||||
|
||||
// === LOGALL writes very detailed informations to vba-trace.log ===
|
||||
//#define LOGALL
|
||||
|
||||
|
||||
#include "stdafx.h" // includes VBA.h for 'theApp.throttle'
|
||||
|
||||
// Interface
|
||||
|
@ -37,11 +42,6 @@
|
|||
// Debug
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#define NBUFFERS 5
|
||||
//#define LOGALL
|
||||
// LOGALL writes very detailed informations to vba-trace.log
|
||||
|
||||
#ifndef LOGALL
|
||||
#define winlog //
|
||||
#define debugState() //
|
||||
|
@ -65,7 +65,7 @@ private:
|
|||
bool buffersLoaded;
|
||||
ALCdevice *device;
|
||||
ALCcontext *context;
|
||||
ALuint buffer[NBUFFERS];
|
||||
ALuint *buffer;
|
||||
ALuint tempBuffer;
|
||||
ALuint source;
|
||||
int freq;
|
||||
|
@ -82,7 +82,8 @@ OpenAL::OpenAL()
|
|||
buffersLoaded = false;
|
||||
device = NULL;
|
||||
context = NULL;
|
||||
memset( buffer, 0, NBUFFERS * sizeof( ALuint ) );
|
||||
buffer = (ALuint*)malloc( theApp.oalBufferCount * sizeof( ALuint ) );
|
||||
memset( buffer, 0, theApp.oalBufferCount * sizeof( ALuint ) );
|
||||
tempBuffer = 0;
|
||||
source = 0;
|
||||
}
|
||||
|
@ -101,9 +102,11 @@ OpenAL::~OpenAL()
|
|||
ALFunction.alDeleteSources( 1, &source );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
ALFunction.alDeleteBuffers( NBUFFERS, buffer );
|
||||
ALFunction.alDeleteBuffers( theApp.oalBufferCount, buffer );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
free( buffer );
|
||||
|
||||
ALFunction.alcMakeContextCurrent( NULL );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
|
@ -179,7 +182,7 @@ bool OpenAL::init()
|
|||
ALCboolean retVal = ALFunction.alcMakeContextCurrent( context );
|
||||
assert( ALC_TRUE == retVal );
|
||||
|
||||
ALFunction.alGenBuffers( NBUFFERS, buffer );
|
||||
ALFunction.alGenBuffers( theApp.oalBufferCount, buffer );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
ALFunction.alGenSources( 1, &source );
|
||||
|
@ -266,13 +269,13 @@ void OpenAL::write()
|
|||
if( !buffersLoaded ) {
|
||||
// ==initial buffer filling==
|
||||
winlog( " initial buffer filling\n" );
|
||||
for( int i = 0 ; i < NBUFFERS ; i++ ) {
|
||||
for( int i = 0 ; i < theApp.oalBufferCount ; i++ ) {
|
||||
// filling the buffers explicitly with silence would be cleaner...
|
||||
ALFunction.alBufferData( buffer[i], AL_FORMAT_STEREO16, soundFinalWave, soundBufferLen, freq );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
}
|
||||
|
||||
ALFunction.alSourceQueueBuffers( source, NBUFFERS, buffer );
|
||||
ALFunction.alSourceQueueBuffers( source, theApp.oalBufferCount, buffer );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
buffersLoaded = true;
|
||||
|
@ -282,7 +285,7 @@ void OpenAL::write()
|
|||
ALFunction.alGetSourcei( source, AL_BUFFERS_PROCESSED, &nBuffersProcessed );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
if( nBuffersProcessed == NBUFFERS ) {
|
||||
if( nBuffersProcessed == theApp.oalBufferCount ) {
|
||||
static int i = 0;
|
||||
log( "OpenAL: Buffers were not refilled fast enough (%i)\n", i++ );
|
||||
}
|
||||
|
|
|
@ -280,6 +280,7 @@ VBA::VBA()
|
|||
audioAPI = DIRECTSOUND;
|
||||
#ifndef NO_OAL
|
||||
oalDevice = NULL;
|
||||
oalBufferCount = 5;
|
||||
#endif
|
||||
iconic = false;
|
||||
ddrawEmulationOnly = false;
|
||||
|
@ -1714,6 +1715,8 @@ void VBA::loadSettings()
|
|||
}
|
||||
oalDevice = (TCHAR*)malloc( ( buffer.GetLength() + 1 ) * sizeof( TCHAR ) );
|
||||
_tcscpy( oalDevice, buffer.GetBuffer() );
|
||||
|
||||
oalBufferCount = regQueryDwordValue( "oalBufferCount", 5 );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2695,6 +2698,7 @@ void VBA::saveSettings()
|
|||
|
||||
#ifndef NO_OAL
|
||||
regSetStringValue( "oalDevice", oalDevice );
|
||||
regSetDwordValue( "oalBufferCount", oalBufferCount );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -155,6 +155,7 @@ class VBA : public CWinApp
|
|||
AUDIO_API audioAPI;
|
||||
#ifndef NO_OAL
|
||||
TCHAR *oalDevice;
|
||||
int oalBufferCount;
|
||||
#endif
|
||||
bool iconic;
|
||||
bool ddrawEmulationOnly;
|
||||
|
|
|
@ -26,15 +26,18 @@ LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
|
|||
// Dialog
|
||||
//
|
||||
|
||||
IDD_OAL_CONFIG DIALOGEX 0, 0, 167, 53
|
||||
IDD_OAL_CONFIG DIALOGEX 0, 0, 167, 114
|
||||
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
|
||||
DEFPUSHBUTTON "OK",IDOK,66,96,48,12
|
||||
PUSHBUTTON "Cancel",IDCANCEL,114,96,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
|
||||
GROUPBOX "Sound Buffer Count",IDC_STATIC,6,36,156,54
|
||||
CONTROL "",IDC_SLIDER_BUFFERCOUNT,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,12,48,144,24
|
||||
CTEXT "bufferInfo",IDC_BUFFERINFO,12,72,144,12,0,WS_EX_DLGMODALFRAME
|
||||
END
|
||||
|
||||
|
||||
|
@ -51,7 +54,7 @@ BEGIN
|
|||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 160
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 46
|
||||
BOTTOMMARGIN, 107
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
|
|
@ -512,6 +512,8 @@
|
|||
#define IDC_LY 1267
|
||||
#define IDC_APPENDMODE 1268
|
||||
#define IDC_DEVICE 1269
|
||||
#define IDC_SLIDER_BUFFERCOUNT 1270
|
||||
#define IDC_BUFFERINFO 1271
|
||||
#define ID_HELP_ABOUT 40001
|
||||
#define ID_FILE_EXIT 40002
|
||||
#define ID_OPTIONS_VIDEO_FRAMESKIP_0 40003
|
||||
|
@ -821,7 +823,7 @@
|
|||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 161
|
||||
#define _APS_NEXT_COMMAND_VALUE 40353
|
||||
#define _APS_NEXT_CONTROL_VALUE 1270
|
||||
#define _APS_NEXT_CONTROL_VALUE 1272
|
||||
#define _APS_NEXT_SYMED_VALUE 103
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue