# HG changeset patch # User reimar # Date 1230805459 0 # Node ID a3ec147048ceb8eb1274331eed668f6c0e781cbe # Parent 0fb5551413f7ed3de482e7a33a06312d709a5470 Avoid a uselessly high number of wakeups when playing audio-only files. diff -r 0fb5551413f7 -r a3ec147048ce mplayer.c --- a/mplayer.c Thu Jan 01 09:47:21 2009 +0000 +++ b/mplayer.c Thu Jan 01 10:24:19 2009 +0000 @@ -2015,6 +2015,7 @@ current_module="play_audio"; while (1) { + int sleep_time; // all the current uses of ao_data.pts seem to be in aos that handle // sync completely wrong; there should be no need to use ao_data.pts // in get_space() @@ -2026,7 +2027,9 @@ // handle audio-only case: // this is where mplayer sleeps during audio-only playback // to avoid 100% CPU use - usec_sleep(10000); // Wait a tick before retry + sleep_time = (ao_data.outburst - bytes_to_write) * 1000 / ao_data.samplerate; + if (sleep_time < 10) sleep_time = 10; // limit to 100 wakeups per second + usec_sleep(sleep_time * 1000); } while (bytes_to_write) {