[PATCH v8 5/5] wmp: IWMPSettings implement put/get volume

Anton Romanov theli.ua at gmail.com
Tue Apr 3 00:36:35 CDT 2018


Signed-off-by: Anton Romanov <theli.ua at gmail.com>
---
 dlls/wmp/player.c      | 30 ++++++++++++++++++++++++++----
 dlls/wmp/tests/media.c |  8 +++++++-
 dlls/wmp/wmp_private.h |  1 +
 3 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/dlls/wmp/player.c b/dlls/wmp/player.c
index 08a78ab044..36ac0eacb3 100644
--- a/dlls/wmp/player.c
+++ b/dlls/wmp/player.c
@@ -952,16 +952,32 @@ static HRESULT WINAPI WMPSettings_put_balance(IWMPSettings *iface, LONG v)
 
 static HRESULT WINAPI WMPSettings_get_volume(IWMPSettings *iface, LONG *p)
 {
+    HRESULT hres;
     WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    TRACE("(%p)->(%p)\n", This, p);
+    if (!This->filter_graph) {
+        return S_FALSE;
+    }
+    hres = IBasicAudio_get_Volume(This->basic_audio, p);
+    /* IBasicAudio -   [-10000, 0], wmp - [0, 100] */
+    if (SUCCEEDED(hres))
+        *p = (*p + 10000) * 100 / 10000;
+    return hres;
 }
 
 static HRESULT WINAPI WMPSettings_put_volume(IWMPSettings *iface, LONG v)
 {
+    HRESULT hres;
     WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
-    FIXME("(%p)->(%d)\n", This, v);
-    return E_NOTIMPL;
+    TRACE("(%p)->(%d)\n", This, v);
+    if (!This->filter_graph) {
+        return S_FALSE;
+    }
+    /* IBasicAudio -   [-10000, 0], wmp - [0, 100] */
+    v = 10000 * v / 100 - 10000;
+    hres = IBasicAudio_put_Volume(This->basic_audio, v);
+    TRACE("ret: %d", hres);
+    return hres;
 }
 
 static HRESULT WINAPI WMPSettings_getMode(IWMPSettings *iface, BSTR mode, VARIANT_BOOL *p)
@@ -1480,6 +1496,8 @@ static HRESULT WINAPI WMPControls_play(IWMPControls *iface)
                 IMediaEventEx_Release(media_event_ex);
             }
         }
+        if (SUCCEEDED(hres))
+            hres = IGraphBuilder_QueryInterface(This->filter_graph, &IID_IBasicAudio, (void**)&This->basic_audio);
     }
 
     update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsTransitioning);
@@ -1521,11 +1539,15 @@ static HRESULT WINAPI WMPControls_stop(IWMPControls *iface)
     if (This->media_seeking) {
         IMediaSeeking_Release(This->media_seeking);
     }
+    if (This->basic_audio) {
+        IBasicAudio_Release(This->basic_audio);
+    }
     IGraphBuilder_Release(This->filter_graph);
     This->filter_graph = NULL;
     This->media_control = NULL;
     This->media_event = NULL;
     This->media_seeking = NULL;
+    This->basic_audio = NULL;
 
     update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposPlaylistOpenNoMedia);
     update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsStopped);
diff --git a/dlls/wmp/tests/media.c b/dlls/wmp/tests/media.c
index 5c03b12db8..5343f2fef3 100644
--- a/dlls/wmp/tests/media.c
+++ b/dlls/wmp/tests/media.c
@@ -343,7 +343,6 @@ static void test_wmp(void)
 
     hres = IWMPSettings_put_autoStart(settings, VARIANT_FALSE);
     ok(hres == S_OK, "Could not put autoStart in IWMPSettings: %08x\n", hres);
-    IWMPSettings_Release(settings);
 
     controls = NULL;
     hres = IWMPPlayer4_get_controls(player4, &controls);
@@ -479,7 +478,14 @@ playback_skip:
     hres = IConnectionPoint_Unadvise(point, dw);
     ok(hres == S_OK, "Unadvise failed: %08x\n", hres);
 
+    hres = IWMPSettings_put_volume(settings, 36);
+    ok(hres == S_OK, "IWMPSettings_put_volume failed: %08x\n", hres);
+    hres = IWMPSettings_get_volume(settings, &progress);
+    ok(hres == S_OK, "IWMPSettings_get_volume failed: %08x\n", hres);
+    ok(progress == 36, "unexpected value: %d\n", progress);
+
     IConnectionPoint_Release(point);
+    IWMPSettings_Release(settings);
     IWMPControls_Release(controls);
     IWMPPlayer4_Release(player4);
     IOleObject_Release(oleobj);
diff --git a/dlls/wmp/wmp_private.h b/dlls/wmp/wmp_private.h
index c5ea0a93d2..5e7dda55ba 100644
--- a/dlls/wmp/wmp_private.h
+++ b/dlls/wmp/wmp_private.h
@@ -79,6 +79,7 @@ struct WindowsMediaPlayer {
     IMediaControl* media_control;
     IMediaEvent* media_event;
     IMediaSeeking* media_seeking;
+    IBasicAudio* basic_audio;
 
     /* Async event notification */
     HWND msg_window;
-- 
2.16.2




More information about the wine-devel mailing list