[vlc-commits] mmdevice: inline the only call to var_InheritWide()

Steve Lhomme git at videolan.org
Wed Apr 3 09:55:56 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Apr  3 08:49:19 2019 +0200| [892810977b0a2a2f9f1b48fde74bdb200ddc07ca] | committer: Steve Lhomme

mmdevice: inline the only call to var_InheritWide()

And calling SetDisplayName on NULL returns an error so avoid doing it.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=892810977b0a2a2f9f1b48fde74bdb200ddc07ca
---

 modules/audio_output/mmdevice.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index 4c79cabf1d..7762ee626a 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -785,18 +785,6 @@ static int DeviceSelect(audio_output_t *aout, const char *id)
 }
 
 /*** Initialization / deinitialization **/
-static wchar_t *var_InheritWide(vlc_object_t *obj, const char *name)
-{
-    char *v8 = var_InheritString(obj, name);
-    if (v8 == NULL)
-        return NULL;
-
-    wchar_t *v16 = ToWide(v8);
-    free(v8);
-    return v16;
-}
-#define var_InheritWide(o,n) var_InheritWide(VLC_OBJECT(o),n)
-
 /** MMDevice audio output thread.
  * This thread takes cares of the audio session control. Inconveniently enough,
  * the audio session control interface must:
@@ -896,9 +884,17 @@ static HRESULT MMSession(audio_output_t *aout, IMMDeviceEnumerator *it)
                                                          &control);
         if (SUCCEEDED(hr))
         {
-            wchar_t *ua = var_InheritWide(aout, "user-agent");
-            IAudioSessionControl_SetDisplayName(control, ua, NULL);
-            free(ua);
+            char *ua = var_InheritString(aout, "user-agent");
+            if (ua != NULL)
+            {
+                wchar_t *wua = ToWide(ua);
+                if (likely(wua != NULL))
+                {
+                    IAudioSessionControl_SetDisplayName(control, wua, NULL);
+                    free(wua);
+                }
+                free(ua);
+            }
 
             IAudioSessionControl_RegisterAudioSessionNotification(control,
                                                          &sys->session_events);



More information about the vlc-commits mailing list