diff options
Diffstat (limited to 'src/sbservices.c')
| -rw-r--r-- | src/sbservices.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/sbservices.c b/src/sbservices.c index dd5f571..7f050bf 100644 --- a/src/sbservices.c +++ b/src/sbservices.c | |||
| @@ -36,7 +36,11 @@ | |||
| 36 | static void sbs_lock(sbservices_client_t client) | 36 | static void sbs_lock(sbservices_client_t client) |
| 37 | { | 37 | { |
| 38 | debug_info("SBServices: Locked"); | 38 | debug_info("SBServices: Locked"); |
| 39 | #ifdef WIN32 | ||
| 40 | EnterCriticalSection(&client->mutex); | ||
| 41 | #else | ||
| 39 | pthread_mutex_lock(&client->mutex); | 42 | pthread_mutex_lock(&client->mutex); |
| 43 | #endif | ||
| 40 | } | 44 | } |
| 41 | 45 | ||
| 42 | /** | 46 | /** |
| @@ -47,7 +51,11 @@ static void sbs_lock(sbservices_client_t client) | |||
| 47 | static void sbs_unlock(sbservices_client_t client) | 51 | static void sbs_unlock(sbservices_client_t client) |
| 48 | { | 52 | { |
| 49 | debug_info("SBServices: Unlocked"); | 53 | debug_info("SBServices: Unlocked"); |
| 54 | #ifdef WIN32 | ||
| 55 | LeaveCriticalSection(&client->mutex); | ||
| 56 | #else | ||
| 50 | pthread_mutex_unlock(&client->mutex); | 57 | pthread_mutex_unlock(&client->mutex); |
| 58 | #endif | ||
| 51 | } | 59 | } |
| 52 | 60 | ||
| 53 | /** | 61 | /** |
| @@ -100,7 +108,11 @@ sbservices_error_t sbservices_client_new(idevice_t device, uint16_t port, sbserv | |||
| 100 | 108 | ||
| 101 | sbservices_client_t client_loc = (sbservices_client_t) malloc(sizeof(struct sbservices_client_private)); | 109 | sbservices_client_t client_loc = (sbservices_client_t) malloc(sizeof(struct sbservices_client_private)); |
| 102 | client_loc->parent = plistclient; | 110 | client_loc->parent = plistclient; |
| 111 | #ifdef WIN32 | ||
| 112 | InitializeCriticalSection(&client_loc->mutex); | ||
| 113 | #else | ||
| 103 | pthread_mutex_init(&client_loc->mutex, NULL); | 114 | pthread_mutex_init(&client_loc->mutex, NULL); |
| 115 | #endif | ||
| 104 | 116 | ||
| 105 | *client = client_loc; | 117 | *client = client_loc; |
| 106 | return SBSERVICES_E_SUCCESS; | 118 | return SBSERVICES_E_SUCCESS; |
| @@ -122,7 +134,11 @@ sbservices_error_t sbservices_client_free(sbservices_client_t client) | |||
| 122 | 134 | ||
| 123 | sbservices_error_t err = sbservices_error(property_list_service_client_free(client->parent)); | 135 | sbservices_error_t err = sbservices_error(property_list_service_client_free(client->parent)); |
| 124 | client->parent = NULL; | 136 | client->parent = NULL; |
| 137 | #ifdef WIN32 | ||
| 138 | DeleteCriticalSection(&client->mutex); | ||
| 139 | #else | ||
| 125 | pthread_mutex_destroy(&client->mutex); | 140 | pthread_mutex_destroy(&client->mutex); |
| 141 | #endif | ||
| 126 | free(client); | 142 | free(client); |
| 127 | 143 | ||
| 128 | return err; | 144 | return err; |
