2018-11-15 23:31:39 +00:00
|
|
|
/*****************************************************************************\
|
|
|
|
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
|
|
|
This file is licensed under the Snes9x License.
|
|
|
|
For further information, consult the LICENSE file in the root directory.
|
|
|
|
\*****************************************************************************/
|
2010-09-25 15:46:12 +00:00
|
|
|
|
|
|
|
#ifndef CXHAUDIO2_H
|
|
|
|
#define CXAUDIO2_H
|
|
|
|
#include "XAudio2.h"
|
|
|
|
#include "../snes9x.h"
|
|
|
|
#include <windows.h>
|
|
|
|
#include "IS9xSoundOutput.h"
|
|
|
|
|
|
|
|
class CXAudio2 : public IXAudio2VoiceCallback, public IS9xSoundOutput
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
IXAudio2SourceVoice *pSourceVoice;
|
|
|
|
IXAudio2 *pXAudio2;
|
|
|
|
IXAudio2MasteringVoice* pMasterVoice;
|
|
|
|
|
|
|
|
bool initDone; // has init been called successfully?
|
|
|
|
|
|
|
|
volatile LONG bufferCount; // currently submitted XAudio2 buffers
|
|
|
|
|
|
|
|
UINT32 sum_bufferSize; // the size of soundBuffer
|
|
|
|
UINT32 singleBufferSamples; // samples in one block
|
|
|
|
UINT32 singleBufferBytes; // bytes in one block
|
|
|
|
UINT32 blockCount; // soundBuffer is divided into blockCount blocks
|
2019-02-06 23:29:46 +00:00
|
|
|
// currently set to 8
|
2010-09-25 15:46:12 +00:00
|
|
|
UINT32 writeOffset; // offset into the buffer for the next block
|
2019-02-06 23:29:46 +00:00
|
|
|
UINT32 partialOffset; // offset into non-complete block
|
2010-09-25 15:46:12 +00:00
|
|
|
uint8 *soundBuffer; // the buffer itself
|
|
|
|
|
|
|
|
bool InitVoices(void);
|
|
|
|
void DeInitVoices(void);
|
|
|
|
|
|
|
|
void PushBuffer(UINT32 AudioBytes,BYTE *pAudioData,void *pContext);
|
|
|
|
void BeginPlayback(void);
|
|
|
|
void StopPlayback(void);
|
|
|
|
void ProcessSound(void);
|
|
|
|
bool InitXAudio2(void);
|
|
|
|
void DeInitXAudio2(void);
|
|
|
|
|
2018-12-15 13:19:16 +00:00
|
|
|
std::vector<std::wstring> GetDeviceList();
|
|
|
|
int FindDeviceIndex(TCHAR *audio_device);
|
|
|
|
|
2010-09-25 15:46:12 +00:00
|
|
|
public:
|
|
|
|
CXAudio2(void);
|
|
|
|
~CXAudio2(void);
|
|
|
|
|
|
|
|
// inherited from IXAudio2VoiceCallback - we only use OnBufferEnd
|
|
|
|
STDMETHODIMP_(void) OnBufferEnd(void *pBufferContext);
|
|
|
|
STDMETHODIMP_(void) OnBufferStart(void *pBufferContext){}
|
|
|
|
STDMETHODIMP_(void) OnLoopEnd(void *pBufferContext){}
|
|
|
|
STDMETHODIMP_(void) OnStreamEnd() {}
|
|
|
|
STDMETHODIMP_(void) OnVoiceError(void *pBufferContext, HRESULT Error) {}
|
|
|
|
STDMETHODIMP_(void) OnVoiceProcessingPassEnd() {}
|
|
|
|
STDMETHODIMP_(void) OnVoiceProcessingPassStart(UINT32 BytesRequired) {}
|
|
|
|
|
|
|
|
|
|
|
|
// Inherited from IS9xSoundOutput
|
|
|
|
bool InitSoundOutput(void) { return InitXAudio2(); }
|
|
|
|
void DeInitSoundOutput(void) { DeInitXAudio2(); }
|
|
|
|
bool SetupSound(void);
|
2017-11-24 23:10:44 +00:00
|
|
|
void SetVolume(double volume);
|
2010-09-25 15:46:12 +00:00
|
|
|
};
|
|
|
|
|
2018-11-15 23:31:39 +00:00
|
|
|
#endif
|