From 053b8df4ba9042f18ceea622f85ea196e2370932 Mon Sep 17 00:00:00 2001 From: Julien BLACHE Date: Wed, 8 Sep 2010 19:37:41 +0200 Subject: [PATCH] Factor out common code to increase playcount while streaming --- src/httpd.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) 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