diff --git a/src/httpd.c b/src/httpd.c index 061dfaae..1a8ec271 100644 --- a/src/httpd.c +++ b/src/httpd.c @@ -148,6 +148,18 @@ stream_end(struct stream_ctx *st, int failed) free(st); } +static void +stream_up_playcount(struct stream_ctx *st) +{ + if (!st->marked + && (st->stream_size > ((st->size * 50) / 100)) + && (st->offset > ((st->size * 80) / 100))) + { + st->marked = 1; + db_file_inc_playcount(st->id); + } +} + static void stream_chunk_resched_cb(struct evhttp_connection *evcon, void *arg) { @@ -218,13 +230,7 @@ stream_chunk_xcode_cb(int fd, short event, void *arg) st->offset += ret; - if (!st->marked - && (st->stream_size > ((st->size * 50) / 100)) - && (st->offset > ((st->size * 80) / 100))) - { - st->marked = 1; - db_file_inc_playcount(st->id); - } + stream_up_playcount(st); return; @@ -280,13 +286,7 @@ stream_chunk_raw_cb(int fd, short event, void *arg) st->offset += ret; - if (!st->marked - && (st->stream_size > ((st->size * 50) / 100)) - && (st->offset > ((st->size * 80) / 100))) - { - st->marked = 1; - db_file_inc_playcount(st->id); - } + stream_up_playcount(st); } static void