mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-23 19:42:31 -05:00
Fix for iTunes 7 password prompt on movie playback
This commit is contained in:
parent
3caf85e221
commit
aa7b98f214
@ -200,11 +200,11 @@ void db_readlock(void) {
|
||||
void db_writelock(void) {
|
||||
int err;
|
||||
|
||||
// DPRINTF(E_SPAM,L_LOCK,"entering db_writelock\n");
|
||||
DPRINTF(E_SPAM,L_LOCK,"entering db_writelock\n");
|
||||
if((err=pthread_rwlock_wrlock(&db_rwlock))) {
|
||||
DPRINTF(E_FATAL,L_DB,"cannot lock rwlock: %s\n",strerror(err));
|
||||
}
|
||||
// DPRINTF(E_SPAM,L_LOCK,"db_writelock acquired\n");
|
||||
DPRINTF(E_SPAM,L_LOCK,"db_writelock acquired\n");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -213,7 +213,7 @@ void db_writelock(void) {
|
||||
* useless, but symmetrical
|
||||
*/
|
||||
int db_unlock(void) {
|
||||
// DPRINTF(E_SPAM,L_LOCK,"releasing db lock\n");
|
||||
DPRINTF(E_SPAM,L_LOCK,"releasing db lock\n");
|
||||
return pthread_rwlock_unlock(&db_rwlock);
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,8 @@
|
||||
static sqlite3 *db_sqlite3_songs; /**< Database that holds the mp3 info */
|
||||
static pthread_mutex_t db_sqlite3_mutex = PTHREAD_MUTEX_INITIALIZER; /**< sqlite not reentrant */
|
||||
static sqlite3_stmt *db_sqlite3_stmt;
|
||||
static const char *db_sqlite3_ptail;
|
||||
static int db_sqlite3_finalized;
|
||||
static int db_sqlite3_reload=0;
|
||||
static char *db_sqlite3_enum_query=NULL;
|
||||
static char **db_sqlite3_row = NULL;
|
||||
@ -230,29 +232,30 @@ int db_sqlite3_enum_begin(char **pe, char *fmt, ...) {
|
||||
db_sqlite3_enum_query = sqlite3_vmprintf(fmt,ap);
|
||||
va_end(ap);
|
||||
|
||||
db_sqlite3_finalized=0;
|
||||
return db_sqlite3_enum_begin_helper(pe);
|
||||
}
|
||||
|
||||
int db_sqlite3_enum_begin_helper(char **pe) {
|
||||
int err;
|
||||
const char *ptail;
|
||||
|
||||
if(!db_sqlite3_enum_query)
|
||||
*((int*)NULL) = 1;
|
||||
|
||||
|
||||
DPRINTF(E_DBG,L_DB,"Executing: %s\n",db_sqlite3_enum_query);
|
||||
err=sqlite3_prepare(db_sqlite3_songs,db_sqlite3_enum_query,-1,
|
||||
&db_sqlite3_stmt,&ptail);
|
||||
&db_sqlite3_stmt,&db_sqlite3_ptail);
|
||||
|
||||
if(err != SQLITE_OK) {
|
||||
db_get_error(pe,DB_E_SQL_ERROR,sqlite3_errmsg(db_sqlite3_songs));
|
||||
db_sqlite3_unlock();
|
||||
sqlite3_free(db_sqlite3_enum_query);
|
||||
db_sqlite3_enum_query=NULL;
|
||||
db_sqlite3_unlock();
|
||||
return DB_E_SQL_ERROR;
|
||||
}
|
||||
|
||||
DPRINTF(E_SPAM,L_DB,"Prepared statement: %08X\n",db_sqlite3_stmt);
|
||||
|
||||
/* otherwise, we leave the db locked while we walk through the enums */
|
||||
if(db_sqlite3_row)
|
||||
free(db_sqlite3_row);
|
||||
@ -284,10 +287,11 @@ int db_sqlite3_enum_fetch(char **pe, SQL_ROW *pr) {
|
||||
*((int*)NULL) = 1;
|
||||
|
||||
while(counter--) {
|
||||
DPRINTF(E_SPAM,L_DB,"Fetching statement: %08X\n",db_sqlite3_stmt);
|
||||
err=sqlite3_step(db_sqlite3_stmt);
|
||||
if(err != SQLITE_BUSY)
|
||||
break;
|
||||
usleep(100);
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
if(err == SQLITE_DONE) {
|
||||
@ -299,6 +303,7 @@ int db_sqlite3_enum_fetch(char **pe, SQL_ROW *pr) {
|
||||
}
|
||||
|
||||
if(err == SQLITE_ROW) {
|
||||
DPRINTF(E_SPAM,L_DB,"Got row\n");
|
||||
cols = sqlite3_column_count(db_sqlite3_stmt);
|
||||
|
||||
if(!db_sqlite3_row) {
|
||||
@ -321,7 +326,9 @@ int db_sqlite3_enum_fetch(char **pe, SQL_ROW *pr) {
|
||||
db_sqlite3_row = NULL;
|
||||
|
||||
db_get_error(pe,DB_E_SQL_ERROR,sqlite3_errmsg(db_sqlite3_songs));
|
||||
DPRINTF(E_SPAM,L_DB,"Finalizing statement: %08X\n",db_sqlite3_stmt);
|
||||
sqlite3_finalize(db_sqlite3_stmt);
|
||||
db_sqlite3_finalized=1;
|
||||
|
||||
return DB_E_SQL_ERROR;
|
||||
}
|
||||
@ -341,11 +348,14 @@ int db_sqlite3_enum_end(char **pe) {
|
||||
sqlite3_free(db_sqlite3_enum_query);
|
||||
db_sqlite3_enum_query = NULL;
|
||||
|
||||
err = sqlite3_finalize(db_sqlite3_stmt);
|
||||
if(err != SQLITE_OK) {
|
||||
db_get_error(pe,DB_E_SQL_ERROR,sqlite3_errmsg(db_sqlite3_songs));
|
||||
db_sqlite3_unlock();
|
||||
return DB_E_SQL_ERROR;
|
||||
if(!db_sqlite3_finalized) {
|
||||
DPRINTF(E_SPAM,L_DB,"Finalizing statement: %08X\n",db_sqlite3_stmt);
|
||||
err = sqlite3_finalize(db_sqlite3_stmt);
|
||||
if(err != SQLITE_OK) {
|
||||
db_get_error(pe,DB_E_SQL_ERROR,sqlite3_errmsg(db_sqlite3_songs));
|
||||
db_sqlite3_unlock();
|
||||
return DB_E_SQL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
db_sqlite3_unlock();
|
||||
|
@ -193,13 +193,6 @@ EXPORT int pi_should_transcode(WS_CONNINFO *pwsc, char *codec) {
|
||||
}
|
||||
|
||||
|
||||
EXPORT int pi_db_count(void) {
|
||||
int count;
|
||||
db_get_song_count(NULL, &count);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
EXPORT int pi_db_enum_start(char **pe, DB_QUERY *pinfo) {
|
||||
DBQUERYINFO *pqi;
|
||||
int result;
|
||||
@ -462,19 +455,23 @@ EXPORT int pi_db_revision(void) {
|
||||
return db_revision();
|
||||
}
|
||||
|
||||
/* FIXME: error checking */
|
||||
EXPORT int pi_db_count_items(int what) {
|
||||
int count=0;
|
||||
char *pe = NULL;
|
||||
|
||||
switch(what) {
|
||||
case COUNT_SONGS:
|
||||
db_get_song_count(NULL,&count);
|
||||
db_get_song_count(&pe,&count);
|
||||
break;
|
||||
case COUNT_PLAYLISTS:
|
||||
db_get_playlist_count(NULL,&count);
|
||||
db_get_playlist_count(&pe,&count);
|
||||
break;
|
||||
}
|
||||
|
||||
if(pe) {
|
||||
DPRINTF(E_LOG,L_DB,"Error getting item count: %s\n",pe);
|
||||
free(pe);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,6 @@ extern EXPORT void pi_log(int, char *, ...);
|
||||
extern EXPORT int pi_should_transcode(struct tag_ws_conninfo *, char *);
|
||||
|
||||
/* db functions */
|
||||
extern EXPORT int pi_db_count(void);
|
||||
extern EXPORT int pi_db_enum_start(char **, DB_QUERY *);
|
||||
extern EXPORT int pi_db_enum_fetch_row(char **, char ***, DB_QUERY *);
|
||||
extern EXPORT int pi_db_enum_end(char **);
|
||||
|
@ -183,6 +183,8 @@ int plugin_can_handle(WS_CONNINFO *pwsc) {
|
||||
return TRUE;
|
||||
if(strncasecmp(uri,"/logout",7) == 0)
|
||||
return TRUE;
|
||||
if(strncasecmp(uri,"/activity",9) == 0)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -201,6 +203,8 @@ int plugin_auth(WS_CONNINFO *pwsc, char *username, char *password) {
|
||||
return TRUE;
|
||||
if(strncasecmp(uri,"/databases/1/items/",19) == 0)
|
||||
return TRUE;
|
||||
if(strncasecmp(uri,"/activity",9) == 0)
|
||||
return TRUE;
|
||||
|
||||
return pi_ws_matchesrole(pwsc,username,password,"user");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user