mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-14 08:15:02 -05:00
properly implement mtco for indexed operations. Fixes ticket #53
This commit is contained in:
parent
cb30e0446f
commit
e6b57ef704
@ -125,6 +125,7 @@ typedef struct tag_dbqueryinfo {
|
|||||||
int playlist_id;
|
int playlist_id;
|
||||||
int db_id;
|
int db_id;
|
||||||
int session_id;
|
int session_id;
|
||||||
|
int specifiedtotalcount;
|
||||||
int uri_count;
|
int uri_count;
|
||||||
char *uri_sections[10];
|
char *uri_sections[10];
|
||||||
PARSETREE pt;
|
PARSETREE pt;
|
||||||
|
13
src/db-sql.c
13
src/db-sql.c
@ -1005,7 +1005,6 @@ int db_sql_enum_start(char **pe, DBQUERYINFO *pinfo) {
|
|||||||
query_rest[0] = '\0';
|
query_rest[0] = '\0';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* get the where qualifier to filter based on playlist, if there */
|
/* get the where qualifier to filter based on playlist, if there */
|
||||||
if((pinfo->playlist_id) && (pinfo->playlist_id != 1)) {
|
if((pinfo->playlist_id) && (pinfo->playlist_id != 1)) {
|
||||||
err = db_sql_enum_begin_fn(pe, "select type,query from playlists "
|
err = db_sql_enum_begin_fn(pe, "select type,query from playlists "
|
||||||
@ -1131,20 +1130,20 @@ int db_sql_enum_start(char **pe, DBQUERYINFO *pinfo) {
|
|||||||
DPRINTF(E_DBG,L_DB,"No query/filter\n");
|
DPRINTF(E_DBG,L_DB,"No query/filter\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pinfo->index_type == indexTypeLast) {
|
|
||||||
/* We don't really care how many items unless we are
|
if(pinfo->index_type != indexTypeNone) {
|
||||||
* doing a "last n items" query */
|
/* the only time returned count is not specifiedtotalcount
|
||||||
|
* is if we have an index. */
|
||||||
strcpy(scratch,query_count);
|
strcpy(scratch,query_count);
|
||||||
strcat(scratch,query_rest);
|
strcat(scratch,query_rest);
|
||||||
if(browse)
|
if(browse)
|
||||||
strcat(scratch,")");
|
strcat(scratch,")");
|
||||||
|
|
||||||
|
|
||||||
err = db_sql_fetch_int(pe,&results,"%s",scratch);
|
err = db_sql_fetch_int(pe,&results,"%s",scratch);
|
||||||
if(err != DB_E_SUCCESS)
|
if(err != DB_E_SUCCESS)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
DPRINTF(E_DBG,L_DB,"Number of results: %d\n",results);
|
DPRINTF(E_DBG,L_DB,"Number of results: %d\n",results);
|
||||||
|
pinfo->specifiedtotalcount = results;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(query,query_select);
|
strcpy(query,query_select);
|
||||||
|
@ -1160,6 +1160,7 @@ void dispatch_playlistitems(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
|||||||
int list_length;
|
int list_length;
|
||||||
unsigned char *block;
|
unsigned char *block;
|
||||||
char *pe = NULL;
|
char *pe = NULL;
|
||||||
|
int mtco;
|
||||||
|
|
||||||
if(ws_getvar(pwsc,"meta")) {
|
if(ws_getvar(pwsc,"meta")) {
|
||||||
pqi->meta = db_encode_meta(ws_getvar(pwsc,"meta"));
|
pqi->meta = db_encode_meta(ws_getvar(pwsc,"meta"));
|
||||||
@ -1189,10 +1190,14 @@ void dispatch_playlistitems(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
|||||||
|
|
||||||
DPRINTF(E_DBG,L_DAAP,"Item enum: got %d songs, dmap size: %d\n",song_count,list_length);
|
DPRINTF(E_DBG,L_DAAP,"Item enum: got %d songs, dmap size: %d\n",song_count,list_length);
|
||||||
|
|
||||||
|
mtco = song_count;
|
||||||
|
if(pqi->index_type != indexTypeNone)
|
||||||
|
mtco = pqi->specifiedtotalcount;
|
||||||
|
|
||||||
current += db_dmap_add_container(current,"apso",list_length + 53);
|
current += db_dmap_add_container(current,"apso",list_length + 53);
|
||||||
current += db_dmap_add_int(current,"mstt",200); /* 12 */
|
current += db_dmap_add_int(current,"mstt",200); /* 12 */
|
||||||
current += db_dmap_add_char(current,"muty",0); /* 9 */
|
current += db_dmap_add_char(current,"muty",0); /* 9 */
|
||||||
current += db_dmap_add_int(current,"mtco",song_count); /* 12 */
|
current += db_dmap_add_int(current,"mtco",mtco); /* 12 */
|
||||||
current += db_dmap_add_int(current,"mrco",song_count); /* 12 */
|
current += db_dmap_add_int(current,"mrco",song_count); /* 12 */
|
||||||
current += db_dmap_add_container(current,"mlcl",list_length);
|
current += db_dmap_add_container(current,"mlcl",list_length);
|
||||||
|
|
||||||
@ -1224,6 +1229,7 @@ void dispatch_browse(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
|||||||
char *response_type;
|
char *response_type;
|
||||||
int which_field=5;
|
int which_field=5;
|
||||||
char *pe = NULL;
|
char *pe = NULL;
|
||||||
|
int mtco;
|
||||||
|
|
||||||
if(strcasecmp(pqi->uri_sections[2],"browse") == 0) {
|
if(strcasecmp(pqi->uri_sections[2],"browse") == 0) {
|
||||||
which_field = 3;
|
which_field = 3;
|
||||||
@ -1263,11 +1269,15 @@ void dispatch_browse(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
|||||||
DPRINTF(E_DBG,L_DAAP|L_BROW,"Item enum: got %d items, dmap size: %d\n",
|
DPRINTF(E_DBG,L_DAAP|L_BROW,"Item enum: got %d items, dmap size: %d\n",
|
||||||
item_count,list_length);
|
item_count,list_length);
|
||||||
|
|
||||||
|
mtco = item_count;
|
||||||
|
if(pqi->index_type != indexTypeNone)
|
||||||
|
mtco = pqi->specifiedtotalcount;
|
||||||
|
|
||||||
current += db_dmap_add_container(current,"abro",list_length + 44);
|
current += db_dmap_add_container(current,"abro",list_length + 44);
|
||||||
current += db_dmap_add_int(current,"mstt",200); /* 12 */
|
current += db_dmap_add_int(current,"mstt",200); /* 12 */
|
||||||
current += db_dmap_add_int(current,"mtco",item_count); /* 12 */
|
current += db_dmap_add_int(current,"mtco",mtco); /* 12 */
|
||||||
current += db_dmap_add_int(current,"mrco",item_count); /* 12 */
|
current += db_dmap_add_int(current,"mrco",item_count); /* 12 */
|
||||||
current += db_dmap_add_container(current,response_type,list_length); /* 8 + length */
|
current += db_dmap_add_container(current,response_type,list_length); /* 8+ */
|
||||||
|
|
||||||
dispatch_output_start(pwsc,pqi,52+list_length);
|
dispatch_output_start(pwsc,pqi,52+list_length);
|
||||||
dispatch_output_write(pwsc,pqi,browse_response,52);
|
dispatch_output_write(pwsc,pqi,browse_response,52);
|
||||||
@ -1295,6 +1305,7 @@ void dispatch_playlists(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
|||||||
int list_length;
|
int list_length;
|
||||||
unsigned char *block;
|
unsigned char *block;
|
||||||
char *pe = NULL;
|
char *pe = NULL;
|
||||||
|
int mtco;
|
||||||
|
|
||||||
/* currently, this is ignored for playlist queries */
|
/* currently, this is ignored for playlist queries */
|
||||||
if(ws_getvar(pwsc,"meta")) {
|
if(ws_getvar(pwsc,"meta")) {
|
||||||
@ -1325,10 +1336,14 @@ void dispatch_playlists(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
|||||||
|
|
||||||
DPRINTF(E_DBG,L_DAAP,"Item enum: got %d playlists, dmap size: %d\n",pl_count,list_length);
|
DPRINTF(E_DBG,L_DAAP,"Item enum: got %d playlists, dmap size: %d\n",pl_count,list_length);
|
||||||
|
|
||||||
|
mtco = pl_count;
|
||||||
|
if(pqi->index_type != indexTypeNone)
|
||||||
|
mtco = pqi->specifiedtotalcount;
|
||||||
|
|
||||||
current += db_dmap_add_container(current,"aply",list_length + 53);
|
current += db_dmap_add_container(current,"aply",list_length + 53);
|
||||||
current += db_dmap_add_int(current,"mstt",200); /* 12 */
|
current += db_dmap_add_int(current,"mstt",200); /* 12 */
|
||||||
current += db_dmap_add_char(current,"muty",0); /* 9 */
|
current += db_dmap_add_char(current,"muty",0); /* 9 */
|
||||||
current += db_dmap_add_int(current,"mtco",pl_count); /* 12 */
|
current += db_dmap_add_int(current,"mtco",mtco); /* 12 */
|
||||||
current += db_dmap_add_int(current,"mrco",pl_count); /* 12 */
|
current += db_dmap_add_int(current,"mrco",pl_count); /* 12 */
|
||||||
current += db_dmap_add_container(current,"mlcl",list_length);
|
current += db_dmap_add_container(current,"mlcl",list_length);
|
||||||
|
|
||||||
@ -1359,6 +1374,7 @@ void dispatch_items(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
|||||||
int list_length;
|
int list_length;
|
||||||
unsigned char *block;
|
unsigned char *block;
|
||||||
char *pe = NULL;
|
char *pe = NULL;
|
||||||
|
int mtco;
|
||||||
|
|
||||||
if(ws_getvar(pwsc,"meta")) {
|
if(ws_getvar(pwsc,"meta")) {
|
||||||
pqi->meta = db_encode_meta(ws_getvar(pwsc,"meta"));
|
pqi->meta = db_encode_meta(ws_getvar(pwsc,"meta"));
|
||||||
@ -1385,10 +1401,14 @@ void dispatch_items(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
|||||||
|
|
||||||
DPRINTF(E_DBG,L_DAAP,"Item enum: got %d songs, dmap size: %d\n",song_count,list_length);
|
DPRINTF(E_DBG,L_DAAP,"Item enum: got %d songs, dmap size: %d\n",song_count,list_length);
|
||||||
|
|
||||||
|
mtco = song_count;
|
||||||
|
if(pqi->index_type != indexTypeNone)
|
||||||
|
mtco = pqi->specifiedtotalcount;
|
||||||
|
|
||||||
current += db_dmap_add_container(current,"adbs",list_length + 53);
|
current += db_dmap_add_container(current,"adbs",list_length + 53);
|
||||||
current += db_dmap_add_int(current,"mstt",200); /* 12 */
|
current += db_dmap_add_int(current,"mstt",200); /* 12 */
|
||||||
current += db_dmap_add_char(current,"muty",0); /* 9 */
|
current += db_dmap_add_char(current,"muty",0); /* 9 */
|
||||||
current += db_dmap_add_int(current,"mtco",song_count); /* 12 */
|
current += db_dmap_add_int(current,"mtco",mtco); /* 12 */
|
||||||
current += db_dmap_add_int(current,"mrco",song_count); /* 12 */
|
current += db_dmap_add_int(current,"mrco",song_count); /* 12 */
|
||||||
current += db_dmap_add_container(current,"mlcl",list_length);
|
current += db_dmap_add_container(current,"mlcl",list_length);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user