2014-06-23 02:15:35 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "../Core/APU.h"
|
|
|
|
|
|
|
|
class SoundManager : public IAudioDevice
|
|
|
|
{
|
|
|
|
public:
|
2014-06-23 23:02:09 +00:00
|
|
|
SoundManager(HWND hWnd);
|
2014-06-23 02:15:35 +00:00
|
|
|
~SoundManager();
|
|
|
|
|
|
|
|
void Release();
|
|
|
|
void PlayBuffer(int16_t *soundBuffer, uint32_t bufferSize);
|
2014-06-23 17:52:53 +00:00
|
|
|
void Play();
|
|
|
|
void Pause();
|
|
|
|
void Reset();
|
2014-06-23 02:15:35 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool InitializeDirectSound(HWND);
|
|
|
|
void ShutdownDirectSound();
|
|
|
|
void ClearSecondaryBuffer();
|
|
|
|
void CopyToSecondaryBuffer(uint8_t *data, uint32_t size);
|
|
|
|
|
|
|
|
private:
|
2014-06-23 17:52:53 +00:00
|
|
|
uint16_t _lastWriteOffset = 0;
|
2015-07-18 00:58:57 +00:00
|
|
|
uint16_t _previousLatency = 0;
|
2014-06-23 17:52:53 +00:00
|
|
|
|
2014-06-23 02:15:35 +00:00
|
|
|
IDirectSound8* _directSound;
|
|
|
|
IDirectSoundBuffer* _primaryBuffer;
|
|
|
|
IDirectSoundBuffer8* _secondaryBuffer;
|
|
|
|
};
|