mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-13 16:03:23 -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 db_id;
|
||||
int session_id;
|
||||
int specifiedtotalcount;
|
||||
int uri_count;
|
||||
char *uri_sections[10];
|
||||
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';
|
||||
|
||||
|
||||
|
||||
/* get the where qualifier to filter based on playlist, if there */
|
||||
if((pinfo->playlist_id) && (pinfo->playlist_id != 1)) {
|
||||
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");
|
||||
}
|
||||
|
||||
if(pinfo->index_type == indexTypeLast) {
|
||||
/* We don't really care how many items unless we are
|
||||
* doing a "last n items" query */
|
||||
|
||||
if(pinfo->index_type != indexTypeNone) {
|
||||
/* the only time returned count is not specifiedtotalcount
|
||||
* is if we have an index. */
|
||||
strcpy(scratch,query_count);
|
||||
strcat(scratch,query_rest);
|
||||
if(browse)
|
||||
strcat(scratch,")");
|
||||
|
||||
|
||||
|
||||
err = db_sql_fetch_int(pe,&results,"%s",scratch);
|
||||
if(err != DB_E_SUCCESS)
|
||||
return err;
|
||||
|
||||
DPRINTF(E_DBG,L_DB,"Number of results: %d\n",results);
|
||||
pinfo->specifiedtotalcount = results;
|
||||
}
|
||||
|
||||
strcpy(query,query_select);
|
||||
|
@ -1160,6 +1160,7 @@ void dispatch_playlistitems(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
||||
int list_length;
|
||||
unsigned char *block;
|
||||
char *pe = NULL;
|
||||
int mtco;
|
||||
|
||||
if(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);
|
||||
|
||||
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_int(current,"mstt",200); /* 12 */
|
||||
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_container(current,"mlcl",list_length);
|
||||
|
||||
@ -1224,6 +1229,7 @@ void dispatch_browse(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
||||
char *response_type;
|
||||
int which_field=5;
|
||||
char *pe = NULL;
|
||||
int mtco;
|
||||
|
||||
if(strcasecmp(pqi->uri_sections[2],"browse") == 0) {
|
||||
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",
|
||||
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_int(current,"mstt",200); /* 12 */
|
||||
current += db_dmap_add_int(current,"mtco",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_int(current,"mstt",200); /* 12 */
|
||||
current += db_dmap_add_int(current,"mtco",mtco); /* 12 */
|
||||
current += db_dmap_add_int(current,"mrco",item_count); /* 12 */
|
||||
current += db_dmap_add_container(current,response_type,list_length); /* 8+ */
|
||||
|
||||
dispatch_output_start(pwsc,pqi,52+list_length);
|
||||
dispatch_output_write(pwsc,pqi,browse_response,52);
|
||||
@ -1295,6 +1305,7 @@ void dispatch_playlists(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
||||
int list_length;
|
||||
unsigned char *block;
|
||||
char *pe = NULL;
|
||||
int mtco;
|
||||
|
||||
/* currently, this is ignored for playlist queries */
|
||||
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);
|
||||
|
||||
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_int(current,"mstt",200); /* 12 */
|
||||
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_container(current,"mlcl",list_length);
|
||||
|
||||
@ -1359,6 +1374,7 @@ void dispatch_items(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
||||
int list_length;
|
||||
unsigned char *block;
|
||||
char *pe = NULL;
|
||||
int mtco;
|
||||
|
||||
if(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);
|
||||
|
||||
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_int(current,"mstt",200); /* 12 */
|
||||
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_container(current,"mlcl",list_length);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user