mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-01 01:53:23 -05:00
Factor out common code to increase playcount while streaming
This commit is contained in:
parent
b0a8e879e4
commit
053b8df4ba
28
src/httpd.c
28
src/httpd.c
@ -148,6 +148,18 @@ stream_end(struct stream_ctx *st, int failed)
|
|||||||
free(st);
|
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
|
static void
|
||||||
stream_chunk_resched_cb(struct evhttp_connection *evcon, void *arg)
|
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;
|
st->offset += ret;
|
||||||
|
|
||||||
if (!st->marked
|
stream_up_playcount(st);
|
||||||
&& (st->stream_size > ((st->size * 50) / 100))
|
|
||||||
&& (st->offset > ((st->size * 80) / 100)))
|
|
||||||
{
|
|
||||||
st->marked = 1;
|
|
||||||
db_file_inc_playcount(st->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -280,13 +286,7 @@ stream_chunk_raw_cb(int fd, short event, void *arg)
|
|||||||
|
|
||||||
st->offset += ret;
|
st->offset += ret;
|
||||||
|
|
||||||
if (!st->marked
|
stream_up_playcount(st);
|
||||||
&& (st->stream_size > ((st->size * 50) / 100))
|
|
||||||
&& (st->offset > ((st->size * 80) / 100)))
|
|
||||||
{
|
|
||||||
st->marked = 1;
|
|
||||||
db_file_inc_playcount(st->id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user