Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cSoundMixer.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cSoundMixer_H
7 #define _INC_cSoundMixer_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../AV/cSoundBase.h"
17 
18 namespace Gray
19 {
20 #if defined(_WIN32)
21  template <> inline void cHandlePtr<HMIXER>::CloseHandle(HMIXER h) // static
22  {
24  ::mixerClose(h);
25  }
26 #elif defined(__linux__)
27  typedef HANDLE HMIXER; // Normal cOSHandle
28 #define MIXER_OBJECTF_MIXER 0
29 #endif
30 }
31 
32 namespace GrayLib
33 {
34 #ifdef _WIN32
35  class GRAYLIB_LINK cSoundMixerCaps : public _GTNSND(MIXERCAPS)
36  {
37  public:
38  static UINT GRAYCALL GetNumDevs();
39  static MMRESULT GRAYCALL GetDevCaps(UINT i, OUT cSoundMixerCaps & caps);
40  };
41 #endif
42 
44  {
51 
52  public:
53 #if defined(_WIN32)
54  HMIXER m_hMixer;
55 #elif defined(__linux__)
56  cOSHandle m_hMixer;
57 #endif
58 
59  public:
60  cSoundMixer() noexcept;
61  ~cSoundMixer(void);
62 
63  operator HMIXER() const noexcept
64  {
65  return m_hMixer;
66  }
67  HMIXER get_Handle() const noexcept
68  {
69  return m_hMixer;
70  }
71  bool isOpen() const noexcept
72  {
73 #if defined(_WIN32)
74  return m_hMixer != WINHANDLE_NULL;
75 #elif defined(__linux__)
76  return m_hMixer.isValidHandle();
77 #endif
78  }
79 
80  HRESULT OpenMixer(UINT uMixerDeviceID = 0, DWORD_PTR dwCallback = 0, DWORD_PTR dwInstanceData = 0, DWORD dwOpenFlags = MIXER_OBJECTF_MIXER);
81  void CloseMixer();
82 
83 #ifdef _WIN32
84  HRESULT getCaps(_GTNSND(MIXERCAPS)* pCaps) const
85  {
86  return GetHResultFrom(_GTNSND(::mixerGetDevCaps)((UINT_PTR)m_hMixer, pCaps, sizeof(*pCaps)));
87  }
88  HRESULT getID(UINT* puMxId) const
89  {
90  return GetHResultFrom(::mixerGetID((HMIXEROBJ)m_hMixer, puMxId, MIXER_OBJECTF_HMIXER));
91  }
92 
93  HRESULT GetLineInfo(_Inout_ _GTNSND(MIXERLINE)* pMxl, IN DWORD dwInfoFlags) const
94  {
95  // pMxl->cbStruct = sizeof(MIXERLINE);
96  // pMxl->dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
97  // dwInfoFlags = MIXER_GETLINEINFOF_COMPONENTTYPE
98  return GetHResultFrom(_GTNSND(::mixerGetLineInfo)((HMIXEROBJ)m_hMixer, pMxl, dwInfoFlags | MIXER_OBJECTF_HMIXER));
99  }
100  HRESULT GetLineControls(_Inout_ _GTNSND(MIXERLINECONTROLS)* pMxlc, IN DWORD dwControls) const
101  {
102  // pMxlc->cbStruct = sizeof(MIXERLINECONTROLS);
103  // dwControls = MIXER_GETLINECONTROLSF_ONEBYTYPE;
104  return GetHResultFrom(_GTNSND(::mixerGetLineControls)((HMIXEROBJ)m_hMixer, pMxlc, dwControls | MIXER_OBJECTF_HMIXER));
105  }
106  HRESULT SetControlDetails(IN MIXERCONTROLDETAILS* pMxcd, IN DWORD dwDetails) const
107  {
108  // pMxcd->cbStruct = sizeof(MIXERCONTROLDETAILS);
109  // dwDetails = MIXER_SETCONTROLDETAILSF_VALUE;
110  return GetHResultFrom(::mixerSetControlDetails((HMIXEROBJ)m_hMixer, pMxcd, dwDetails | MIXER_OBJECTF_HMIXER));
111  }
112  HRESULT GetControlDetails(_Inout_ MIXERCONTROLDETAILS* pMxcd, IN DWORD dwDetails) const
113  {
114  // dwDetails = MIXER_GETCONTROLDETAILSF_VALUE;
115  return GetHResultFrom(_GTNSND(::mixerGetControlDetails)((HMIXEROBJ)m_hMixer, pMxcd, dwDetails | MIXER_OBJECTF_HMIXER));
116  }
117 
118  DWORD SendMessageX(IN UINT uMsg, IN DWORD_PTR dwParam1, IN DWORD_PTR dwParam2) const
119  {
120  // WINMSG_t
121  return ::mixerMessage(m_hMixer, uMsg, dwParam1, dwParam2);
122  }
123 #endif
124 
126  };
127 }
128 
129 #endif // _INC_cSoundMixer_H
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define WINHANDLE_NULL
HWND, HPEN, etc are NOT OS Handles. like HWND_DESKTOP. like HANDLEPTR_NULL. This is a WINAPI void* ha...
Definition: cOSHandle.h:23
#define _GTNSND
Definition: cSoundBase.h:26
Definition: cSoundMixer.h:44
HMIXER get_Handle() const noexcept
Definition: cSoundMixer.h:67
bool isOpen() const noexcept
Definition: cSoundMixer.h:71
UNITTEST_FRIEND(cSoundMixer)
void CloseHandle()
Definition: cHandlePtr.h:79
Definition: cOSHandle.h:59
Definition: cMesh.h:22
< The main namespace for all Core functions.
Definition: GrayCore.cpp:14
wrap WAVEFORMATEX
Definition: cSoundBase.h:44