xmbc fixes

This commit is contained in:
Ron Pedde 2007-01-29 06:45:21 +00:00
parent 874821fbe1
commit ec9ab04b40
4 changed files with 71 additions and 33 deletions

View File

@ -1064,6 +1064,8 @@ int db_sql_update_playlists(char **pe) {
SQL_ROW row;
char *where_clause;
DPRINTF(E_LOG,L_DB,"Updating playlists\n");
/* FIXME: There is a race here for externally added playlists */
err = db_sql_fetch_int(pe,&playlists,"select count(*) from playlists");
@ -1088,9 +1090,9 @@ int db_sql_update_playlists(char **pe) {
(index < playlists))
{
/* process row */
pinfo[index].plid=strdup(STR(row[0]));
pinfo[index].type=strdup(STR(row[1]));
pinfo[index].clause=strdup(STR(row[2]));
pinfo[index].plid=strdup(STR(row[PL_ID]));
pinfo[index].type=strdup(STR(row[PL_TYPE]));
pinfo[index].clause=strdup(STR(row[PL_QUERY]));
DPRINTF(E_SPAM,L_DB,"Found playlist %s: type %s, clause %s\n",pinfo[index].plid,
pinfo[index].type,pinfo[index].clause);
index++;

View File

@ -346,6 +346,34 @@ int dmap_add_int(unsigned char *where, char *tag, int value) {
return 12;
}
int dmap_add_long(unsigned char *where, char *tag, uint64_t value) {
uint32_t v_hi;
uint32_t v_lo;
/* tag */
memcpy(where,tag,4);
/* len */
where[4]=where[5]=where[6]=0;
where[7]=8;
v_hi = (value >> 32) & 0xFFFFFFFF;
v_lo = value & 0xFFFFFFFF;
/* value */
where[8] = (v_hi >> 24) & 0xFF;
where[9] = (v_hi >> 16) & 0xFF;
where[10] = (v_hi >> 8) & 0xFF;
where[11] = v_hi & 0xFF;
where[12] = (v_lo >> 24) & 0xFF;
where[13] = (v_lo >> 16) & 0xFF;
where[14] = (v_lo >> 8) & 0xFF;
where[15] = v_lo & 0xFF;
return 16;
}
/**
* add a string type to a dmap block (type 0x09)
*
@ -522,9 +550,15 @@ int daap_get_size(PRIVINFO *pinfo, char **valarray) {
if(daap_wantsmeta(pinfo->meta, metaItemId))
size += 12; /* miid */
if(daap_wantsmeta(pinfo->meta, metaItunesSmartPlaylist)) {
if(valarray[PL_TYPE] && (atoi(valarray[PL_TYPE])==1))
if(valarray[PL_TYPE] && (atoi(valarray[PL_TYPE])==1) &&
(atoi(valarray[PL_ID]) != 1))
size += 9; /* aeSP */
}
if(atoi(valarray[PL_ID]) == 1) {
size += 9; /* abpl */
}
if(daap_wantsmeta(pinfo->meta, metaItemName))
size += (8 + (int) strlen(valarray[PL_TITLE])); /* minm */
if(valarray[PL_TYPE] && (atoi(valarray[PL_TYPE])==1) &&
@ -563,8 +597,7 @@ int daap_get_size(PRIVINFO *pinfo, char **valarray) {
if(daap_wantsmeta(pinfo->meta, metaSongArtist))
/* asar */
size += DMAPLEN(valarray[SG_ARTIST]);
if(valarray[SG_BPM] && atoi(valarray[SG_BPM]) &&
daap_wantsmeta(pinfo->meta, metaSongBPM))
if(daap_wantsmeta(pinfo->meta, metaSongBPM))
/* asbt */
size += 10;
if(daap_wantsmeta(pinfo->meta, metaSongBitRate)) {
@ -600,12 +633,10 @@ int daap_get_size(PRIVINFO *pinfo, char **valarray) {
daap_wantsmeta(pinfo->meta,metaSongDateModified))
/* asdm */
size += 12;
if(valarray[SG_TOTAL_DISCS] && atoi(valarray[SG_TOTAL_DISCS]) &&
daap_wantsmeta(pinfo->meta, metaSongDiscCount))
if(daap_wantsmeta(pinfo->meta, metaSongDiscCount))
/* asdc */
size += 10;
if(valarray[SG_DISC] && atoi(valarray[SG_DISC]) &&
daap_wantsmeta(pinfo->meta, metaSongDiscNumber))
if(daap_wantsmeta(pinfo->meta, metaSongDiscNumber))
/* asdn */
size += 10;
if(daap_wantsmeta(pinfo->meta, metaSongGenre))
@ -663,8 +694,7 @@ int daap_get_size(PRIVINFO *pinfo, char **valarray) {
daap_wantsmeta(pinfo->meta, metaSongTrackNumber))
/* astn */
size += 10;
if(valarray[SG_RATING] && atoi(valarray[SG_RATING]) &&
daap_wantsmeta(pinfo->meta, metaSongUserRating))
if(daap_wantsmeta(pinfo->meta, metaSongUserRating))
/* asur */
size += 9;
if(valarray[SG_YEAR] && atoi(valarray[SG_YEAR]) &&
@ -711,9 +741,14 @@ int daap_build_dmap(PRIVINFO *pinfo, char **valarray, unsigned char *presult, in
current += dmap_add_int(current,"miid",atoi(valarray[PL_ID]));
current += dmap_add_int(current,"mimc",atoi(valarray[PL_ITEMS]));
if(daap_wantsmeta(pinfo->meta,metaItunesSmartPlaylist)) {
if(valarray[PL_TYPE] && (atoi(valarray[PL_TYPE]) == 1))
if(valarray[PL_TYPE] && (atoi(valarray[PL_TYPE]) == 1) &&
(atoi(valarray[PL_ID]) != 1))
current += dmap_add_char(current,"aeSP",1);
}
if(atoi(valarray[PL_ID]) == 1) {
current += dmap_add_char(current,"abpl",1);
}
if(daap_wantsmeta(pinfo->meta,metaItemName))
current += dmap_add_string(current,"minm",valarray[PL_TITLE]);
if((valarray[PL_TYPE]) && (atoi(valarray[PL_TYPE])==1) &&
@ -748,7 +783,7 @@ int daap_build_dmap(PRIVINFO *pinfo, char **valarray, unsigned char *presult, in
current += dmap_add_string(current,"asal",valarray[SG_ALBUM]);
if(EMIT(valarray[4]) && daap_wantsmeta(pinfo->meta, metaSongArtist))
current += dmap_add_string(current,"asar",valarray[SG_ARTIST]);
if(valarray[23] && atoi(valarray[23]) && daap_wantsmeta(pinfo->meta, metaSongBPM))
if(daap_wantsmeta(pinfo->meta, metaSongBPM))
current += dmap_add_short(current,"asbt",
(short)atoi(valarray[SG_BPM]));
if(valarray[SG_BITRATE] && atoi(valarray[SG_BITRATE]) &&
@ -794,12 +829,10 @@ int daap_build_dmap(PRIVINFO *pinfo, char **valarray, unsigned char *presult, in
current += dmap_add_int(current,"asdm",
(int)atoi(valarray[SG_TIME_MODIFIED]));
if(valarray[SG_TOTAL_DISCS] && atoi(valarray[SG_TOTAL_DISCS]) &&
daap_wantsmeta(pinfo->meta, metaSongDiscCount))
if(daap_wantsmeta(pinfo->meta, metaSongDiscCount))
current += dmap_add_short(current,"asdc",
(short)atoi(valarray[SG_TOTAL_DISCS]));
if(valarray[SG_DISC] && atoi(valarray[SG_DISC]) &&
daap_wantsmeta(pinfo->meta, metaSongDiscNumber))
if(daap_wantsmeta(pinfo->meta, metaSongDiscNumber))
current += dmap_add_short(current,"asdn",
(short)atoi(valarray[SG_DISC]));
@ -864,8 +897,7 @@ int daap_build_dmap(PRIVINFO *pinfo, char **valarray, unsigned char *presult, in
current += dmap_add_short(current,"astn",
(short)atoi(valarray[SG_TRACK]));
if(valarray[SG_RATING] && atoi(valarray[SG_RATING]) &&
daap_wantsmeta(pinfo->meta, metaSongUserRating))
if(daap_wantsmeta(pinfo->meta, metaSongUserRating))
current += dmap_add_char(current,"asur",
(char)atoi(valarray[SG_RATING]));

View File

@ -23,6 +23,7 @@ extern int daap_wantsmeta(MetaField_t meta, MetaFieldName_t fieldNo);
extern int dmap_add_char(unsigned char *where, char *tag, char value);
extern int dmap_add_short(unsigned char *where, char *tag, short value);
extern int dmap_add_int(unsigned char *where, char *tag, int value);
extern int dmap_add_long(unsigned char *where, char *tag, uint64_t value);
extern int dmap_add_string(unsigned char *where, char *tag, char *value);
extern int dmap_add_literal(unsigned char *where, char *tag, char *value, int size);
extern int dmap_add_container(unsigned char *where, char *tag, int size);

View File

@ -102,7 +102,7 @@ PLUGIN_REND_INFO _pri[] = {
{ NULL, NULL }
};
PLUGIN_INPUT_FN *_ppi;
PLUGIN_INFO _pi = {
PLUGIN_INFO _pi = {
PLUGIN_VERSION, /* version */
PLUGIN_OUTPUT, /* type */
"daap/" VERSION, /* server */
@ -118,11 +118,11 @@ typedef struct tag_response {
char *uri[10];
void (*dispatch)(WS_CONNINFO *, PRIVINFO *);
} PLUGIN_RESPONSE;
PLUGIN_RESPONSE daap_uri_map[] = {
{{"server-info", NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL },
out_daap_server_info },
{{"content-codes", NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL },
{{"content-codes", NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL },
out_daap_content_codes },
{{"login", NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL },
out_daap_login },
@ -305,7 +305,7 @@ void plugin_handler(WS_CONNINFO *pwsc) {
string = _ppi->ws_uri(pwsc);
string++;
_ppi->log(E_DBG,"Mallocing privinfo...\n");
ppi = (PRIVINFO *)malloc(sizeof(PRIVINFO));
if(ppi) {
@ -354,7 +354,7 @@ 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);
if(_ppi->ws_getvar(pwsc,"query")) {
@ -384,7 +384,7 @@ void plugin_handler(WS_CONNINFO *pwsc) {
if((ppi->uri_sections[part]) && (!daap_uri_map[index].uri[part]))
break;
if((daap_uri_map[index].uri[part]) &&
if((daap_uri_map[index].uri[part]) &&
(strcmp(daap_uri_map[index].uri[part],"*") != 0)) {
if(strcmp(daap_uri_map[index].uri[part],
ppi->uri_sections[part])!= 0)
@ -1170,7 +1170,7 @@ void out_daap_playlists(WS_CONNINFO *pwsc, PRIVINFO *ppi) {
_ppi->log(E_DBG,"Item enum: got %d playlists, dmap size: %d\n",pl_count,list_length);
mtco = pl_count;
if((ppi->dq.offset) || (ppi->dq.limit))
if((ppi->dq.offset) || (ppi->dq.limit))
mtco = ppi->dq.totalcount;
current += dmap_add_container(current,"aply",list_length + 53);
@ -1301,22 +1301,23 @@ void out_daap_dbinfo(WS_CONNINFO *pwsc, PRIVINFO *ppi) {
namelen=(int) strlen(servername);
current += dmap_add_container(current,"avdb",105 + namelen);
current += dmap_add_container(current,"avdb",121 + namelen);
current += dmap_add_int(current,"mstt",200); /* 12 */
current += dmap_add_char(current,"muty",0); /* 9 */
current += dmap_add_int(current,"mtco",1); /* 12 */
current += dmap_add_int(current,"mrco",1); /* 12 */
current += dmap_add_container(current,"mlcl",52 + namelen);
current += dmap_add_container(current,"mlit",44 + namelen);
current += dmap_add_container(current,"mlcl",68 + namelen);
current += dmap_add_container(current,"mlit",60 + namelen);
current += dmap_add_int(current,"miid",1); /* 12 */
current += dmap_add_long(current,"mper",1); /* 16 */
current += dmap_add_string(current,"minm",servername); /* 8 + namelen */
count = _ppi->db_count_items(COUNT_SONGS);
current += dmap_add_int(current,"mimc",count); /* 12 */
count = _ppi->db_count_items(COUNT_PLAYLISTS);
current += dmap_add_int(current,"mctc",count); /* 12 */
out_daap_output_start(pwsc,ppi,113+namelen);
out_daap_output_write(pwsc,ppi,dbinfo_response,113+namelen);
out_daap_output_start(pwsc,ppi,129+namelen);
out_daap_output_write(pwsc,ppi,dbinfo_response,129+namelen);
out_daap_output_end(pwsc,ppi);
return;
@ -1409,7 +1410,7 @@ void out_daap_server_info(WS_CONNINFO *pwsc, PRIVINFO *ppi) {
_ppi->server_name(servername,&size);
// supports_update = conf_get_int("daap","supports_update",1);
actual_length=130 + (int) strlen(servername);
actual_length=139 + (int) strlen(servername);
if(!supports_update)
actual_length -= 9;
@ -1444,6 +1445,8 @@ void out_daap_server_info(WS_CONNINFO *pwsc, PRIVINFO *ppi) {
current += dmap_add_char(current,"msix",0); /* 9 */
current += dmap_add_char(current,"msbr",0); /* 9 */
current += dmap_add_char(current,"msqy",0); /* 9 */
current += dmap_add_char(current,"mspi",0);
current += dmap_add_int(current,"msdc",1); /* 12 */
if(supports_update)