From 17d43edafbfad42a3f87dc40e9dad9b563267349 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Thu, 3 May 2018 16:12:12 +0200 Subject: [PATCH 1/2] Fixed mac sound backend initialization. --- channels/rdpsnd/client/mac/rdpsnd_mac.c | 66 +++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 5 deletions(-) diff --git a/channels/rdpsnd/client/mac/rdpsnd_mac.c b/channels/rdpsnd/client/mac/rdpsnd_mac.c index db98057d9..ce8a83c24 100644 --- a/channels/rdpsnd/client/mac/rdpsnd_mac.c +++ b/channels/rdpsnd/client/mac/rdpsnd_mac.c @@ -85,8 +85,8 @@ static BOOL rdpsnd_mac_set_format(rdpsndDevicePlugin* device, const AUDIO_FORMAT mac->audioFormat.mFramesPerPacket = 1; mac->audioFormat.mChannelsPerFrame = format->nChannels; mac->audioFormat.mBitsPerChannel = format->wBitsPerSample; - mac->audioFormat.mBytesPerFrame = (format->wBitsPerSample * format->nChannels) / 8; - mac->audioFormat.mBytesPerPacket = format->nBlockAlign; + mac->audioFormat.mBytesPerFrame = mac->audioFormat.mBitsPerChannel * mac->audioFormat.mChannelsPerFrame / 8; + mac->audioFormat.mBytesPerPacket = mac->audioFormat.mBytesPerFrame * mac->audioFormat.mFramesPerPacket; mac->audioFormat.mReserved = 0; switch (format->wFormatTag) @@ -104,13 +104,69 @@ static BOOL rdpsnd_mac_set_format(rdpsndDevicePlugin* device, const AUDIO_FORMAT break; default: - break; + return FALSE; } rdpsnd_print_audio_format(format); return TRUE; } +static char *FormatError(OSStatus st) +{ + switch (st) { + case kAudioFileUnspecifiedError: + return "kAudioFileUnspecifiedError"; + + case kAudioFileUnsupportedFileTypeError: + return "kAudioFileUnsupportedFileTypeError"; + + case kAudioFileUnsupportedDataFormatError: + return "kAudioFileUnsupportedDataFormatError"; + + case kAudioFileUnsupportedPropertyError: + return "kAudioFileUnsupportedPropertyError"; + + case kAudioFileBadPropertySizeError: + return "kAudioFileBadPropertySizeError"; + + case kAudioFilePermissionsError: + return "kAudioFilePermissionsError"; + + case kAudioFileNotOptimizedError: + return "kAudioFileNotOptimizedError"; + + case kAudioFileInvalidChunkError: + return "kAudioFileInvalidChunkError"; + + case kAudioFileDoesNotAllow64BitDataSizeError: + return "kAudioFileDoesNotAllow64BitDataSizeError"; + + case kAudioFileInvalidPacketOffsetError: + return "kAudioFileInvalidPacketOffsetError"; + + case kAudioFileInvalidFileError: + return "kAudioFileInvalidFileError"; + + case kAudioFileOperationNotSupportedError: + return "kAudioFileOperationNotSupportedError"; + + case kAudioFileNotOpenError: + return "kAudioFileNotOpenError"; + + case kAudioFileEndOfFileError: + return "kAudioFileEndOfFileError"; + + case kAudioFilePositionError: + return "kAudioFilePositionError"; + + case kAudioFileFileNotFoundError: + return "kAudioFileFileNotFoundError"; + + default: + return "unknown error"; + } +} + static BOOL rdpsnd_mac_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* format, UINT32 latency) { int index; @@ -128,10 +184,10 @@ static BOOL rdpsnd_mac_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* form status = AudioQueueNewOutput(&(mac->audioFormat), mac_audio_queue_output_cb, mac, NULL, NULL, 0, &(mac->audioQueue)); - if (status != 0) { - WLog_ERR(TAG, "AudioQueueNewOutput failure\n"); + const char* err = FormatError(status); + WLog_ERR(TAG, "AudioQueueNewOutput failure %s", err); return FALSE; } From 670c1190c4b403ecbd297d0acf6f2314306db880 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Fri, 4 May 2018 09:44:06 +0200 Subject: [PATCH 2/2] Fixed formats supported by backend. --- channels/rdpsnd/client/mac/rdpsnd_mac.c | 85 +++++++++++++------------ 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/channels/rdpsnd/client/mac/rdpsnd_mac.c b/channels/rdpsnd/client/mac/rdpsnd_mac.c index ce8a83c24..02a6da252 100644 --- a/channels/rdpsnd/client/mac/rdpsnd_mac.c +++ b/channels/rdpsnd/client/mac/rdpsnd_mac.c @@ -85,8 +85,10 @@ static BOOL rdpsnd_mac_set_format(rdpsndDevicePlugin* device, const AUDIO_FORMAT mac->audioFormat.mFramesPerPacket = 1; mac->audioFormat.mChannelsPerFrame = format->nChannels; mac->audioFormat.mBitsPerChannel = format->wBitsPerSample; - mac->audioFormat.mBytesPerFrame = mac->audioFormat.mBitsPerChannel * mac->audioFormat.mChannelsPerFrame / 8; - mac->audioFormat.mBytesPerPacket = mac->audioFormat.mBytesPerFrame * mac->audioFormat.mFramesPerPacket; + mac->audioFormat.mBytesPerFrame = mac->audioFormat.mBitsPerChannel * + mac->audioFormat.mChannelsPerFrame / 8; + mac->audioFormat.mBytesPerPacket = mac->audioFormat.mBytesPerFrame * + mac->audioFormat.mFramesPerPacket; mac->audioFormat.mReserved = 0; switch (format->wFormatTag) @@ -111,60 +113,61 @@ static BOOL rdpsnd_mac_set_format(rdpsndDevicePlugin* device, const AUDIO_FORMAT return TRUE; } -static char *FormatError(OSStatus st) +static char* FormatError(OSStatus st) { - switch (st) { - case kAudioFileUnspecifiedError: - return "kAudioFileUnspecifiedError"; + switch (st) + { + case kAudioFileUnspecifiedError: + return "kAudioFileUnspecifiedError"; - case kAudioFileUnsupportedFileTypeError: - return "kAudioFileUnsupportedFileTypeError"; + case kAudioFileUnsupportedFileTypeError: + return "kAudioFileUnsupportedFileTypeError"; - case kAudioFileUnsupportedDataFormatError: - return "kAudioFileUnsupportedDataFormatError"; + case kAudioFileUnsupportedDataFormatError: + return "kAudioFileUnsupportedDataFormatError"; - case kAudioFileUnsupportedPropertyError: - return "kAudioFileUnsupportedPropertyError"; + case kAudioFileUnsupportedPropertyError: + return "kAudioFileUnsupportedPropertyError"; - case kAudioFileBadPropertySizeError: - return "kAudioFileBadPropertySizeError"; + case kAudioFileBadPropertySizeError: + return "kAudioFileBadPropertySizeError"; - case kAudioFilePermissionsError: - return "kAudioFilePermissionsError"; + case kAudioFilePermissionsError: + return "kAudioFilePermissionsError"; - case kAudioFileNotOptimizedError: - return "kAudioFileNotOptimizedError"; + case kAudioFileNotOptimizedError: + return "kAudioFileNotOptimizedError"; - case kAudioFileInvalidChunkError: - return "kAudioFileInvalidChunkError"; + case kAudioFileInvalidChunkError: + return "kAudioFileInvalidChunkError"; - case kAudioFileDoesNotAllow64BitDataSizeError: - return "kAudioFileDoesNotAllow64BitDataSizeError"; + case kAudioFileDoesNotAllow64BitDataSizeError: + return "kAudioFileDoesNotAllow64BitDataSizeError"; - case kAudioFileInvalidPacketOffsetError: - return "kAudioFileInvalidPacketOffsetError"; + case kAudioFileInvalidPacketOffsetError: + return "kAudioFileInvalidPacketOffsetError"; - case kAudioFileInvalidFileError: - return "kAudioFileInvalidFileError"; + case kAudioFileInvalidFileError: + return "kAudioFileInvalidFileError"; - case kAudioFileOperationNotSupportedError: - return "kAudioFileOperationNotSupportedError"; + case kAudioFileOperationNotSupportedError: + return "kAudioFileOperationNotSupportedError"; - case kAudioFileNotOpenError: - return "kAudioFileNotOpenError"; + case kAudioFileNotOpenError: + return "kAudioFileNotOpenError"; - case kAudioFileEndOfFileError: - return "kAudioFileEndOfFileError"; + case kAudioFileEndOfFileError: + return "kAudioFileEndOfFileError"; - case kAudioFilePositionError: - return "kAudioFilePositionError"; + case kAudioFilePositionError: + return "kAudioFilePositionError"; - case kAudioFileFileNotFoundError: - return "kAudioFileFileNotFoundError"; + case kAudioFileFileNotFoundError: + return "kAudioFileFileNotFoundError"; - default: - return "unknown error"; - } + default: + return "unknown error"; + } } static BOOL rdpsnd_mac_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* format, UINT32 latency) @@ -184,6 +187,7 @@ static BOOL rdpsnd_mac_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* form status = AudioQueueNewOutput(&(mac->audioFormat), mac_audio_queue_output_cb, mac, NULL, NULL, 0, &(mac->audioQueue)); + if (status != 0) { const char* err = FormatError(status); @@ -255,14 +259,11 @@ static BOOL rdpsnd_mac_format_supported(rdpsndDevicePlugin* device, const AUDIO_ case WAVE_FORMAT_PCM: case WAVE_FORMAT_ALAW: case WAVE_FORMAT_MULAW: - case WAVE_FORMAT_GSM610: return TRUE; default: return FALSE; } - - return FALSE; } static BOOL rdpsnd_mac_set_volume(rdpsndDevicePlugin* device, UINT32 value)