mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-09 04:38:10 -05:00
Fix indexing, move updates back into core
This commit is contained in:
parent
4a9d8993b3
commit
c90e2394c5
@ -151,6 +151,7 @@ typedef struct tag_plugin_input_fn {
|
|||||||
int (*db_delete_playlist_item)(char **pe, int playlistid, int songid);
|
int (*db_delete_playlist_item)(char **pe, int playlistid, int songid);
|
||||||
int (*db_revision)(void);
|
int (*db_revision)(void);
|
||||||
int (*db_count_items)(int what);
|
int (*db_count_items)(int what);
|
||||||
|
int (*db_wait_update)(struct tag_ws_conninfo *);
|
||||||
|
|
||||||
char *(*conf_alloc_string)(char *section, char *key, char *dflt);
|
char *(*conf_alloc_string)(char *section, char *key, char *dflt);
|
||||||
void (*conf_dispose_string)(char *str);
|
void (*conf_dispose_string)(char *str);
|
||||||
|
35
src/plugin.c
35
src/plugin.c
@ -94,6 +94,7 @@ int pi_db_enum_restart(char **pe, DB_QUERY *pinfo);
|
|||||||
void pi_db_enum_dispose(char **pe, DB_QUERY *pinfo);
|
void pi_db_enum_dispose(char **pe, DB_QUERY *pinfo);
|
||||||
void pi_stream(WS_CONNINFO *pwsc, char *id);
|
void pi_stream(WS_CONNINFO *pwsc, char *id);
|
||||||
int pi_db_count_items(int what);
|
int pi_db_count_items(int what);
|
||||||
|
int pi_db_wait_update(WS_CONNINFO *pwsc);
|
||||||
void pi_conf_dispose_string(char *str);
|
void pi_conf_dispose_string(char *str);
|
||||||
|
|
||||||
PLUGIN_INPUT_FN pi = {
|
PLUGIN_INPUT_FN pi = {
|
||||||
@ -128,6 +129,7 @@ PLUGIN_INPUT_FN pi = {
|
|||||||
db_delete_playlist_item,
|
db_delete_playlist_item,
|
||||||
db_revision,
|
db_revision,
|
||||||
pi_db_count_items,
|
pi_db_count_items,
|
||||||
|
pi_db_wait_update,
|
||||||
|
|
||||||
conf_alloc_string,
|
conf_alloc_string,
|
||||||
pi_conf_dispose_string,
|
pi_conf_dispose_string,
|
||||||
@ -769,6 +771,39 @@ void pi_db_enum_dispose(char **pe, DB_QUERY *pinfo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pi_db_wait_update(WS_CONNINFO *pwsc) {
|
||||||
|
int clientver=1;
|
||||||
|
fd_set rset;
|
||||||
|
struct timeval tv;
|
||||||
|
int result;
|
||||||
|
int lastver=0;
|
||||||
|
|
||||||
|
if(ws_getvar(pwsc,"revision-number")) {
|
||||||
|
clientver=atoi(ws_getvar(pwsc,"revision-number"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* wait for db_version to be stable for 30 seconds */
|
||||||
|
while((clientver == db_revision()) ||
|
||||||
|
(lastver && (db_revision() != lastver))) {
|
||||||
|
lastver = db_revision();
|
||||||
|
|
||||||
|
FD_ZERO(&rset);
|
||||||
|
FD_SET(pwsc->fd,&rset);
|
||||||
|
|
||||||
|
tv.tv_sec=30;
|
||||||
|
tv.tv_usec=0;
|
||||||
|
|
||||||
|
result=select(pwsc->fd+1,&rset,NULL,NULL,&tv);
|
||||||
|
if(FD_ISSET(pwsc->fd,&rset)) {
|
||||||
|
/* can't be ready for read, must be error */
|
||||||
|
DPRINTF(E_DBG,L_DAAP,"Update session stopped\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
void pi_stream(WS_CONNINFO *pwsc, char *id) {
|
void pi_stream(WS_CONNINFO *pwsc, char *id) {
|
||||||
int session = 0;
|
int session = 0;
|
||||||
MP3FILE *pmp3;
|
MP3FILE *pmp3;
|
||||||
|
@ -125,7 +125,7 @@ PLUGIN_RESPONSE daap_uri_map[] = {
|
|||||||
out_daap_content_codes },
|
out_daap_content_codes },
|
||||||
{{"login", NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL },
|
{{"login", NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL },
|
||||||
out_daap_login },
|
out_daap_login },
|
||||||
{{"updates", NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL },
|
{{"update", NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL },
|
||||||
out_daap_update },
|
out_daap_update },
|
||||||
{{"logout", NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL },
|
{{"logout", NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL },
|
||||||
out_daap_logout },
|
out_daap_logout },
|
||||||
@ -354,6 +354,11 @@ void plugin_handler(WS_CONNINFO *pwsc) {
|
|||||||
_ppi->log(E_DBG,"Index %s: offset %d, limit %d\n",index_req,
|
_ppi->log(E_DBG,"Index %s: offset %d, limit %d\n",index_req,
|
||||||
ppi->dq.offset,ppi->dq.limit);
|
ppi->dq.offset,ppi->dq.limit);
|
||||||
|
|
||||||
|
if(_ppi->ws_getvar(pwsc,"query")) {
|
||||||
|
ppi->dq.filter_type = FILTER_TYPE_APPLE;
|
||||||
|
ppi->dq.filter = _ppi->ws_getvar(pwsc,"query");
|
||||||
|
}
|
||||||
|
|
||||||
_ppi->log(E_DBG,"Tokenizing url\n");
|
_ppi->log(E_DBG,"Tokenizing url\n");
|
||||||
while((ppi->uri_count < 10) && (token=strtok_r(string,"/",&save))) {
|
while((ppi->uri_count < 10) && (token=strtok_r(string,"/",&save))) {
|
||||||
string=NULL;
|
string=NULL;
|
||||||
@ -1051,18 +1056,25 @@ void out_daap_browse(WS_CONNINFO *pwsc, PRIVINFO *ppi) {
|
|||||||
which_field = 3;
|
which_field = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ppi->log(E_DBG,"Browsing by %s (field %d)\n",
|
||||||
|
ppi->uri_sections[which_field],which_field);
|
||||||
|
|
||||||
ppi->dq.query_type = QUERY_TYPE_DISTINCT;
|
ppi->dq.query_type = QUERY_TYPE_DISTINCT;
|
||||||
ppi->dq.distinct_field = ppi->uri_sections[which_field];
|
ppi->dq.distinct_field = ppi->uri_sections[which_field];
|
||||||
which_field = 3;
|
// which_field = 3;
|
||||||
|
|
||||||
if(!strcmp(ppi->uri_sections[which_field],"artists")) {
|
if(!strcmp(ppi->uri_sections[which_field],"artists")) {
|
||||||
response_type = "abar";
|
response_type = "abar";
|
||||||
|
ppi->dq.distinct_field = "artist";
|
||||||
} else if(!strcmp(ppi->uri_sections[which_field],"genres")) {
|
} else if(!strcmp(ppi->uri_sections[which_field],"genres")) {
|
||||||
response_type = "abgn";
|
response_type = "abgn";
|
||||||
|
ppi->dq.distinct_field = "genre";
|
||||||
} else if(!strcmp(ppi->uri_sections[which_field],"albums")) {
|
} else if(!strcmp(ppi->uri_sections[which_field],"albums")) {
|
||||||
response_type = "abal";
|
response_type = "abal";
|
||||||
|
ppi->dq.distinct_field = "album";
|
||||||
} else if(!strcmp(ppi->uri_sections[which_field],"composers")) {
|
} else if(!strcmp(ppi->uri_sections[which_field],"composers")) {
|
||||||
response_type = "abcp";
|
response_type = "abcp";
|
||||||
|
ppi->dq.distinct_field = "composer";
|
||||||
} else {
|
} else {
|
||||||
_ppi->log(E_WARN,"Invalid browse request type %s\n",ppi->uri_sections[3]);
|
_ppi->log(E_WARN,"Invalid browse request type %s\n",ppi->uri_sections[3]);
|
||||||
out_daap_error(pwsc,ppi,"abro","Invalid browse type");
|
out_daap_error(pwsc,ppi,"abro","Invalid browse type");
|
||||||
@ -1251,36 +1263,13 @@ void out_daap_items(WS_CONNINFO *pwsc, PRIVINFO *ppi) {
|
|||||||
void out_daap_update(WS_CONNINFO *pwsc, PRIVINFO *ppi) {
|
void out_daap_update(WS_CONNINFO *pwsc, PRIVINFO *ppi) {
|
||||||
unsigned char update_response[32];
|
unsigned char update_response[32];
|
||||||
unsigned char *current=update_response;
|
unsigned char *current=update_response;
|
||||||
int clientver=1;
|
|
||||||
fd_set rset;
|
|
||||||
struct timeval tv;
|
|
||||||
int result;
|
|
||||||
int lastver=0;
|
|
||||||
|
|
||||||
_ppi->log(E_DBG,"Preparing to send update response\n");
|
_ppi->log(E_DBG,"Preparing to send update response\n");
|
||||||
_ppi->config_set_status(pwsc,ppi->session_id,"Waiting for DB update");
|
_ppi->config_set_status(pwsc,ppi->session_id,"Waiting for DB update");
|
||||||
|
|
||||||
if(_ppi->ws_getvar(pwsc,"revision-number")) {
|
if(!_ppi->db_wait_update(pwsc)) {
|
||||||
clientver=atoi(_ppi->ws_getvar(pwsc,"revision-number"));
|
_ppi->log(E_DBG,"Update session stopped\n");
|
||||||
}
|
return;
|
||||||
|
|
||||||
/* wait for db_version to be stable for 30 seconds */
|
|
||||||
while((clientver == _ppi->db_revision()) ||
|
|
||||||
(lastver && (_ppi->db_revision() != lastver))) {
|
|
||||||
lastver = _ppi->db_revision();
|
|
||||||
|
|
||||||
FD_ZERO(&rset);
|
|
||||||
FD_SET(_ppi->ws_fd(pwsc),&rset);
|
|
||||||
|
|
||||||
tv.tv_sec=30;
|
|
||||||
tv.tv_usec=0;
|
|
||||||
|
|
||||||
result=select(_ppi->ws_fd(pwsc)+1,&rset,NULL,NULL,&tv);
|
|
||||||
if(FD_ISSET(_ppi->ws_fd(pwsc),&rset)) {
|
|
||||||
/* can't be ready for read, must be error */
|
|
||||||
_ppi->log(E_DBG,"Update session stopped\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* otherwise, send the info about this version */
|
/* otherwise, send the info about this version */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user