diff --git a/channels/audin/client/pulse/audin_pulse.c b/channels/audin/client/pulse/audin_pulse.c index bc6367d45..2a42d495a 100644 --- a/channels/audin/client/pulse/audin_pulse.c +++ b/channels/audin/client/pulse/audin_pulse.c @@ -139,7 +139,7 @@ static UINT audin_pulse_connect(IAudinDevice* device) if (!pulse->context) return ERROR_INVALID_PARAMETER; - if (pa_context_connect(pulse->context, NULL, 0, NULL)) + if (pa_context_connect(pulse->context, NULL, PA_CONTEXT_NOFLAGS, NULL)) { WLog_Print(pulse->log, WLOG_ERROR, "pa_context_connect failed (%d)", pa_context_errno(pulse->context)); @@ -253,7 +253,6 @@ static BOOL audin_pulse_format_supported(IAudinDevice* device, const AUDIO_FORMA static UINT audin_pulse_set_format(IAudinDevice* device, const AUDIO_FORMAT* format, UINT32 FramesPerPacket) { - pa_sample_spec sample_spec = { 0 }; AudinPulseDevice* pulse = (AudinPulseDevice*)device; if (!pulse || !format) @@ -265,21 +264,18 @@ static UINT audin_pulse_set_format(IAudinDevice* device, const AUDIO_FORMAT* for if (FramesPerPacket > 0) pulse->frames_per_packet = FramesPerPacket; - sample_spec.rate = format->nSamplesPerSec; - - sample_spec.channels = WINPR_ASSERTING_INT_CAST(uint8_t, format->nChannels); - + pa_sample_format_t sformat = PA_SAMPLE_INVALID; switch (format->wFormatTag) { case WAVE_FORMAT_PCM: /* PCM */ switch (format->wBitsPerSample) { case 8: - sample_spec.format = PA_SAMPLE_U8; + sformat = PA_SAMPLE_U8; break; case 16: - sample_spec.format = PA_SAMPLE_S16LE; + sformat = PA_SAMPLE_S16LE; break; default: @@ -292,6 +288,12 @@ static UINT audin_pulse_set_format(IAudinDevice* device, const AUDIO_FORMAT* for return ERROR_INTERNAL_ERROR; } + const pa_sample_spec sample_spec = { + .format = sformat, + .rate = format->nSamplesPerSec, + .channels = WINPR_ASSERTING_INT_CAST(uint8_t, format->nChannels), + }; + pulse->sample_spec = sample_spec; pulse->format = *format; return CHANNEL_RC_OK; diff --git a/channels/rdpsnd/client/pulse/rdpsnd_pulse.c b/channels/rdpsnd/client/pulse/rdpsnd_pulse.c index 24c0f0d83..5c879aa3b 100644 --- a/channels/rdpsnd/client/pulse/rdpsnd_pulse.c +++ b/channels/rdpsnd/client/pulse/rdpsnd_pulse.c @@ -171,7 +171,7 @@ static BOOL rdpsnd_pulse_connect(rdpsndDevicePlugin* device) pa_threaded_mainloop_lock(pulse->mainloop); - if (pa_context_connect(pulse->context, NULL, 0, NULL) < 0) + if (pa_context_connect(pulse->context, NULL, PA_CONTEXT_NOFLAGS, NULL) < 0) { pa_threaded_mainloop_unlock(pulse->mainloop); return FALSE; @@ -301,8 +301,6 @@ static void rdpsnd_pulse_close(rdpsndDevicePlugin* device) static BOOL rdpsnd_pulse_set_format_spec(rdpsndPulsePlugin* pulse, const AUDIO_FORMAT* format) { - pa_sample_spec sample_spec = { 0 }; - WINPR_ASSERT(format); if (!rdpsnd_check_pulse(pulse, FALSE)) @@ -311,20 +309,18 @@ static BOOL rdpsnd_pulse_set_format_spec(rdpsndPulsePlugin* pulse, const AUDIO_F if (!rdpsnd_pulse_format_supported(&pulse->device, format)) return FALSE; - sample_spec.rate = format->nSamplesPerSec; - sample_spec.channels = WINPR_ASSERTING_INT_CAST(uint8_t, format->nChannels); - + pa_sample_format_t sformat = PA_SAMPLE_INVALID; switch (format->wFormatTag) { case WAVE_FORMAT_PCM: switch (format->wBitsPerSample) { case 8: - sample_spec.format = PA_SAMPLE_U8; + sformat = PA_SAMPLE_U8; break; case 16: - sample_spec.format = PA_SAMPLE_S16LE; + sformat = PA_SAMPLE_S16LE; break; default: @@ -337,6 +333,10 @@ static BOOL rdpsnd_pulse_set_format_spec(rdpsndPulsePlugin* pulse, const AUDIO_F return FALSE; } + const pa_sample_spec sample_spec = { .format = sformat, + .rate = format->nSamplesPerSec, + .channels = + WINPR_ASSERTING_INT_CAST(uint8_t, format->nChannels) }; pulse->sample_spec = sample_spec; return TRUE; }