mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-23 12:43:18 -05:00
Don't increase play count if not streaming at least half of the file
When streaming AAC/MP4 files that aren't stream-optimized (metadata at the end of the file), clients will seek through the file to grab the metadata prior to playing the file, causing the play count to increase by 2 or 3. To counter that, do not increase play count if not streaming at least half of the file.
This commit is contained in:
parent
403153f64b
commit
7cb0eec5d5
15
src/httpd.c
15
src/httpd.c
@ -78,6 +78,7 @@ struct stream_ctx {
|
||||
int id;
|
||||
int fd;
|
||||
size_t size;
|
||||
size_t stream_size;
|
||||
size_t offset;
|
||||
size_t start_offset;
|
||||
size_t end_offset;
|
||||
@ -200,7 +201,9 @@ stream_chunk_xcode_cb(int fd, short event, void *arg)
|
||||
|
||||
st->offset += ret;
|
||||
|
||||
if (!st->marked && (st->offset > ((st->size * 80) / 100)))
|
||||
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);
|
||||
@ -258,7 +261,9 @@ stream_chunk_raw_cb(int fd, short event, void *arg)
|
||||
|
||||
st->offset += ret;
|
||||
|
||||
if (!st->marked && (st->offset > ((st->size * 80) / 100)))
|
||||
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);
|
||||
@ -523,12 +528,18 @@ httpd_stream_file(struct evhttp_request *req, int id)
|
||||
|
||||
st->id = mfi->id;
|
||||
st->start_offset = offset;
|
||||
st->stream_size = st->size;
|
||||
st->req = req;
|
||||
|
||||
if ((offset == 0) && (end_offset == 0))
|
||||
evhttp_send_reply_start(req, HTTP_OK, "OK");
|
||||
else
|
||||
{
|
||||
if (offset > 0)
|
||||
st->stream_size -= offset;
|
||||
if (end_offset > 0)
|
||||
st->stream_size -= (st->size - end_offset);
|
||||
|
||||
DPRINTF(E_DBG, L_HTTPD, "Stream request with range %ld-%ld\n", offset, end_offset);
|
||||
|
||||
ret = snprintf(buf, sizeof(buf), "bytes %ld-%ld/%ld",
|
||||
|
Loading…
x
Reference in New Issue
Block a user