openMSX
DirectXSoundDriver.hh
Go to the documentation of this file.
1 #ifndef DIRECTXSOUNDDRIVER_HH
2 #define DIRECTXSOUNDDRIVER_HH
3 #ifdef _WIN32
4 
5 #include "SoundDriver.hh"
6 #ifdef WIN32_LEAN_AND_MEAN
7 #undef WIN32_LEAN_AND_MEAN // Needed for <dsound.h>
8 #endif
9 #define DIRECTSOUND_VERSION 0x0500
10 #include <windows.h>
11 #include <dsound.h>
12 
13 namespace openmsx {
14 
15 class DirectXSoundDriver final : public SoundDriver
16 {
17 public:
18  DirectXSoundDriver(const DirectXSoundDriver&) = delete;
19  DirectXSoundDriver& operator=(const DirectXSoundDriver&) = delete;
20 
21  DirectXSoundDriver(unsigned sampleRate, unsigned bufferSize);
22  ~DirectXSoundDriver();
23 
24  void mute() override;
25  void unmute() override;
26 
27  unsigned getFrequency() const override;
28  unsigned getSamples() const override;
29 
30  void uploadBuffer(short* buffer, unsigned len) override;
31 
32 private:
33  void dxClear();
34  int dxCanWrite(unsigned start, unsigned size);
35  void dxWriteOne(short* buffer, unsigned lockSize);
36 
37  enum DxState { DX_SOUND_DISABLED, DX_SOUND_ENABLED, DX_SOUND_RUNNING };
38  DxState state;
39  unsigned bufferOffset;
40  unsigned bufferSize;
41  unsigned fragmentSize;
42  int skipCount;
43  LPDIRECTSOUNDBUFFER primaryBuffer;
44  LPDIRECTSOUNDBUFFER secondaryBuffer;
45  LPDIRECTSOUND directSound;
46 
47  unsigned frequency;
48 };
49 
50 } // namespace openmsx
51 
52 #endif // _WIN32
53 #endif // DIRECTXSOUNDDRIVER_HH
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
size_t size() const