summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-05-23 21:58:50 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-05-23 21:58:50 +0000
commit939df8d5a815d72f83a41683611edb738b46e19e (patch)
tree6a8237a5a445c06c58507a9a7915de14d3e52c6d /stream
parent7dcf9d45ed8b5ac19314f1755fc728d8f6fb3b46 (diff)
downloadmpv-939df8d5a815d72f83a41683611edb738b46e19e.tar.bz2
mpv-939df8d5a815d72f83a41683611edb738b46e19e.tar.xz
Extract the cache main loop into a separate function.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31201 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'stream')
-rw-r--r--stream/cache2.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/stream/cache2.c b/stream/cache2.c
index 48ebe50123..7bdeabd9e3 100644
--- a/stream/cache2.c
+++ b/stream/cache2.c
@@ -345,6 +345,24 @@ static void dummy_sighandler(int x) {
}
/**
+ * Main loop of the cache process or thread.
+ */
+static void cache_mainloop(cache_vars_t *s) {
+ int sleep_count = 0;
+ do {
+ if (!cache_fill(s)) {
+ if (sleep_count < INITIAL_FILL_USLEEP_COUNT) {
+ sleep_count++;
+ usec_sleep(INITIAL_FILL_USLEEP_TIME);
+ } else
+ usec_sleep(FILL_USLEEP_TIME); // idle
+ } else
+ sleep_count = 0;
+// cache_stats(s->cache_data);
+ } while (cache_execute_control(s));
+}
+
+/**
* \return 1 on success, 0 if the function was interrupted and -1 on error
*/
int stream_enable_cache(stream_t *stream,int size,int min,int seek_limit){
@@ -436,19 +454,7 @@ static void ThreadProc( void *s ){
// cache thread mainloop:
signal(SIGTERM,exit_sighandler); // kill
signal(SIGUSR1, dummy_sighandler); // wakeup
- {
- int sleep_count = 0;
- do {
- if(!cache_fill(s)){
- if (sleep_count < INITIAL_FILL_USLEEP_COUNT) {
- sleep_count++;
- usec_sleep(INITIAL_FILL_USLEEP_TIME);
- } else
- usec_sleep(FILL_USLEEP_TIME); // idle
- } else
- sleep_count = 0;
-// cache_stats(s->cache_data);
- } while (cache_execute_control(s));
+ cache_mainloop(s);
#if defined(__MINGW32__) || defined(__OS2__)
_endthread();
#elif defined(PTHREAD_CACHE)
@@ -457,7 +463,6 @@ static void ThreadProc( void *s ){
// make sure forked code never leaves this function
exit(0);
#endif
- }
}
int cache_stream_fill_buffer(stream_t *s){