diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2010-02-27 21:02:44 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2010-02-27 21:02:44 +0000 |
commit | 827df51f1db5ab8ae774396c5d7fa955908e306e (patch) | |
tree | 63301e815ca8a7f8ee596d0b13eac69d4d82e728 | |
parent | f21d2dcc7e1d0832584b7bec500b690c3f351678 (diff) |
Threaded cache fixes: do not free the stream_t struct twice on windows
and make sure the cache thread quits also for streams without a control
function (e.g. http).
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30773 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | stream/cache2.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/stream/cache2.c b/stream/cache2.c index 1a7942d098..2e2aadc3fe 100644 --- a/stream/cache2.c +++ b/stream/cache2.c @@ -222,14 +222,14 @@ static int cache_fill(cache_vars_t *s) } static int cache_execute_control(cache_vars_t *s) { - int res = 1; static unsigned last; - if (!s->stream->control) { + int quit = s->control == -2; + if (quit || !s->stream->control) { s->stream_time_length = 0; s->control_new_pos = 0; s->control_res = STREAM_UNSUPPORTED; s->control = -1; - return res; + return !quit; } if (GetTimerMS() - last > 99) { double len; @@ -239,7 +239,7 @@ static int cache_execute_control(cache_vars_t *s) { s->stream_time_length = 0; last = GetTimerMS(); } - if (s->control == -1) return res; + if (s->control == -1) return 1; switch (s->control) { case STREAM_CTRL_GET_CURRENT_TIME: case STREAM_CTRL_SEEK_TO_TIME: @@ -254,15 +254,13 @@ static int cache_execute_control(cache_vars_t *s) { case STREAM_CTRL_SET_ANGLE: s->control_res = s->stream->control(s->stream, s->control, &s->control_uint_arg); break; - case -2: - res = 0; default: s->control_res = STREAM_UNSUPPORTED; break; } s->control_new_pos = s->stream->pos; s->control = -1; - return res; + return 1; } static cache_vars_t* cache_init(int size,int sector){ @@ -314,9 +312,9 @@ void cache_uninit(stream_t *s) { } if(!c) return; #if defined(__MINGW32__) || defined(PTHREAD_CACHE) || defined(__OS2__) - free(c->stream); free(c->buffer); c->buffer = NULL; + c->stream = NULL; free(s->cache_data); #else shmem_free(c->buffer,c->buffer_size); |