[MMDEVAPI] Sync with Wine Staging 3.3. CORE-14434
[reactos.git] / dll / win32 / mmdevapi / audiovolume.c
index 63a414d..76f9f4e 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#define COBJMACROS
+#include "config.h"
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winnls.h"
+#include "winreg.h"
+#include "wine/debug.h"
+#include "wine/unicode.h"
+
+#include "ole2.h"
+#include "mmdeviceapi.h"
+#include "mmsystem.h"
+#include "dsound.h"
+#include "audioclient.h"
+#include "endpointvolume.h"
+#include "audiopolicy.h"
+
 #include "mmdevapi.h"
 
+WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi);
+
 typedef struct AEVImpl {
     IAudioEndpointVolumeEx IAudioEndpointVolumeEx_iface;
     LONG ref;
-    float level;
+    float master_vol;
     BOOL mute;
 } AEVImpl;
 
@@ -102,9 +124,12 @@ static HRESULT WINAPI AEV_SetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, fl
 {
     AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
 
-    FIXME("(%p)->(%f,%s): stub\n", iface, leveldb, debugstr_guid(ctx));
+    TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx));
+
+    if(leveldb < -100.f || leveldb > 0.f)
+        return E_INVALIDARG;
 
-    This->level = leveldb;
+    This->master_vol = leveldb;
 
     return S_OK;
 }
@@ -120,12 +145,12 @@ static HRESULT WINAPI AEV_GetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, fl
 {
     AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
 
-    FIXME("(%p)->(%p): stub\n", iface, leveldb);
+    TRACE("(%p)->(%p)\n", iface, leveldb);
 
     if (!leveldb)
         return E_POINTER;
 
-    *leveldb = This->level;
+    *leveldb = This->master_vol;
 
     return S_OK;
 }
@@ -174,19 +199,22 @@ static HRESULT WINAPI AEV_GetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *if
 static HRESULT WINAPI AEV_SetMute(IAudioEndpointVolumeEx *iface, BOOL mute, const GUID *ctx)
 {
     AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
+    HRESULT ret;
 
-    FIXME("(%p)->(%u,%s): stub\n", iface, mute, debugstr_guid(ctx));
+    TRACE("(%p)->(%u,%s)\n", iface, mute, debugstr_guid(ctx));
+
+    ret = This->mute == mute ? S_FALSE : S_OK;
 
     This->mute = mute;
 
-    return S_OK;
+    return ret;
 }
 
 static HRESULT WINAPI AEV_GetMute(IAudioEndpointVolumeEx *iface, BOOL *mute)
 {
     AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
 
-    FIXME("(%p)->(%p): stub\n", iface, mute);
+    TRACE("(%p)->(%p)\n", iface, mute);
 
     if (!mute)
         return E_POINTER;
@@ -230,14 +258,14 @@ static HRESULT WINAPI AEV_QueryHardwareSupport(IAudioEndpointVolumeEx *iface, DW
 
 static HRESULT WINAPI AEV_GetVolumeRange(IAudioEndpointVolumeEx *iface, float *mindb, float *maxdb, float *inc)
 {
-    FIXME("(%p)->(%p,%p,%p): stub\n", iface, mindb, maxdb, inc);
+    TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc);
 
     if (!mindb || !maxdb || !inc)
         return E_POINTER;
 
-    *mindb = 0.0f;
-    *maxdb = 1.0f;
-    *inc = 0.1f;
+    *mindb = -100.f;
+    *maxdb = 0.f;
+    *inc = 1.f;
 
     return S_OK;
 }
@@ -276,19 +304,17 @@ static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl = {
     AEV_GetVolumeRangeChannel
 };
 
-HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolume **ppv)
+HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolumeEx **ppv)
 {
     AEVImpl *This;
 
     *ppv = NULL;
-    This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
+    This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
     if (!This)
         return E_OUTOFMEMORY;
     This->IAudioEndpointVolumeEx_iface.lpVtbl = &AEVImpl_Vtbl;
     This->ref = 1;
-    This->level = 1.0f;
-    This->mute = FALSE;
 
-    *ppv = (IAudioEndpointVolume*)&This->IAudioEndpointVolumeEx_iface;
+    *ppv = &This->IAudioEndpointVolumeEx_iface;
     return S_OK;
 }