Am 15/09/2011 02:39, schrieb Michael Karcher:
Am Mittwoch, den 14.09.2011, 23:51 +0200 schrieb Thomas Arp:O.K., here is my patch, please review.Thanks for your patch.diff --git a/libnetmd/common.c b/libnetmd/common.c index 1f7b660..7e039ed 100644 --- a/libnetmd/common.c +++ b/libnetmd/common.c @@ -62,7 +62,7 @@ static int netmd_poll(libusb_device_handle *dev, unsigned char *buf, int tries) } if (i> 0) { - sleep(1); + usleep(200000); } }usleep is probably not present in Visual C++, as it is a Unix function. mingw most likely supports it for compatiblity reasons. If the code should be even more portable, do use Sleep on Windows as you initially suggested.-int min(int a,int b); +#ifndef min + #define min(a,b) ((a)<(b)?(a):(b)) +#endif +As it seems that utils.h is only included inside libhimd, this is fine. #define'ing min for public headers seems like a bad idea to me. Your patch is fine except for the usleep quirk. I don't know whether we care about non-GNU compilation on Windows, but if we do, we should not use usleep on Windows (as I said up there). Regards, Michael Karcher
O.K:, i changed this. Regards Thomas
From f59ac22598a8a3cac5d62cae79c6379dee08e48a Mon Sep 17 00:00:00 2001 From: Thomas Arp <manner.moe@gmx.de> Date: Thu, 15 Sep 2011 07:56:07 +0200 Subject: [PATCH 2/2] use os internal Sleep() function on windows --- libnetmd/common.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/libnetmd/common.c b/libnetmd/common.c index 7e039ed..174f172 100644 --- a/libnetmd/common.c +++ b/libnetmd/common.c @@ -34,6 +34,13 @@ #define NETMD_RECV_TIMEOUT 1000 #define NETMD_RECV_TRIES 30 +#ifdef WIN32 + #include <windows.h> + #define msleep(x) Sleep(x) +#else + #define msleep(x) usleep(1000*x) +#endif + /* polls to see if minidisc wants to send data @@ -62,7 +69,7 @@ static int netmd_poll(libusb_device_handle *dev, unsigned char *buf, int tries) } if (i > 0) { - usleep(200000); + msleep(200); } } -- 1.7.6.msysgit.0