coastline 0.0.4
Loading...
Searching...
No Matches
directsoundstate.h
Go to the documentation of this file.
1#ifndef COASTLINE_EAR_DIRECTSOUNDSTATE_H
2#define COASTLINE_EAR_DIRECTSOUNDSTATE_H
3
4#if TGR_PLATFORM == TGR_PLATFORM_WIN
5#include <windows.h>
6
8struct IDirectSound;
9struct _DSBUFFERDESC;
10#else
11#include "common/types.h"
12#include "ear/wavechunks.h"
13
14class EarSdlVoice;
15#endif
16
21class [[gnu::packed]] EarDirectSoundPlaybackState {
22public:
23#if TGR_PLATFORM == TGR_PLATFORM_WIN
26#else
28 using Buffer = EarSdlVoice;
29#endif
30
35 void Initialize();
36
38 Buffer *GetBuffer() const {
39 return buffer;
40 }
41
42 void ClearBuffer() {
43 buffer = nullptr;
44 }
45
47 return playCursor;
48 }
49
53 void SetPlayCursor(DWORD cursor) {
54 playCursor = cursor;
55 }
56#if TGR_PLATFORM == TGR_PLATFORM_WIN
63 HRESULT CreateBuffer(IDirectSound *device, _DSBUFFERDESC *description);
64#else
72 bool CreateBuffer(const EarWaveFormat &format, DWORD bytes);
73#endif
80
81private:
82 Buffer *buffer;
83 DWORD writeCursor;
84 DWORD playCursor;
85};
86
87#endif /* COASTLINE_EAR_DIRECTSOUNDSTATE_H */
Device buffer reference and cached byte cursors for Windows DirectSound or the SDL mixer.
Definition directsoundstate.h:21
DWORD GetPlayCursor() const
Definition directsoundstate.h:46
IDirectSoundBuffer Buffer
Windows device buffer type.
Definition directsoundstate.h:25
Buffer * GetBuffer() const
Definition directsoundstate.h:38
void ClearBuffer()
Clear the buffer reference without stopping or releasing the buffer.
Definition directsoundstate.h:42
void Initialize()
Reset the buffer pointer and both cached byte cursors without releasing prior resources.
HRESULT CreateBuffer(IDirectSound *device, _DSBUFFERDESC *description)
Create a Windows buffer and store the returned reference without releasing a prior buffer.
void SetPlayCursor(DWORD cursor)
Replace the cached cursor without seeking the device.
Definition directsoundstate.h:53
void UpdateCursors()
Query both cached byte cursors from a non-null device buffer.
A buffer of samples the mixer plays, as a secondary buffer of DirectSound plays in the original.
Definition sdlmixer.h:18
The integer and floating-point types of the console, for headers shared with Windows.
WAVEFORMATEX EarWaveFormat
Definition wavechunks.h:23
typedef DWORD
typedef HRESULT