mirror of https://github.com/FreeRDP/FreeRDP
libfreerdp-utils: remove sleep utils in favor of WinPR
This commit is contained in:
parent
2045a5aec8
commit
92bf3e4ae0
|
@ -41,9 +41,9 @@
|
|||
#include <freerdp/utils/list.h>
|
||||
#include <freerdp/utils/thread.h>
|
||||
#include <freerdp/utils/event.h>
|
||||
#include <freerdp/utils/sleep.h>
|
||||
#include <freerdp/client/tsmf.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/synch.h>
|
||||
|
||||
#include "tsmf_constants.h"
|
||||
|
@ -341,7 +341,7 @@ static void tsmf_sample_playback_video(TSMF_SAMPLE* sample)
|
|||
(sample->end_time >= presentation->audio_start_time ||
|
||||
sample->end_time < stream->last_end_time))
|
||||
{
|
||||
freerdp_usleep((stream->next_start_time - t) / 10);
|
||||
USleep((stream->next_start_time - t) / 10);
|
||||
}
|
||||
stream->next_start_time = t + sample->duration - 50000;
|
||||
|
||||
|
@ -674,10 +674,11 @@ static void* tsmf_stream_playback_func(void* arg)
|
|||
{
|
||||
tsmf_stream_process_ack(stream);
|
||||
sample = tsmf_stream_pop_sample(stream, 1);
|
||||
|
||||
if (sample)
|
||||
tsmf_sample_playback(sample);
|
||||
else
|
||||
freerdp_usleep(5000);
|
||||
USleep(5000);
|
||||
}
|
||||
if (stream->eos || presentation->eos)
|
||||
{
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Sleep Utils
|
||||
*
|
||||
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FREERDP_UTILS_SLEEP_H
|
||||
#define FREERDP_UTILS_SLEEP_H
|
||||
|
||||
#include <freerdp/api.h>
|
||||
#include <freerdp/types.h>
|
||||
|
||||
FREERDP_API void freerdp_sleep(UINT32 seconds);
|
||||
FREERDP_API void freerdp_usleep(UINT32 useconds);
|
||||
|
||||
#endif /* FREERDP_UTILS_SLEEP_H */
|
|
@ -33,6 +33,5 @@
|
|||
FREERDP_API UINT64 freerdp_windows_gmtime();
|
||||
FREERDP_API UINT64 freerdp_get_windows_time_from_unix_time(time_t unix_time);
|
||||
FREERDP_API time_t freerdp_get_unix_time_from_windows_time(UINT64 windows_time);
|
||||
FREERDP_API time_t freerdp_get_unix_time_from_generalized_time(const char* generalized_time);
|
||||
|
||||
#endif /* FREERDP_TIME_UTILS_H */
|
||||
|
|
|
@ -37,7 +37,6 @@ typedef struct rdp_ntlm_http rdpNtlmHttp;
|
|||
#include <freerdp/settings.h>
|
||||
#include <freerdp/crypto/tls.h>
|
||||
#include <freerdp/crypto/crypto.h>
|
||||
#include <freerdp/utils/sleep.h>
|
||||
#include <freerdp/utils/debug.h>
|
||||
#include <freerdp/utils/stream.h>
|
||||
#include <winpr/print.h>
|
||||
|
|
|
@ -76,7 +76,6 @@ typedef struct _RPC_PDU
|
|||
#include <freerdp/settings.h>
|
||||
#include <freerdp/crypto/tls.h>
|
||||
#include <freerdp/crypto/crypto.h>
|
||||
#include <freerdp/utils/sleep.h>
|
||||
#include <freerdp/utils/debug.h>
|
||||
#include <freerdp/utils/stream.h>
|
||||
#include <winpr/print.h>
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
#include <freerdp/error.h>
|
||||
#include <freerdp/utils/tcp.h>
|
||||
#include <freerdp/utils/sleep.h>
|
||||
#include <freerdp/utils/stream.h>
|
||||
|
||||
#include <time.h>
|
||||
|
@ -320,7 +319,7 @@ int transport_read_layer(rdpTransport* transport, UINT8* data, int bytes)
|
|||
{
|
||||
/* instead of sleeping, we should wait timeout on the socket
|
||||
but this only happens on initial connection */
|
||||
freerdp_usleep(transport->usleep_interval);
|
||||
USleep(transport->usleep_interval);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -421,7 +420,7 @@ int transport_read(rdpTransport* transport, STREAM* s)
|
|||
|
||||
if ((status == 0) && (transport->blocking))
|
||||
{
|
||||
freerdp_usleep(transport->usleep_interval);
|
||||
USleep(transport->usleep_interval);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -487,7 +486,7 @@ int transport_write(rdpTransport* transport, STREAM* s)
|
|||
if (status == 0)
|
||||
{
|
||||
/* blocking while sending */
|
||||
freerdp_usleep(transport->usleep_interval);
|
||||
USleep(transport->usleep_interval);
|
||||
|
||||
/* when sending is blocked in nonblocking mode, the receiving buffer should be checked */
|
||||
if (!transport->blocking)
|
||||
|
|
|
@ -29,7 +29,6 @@ set(${MODULE_PREFIX}_SRCS
|
|||
profiler.c
|
||||
rail.c
|
||||
signal.c
|
||||
sleep.c
|
||||
stopwatch.c
|
||||
stream.c
|
||||
string.c
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Sleep Utils
|
||||
*
|
||||
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <winpr/windows.h>
|
||||
|
||||
#include <freerdp/utils/sleep.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#define _XOPEN_SOURCE 500
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
void freerdp_sleep(UINT32 seconds)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
sleep(seconds);
|
||||
#else
|
||||
Sleep(seconds * 1000);
|
||||
#endif
|
||||
}
|
||||
|
||||
void freerdp_usleep(UINT32 useconds)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
usleep(useconds);
|
||||
#else
|
||||
UINT64 t1;
|
||||
UINT64 t2;
|
||||
UINT64 freq;
|
||||
|
||||
QueryPerformanceCounter((LARGE_INTEGER*) &t1);
|
||||
QueryPerformanceCounter((LARGE_INTEGER*) &freq);
|
||||
|
||||
do
|
||||
{
|
||||
QueryPerformanceCounter((LARGE_INTEGER*) &t2);
|
||||
}
|
||||
while ((t2 - t1) < useconds);
|
||||
#endif
|
||||
}
|
|
@ -27,6 +27,7 @@
|
|||
#include <time.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/synch.h>
|
||||
#include <winpr/windows.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -35,7 +36,6 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#include <freerdp/utils/sleep.h>
|
||||
#include <freerdp/utils/thread.h>
|
||||
|
||||
freerdp_thread* freerdp_thread_new(void)
|
||||
|
@ -79,7 +79,7 @@ void freerdp_thread_stop(freerdp_thread* thread)
|
|||
while ((thread->status > 0) && (i < 1000))
|
||||
{
|
||||
i++;
|
||||
freerdp_usleep(100000);
|
||||
USleep(100000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,34 +53,3 @@ time_t freerdp_get_unix_time_from_windows_time(UINT64 windows_time)
|
|||
unix_time = (windows_time - 621355968000000000ULL) / 10000000;
|
||||
return unix_time;
|
||||
}
|
||||
|
||||
time_t freerdp_get_unix_time_from_generalized_time(const char* generalized_time)
|
||||
{
|
||||
int Y, m, d;
|
||||
int H, M, S;
|
||||
struct tm gt;
|
||||
time_t unix_time = 0;
|
||||
|
||||
/*
|
||||
* GeneralizedTime:
|
||||
*
|
||||
* 12th November 1997 at 15:30:10,5 PM
|
||||
*
|
||||
* "19971112153010.5Z"
|
||||
* "19971112173010.5+0200"
|
||||
*/
|
||||
|
||||
memset(>, 0, sizeof(struct tm));
|
||||
sscanf(generalized_time, "%4d%2d%2d%2d%2d%2d", &Y, &m, &d, &H, &M, &S);
|
||||
|
||||
gt.tm_year = Y - 1900; /* Year since 1900 */
|
||||
gt.tm_mon = m; /* Months since January */
|
||||
gt.tm_mday = d; /* Day of the month */
|
||||
gt.tm_hour = H; /* Hour since midnight */
|
||||
gt.tm_min = M; /* Minutes after the hour */
|
||||
gt.tm_sec = S; /* Seconds after the minute */
|
||||
|
||||
unix_time = mktime(>);
|
||||
|
||||
return unix_time;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <winpr/crt.h>
|
||||
|
||||
#include <freerdp/constants.h>
|
||||
#include <freerdp/utils/sleep.h>
|
||||
#include <freerdp/server/rdpsnd.h>
|
||||
|
||||
#include "mf_audin.h"
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include <winpr/synch.h>
|
||||
|
||||
#include <freerdp/constants.h>
|
||||
#include <freerdp/utils/sleep.h>
|
||||
#include <freerdp/server/rdpsnd.h>
|
||||
|
||||
#include "sf_audin.h"
|
||||
|
@ -351,10 +350,10 @@ static BOOL test_sleep_tsdiff(UINT32 *old_sec, UINT32 *old_usec, UINT32 new_sec,
|
|||
}
|
||||
|
||||
if (sec > 0)
|
||||
freerdp_sleep(sec);
|
||||
Sleep(sec * 1000);
|
||||
|
||||
if (usec > 0)
|
||||
freerdp_usleep(usec);
|
||||
USleep(usec);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <winpr/windows.h>
|
||||
|
||||
#include <freerdp/listener.h>
|
||||
#include <freerdp/utils/sleep.h>
|
||||
#include <freerdp/codec/rfx.h>
|
||||
#include <freerdp/utils/stream.h>
|
||||
|
||||
|
@ -342,4 +341,4 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam)
|
|||
printf("Exiting Peer Main Loop Thread\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
#include <sys/select.h>
|
||||
#include <sys/signal.h>
|
||||
|
||||
#include <freerdp/utils/sleep.h>
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/synch.h>
|
||||
|
||||
#include "xf_encode.h"
|
||||
|
||||
|
@ -100,7 +101,7 @@ void* xf_frame_rate_thread(void* param)
|
|||
|
||||
event = xf_event_new(XF_EVENT_TYPE_FRAME_TICK);
|
||||
xf_event_push(xfp->event_queue, (xfEvent*) event);
|
||||
freerdp_usleep(wait_interval);
|
||||
USleep(wait_interval);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,12 +33,12 @@
|
|||
#include <sys/select.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/synch.h>
|
||||
|
||||
#include <freerdp/freerdp.h>
|
||||
#include <freerdp/locale/keyboard.h>
|
||||
#include <freerdp/codec/color.h>
|
||||
#include <freerdp/utils/file.h>
|
||||
#include <freerdp/utils/sleep.h>
|
||||
#include <freerdp/utils/thread.h>
|
||||
|
||||
extern char* xf_pcap_file;
|
||||
|
@ -364,10 +364,10 @@ static BOOL xf_peer_sleep_tsdiff(UINT32 *old_sec, UINT32 *old_usec, UINT32 new_s
|
|||
}
|
||||
|
||||
if (sec > 0)
|
||||
freerdp_sleep(sec);
|
||||
Sleep(sec * 1000);
|
||||
|
||||
if (usec > 0)
|
||||
freerdp_usleep(usec);
|
||||
USleep(usec);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -176,6 +176,9 @@ WINPR_API BOOL DeleteSynchronizationBarrier(LPSYNCHRONIZATION_BARRIER lpBarrier)
|
|||
WINPR_API VOID Sleep(DWORD dwMilliseconds);
|
||||
WINPR_API DWORD SleepEx(DWORD dwMilliseconds, BOOL bAlertable);
|
||||
|
||||
/* Portable usleep() */
|
||||
WINPR_API VOID USleep(DWORD dwMicroseconds);
|
||||
|
||||
/* Address */
|
||||
|
||||
WINPR_API VOID WakeByAddressAll(PVOID Address);
|
||||
|
|
|
@ -21,23 +21,48 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <winpr/synch.h>
|
||||
#include <winpr/windows.h>
|
||||
|
||||
/**
|
||||
* Sleep
|
||||
* SleepEx
|
||||
*/
|
||||
#include <winpr/synch.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#define _XOPEN_SOURCE 500
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
VOID Sleep(DWORD dwMilliseconds)
|
||||
{
|
||||
|
||||
usleep(dwMilliseconds * 1000);
|
||||
}
|
||||
|
||||
DWORD SleepEx(DWORD dwMilliseconds, BOOL bAlertable)
|
||||
{
|
||||
usleep(dwMilliseconds * 1000);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
VOID USleep(DWORD dwMicroseconds)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
usleep(dwMicroseconds);
|
||||
#else
|
||||
UINT64 t1;
|
||||
UINT64 t2;
|
||||
UINT64 freq;
|
||||
|
||||
QueryPerformanceCounter((LARGE_INTEGER*) &t1);
|
||||
QueryPerformanceCounter((LARGE_INTEGER*) &freq);
|
||||
|
||||
do
|
||||
{
|
||||
QueryPerformanceCounter((LARGE_INTEGER*) &t2);
|
||||
}
|
||||
while ((t2 - t1) < dwMicroseconds);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue