summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Holmgren <magnushol@gmail.com>2005-12-04 12:18:01 +0000
committerMagnus Holmgren <magnushol@gmail.com>2005-12-04 12:18:01 +0000
commit11b2ade5c80d6bcd95f65ac1e3aed9dbf59690c5 (patch)
treeef6a6316ed17f88479d462587a9776e41a34ef6f
parentf9fa33f6911e15a033687184057b5867da43a965 (diff)
downloadrockbox-11b2ade5c80d6bcd95f65ac1e3aed9dbf59690c5.tar.gz
rockbox-11b2ade5c80d6bcd95f65ac1e3aed9dbf59690c5.zip
Simplified yield() in the Win32 simulator. Now only hogs the CPU during playback, and playback doesn't stutter that much.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8143 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--uisimulator/win32/thread-win32.c16
1 files changed, 1 insertions, 15 deletions
diff --git a/uisimulator/win32/thread-win32.c b/uisimulator/win32/thread-win32.c
index bfad7cc1e8..7c33017c7e 100644
--- a/uisimulator/win32/thread-win32.c
+++ b/uisimulator/win32/thread-win32.c
@@ -33,22 +33,8 @@ CRITICAL_SECTION CriticalSection;
33 33
34void yield(void) 34void yield(void)
35{ 35{
36 static clock_t last = 0;
37 clock_t now;
38
39 LeaveCriticalSection(&CriticalSection); 36 LeaveCriticalSection(&CriticalSection);
40 /* Don't call Sleep() too often (as the smallest sleep really is a bit 37 Sleep(1);
41 * longer). This keeps CPU usage low, yet allows sound playback to work
42 * well (at least on one particular computer).
43 */
44 now = clock();
45
46 if (now - last > CLOCKS_PER_SEC / 200)
47 {
48 last = now;
49 Sleep(1);
50 }
51
52 EnterCriticalSection(&CriticalSection); 38 EnterCriticalSection(&CriticalSection);
53} 39}
54 40