channels: Fix memory leak and make log messages more precise
authorMartin Fleisz <martin.fleisz@thincast.com>
Wed, 8 Jan 2020 12:31:20 +0000 (13:31 +0100)
committerakallabeth <akallabeth@users.noreply.github.com>
Wed, 8 Jan 2020 15:49:15 +0000 (16:49 +0100)
channels/audin/client/audin_main.c
channels/audin/client/winmm/audin_winmm.c
channels/rdpsnd/client/rdpsnd_main.c
channels/rdpsnd/client/winmm/rdpsnd_winmm.c

index 6bed8bc..1b14fd3 100644 (file)
@@ -1027,9 +1027,10 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
        {
                if ((error = audin_load_device_plugin(audin, audin->subsystem, args)))
                {
-                       WLog_Print(audin->log, WLOG_ERROR,
-                                  "audin_load_device_plugin %s failed with error %" PRIu32 "!",
-                                  audin->subsystem, error);
+                       WLog_Print(
+                           audin->log, WLOG_ERROR,
+                           "Unable to load microphone redirection subsystem %s because of error %" PRIu32 "",
+                           audin->subsystem, error);
                        goto out;
                }
        }
@@ -1064,7 +1065,7 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
        {
                /* If we have no audin device do not register plugin but still return OK or the client will
                 * just disconnect due to a missing microphone. */
-               WLog_Print(audin->log, WLOG_ERROR, "no sound device.");
+               WLog_Print(audin->log, WLOG_ERROR, "No microphone device could be found.");
                error = CHANNEL_RC_OK;
                goto out;
        }
index 8c18e30..5928523 100644 (file)
@@ -465,7 +465,10 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEn
        UINT error;
 
        if (waveInGetNumDevs() == 0)
+       {
+               WLog_Print(winmm->log, WLOG_ERROR, "No microphone available!");
                return ERROR_DEVICE_NOT_AVAILABLE;
+       }
 
        winmm = (AudinWinmmDevice*)calloc(1, sizeof(AudinWinmmDevice));
 
index f172b20..384c5c6 100644 (file)
@@ -851,7 +851,7 @@ static UINT rdpsnd_process_connect(rdpsndPlugin* rdpsnd)
        {
                if ((status = rdpsnd_load_device_plugin(rdpsnd, rdpsnd->subsystem, args)))
                {
-                       WLog_ERR(TAG, "unable to load the %s subsystem plugin because of error %" PRIu32 "",
+                       WLog_ERR(TAG, "Unable to load sound playback subsystem %s because of error %" PRIu32 "",
                                 rdpsnd->subsystem, status);
                        return status;
                }
@@ -866,7 +866,8 @@ static UINT rdpsnd_process_connect(rdpsndPlugin* rdpsnd)
                        const char* device_name = backends[x].device;
 
                        if ((status = rdpsnd_load_device_plugin(rdpsnd, subsystem_name, args)))
-                               WLog_ERR(TAG, "unable to load the %s subsystem plugin because of error %" PRIu32 "",
+                               WLog_ERR(TAG,
+                                        "Unable to load sound playback subsystem %s because of error %" PRIu32 "",
                                         subsystem_name, status);
 
                        if (!rdpsnd->device)
index 5abcb1f..8fade6e 100644 (file)
@@ -303,13 +303,16 @@ UINT freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS p
 {
        ADDIN_ARGV* args;
        rdpsndWinmmPlugin* winmm;
-       winmm = (rdpsndWinmmPlugin*)calloc(1, sizeof(rdpsndWinmmPlugin));
-
-       if (!winmm)
-               return CHANNEL_RC_NO_MEMORY;
 
        if (waveOutGetNumDevs() == 0)
+       {
+               WLog_Print(winmm->log, WLOG_ERROR, "No sound playback device available!");
                return ERROR_DEVICE_NOT_AVAILABLE;
+       }
+
+       winmm = (rdpsndWinmmPlugin*)calloc(1, sizeof(rdpsndWinmmPlugin));
+       if (!winmm)
+               return CHANNEL_RC_NO_MEMORY;
 
        winmm->device.Open = rdpsnd_winmm_open;
        winmm->device.FormatSupported = rdpsnd_winmm_format_supported;