From 2d1e5f6d6087e506f89e90ac6cf3293d7fdfc9a7 Mon Sep 17 00:00:00 2001 From: chme Date: Sun, 4 Dec 2016 17:48:35 +0100 Subject: [PATCH] [player/db] Remove function "db_file_get_seekpos" --- src/db.c | 25 ------------------------- src/db.h | 3 --- src/player.c | 15 +++++++++++---- 3 files changed, 11 insertions(+), 32 deletions(-) diff --git a/src/db.c b/src/db.c index 7f82a9da..62592ef7 100644 --- a/src/db.c +++ b/src/db.c @@ -2024,31 +2024,6 @@ db_files_get_count_bymatch(char *path) #undef Q_TMPL } -int -db_file_get_seekpos(uint32_t id) -{ -#define Q_TMPL "SELECT seek FROM files f WHERE f.id = %d;" - char *query; - int seek_ms; - - query = sqlite3_mprintf(Q_TMPL, id); - if (!query) - { - DPRINTF(E_LOG, L_DB, "Out of memory making seekpos query string.\n"); - - return -1; - } - - seek_ms = db_get_count(query); - sqlite3_free(query); - - if (seek_ms < 0) - seek_ms = 0; - - return seek_ms; -#undef Q_TMPL -} - void db_files_update_songartistid(void) { diff --git a/src/db.h b/src/db.h index 600e3b38..47e212f6 100644 --- a/src/db.h +++ b/src/db.h @@ -498,9 +498,6 @@ db_files_get_album_count(void); int db_files_get_count_bymatch(char *path); -int -db_file_get_seekpos(uint32_t id); - void db_files_update_songartistid(void); diff --git a/src/player.c b/src/player.c index 7c52ee70..17ea5172 100644 --- a/src/player.c +++ b/src/player.c @@ -2280,6 +2280,7 @@ static enum command_state playback_start_item(void *arg, int *retval) { struct db_queue_item *queue_item = arg; + struct media_file_info *mfi; struct output_device *device; struct player_source *ps; int seek_ms; @@ -2316,16 +2317,22 @@ playback_start_item(void *arg, int *retval) ps = source_new(queue_item); if (!ps) - { + { playback_abort(); *retval = -1; return COMMAND_END; } + seek_ms = 0; if (queue_item->file_id > 0) - seek_ms = db_file_get_seekpos(queue_item->file_id); - else - seek_ms = 0; + { + mfi = db_file_fetch_byid(queue_item->file_id); + if (mfi) + { + seek_ms = mfi->seek; + free_mfi(mfi, 0); + } + } ret = source_open(ps, last_rtptime + AIRTUNES_V2_PACKET_SAMPLES, seek_ms); if (ret < 0)