mirror of
https://github.com/FreeRDP/FreeRDP.git
synced 2024-11-23 01:44:35 +08:00
[warnings] fix some compiler warnings
* fix compiler warnings found in a lot of places * add missing enum type for clipboard channel * mark deallocator for winpr image function
This commit is contained in:
parent
d11be9025d
commit
dc76879e0b
@ -32,6 +32,8 @@ static const char* CB_MSG_TYPE_STR(UINT32 type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CB_TYPE_NONE:
|
||||
return "CB_TYPE_NONE";
|
||||
case CB_MONITOR_READY:
|
||||
return "CB_MONITOR_READY";
|
||||
case CB_FORMAT_LIST:
|
||||
|
@ -131,13 +131,13 @@ static int connect_to_sshagent(const char* udspath)
|
||||
static DWORD WINAPI sshagent_read_thread(LPVOID data)
|
||||
{
|
||||
SSHAGENT_CHANNEL_CALLBACK* callback = (SSHAGENT_CHANNEL_CALLBACK*)data;
|
||||
BYTE buffer[4096];
|
||||
BYTE buffer[4096] = { 0 };
|
||||
int going = 1;
|
||||
UINT status = CHANNEL_RC_OK;
|
||||
|
||||
while (going)
|
||||
{
|
||||
int bytes_read = read(callback->agent_fd, buffer, sizeof(buffer));
|
||||
const ssize_t bytes_read = read(callback->agent_fd, buffer, sizeof(buffer));
|
||||
|
||||
if (bytes_read == 0)
|
||||
{
|
||||
@ -153,11 +153,16 @@ static DWORD WINAPI sshagent_read_thread(LPVOID data)
|
||||
going = 0;
|
||||
}
|
||||
}
|
||||
else if ((size_t)bytes_read > ULONG_MAX)
|
||||
{
|
||||
status = ERROR_READ_FAULT;
|
||||
going = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Something read: forward to virtual channel */
|
||||
IWTSVirtualChannel* channel = callback->generic.channel;
|
||||
status = channel->Write(channel, bytes_read, buffer, NULL);
|
||||
status = channel->Write(channel, (ULONG)bytes_read, buffer, NULL);
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
@ -184,15 +189,15 @@ static UINT sshagent_on_data_received(IWTSVirtualChannelCallback* pChannelCallba
|
||||
{
|
||||
SSHAGENT_CHANNEL_CALLBACK* callback = (SSHAGENT_CHANNEL_CALLBACK*)pChannelCallback;
|
||||
BYTE* pBuffer = Stream_Pointer(data);
|
||||
UINT32 cbSize = Stream_GetRemainingLength(data);
|
||||
size_t cbSize = Stream_GetRemainingLength(data);
|
||||
BYTE* pos = pBuffer;
|
||||
/* Forward what we have received to the ssh agent */
|
||||
UINT32 bytes_to_write = cbSize;
|
||||
size_t bytes_to_write = cbSize;
|
||||
errno = 0;
|
||||
|
||||
while (bytes_to_write > 0)
|
||||
{
|
||||
int bytes_written = write(callback->agent_fd, pos, bytes_to_write);
|
||||
const ssize_t bytes_written = write(callback->agent_fd, pos, bytes_to_write);
|
||||
|
||||
if (bytes_written < 0)
|
||||
{
|
||||
|
@ -141,10 +141,6 @@ static BOOL tsmf_alsa_set_format(ITSMFAudioDevice* audio, UINT32 sample_rate, UI
|
||||
|
||||
static BOOL tsmf_alsa_play(ITSMFAudioDevice* audio, const BYTE* src, UINT32 data_size)
|
||||
{
|
||||
int len = 0;
|
||||
int error = 0;
|
||||
int frames = 0;
|
||||
const BYTE* end = NULL;
|
||||
const BYTE* pindex = NULL;
|
||||
TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*)audio;
|
||||
DEBUG_TSMF("data_size %" PRIu32 "", data_size);
|
||||
@ -153,22 +149,22 @@ static BOOL tsmf_alsa_play(ITSMFAudioDevice* audio, const BYTE* src, UINT32 data
|
||||
{
|
||||
const size_t rbytes_per_frame = 1ULL * alsa->actual_channels * alsa->bytes_per_sample;
|
||||
pindex = src;
|
||||
end = pindex + data_size;
|
||||
const BYTE* end = pindex + data_size;
|
||||
|
||||
while (pindex < end)
|
||||
{
|
||||
len = end - pindex;
|
||||
frames = len / rbytes_per_frame;
|
||||
error = snd_pcm_writei(alsa->out_handle, pindex, frames);
|
||||
const size_t len = (size_t)(end - pindex);
|
||||
const size_t frames = len / rbytes_per_frame;
|
||||
snd_pcm_sframes_t error = snd_pcm_writei(alsa->out_handle, pindex, frames);
|
||||
|
||||
if (error == -EPIPE)
|
||||
{
|
||||
snd_pcm_recover(alsa->out_handle, error, 0);
|
||||
snd_pcm_recover(alsa->out_handle, -EPIPE, 0);
|
||||
error = 0;
|
||||
}
|
||||
else if (error < 0)
|
||||
{
|
||||
DEBUG_TSMF("error len %d", error);
|
||||
DEBUG_TSMF("error len %ld", error);
|
||||
snd_pcm_close(alsa->out_handle);
|
||||
alsa->out_handle = 0;
|
||||
tsmf_alsa_open_device(alsa);
|
||||
@ -180,7 +176,7 @@ static BOOL tsmf_alsa_play(ITSMFAudioDevice* audio, const BYTE* src, UINT32 data
|
||||
if (error == 0)
|
||||
break;
|
||||
|
||||
pindex += error * rbytes_per_frame;
|
||||
pindex += (size_t)error * rbytes_per_frame;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ typedef struct
|
||||
enum AVCodecID codec_id;
|
||||
#endif
|
||||
AVCodecContext* codec_context;
|
||||
AVCodec* codec;
|
||||
const AVCodec* codec;
|
||||
AVFrame* frame;
|
||||
int prepared;
|
||||
|
||||
@ -458,10 +458,7 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UI
|
||||
TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder;
|
||||
int len = 0;
|
||||
int frame_size = 0;
|
||||
UINT32 src_size = 0;
|
||||
const BYTE* src = NULL;
|
||||
BYTE* dst = NULL;
|
||||
int dst_offset = 0;
|
||||
|
||||
#if 0
|
||||
WLog_DBG(TAG, ("tsmf_ffmpeg_decode_audio: data_size %"PRIu32"", data_size));
|
||||
|
||||
@ -484,10 +481,10 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UI
|
||||
return FALSE;
|
||||
|
||||
/* align the memory for SSE2 needs */
|
||||
dst = (BYTE*)(((uintptr_t)mdecoder->decoded_data + 15) & ~0x0F);
|
||||
dst_offset = dst - mdecoder->decoded_data;
|
||||
src = data;
|
||||
src_size = data_size;
|
||||
BYTE* dst = (BYTE*)(((uintptr_t)mdecoder->decoded_data + 15) & ~0x0F);
|
||||
size_t dst_offset = (size_t)(dst - mdecoder->decoded_data);
|
||||
const BYTE* src = data;
|
||||
UINT32 src_size = data_size;
|
||||
|
||||
while (src_size > 0)
|
||||
{
|
||||
@ -504,11 +501,12 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UI
|
||||
mdecoder->decoded_data = tmp_data;
|
||||
dst = (BYTE*)(((uintptr_t)mdecoder->decoded_data + 15) & ~0x0F);
|
||||
|
||||
if (dst - mdecoder->decoded_data != dst_offset)
|
||||
const size_t diff = (size_t)(dst - mdecoder->decoded_data);
|
||||
if (diff != dst_offset)
|
||||
{
|
||||
/* re-align the memory if the alignment has changed after realloc */
|
||||
memmove(dst, mdecoder->decoded_data + dst_offset, mdecoder->decoded_size);
|
||||
dst_offset = dst - mdecoder->decoded_data;
|
||||
dst_offset = diff;
|
||||
}
|
||||
|
||||
dst += mdecoder->decoded_size;
|
||||
|
@ -167,7 +167,6 @@ static BOOL tsmf_oss_set_format(ITSMFAudioDevice* audio, UINT32 sample_rate, UIN
|
||||
|
||||
static BOOL tsmf_oss_play(ITSMFAudioDevice* audio, const BYTE* data, UINT32 data_size)
|
||||
{
|
||||
int status = 0;
|
||||
UINT32 offset = 0;
|
||||
TSMFOssAudioDevice* oss = (TSMFOssAudioDevice*)audio;
|
||||
DEBUG_TSMF("tsmf_oss_play: data_size %" PRIu32 "", data_size);
|
||||
@ -183,7 +182,7 @@ static BOOL tsmf_oss_play(ITSMFAudioDevice* audio, const BYTE* data, UINT32 data
|
||||
|
||||
while (offset < data_size)
|
||||
{
|
||||
status = write(oss->pcm_handle, &data[offset], (data_size - offset));
|
||||
const ssize_t status = write(oss->pcm_handle, &data[offset], (data_size - offset));
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
|
@ -251,6 +251,8 @@ static const TSMFMediaTypeMap tsmf_format_type_map[] = {
|
||||
|
||||
static void tsmf_print_guid(const BYTE* guid)
|
||||
{
|
||||
WINPR_UNUSED(guid);
|
||||
|
||||
#ifdef WITH_DEBUG_TSMF
|
||||
char guidString[37];
|
||||
|
||||
@ -321,7 +323,7 @@ static UINT32 tsmf_codec_parse_VIDEOINFOHEADER2(TS_AM_MEDIA_TYPE* mediatype, wSt
|
||||
/* VIDEOINFOHEADER2.AvgTimePerFrame */
|
||||
Stream_Read_UINT64(s, AvgTimePerFrame);
|
||||
mediatype->SamplesPerSecond.Numerator = 1000000;
|
||||
mediatype->SamplesPerSecond.Denominator = (int)(AvgTimePerFrame / 10LL);
|
||||
mediatype->SamplesPerSecond.Denominator = (UINT32)(AvgTimePerFrame / 10ULL);
|
||||
/* Remaining fields before bmiHeader */
|
||||
Stream_Seek(s, 24);
|
||||
return 72;
|
||||
@ -359,7 +361,7 @@ static UINT32 tsmf_codec_parse_VIDEOINFOHEADER(TS_AM_MEDIA_TYPE* mediatype, wStr
|
||||
/* VIDEOINFOHEADER.AvgTimePerFrame */
|
||||
Stream_Read_UINT64(s, AvgTimePerFrame);
|
||||
mediatype->SamplesPerSecond.Numerator = 1000000;
|
||||
mediatype->SamplesPerSecond.Denominator = (int)(AvgTimePerFrame / 10LL);
|
||||
mediatype->SamplesPerSecond.Denominator = (UINT32)(AvgTimePerFrame / 10ULL);
|
||||
return 48;
|
||||
}
|
||||
|
||||
@ -393,7 +395,7 @@ static BOOL tsmf_read_format_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s, UINT3
|
||||
return FALSE;
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, nsize))
|
||||
return FALSE;
|
||||
mediatype->ExtraDataSize = nsize;
|
||||
mediatype->ExtraDataSize = (UINT32)nsize;
|
||||
mediatype->ExtraData = Stream_Pointer(s);
|
||||
}
|
||||
break;
|
||||
|
@ -57,8 +57,8 @@ struct s_ITSMFDecoder
|
||||
UINT64 (*GetRunningTime)(ITSMFDecoder* decoder);
|
||||
/* Update Gstreamer Rendering Area */
|
||||
BOOL(*UpdateRenderingArea)
|
||||
(ITSMFDecoder* decoder, int newX, int newY, int newWidth, int newHeight, int numRectangles,
|
||||
RDP_RECT* rectangles);
|
||||
(ITSMFDecoder* decoder, UINT32 newX, UINT32 newY, UINT32 newWidth, UINT32 newHeight,
|
||||
UINT32 numRectangles, const RECTANGLE_32* rectangles);
|
||||
/* Change Gstreamer Audio Volume */
|
||||
BOOL (*ChangeVolume)(ITSMFDecoder* decoder, UINT32 newVolume, UINT32 muted);
|
||||
/* Check buffer level */
|
||||
|
@ -68,8 +68,6 @@ UINT tsmf_ifman_rim_exchange_capability_request(TSMF_IFMAN* ifman)
|
||||
*/
|
||||
UINT tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman)
|
||||
{
|
||||
UINT32 v = 0;
|
||||
UINT32 pos = 0;
|
||||
UINT32 CapabilityType = 0;
|
||||
UINT32 cbCapabilityLength = 0;
|
||||
UINT32 numHostCapabilities = 0;
|
||||
@ -81,9 +79,9 @@ UINT tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, ifman->input, ifman->input_size))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
pos = Stream_GetPosition(ifman->output);
|
||||
const size_t xpos = Stream_GetPosition(ifman->output);
|
||||
Stream_Copy(ifman->input, ifman->output, ifman->input_size);
|
||||
Stream_SetPosition(ifman->output, pos);
|
||||
Stream_SetPosition(ifman->output, xpos);
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, ifman->output, 4))
|
||||
return ERROR_INVALID_DATA;
|
||||
@ -101,28 +99,34 @@ UINT tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, ifman->output, cbCapabilityLength))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
pos = Stream_GetPosition(ifman->output);
|
||||
const size_t pos = Stream_GetPosition(ifman->output);
|
||||
|
||||
switch (CapabilityType)
|
||||
{
|
||||
case 1: /* Protocol version request */
|
||||
{
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, ifman->output, 4))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
Stream_Read_UINT32(ifman->output, v);
|
||||
const UINT32 v = Stream_Get_UINT32(ifman->output);
|
||||
WINPR_UNUSED(v);
|
||||
DEBUG_TSMF("server protocol version %" PRIu32 "", v);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: /* Supported platform */
|
||||
{
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, ifman->output, 4))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
Stream_Peek_UINT32(ifman->output, v);
|
||||
const UINT32 v = Stream_Get_UINT32(ifman->output);
|
||||
WINPR_UNUSED(v);
|
||||
DEBUG_TSMF("server supported platform %" PRIu32 "", v);
|
||||
/* Claim that we support both MF and DShow platforms. */
|
||||
Stream_Write_UINT32(ifman->output, MMREDIR_CAPABILITY_PLATFORM_MF |
|
||||
MMREDIR_CAPABILITY_PLATFORM_DSHOW);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
WLog_ERR(TAG, "skipping unknown capability type %" PRIu32 "", CapabilityType);
|
||||
@ -482,8 +486,7 @@ UINT tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman)
|
||||
UINT32 Width = 0;
|
||||
UINT32 Height = 0;
|
||||
UINT32 cbVisibleRect = 0;
|
||||
RDP_RECT* rects = NULL;
|
||||
int num_rects = 0;
|
||||
RECTANGLE_32* rects = NULL;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
size_t pos = 0;
|
||||
|
||||
@ -505,34 +508,32 @@ UINT tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman)
|
||||
Stream_Read_UINT32(ifman->input, Top);
|
||||
Stream_SetPosition(ifman->input, pos + numGeometryInfo);
|
||||
Stream_Read_UINT32(ifman->input, cbVisibleRect);
|
||||
num_rects = cbVisibleRect / 16;
|
||||
const UINT32 num_rects = cbVisibleRect / 16;
|
||||
DEBUG_TSMF("numGeometryInfo %" PRIu32 " Width %" PRIu32 " Height %" PRIu32 " Left %" PRIu32
|
||||
" Top %" PRIu32 " cbVisibleRect %" PRIu32 " num_rects %d",
|
||||
numGeometryInfo, Width, Height, Left, Top, cbVisibleRect, num_rects);
|
||||
|
||||
if (num_rects > 0)
|
||||
{
|
||||
rects = (RDP_RECT*)calloc(num_rects, sizeof(RDP_RECT));
|
||||
rects = (RECTANGLE_32*)calloc(num_rects, sizeof(RECTANGLE_32));
|
||||
|
||||
for (UINT32 i = 0; i < num_rects; i++)
|
||||
for (size_t i = 0; i < num_rects; i++)
|
||||
{
|
||||
Stream_Read_UINT16(ifman->input, rects[i].y); /* Top */
|
||||
Stream_Seek_UINT16(ifman->input);
|
||||
Stream_Read_UINT16(ifman->input, rects[i].x); /* Left */
|
||||
Stream_Seek_UINT16(ifman->input);
|
||||
Stream_Read_UINT16(ifman->input, rects[i].height); /* Bottom */
|
||||
Stream_Seek_UINT16(ifman->input);
|
||||
Stream_Read_UINT16(ifman->input, rects[i].width); /* Right */
|
||||
Stream_Seek_UINT16(ifman->input);
|
||||
rects[i].width -= rects[i].x;
|
||||
rects[i].height -= rects[i].y;
|
||||
Stream_Read_UINT32(ifman->input, rects[i].top); /* Top */
|
||||
Stream_Read_UINT32(ifman->input, rects[i].left); /* Left */
|
||||
Stream_Read_UINT32(ifman->input, rects[i].height); /* Bottom */
|
||||
Stream_Read_UINT32(ifman->input, rects[i].width); /* Right */
|
||||
rects[i].width -= rects[i].left;
|
||||
rects[i].height -= rects[i].top;
|
||||
DEBUG_TSMF("rect %d: %" PRId16 " %" PRId16 " %" PRId16 " %" PRId16 "", i, rects[i].x,
|
||||
rects[i].y, rects[i].width, rects[i].height);
|
||||
}
|
||||
}
|
||||
|
||||
if (!tsmf_presentation_set_geometry_info(presentation, Left, Top, Width, Height, num_rects,
|
||||
rects))
|
||||
const BOOL rc = tsmf_presentation_set_geometry_info(presentation, Left, Top, Width, Height,
|
||||
num_rects, rects);
|
||||
free(rects);
|
||||
if (!rc)
|
||||
return ERROR_INVALID_OPERATION;
|
||||
|
||||
ifman->output_pending = TRUE;
|
||||
|
@ -36,8 +36,7 @@
|
||||
|
||||
BOOL tsmf_send_eos_response(IWTSVirtualChannelCallback* pChannelCallback, UINT32 message_id)
|
||||
{
|
||||
wStream* s = NULL;
|
||||
int status = -1;
|
||||
ssize_t status = -1;
|
||||
TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*)pChannelCallback;
|
||||
|
||||
if (!callback)
|
||||
@ -48,7 +47,7 @@ BOOL tsmf_send_eos_response(IWTSVirtualChannelCallback* pChannelCallback, UINT32
|
||||
|
||||
if (callback && callback->stream_id && callback->channel && callback->channel->Write)
|
||||
{
|
||||
s = Stream_New(NULL, 24);
|
||||
wStream* s = Stream_New(NULL, 24);
|
||||
|
||||
if (!s)
|
||||
return FALSE;
|
||||
@ -59,9 +58,10 @@ BOOL tsmf_send_eos_response(IWTSVirtualChannelCallback* pChannelCallback, UINT32
|
||||
Stream_Write_UINT32(s, callback->stream_id); /* StreamId */
|
||||
Stream_Write_UINT32(s, TSMM_CLIENT_EVENT_ENDOFSTREAM); /* EventId */
|
||||
Stream_Write_UINT32(s, 0); /* cbData */
|
||||
DEBUG_TSMF("EOS response size %" PRIuz "", Stream_GetPosition(s));
|
||||
status = callback->channel->Write(callback->channel, Stream_GetPosition(s),
|
||||
Stream_Buffer(s), NULL);
|
||||
const size_t pos = Stream_GetPosition(s);
|
||||
DEBUG_TSMF("EOS response size %" PRIuz "", pos);
|
||||
WINPR_ASSERT(pos <= UINT32_MAX);
|
||||
status = callback->channel->Write(callback->channel, (UINT32)pos, Stream_Buffer(s), NULL);
|
||||
|
||||
if (status)
|
||||
{
|
||||
@ -77,14 +77,13 @@ BOOL tsmf_send_eos_response(IWTSVirtualChannelCallback* pChannelCallback, UINT32
|
||||
BOOL tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback, UINT32 message_id,
|
||||
UINT64 duration, UINT32 data_size)
|
||||
{
|
||||
wStream* s = NULL;
|
||||
int status = -1;
|
||||
ssize_t status = -1;
|
||||
TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*)pChannelCallback;
|
||||
|
||||
if (!callback)
|
||||
return FALSE;
|
||||
|
||||
s = Stream_New(NULL, 32);
|
||||
wStream* s = Stream_New(NULL, 32);
|
||||
|
||||
if (!s)
|
||||
return FALSE;
|
||||
@ -95,7 +94,9 @@ BOOL tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback, UINT32 mess
|
||||
Stream_Write_UINT32(s, callback->stream_id); /* StreamId */
|
||||
Stream_Write_UINT64(s, duration); /* DataDuration */
|
||||
Stream_Write_UINT64(s, data_size); /* cbData */
|
||||
DEBUG_TSMF("ACK response size %" PRIuz "", Stream_GetPosition(s));
|
||||
|
||||
const size_t pos = Stream_GetPosition(s);
|
||||
DEBUG_TSMF("ACK response size %" PRIuz "", pos);
|
||||
|
||||
if (!callback->channel || !callback->channel->Write)
|
||||
{
|
||||
@ -105,8 +106,8 @@ BOOL tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback, UINT32 mess
|
||||
}
|
||||
else
|
||||
{
|
||||
status = callback->channel->Write(callback->channel, Stream_GetPosition(s),
|
||||
Stream_Buffer(s), NULL);
|
||||
WINPR_ASSERT(pos <= UINT32_MAX);
|
||||
status = callback->channel->Write(callback->channel, (UINT32)pos, Stream_Buffer(s), NULL);
|
||||
}
|
||||
|
||||
if (status)
|
||||
@ -125,7 +126,6 @@ BOOL tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback, UINT32 mess
|
||||
*/
|
||||
static UINT tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data)
|
||||
{
|
||||
size_t length = 0;
|
||||
wStream* input = NULL;
|
||||
wStream* output = NULL;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
@ -135,10 +135,10 @@ static UINT tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
|
||||
UINT32 FunctionId = 0;
|
||||
UINT32 InterfaceId = 0;
|
||||
TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*)pChannelCallback;
|
||||
UINT32 cbSize = Stream_GetRemainingLength(data);
|
||||
const size_t cbSize = Stream_GetRemainingLength(data);
|
||||
|
||||
/* 2.2.1 Shared Message Header (SHARED_MSG_HEADER) */
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, data, 12))
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, data, 12) || (cbSize > UINT32_MAX))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
input = data;
|
||||
@ -162,7 +162,7 @@ static UINT tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
|
||||
ifman.stream_id = callback->stream_id;
|
||||
ifman.message_id = MessageId;
|
||||
ifman.input = input;
|
||||
ifman.input_size = cbSize - 12;
|
||||
ifman.input_size = (UINT32)(cbSize - 12U);
|
||||
ifman.output = output;
|
||||
ifman.output_pending = FALSE;
|
||||
ifman.output_interface_id = InterfaceId;
|
||||
@ -374,12 +374,15 @@ static UINT tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
|
||||
if (processed && !ifman.output_pending)
|
||||
{
|
||||
/* Response packet does not have FunctionId */
|
||||
length = Stream_GetPosition(output);
|
||||
const size_t length = Stream_GetPosition(output);
|
||||
if (length > UINT32_MAX)
|
||||
goto out;
|
||||
Stream_SetPosition(output, 0);
|
||||
Stream_Write_UINT32(output, ifman.output_interface_id);
|
||||
Stream_Write_UINT32(output, MessageId);
|
||||
DEBUG_TSMF("response size %d", length);
|
||||
error = callback->channel->Write(callback->channel, length, Stream_Buffer(output), NULL);
|
||||
error = callback->channel->Write(callback->channel, (UINT32)length, Stream_Buffer(output),
|
||||
NULL);
|
||||
|
||||
if (error)
|
||||
{
|
||||
|
@ -79,13 +79,10 @@ struct S_TSMF_PRESENTATION
|
||||
|
||||
wArrayList* stream_list;
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
RECTANGLE_32 rect;
|
||||
|
||||
int nr_rects;
|
||||
void* rects;
|
||||
UINT32 nr_rects;
|
||||
RECTANGLE_32* rects;
|
||||
};
|
||||
|
||||
struct S_TSMF_STREAM
|
||||
@ -166,16 +163,13 @@ static UINT64 get_current_time(void)
|
||||
|
||||
static TSMF_SAMPLE* tsmf_stream_pop_sample(TSMF_STREAM* stream, int sync)
|
||||
{
|
||||
UINT32 count = 0;
|
||||
TSMF_STREAM* s = NULL;
|
||||
TSMF_SAMPLE* sample = NULL;
|
||||
BOOL pending = FALSE;
|
||||
TSMF_PRESENTATION* presentation = NULL;
|
||||
|
||||
if (!stream)
|
||||
return NULL;
|
||||
|
||||
presentation = stream->presentation;
|
||||
TSMF_PRESENTATION* presentation = stream->presentation;
|
||||
|
||||
if (Queue_Count(stream->sample_list) < 1)
|
||||
return NULL;
|
||||
@ -196,11 +190,12 @@ static TSMF_SAMPLE* tsmf_stream_pop_sample(TSMF_STREAM* stream, int sync)
|
||||
if (stream->last_start_time > AUDIO_TOLERANCE)
|
||||
{
|
||||
ArrayList_Lock(presentation->stream_list);
|
||||
count = ArrayList_Count(presentation->stream_list);
|
||||
const size_t count = ArrayList_Count(presentation->stream_list);
|
||||
|
||||
for (UINT32 index = 0; index < count; index++)
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
s = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index);
|
||||
TSMF_STREAM* s =
|
||||
(TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index);
|
||||
|
||||
/* Start time is more reliable than end time as some stream types seem
|
||||
* to have incorrect end times from the server
|
||||
@ -391,12 +386,11 @@ static char* guid_to_string(const BYTE* guid, char* str, size_t len)
|
||||
|
||||
TSMF_PRESENTATION* tsmf_presentation_find_by_id(const BYTE* guid)
|
||||
{
|
||||
UINT32 count = 0;
|
||||
BOOL found = FALSE;
|
||||
char guid_str[GUID_SIZE * 2 + 1] = { 0 };
|
||||
TSMF_PRESENTATION* presentation = NULL;
|
||||
ArrayList_Lock(presentation_list);
|
||||
count = ArrayList_Count(presentation_list);
|
||||
const size_t count = ArrayList_Count(presentation_list);
|
||||
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
@ -420,8 +414,8 @@ TSMF_PRESENTATION* tsmf_presentation_find_by_id(const BYTE* guid)
|
||||
|
||||
static BOOL tsmf_sample_playback_video(TSMF_SAMPLE* sample)
|
||||
{
|
||||
UINT64 t = 0;
|
||||
TSMF_VIDEO_FRAME_EVENT event;
|
||||
WINPR_ASSERT(sample);
|
||||
|
||||
TSMF_STREAM* stream = sample->stream;
|
||||
TSMF_PRESENTATION* presentation = stream->presentation;
|
||||
TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*)sample->channel_callback;
|
||||
@ -431,7 +425,7 @@ static BOOL tsmf_sample_playback_video(TSMF_SAMPLE* sample)
|
||||
|
||||
if (sample->data)
|
||||
{
|
||||
t = get_current_time();
|
||||
const UINT64 t = get_current_time();
|
||||
|
||||
/* Start time is more reliable than end time as some stream types seem to have incorrect
|
||||
* end times from the server
|
||||
@ -440,24 +434,46 @@ static BOOL tsmf_sample_playback_video(TSMF_SAMPLE* sample)
|
||||
((sample->start_time >= presentation->audio_start_time) ||
|
||||
((sample->start_time < stream->last_start_time) && (!sample->invalidTimestamps))))
|
||||
{
|
||||
USleep((stream->next_start_time - t) / 10);
|
||||
size_t delay = (stream->next_start_time - t) / 10;
|
||||
while (delay > 0)
|
||||
{
|
||||
const UINT32 d = (delay > UINT32_MAX) ? UINT32_MAX : (UINT32)delay;
|
||||
USleep(d);
|
||||
delay -= d;
|
||||
}
|
||||
}
|
||||
|
||||
if (sample->stream->width > INT16_MAX)
|
||||
return FALSE;
|
||||
if (sample->stream->height > INT16_MAX)
|
||||
return FALSE;
|
||||
if (presentation->rect.left > INT16_MAX)
|
||||
return FALSE;
|
||||
if (presentation->rect.top > INT16_MAX)
|
||||
return FALSE;
|
||||
if (presentation->rect.width > INT16_MAX)
|
||||
return FALSE;
|
||||
if (presentation->rect.height > INT16_MAX)
|
||||
return FALSE;
|
||||
if (presentation->nr_rects > UINT16_MAX)
|
||||
return FALSE;
|
||||
|
||||
stream->next_start_time = t + sample->duration - 50000;
|
||||
ZeroMemory(&event, sizeof(TSMF_VIDEO_FRAME_EVENT));
|
||||
|
||||
TSMF_VIDEO_FRAME_EVENT event = { 0 };
|
||||
event.frameData = sample->data;
|
||||
event.frameSize = sample->decoded_size;
|
||||
event.framePixFmt = sample->pixfmt;
|
||||
event.frameWidth = sample->stream->width;
|
||||
event.frameHeight = sample->stream->height;
|
||||
event.x = presentation->x;
|
||||
event.y = presentation->y;
|
||||
event.width = presentation->width;
|
||||
event.height = presentation->height;
|
||||
event.frameWidth = (INT16)sample->stream->width;
|
||||
event.frameHeight = (INT16)sample->stream->height;
|
||||
event.x = (INT16)presentation->rect.left;
|
||||
event.y = (INT16)presentation->rect.top;
|
||||
event.width = (INT16)presentation->rect.width;
|
||||
event.height = (INT16)presentation->rect.height;
|
||||
|
||||
if (presentation->nr_rects > 0)
|
||||
{
|
||||
event.numVisibleRects = presentation->nr_rects;
|
||||
event.numVisibleRects = (UINT16)presentation->nr_rects;
|
||||
event.visibleRects = (RECTANGLE_16*)calloc(event.numVisibleRects, sizeof(RECTANGLE_16));
|
||||
|
||||
if (!event.visibleRects)
|
||||
@ -466,36 +482,26 @@ static BOOL tsmf_sample_playback_video(TSMF_SAMPLE* sample)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (size_t x = 0; x < presentation->nr_rects; x++)
|
||||
{
|
||||
const RECTANGLE_32* cur = &presentation->rects[x];
|
||||
RECTANGLE_16* dst = &event.visibleRects[x];
|
||||
if ((cur->left > UINT16_MAX) || (cur->top > UINT16_MAX) ||
|
||||
(cur->width > UINT16_MAX) || (cur->height > UINT16_MAX))
|
||||
{
|
||||
free(event.visibleRects);
|
||||
return FALSE;
|
||||
}
|
||||
dst->right = dst->left = (UINT16)cur->left;
|
||||
dst->bottom = dst->top = (UINT16)cur->top;
|
||||
dst->right += (UINT16)cur->width;
|
||||
dst->bottom += (UINT16)cur->height;
|
||||
}
|
||||
memcpy(event.visibleRects, presentation->rects,
|
||||
presentation->nr_rects * sizeof(RDP_RECT));
|
||||
presentation->nr_rects * sizeof(RECTANGLE_16));
|
||||
presentation->nr_rects = 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Dump a .ppm image for every 30 frames. Assuming the frame is in YUV format, we
|
||||
extract the Y values to create a grayscale image. */
|
||||
static int frame_id = 0;
|
||||
char buf[100];
|
||||
|
||||
if ((frame_id % 30) == 0)
|
||||
{
|
||||
sprintf_s(buf, sizeof(buf), "/tmp/FreeRDP_Frame_%d.ppm", frame_id);
|
||||
FILE* fp = fopen(buf, "wb");
|
||||
if (fp)
|
||||
{
|
||||
fwrite("P5\n", 1, 3, fp);
|
||||
sprintf_s(buf, sizeof(buf), "%"PRIu32" %"PRIu32"\n", sample->stream->width,
|
||||
sample->stream->height);
|
||||
fwrite(buf, 1, strnlen(buf, sizeof(buf)), fp);
|
||||
fwrite("255\n", 1, 4, fp);
|
||||
fwrite(sample->data, 1, sample->stream->width * sample->stream->height, fp);
|
||||
fflush(fp);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
frame_id++;
|
||||
#endif
|
||||
/* The frame data ownership is passed to the event object, and is freed after the event is
|
||||
* processed. */
|
||||
sample->data = NULL;
|
||||
@ -505,9 +511,7 @@ static BOOL tsmf_sample_playback_video(TSMF_SAMPLE* sample)
|
||||
tsmf->FrameEvent(tsmf, &event);
|
||||
|
||||
free(event.frameData);
|
||||
|
||||
if (event.visibleRects != NULL)
|
||||
free(event.visibleRects);
|
||||
free(event.visibleRects);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -574,7 +578,7 @@ static BOOL tsmf_sample_playback(TSMF_SAMPLE* sample)
|
||||
TSMF_STREAM* temp_stream = NULL;
|
||||
TSMF_PRESENTATION* presentation = stream->presentation;
|
||||
ArrayList_Lock(presentation->stream_list);
|
||||
int count = ArrayList_Count(presentation->stream_list);
|
||||
const size_t count = ArrayList_Count(presentation->stream_list);
|
||||
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
@ -1080,11 +1084,10 @@ BOOL tsmf_presentation_stop(TSMF_PRESENTATION* presentation)
|
||||
}
|
||||
|
||||
BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation, UINT32 x, UINT32 y,
|
||||
UINT32 width, UINT32 height, int num_rects,
|
||||
RDP_RECT* rects)
|
||||
UINT32 width, UINT32 height, UINT32 num_rects,
|
||||
const RECTANGLE_32* rects)
|
||||
{
|
||||
TSMF_STREAM* stream = NULL;
|
||||
void* tmp_rects = NULL;
|
||||
BOOL ret = TRUE;
|
||||
|
||||
/* The server may send messages with invalid width / height.
|
||||
@ -1097,19 +1100,19 @@ BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation, UINT32
|
||||
* or not the window is visible. So, always process a valid message with unchanged position/size
|
||||
* and/or no visibility rects.
|
||||
*/
|
||||
presentation->x = x;
|
||||
presentation->y = y;
|
||||
presentation->width = width;
|
||||
presentation->height = height;
|
||||
tmp_rects = realloc(presentation->rects, sizeof(RDP_RECT) * num_rects);
|
||||
presentation->rect.left = x;
|
||||
presentation->rect.top = y;
|
||||
presentation->rect.width = width;
|
||||
presentation->rect.height = height;
|
||||
void* tmp_rects = realloc(presentation->rects, sizeof(RECTANGLE_32) * num_rects);
|
||||
|
||||
if (!tmp_rects && num_rects)
|
||||
return FALSE;
|
||||
|
||||
presentation->nr_rects = num_rects;
|
||||
presentation->rects = tmp_rects;
|
||||
presentation->rects = (RECTANGLE_32*)tmp_rects;
|
||||
if (presentation->rects)
|
||||
CopyMemory(presentation->rects, rects, sizeof(RDP_RECT) * num_rects);
|
||||
CopyMemory(presentation->rects, rects, sizeof(RECTANGLE_32) * num_rects);
|
||||
ArrayList_Lock(presentation->stream_list);
|
||||
size_t count = ArrayList_Count(presentation->stream_list);
|
||||
|
||||
|
@ -47,8 +47,8 @@ BOOL tsmf_presentation_restarted(TSMF_PRESENTATION* presentation);
|
||||
BOOL tsmf_presentation_volume_changed(TSMF_PRESENTATION* presentation, UINT32 newVolume,
|
||||
UINT32 muted);
|
||||
BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation, UINT32 x, UINT32 y,
|
||||
UINT32 width, UINT32 height, int num_rects,
|
||||
RDP_RECT* rects);
|
||||
UINT32 width, UINT32 height, UINT32 num_rects,
|
||||
const RECTANGLE_32* rects);
|
||||
void tsmf_presentation_set_audio_device(TSMF_PRESENTATION* presentation, const char* name,
|
||||
const char* device);
|
||||
void tsmf_presentation_free(TSMF_PRESENTATION* presentation);
|
||||
|
@ -784,6 +784,7 @@ static int libusb_udev_control_pipe_request(IUDEVICE* idev, UINT32 RequestId,
|
||||
int error = 0;
|
||||
UDEVICE* pdev = (UDEVICE*)idev;
|
||||
|
||||
WINPR_ASSERT(EndpointAddress <= UINT8_MAX);
|
||||
/*
|
||||
pdev->request_queue->register_request(pdev->request_queue, RequestId, NULL, 0);
|
||||
*/
|
||||
@ -794,14 +795,18 @@ static int libusb_udev_control_pipe_request(IUDEVICE* idev, UINT32 RequestId,
|
||||
idev->cancel_all_transfer_request(idev);
|
||||
// dummy_wait_s_obj(1);
|
||||
/** set feature to ep (set halt)*/
|
||||
error = libusb_control_transfer(
|
||||
pdev->libusb_handle, LIBUSB_ENDPOINT_OUT | LIBUSB_RECIPIENT_ENDPOINT,
|
||||
LIBUSB_REQUEST_SET_FEATURE, ENDPOINT_HALT, EndpointAddress, NULL, 0, 1000);
|
||||
/*
|
||||
uint8_t request_type, uint8_t bRequest,
|
||||
*/
|
||||
error = libusb_control_transfer(pdev->libusb_handle,
|
||||
LIBUSB_ENDPOINT_OUT | LIBUSB_RECIPIENT_ENDPOINT,
|
||||
LIBUSB_REQUEST_SET_FEATURE, ENDPOINT_HALT,
|
||||
(uint16_t)EndpointAddress, NULL, 0, 1000);
|
||||
break;
|
||||
|
||||
case PIPE_RESET:
|
||||
idev->cancel_all_transfer_request(idev);
|
||||
error = libusb_clear_halt(pdev->libusb_handle, EndpointAddress);
|
||||
error = libusb_clear_halt(pdev->libusb_handle, (uint8_t)EndpointAddress);
|
||||
// func_set_usbd_status(pdev, UsbdStatus, error);
|
||||
break;
|
||||
|
||||
|
@ -35,9 +35,9 @@ class SdlSelectWidget : public SdlWidget
|
||||
SdlSelectWidget& operator=(const SdlSelectWidget& other) = delete;
|
||||
SdlSelectWidget& operator=(SdlSelectWidget&& other) = delete;
|
||||
|
||||
bool set_mouseover(SDL_Renderer* renderer, bool mouseOver);
|
||||
bool set_highlight(SDL_Renderer* renderer, bool highlight);
|
||||
bool update_text(SDL_Renderer* renderer);
|
||||
virtual bool set_mouseover(SDL_Renderer* renderer, bool mouseOver);
|
||||
virtual bool set_highlight(SDL_Renderer* renderer, bool highlight);
|
||||
virtual bool update_text(SDL_Renderer* renderer);
|
||||
|
||||
private:
|
||||
std::string _text;
|
||||
|
@ -207,7 +207,7 @@ bool sdlClip::handle_update(const SDL_ClipboardEvent& ev)
|
||||
clientFormats.erase(u, clientFormats.end());
|
||||
|
||||
const CLIPRDR_FORMAT_LIST formatList = {
|
||||
.common = { .msgType = CB_FORMAT_LIST, .msgFlags = 0 },
|
||||
.common = { .msgType = CB_FORMAT_LIST, .msgFlags = 0, .dataLen = 0 },
|
||||
.numFormats = static_cast<UINT32>(clientFormats.size()),
|
||||
.formats = clientFormats.data(),
|
||||
};
|
||||
@ -258,6 +258,7 @@ UINT sdlClip::SendClientCapabilities()
|
||||
.generalFlags = CB_USE_LONG_FORMAT_NAMES | cliprdr_file_context_current_flags(_file)
|
||||
};
|
||||
CLIPRDR_CAPABILITIES capabilities = {
|
||||
.common = { .msgType = CB_TYPE_NONE, .msgFlags = 0, .dataLen = 0 },
|
||||
.cCapabilitiesSets = 1,
|
||||
.capabilitySets = reinterpret_cast<CLIPRDR_CAPABILITY_SET*>(&generalCapabilitySet)
|
||||
};
|
||||
@ -303,7 +304,10 @@ UINT sdlClip::SendDataResponse(const BYTE* data, size_t size)
|
||||
|
||||
UINT sdlClip::SendDataRequest(uint32_t formatID, const std::string& mime)
|
||||
{
|
||||
CLIPRDR_FORMAT_DATA_REQUEST request = { .requestedFormatId = formatID };
|
||||
CLIPRDR_FORMAT_DATA_REQUEST request = {
|
||||
.common = { .msgType = CB_TYPE_NONE, .msgFlags = 0, .dataLen = 0 },
|
||||
.requestedFormatId = formatID
|
||||
};
|
||||
|
||||
_request_queue.push({ formatID, mime });
|
||||
|
||||
|
@ -405,14 +405,15 @@ static int xf_tsmf_xv_init(xfContext* xfc, TsmfClientContext* tsmf)
|
||||
{
|
||||
xv->xv_pixfmts = (UINT32*)calloc((ret + 1), sizeof(UINT32));
|
||||
|
||||
for (unsigned int i = 0; i < (unsigned int)ret; i++)
|
||||
size_t x = 0;
|
||||
for (; x < (size_t)ret; x++)
|
||||
{
|
||||
xv->xv_pixfmts[i] = fo[i].id;
|
||||
WLog_DBG(TAG, "%c%c%c%c ", ((char*)(xv->xv_pixfmts + i))[0],
|
||||
((char*)(xv->xv_pixfmts + i))[1], ((char*)(xv->xv_pixfmts + i))[2],
|
||||
((char*)(xv->xv_pixfmts + i))[3]);
|
||||
xv->xv_pixfmts[x] = fo[x].id;
|
||||
WLog_DBG(TAG, "%c%c%c%c ", ((char*)(xv->xv_pixfmts + x))[0],
|
||||
((char*)(xv->xv_pixfmts + x))[1], ((char*)(xv->xv_pixfmts + x))[2],
|
||||
((char*)(xv->xv_pixfmts + x))[3]);
|
||||
}
|
||||
xv->xv_pixfmts[i] = 0;
|
||||
xv->xv_pixfmts[x] = 0;
|
||||
}
|
||||
XFree(fo);
|
||||
|
||||
|
@ -1208,7 +1208,7 @@ static int freerdp_client_command_line_post_filter_int(void* context, COMMAND_LI
|
||||
{
|
||||
size_t count = 0;
|
||||
char** ptr = CommandLineParseCommaSeparatedValuesEx("tsmf", arg->Value, &count);
|
||||
if (!freerdp_client_add_dynamic_channel(settings, count, ptr))
|
||||
if (!freerdp_client_add_dynamic_channel(settings, count, (const char* const*)ptr))
|
||||
status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
||||
CommandLineParserFree(ptr);
|
||||
if (status)
|
||||
|
@ -36,6 +36,7 @@
|
||||
/* CLIPRDR_HEADER.msgType */
|
||||
typedef enum
|
||||
{
|
||||
CB_TYPE_NONE = 0x0000, /** @since version 3.10.0 */
|
||||
CB_MONITOR_READY = 0x0001,
|
||||
CB_FORMAT_LIST = 0x0002,
|
||||
CB_FORMAT_LIST_RESPONSE = 0x0003,
|
||||
|
@ -1074,14 +1074,14 @@ void freerdp_set_last_error_ex(rdpContext* context, UINT32 lastError, const char
|
||||
if (lastError == FREERDP_ERROR_SUCCESS)
|
||||
{
|
||||
if (WLog_IsLevelActive(context->log, WLOG_DEBUG))
|
||||
WLog_PrintMessage(context->log, WLOG_MESSAGE_TEXT, WLOG_DEBUG, line, file, fkt,
|
||||
WLog_PrintMessage(context->log, WLOG_MESSAGE_TEXT, WLOG_DEBUG, (size_t)line, file, fkt,
|
||||
"resetting error state");
|
||||
}
|
||||
else if (context->LastError != FREERDP_ERROR_SUCCESS)
|
||||
{
|
||||
if (WLog_IsLevelActive(context->log, WLOG_ERROR))
|
||||
{
|
||||
WLog_PrintMessage(context->log, WLOG_MESSAGE_TEXT, WLOG_ERROR, line, file, fkt,
|
||||
WLog_PrintMessage(context->log, WLOG_MESSAGE_TEXT, WLOG_ERROR, (size_t)line, file, fkt,
|
||||
"TODO: Trying to set error code %s, but %s already set!",
|
||||
freerdp_get_last_error_name(lastError),
|
||||
freerdp_get_last_error_name(context->LastError));
|
||||
|
@ -24,8 +24,6 @@
|
||||
#include <freerdp/version.h>
|
||||
#include <freerdp/build-config.h>
|
||||
|
||||
#define STR(x) #x
|
||||
|
||||
char* freerdp_GetConfigFilePath(BOOL system, const char* filename)
|
||||
{
|
||||
eKnownPathTypes id = system ? KNOWN_PATH_SYSTEM_CONFIG_HOME : KNOWN_PATH_XDG_CONFIG_HOME;
|
||||
|
@ -136,6 +136,7 @@ extern "C"
|
||||
* @return \b NULL in case of failure, a pointer to an allocated buffer otherwise. Use \b free
|
||||
* as deallocator
|
||||
*/
|
||||
WINPR_ATTR_MALLOC(free, 1)
|
||||
WINPR_API void* winpr_image_write_buffer(wImage* image, UINT32 format, size_t* size);
|
||||
WINPR_API int winpr_image_read_buffer(wImage* image, const BYTE* buffer, size_t size);
|
||||
|
||||
|
@ -367,7 +367,15 @@ static void* clipboard_synthesize_image_bmp_to_format(wClipboard* clipboard, UIN
|
||||
|
||||
result = winpr_image_write_buffer(img, bmpFormat, &dsize);
|
||||
if (result)
|
||||
*pSize = dsize;
|
||||
{
|
||||
if (dsize <= UINT32_MAX)
|
||||
*pSize = (UINT32)dsize;
|
||||
else
|
||||
{
|
||||
free(result);
|
||||
result = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
fail:
|
||||
free(bmp);
|
||||
|
@ -54,7 +54,7 @@ static const SCardApiFunctionTable* g_SCardApi = NULL;
|
||||
} \
|
||||
return g_SCardApi->pfn##_name(__VA_ARGS__)
|
||||
|
||||
#define SCARDAPI_STUB_CALL_HANDLE(_name, ...) \
|
||||
#define SCARDAPI_STUB_CALL_HANDLE(_name) \
|
||||
InitOnceExecuteOnce(&g_Initialized, InitializeSCardApiStubs, NULL, NULL); \
|
||||
if (!g_SCardApi || !g_SCardApi->pfn##_name) \
|
||||
{ \
|
||||
@ -62,9 +62,9 @@ static const SCardApiFunctionTable* g_SCardApi = NULL;
|
||||
g_SCardApi, g_SCardApi ? g_SCardApi->pfn##_name : NULL); \
|
||||
return NULL; \
|
||||
} \
|
||||
return g_SCardApi->pfn##_name(__VA_ARGS__)
|
||||
return g_SCardApi->pfn##_name()
|
||||
|
||||
#define SCARDAPI_STUB_CALL_VOID(_name, ...) \
|
||||
#define SCARDAPI_STUB_CALL_VOID(_name) \
|
||||
InitOnceExecuteOnce(&g_Initialized, InitializeSCardApiStubs, NULL, NULL); \
|
||||
if (!g_SCardApi || !g_SCardApi->pfn##_name) \
|
||||
{ \
|
||||
@ -72,7 +72,7 @@ static const SCardApiFunctionTable* g_SCardApi = NULL;
|
||||
g_SCardApi, g_SCardApi ? g_SCardApi->pfn##_name : NULL); \
|
||||
return; \
|
||||
} \
|
||||
g_SCardApi->pfn##_name(__VA_ARGS__)
|
||||
g_SCardApi->pfn##_name()
|
||||
|
||||
/**
|
||||
* Standard Windows Smart Card API
|
||||
|
@ -267,6 +267,7 @@ fail:
|
||||
* Refer to "Compressed Image File Formats: JPEG, PNG, GIF, XBM, BMP" book
|
||||
*/
|
||||
|
||||
WINPR_ATTR_MALLOC(free, 1)
|
||||
static void* winpr_bitmap_write_buffer(const BYTE* data, size_t size, UINT32 width, UINT32 height,
|
||||
UINT32 stride, UINT32 bpp, UINT32* pSize)
|
||||
{
|
||||
@ -641,7 +642,8 @@ static void* winpr_convert_to_jpeg(const void* data, size_t size, UINT32 width,
|
||||
const JSAMPLE* cdata = data;
|
||||
for (size_t x = 0; x < height; x++)
|
||||
{
|
||||
const JDIMENSION offset = x * stride;
|
||||
WINPR_ASSERT(x * stride <= UINT32_MAX);
|
||||
const JDIMENSION offset = (JDIMENSION)x * stride;
|
||||
|
||||
/* libjpeg is not const correct, we must cast here to avoid issues
|
||||
* with newer C compilers type check errors */
|
||||
@ -654,7 +656,8 @@ fail:
|
||||
jpeg_finish_compress(&cinfo);
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
|
||||
*pSize = outsize;
|
||||
WINPR_ASSERT(outsize <= UINT32_MAX);
|
||||
*pSize = (UINT32)outsize;
|
||||
return outbuffer;
|
||||
#endif
|
||||
}
|
||||
@ -750,7 +753,9 @@ static void* winpr_convert_to_webp(const void* data, size_t size, UINT32 width,
|
||||
if (rc)
|
||||
{
|
||||
memcpy(rc, pDstData, dstSize);
|
||||
*pSize = dstSize;
|
||||
|
||||
WINPR_ASSERT(dstSize <= UINT32_MAX);
|
||||
*pSize = (UINT32)dstSize;
|
||||
}
|
||||
WebPFree(pDstData);
|
||||
return rc;
|
||||
@ -944,6 +949,9 @@ static void* winpr_read_png_from_buffer(const void* data, size_t SrcSize, size_t
|
||||
MEMORY_READER_STATE memory_reader_state = { 0 };
|
||||
png_bytepp row_pointers = NULL;
|
||||
png_infop info_ptr = NULL;
|
||||
if (SrcSize > UINT32_MAX)
|
||||
return NULL;
|
||||
|
||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (!png_ptr)
|
||||
goto fail;
|
||||
@ -952,7 +960,7 @@ static void* winpr_read_png_from_buffer(const void* data, size_t SrcSize, size_t
|
||||
goto fail;
|
||||
|
||||
memory_reader_state.buffer = WINPR_CAST_CONST_PTR_AWAY(data, png_bytep);
|
||||
memory_reader_state.bufsize = SrcSize;
|
||||
memory_reader_state.bufsize = (UINT32)SrcSize;
|
||||
memory_reader_state.current_pos = 0;
|
||||
|
||||
png_set_read_fn(png_ptr, &memory_reader_state, read_data_memory);
|
||||
@ -980,7 +988,7 @@ static void* winpr_read_png_from_buffer(const void* data, size_t SrcSize, size_t
|
||||
if (rc)
|
||||
{
|
||||
char* cur = rc;
|
||||
for (int i = 0; i < height; i++)
|
||||
for (png_uint_32 i = 0; i < height; i++)
|
||||
{
|
||||
memcpy(cur, row_pointers[i], copybytes);
|
||||
cur += stride;
|
||||
@ -988,7 +996,8 @@ static void* winpr_read_png_from_buffer(const void* data, size_t SrcSize, size_t
|
||||
*pSize = size;
|
||||
*pWidth = width;
|
||||
*pHeight = height;
|
||||
*pBpp = bpp;
|
||||
WINPR_ASSERT(bpp <= UINT32_MAX);
|
||||
*pBpp = (UINT32)bpp;
|
||||
}
|
||||
}
|
||||
fail:
|
||||
|
Loading…
Reference in New Issue
Block a user