Skip to content

Commit a70ab4d

Browse files
committed
Make --disable-threads work again
1 parent 11a58fb commit a70ab4d

3 files changed

Lines changed: 57 additions & 3 deletions

File tree

audio/common/mmdevice_common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ DWORD CALLBACK mmdevice_thread(PVOID data)
130130

131131
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
132132
if (FAILED(hr))
133-
return;
133+
return 0;
134134

135135
#ifdef __cplusplus
136136
hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
@@ -196,6 +196,7 @@ DWORD CALLBACK mmdevice_thread(PVOID data)
196196
IMMNotificationThreadId = 0;
197197
CoUninitialize();
198198
ExitThread(0);
199+
return 0;
199200
#endif
200201
}
201202

audio/common/mmdevice_common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#ifndef _MMDEVICE_COMMON_H
1717
#define _MMDEVICE_COMMON_H
1818

19+
#ifdef _WIN32
20+
#include <windows.h>
21+
#endif
1922
#include <stdlib.h>
2023

2124
#include <retro_common_api.h>

tasks/task_cloudsync.c

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
#include <lists/dir_list.h>
1919
#include <lists/file_list.h>
2020
#include <lrc_hash.h>
21+
#ifdef HAVE_THREADS
2122
#include <rthreads/rthreads.h>
23+
#endif
2224
#include <streams/file_stream.h>
2325
#include <string/stdstring.h>
2426
#include <time/rtime.h>
@@ -75,7 +77,9 @@ typedef struct
7577
retro_time_t start_time;
7678
} task_cloud_sync_state_t;
7779

80+
#ifdef HAVE_THREADS
7881
static slock_t *tcs_running_lock = NULL;
82+
#endif
7983

8084
/* Forward declarations for conflict resolution */
8185
static void task_cloud_sync_upload_current_file(task_cloud_sync_state_t *sync_state);
@@ -103,9 +107,13 @@ static void task_cloud_sync_begin_handler(void *user_data, const char *path, boo
103107
task_set_title(task, strdup("Cloud Sync failed"));
104108
task_set_flags(task, RETRO_TASK_FLG_FINISHED, true);
105109
}
110+
#ifdef HAVE_THREADS
106111
slock_lock(tcs_running_lock);
112+
#endif
107113
sync_state->waiting = 0;
114+
#ifdef HAVE_THREADS
108115
slock_unlock(tcs_running_lock);
116+
#endif
109117
}
110118

111119
static bool tcs_object_member_handler(void *ctx, const char *s, size_t len)
@@ -204,9 +212,13 @@ static void task_cloud_sync_manifest_handler(void *user_data, const char *path,
204212
RARCH_WARN(CSPFX "Server manifest fetch failed.\n");
205213
sync_state->failures = true;
206214
sync_state->phase = CLOUD_SYNC_PHASE_END;
215+
#ifdef HAVE_THREADS
207216
slock_lock(tcs_running_lock);
217+
#endif
208218
sync_state->waiting = 0;
219+
#ifdef HAVE_THREADS
209220
slock_unlock(tcs_running_lock);
221+
#endif
210222
return;
211223
}
212224

@@ -218,9 +230,13 @@ static void task_cloud_sync_manifest_handler(void *user_data, const char *path,
218230
filestream_close(file);
219231
}
220232
sync_state->phase = CLOUD_SYNC_PHASE_READ_LOCAL_MANIFEST;
233+
#ifdef HAVE_THREADS
221234
slock_lock(tcs_running_lock);
235+
#endif
222236
sync_state->waiting = 0;
237+
#ifdef HAVE_THREADS
223238
slock_unlock(tcs_running_lock);
239+
#endif
224240
}
225241

226242
static void task_cloud_sync_fetch_server_manifest(task_cloud_sync_state_t *sync_state)
@@ -469,13 +485,17 @@ static void task_cloud_sync_add_to_updated_manifest(task_cloud_sync_state_t *syn
469485
{
470486
file_list_t *list;
471487
size_t idx;
488+
#ifdef HAVE_THREADS
472489
slock_lock(tcs_running_lock);
490+
#endif
473491
list = server ? sync_state->updated_server_manifest : sync_state->updated_local_manifest;
474492
idx = list->size;
475493
file_list_append(list, NULL, NULL, 0, 0, 0);
476494
file_list_set_alt_at_offset(list, idx, key);
477495
list->list[idx].userdata = hash;
496+
#ifdef HAVE_THREADS
478497
slock_unlock(tcs_running_lock);
498+
#endif
479499
}
480500

481501
static INLINE int task_cloud_sync_key_cmp(struct item_file *left, struct item_file *right)
@@ -597,9 +617,13 @@ static void task_cloud_sync_fetch_cb(void *user_data, const char *path, bool suc
597617
sync_state->failures = true;
598618
}
599619

620+
#ifdef HAVE_THREADS
600621
slock_lock(tcs_running_lock);
622+
#endif
601623
sync_state->waiting--;
624+
#ifdef HAVE_THREADS
602625
slock_unlock(tcs_running_lock);
626+
#endif
603627

604628
free(fetch_state);
605629
}
@@ -746,9 +770,13 @@ static void task_cloud_sync_upload_cb(void *user_data, const char *path, bool su
746770
sync_state->failures = true;
747771
}
748772

773+
#ifdef HAVE_THREADS
749774
slock_lock(tcs_running_lock);
775+
#endif
750776
sync_state->waiting--;
777+
#ifdef HAVE_THREADS
751778
slock_unlock(tcs_running_lock);
779+
#endif
752780
}
753781

754782
/**
@@ -885,9 +913,13 @@ static void task_cloud_sync_delete_cb(void *user_data, const char *path, bool su
885913
}
886914
RARCH_WARN(CSPFX "Deleting \"%s\" failed.\n", path);
887915
sync_state->failures = true;
916+
#ifdef HAVE_THREADS
888917
slock_lock(tcs_running_lock);
918+
#endif
889919
sync_state->waiting--;
920+
#ifdef HAVE_THREADS
890921
slock_unlock(tcs_running_lock);
922+
#endif
891923
return;
892924
}
893925

@@ -898,9 +930,13 @@ static void task_cloud_sync_delete_cb(void *user_data, const char *path, bool su
898930
task_cloud_sync_add_to_updated_manifest(sync_state, path, NULL, true);
899931
task_cloud_sync_add_to_updated_manifest(sync_state, path, NULL, false);
900932
sync_state->need_manifest_uploaded = true;
933+
#ifdef HAVE_THREADS
901934
slock_lock(tcs_running_lock);
935+
#endif
902936
sync_state->waiting--;
937+
#ifdef HAVE_THREADS
903938
slock_unlock(tcs_running_lock);
939+
#endif
904940
}
905941

906942
static void task_cloud_sync_delete_server_file(task_cloud_sync_state_t *sync_state)
@@ -1126,9 +1162,13 @@ static void task_cloud_sync_update_manifest_cb(void *user_data, const char *path
11261162

11271163
RARCH_LOG(CSPFX "Uploading updated manifest succeeded.\n");
11281164
sync_state->phase = CLOUD_SYNC_PHASE_END;
1165+
#ifdef HAVE_THREADS
11291166
slock_lock(tcs_running_lock);
1167+
#endif
11301168
sync_state->waiting = 0;
1169+
#ifdef HAVE_THREADS
11311170
slock_unlock(tcs_running_lock);
1171+
#endif
11321172
}
11331173

11341174
static RFILE *task_cloud_sync_write_updated_manifest(file_list_t *manifest, char *path)
@@ -1260,15 +1300,23 @@ static void task_cloud_sync_task_handler(retro_task_t *task)
12601300
if (!(sync_state = (task_cloud_sync_state_t *)task->state))
12611301
goto task_finished;
12621302

1303+
#ifdef HAVE_THREADS
12631304
slock_lock(tcs_running_lock);
1264-
/* we can transfer more than one file at a time */
1265-
if (sync_state->waiting > ((sync_state->phase == CLOUD_SYNC_PHASE_DIFF) ? 4U : 0U))
1305+
#endif
1306+
1307+
/* We can transfer more than one file at a time */
1308+
if (sync_state->waiting > ((sync_state->phase == CLOUD_SYNC_PHASE_DIFF)
1309+
? 4U : 0U))
12661310
{
12671311
task->when = cpu_features_get_time_usec() + 17 * 1000; /* 17ms */
1312+
#ifdef HAVE_THREADS
12681313
slock_unlock(tcs_running_lock);
1314+
#endif
12691315
return;
12701316
}
1317+
#ifdef HAVE_THREADS
12711318
slock_unlock(tcs_running_lock);
1319+
#endif
12721320

12731321
if (task->flags & RETRO_TASK_FLG_FINISHED)
12741322
goto task_finished;
@@ -1359,8 +1407,10 @@ static void task_push_cloud_sync_with_mode(int conflict_resolution)
13591407
if (!cloud_sync_enable)
13601408
return;
13611409

1410+
#ifdef HAVE_THREADS
13621411
if (!tcs_running_lock)
13631412
tcs_running_lock = slock_new();
1413+
#endif
13641414

13651415
find_data.func = task_cloud_sync_task_finder;
13661416
if (task_queue_find(&find_data))

0 commit comments

Comments
 (0)