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 #include "noncopyable.hh"
7 #ifdef WIN32_LEAN_AND_MEAN
8 #undef WIN32_LEAN_AND_MEAN // Needed for <dsound.h>
9 #endif
10 #define DIRECTSOUND_VERSION 0x0500
11 #include <windows.h>
12 #include <dsound.h>
13 
14 namespace openmsx {
15 
16 class DirectXSoundDriver final : public SoundDriver, private noncopyable
17 {
18 public:
19  DirectXSoundDriver(unsigned sampleRate, unsigned bufferSize);
20  ~DirectXSoundDriver();
21 
22  void mute() override;
23  void unmute() override;
24 
25  unsigned getFrequency() const override;
26  unsigned getSamples() const override;
27 
28  void uploadBuffer(short* buffer, unsigned len) override;
29 
30 private:
31  void dxClear();
32  int dxCanWrite(unsigned start, unsigned size);
33  void dxWriteOne(short* buffer, unsigned lockSize);
34 
35  enum DxState { DX_SOUND_DISABLED, DX_SOUND_ENABLED, DX_SOUND_RUNNING };
36  DxState state;
37  unsigned bufferOffset;
38  unsigned bufferSize;
39  unsigned fragmentSize;
40  int skipCount;
41  LPDIRECTSOUNDBUFFER primaryBuffer;
42  LPDIRECTSOUNDBUFFER secondaryBuffer;
43  LPDIRECTSOUND directSound;
44 
45  unsigned frequency;
46 };
47 
48 } // namespace openmsx
49 
50 #endif // _WIN32
51 #endif // DIRECTXSOUNDDRIVER_HH
size_t size() const
Based on boost::noncopyable, see boost documentation: http://www.boost.org/libs/utility.
Definition: noncopyable.hh:12