diff --git a/configure.ac b/configure.ac index c4c2b1b4..e2c25e04 100644 --- a/configure.ac +++ b/configure.ac @@ -96,7 +96,13 @@ AC_SEARCH_LIBS([pthread_getthreadid_np], [pthread], [Define to 1 if you have pthread_getthreadid_np])]) AC_SEARCH_LIBS([uuid_generate_random], [uuid], [AC_DEFINE([HAVE_UUID], 1, - [Define to 1 if you have uuid_generate_random function])]) + [Define to 1 if you have uuid_generate_random])]) +AC_SEARCH_LIBS([copy_file_range], [c], + [AC_DEFINE([HAVE_COPY_FILE_RANGE], 1, + [Define to 1 if you have copy_file_range])]) +AC_SEARCH_LIBS([fcopyfile], [c], + [AC_DEFINE([HAVE_FCOPYFILE], 1, + [Define to 1 if you have fcopyfile])]) AC_SEARCH_LIBS([log10], [m]) AC_SEARCH_LIBS([lrint], [m]) diff --git a/docs/advanced/remote-access.md b/docs/advanced/remote-access.md index ba31fd91..29f19aed 100644 --- a/docs/advanced/remote-access.md +++ b/docs/advanced/remote-access.md @@ -8,7 +8,7 @@ need to broadcast the DAAP service to iTunes on your local machine. On macOS the command is: ```shell -dns-sd -P iTunesServer _daap._tcp local 3689 localhost.local 127.0.0.1 "ffid=12345" +dns-sd -P iTunesServer _daap._tcp local 3689 localhost.local 127.0.0.1 "txtvers=1" "ffid=12345678" "Database ID=0123456789abcdef" "Machine ID=0123456789abcdef" "Machine Name=owntone" "mtd-version=28.10" "iTSh Version=131073" "Version=196610" ``` The `ffid` key is required but its value does not matter. diff --git a/src/httpd_dacp.c b/src/httpd_dacp.c index ef8ba943..5349e2c1 100644 --- a/src/httpd_dacp.c +++ b/src/httpd_dacp.c @@ -1852,15 +1852,16 @@ dacp_reply_playqueueedit_clear(struct httpd_request *hreq) const char *param; struct player_status status; - param = httpd_query_value_find(hreq->query, "mode"); - /* * The mode parameter contains the playlist to be cleared. * If mode=0x68697374 (hex representation of the ascii string "hist") clear the history, * otherwise the current playlist. */ - if (strcmp(param,"0x68697374") == 0) - player_queue_clear_history(); + param = httpd_query_value_find(hreq->query, "mode"); + if (param && strcmp(param,"0x68697374") == 0) + { + player_queue_clear_history(); + } else { player_get_status(&status); diff --git a/src/httpd_jsonapi.c b/src/httpd_jsonapi.c index d6d6f85a..93825397 100644 --- a/src/httpd_jsonapi.c +++ b/src/httpd_jsonapi.c @@ -1313,6 +1313,8 @@ jsonapi_reply_spotify(struct httpd_request *hreq) safe_json_add_string(jreply, "webapi_country", webapi_info.country); safe_json_add_string(jreply, "webapi_granted_scope", webapi_info.granted_scope); safe_json_add_string(jreply, "webapi_required_scope", webapi_info.required_scope); + safe_json_add_string(jreply, "webapi_client_id", webapi_info.client_id); + safe_json_add_string(jreply, "webapi_client_secret", webapi_info.client_secret); spotifywebapi_access_token_get(&webapi_token); safe_json_add_string(jreply, "webapi_token", webapi_token.token); diff --git a/src/inputs/spotify_librespotc.c b/src/inputs/spotify_librespotc.c index 05cb91ae..c7c5a2fa 100644 --- a/src/inputs/spotify_librespotc.c +++ b/src/inputs/spotify_librespotc.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -109,6 +110,7 @@ static int postlogin(struct global_ctx *ctx) { struct sp_credentials credentials; + bool use_legacy_mode; char *db_stored_cred; char *ptr; int i; @@ -135,7 +137,13 @@ postlogin(struct global_ctx *ctx) librespotc_bitrate_set(ctx->session, ctx->bitrate_preferred); - DPRINTF(E_LOG, L_SPOTIFY, "Logged into Spotify succesfully with username %s\n", credentials.username); + // For now, use old tcp based protocol as default unless configured not to. + // Note that setup() will switch the old protocol off on error. + use_legacy_mode = !cfg_getbool(cfg_getsec(cfg, "spotify"), "disable_legacy_mode"); + if (use_legacy_mode) + librespotc_legacy_set(ctx->session, true); + + DPRINTF(E_LOG, L_SPOTIFY, "Logged into Spotify succesfully with username %s (%s mode)\n", credentials.username, use_legacy_mode ? "tcp" : "http"); listener_notify(LISTENER_SPOTIFY); @@ -621,13 +629,6 @@ login(const char *username, const char *token, const char **errmsg) if (!ctx->session) goto error; - // For now, use old tcp based protocol as default unless configured not to. - // Note that setup() will switch the old protocol off on error. - if (!cfg_getbool(cfg_getsec(cfg, "spotify"), "disable_legacy_mode")) - librespotc_legacy_set(ctx->session, true); - else - DPRINTF(E_INFO, L_SPOTIFY, "Using experimental http protocol for Spotify\n"); - ret = postlogin(ctx); if (ret < 0) goto error; diff --git a/src/library/filescanner_ffmpeg.c b/src/library/filescanner_ffmpeg.c index e7d440a5..e544e582 100644 --- a/src/library/filescanner_ffmpeg.c +++ b/src/library/filescanner_ffmpeg.c @@ -31,9 +31,9 @@ #include #include -// For file copy +// For file copy (fcopyfile currently Mac OSX only) #include -#if defined(__APPLE__) +#if defined(HAVE_FCOPYFILE) #include #endif @@ -810,9 +810,9 @@ static int fast_copy(int fd_dst, int fd_src) { // Here we use kernel-space copying for performance reasons -#if defined(__APPLE__) +#if defined(HAVE_FCOPYFILE) return fcopyfile(fd_src, fd_dst, 0, COPYFILE_ALL); -#else +#elif defined(HAVE_COPY_FILE_RANGE) struct stat fileinfo = { 0 }; ssize_t bytes_copied; @@ -821,6 +821,23 @@ fast_copy(int fd_dst, int fd_src) if (bytes_copied < 0 || bytes_copied != fileinfo.st_size) return -1; + return 0; +#else + unsigned char buf[4096]; + ssize_t nr; + + while (1) + { + nr = read(fd_src, buf, sizeof(buf)); + if (nr == -1) + return -1; + else if (nr == 0) + return 0; + + if (write(fd_dst, buf, nr) != nr) + return -1; + } + return 0; #endif } diff --git a/src/library/spotify_webapi.c b/src/library/spotify_webapi.c index 9f57eebf..f2f2ca68 100644 --- a/src/library/spotify_webapi.c +++ b/src/library/spotify_webapi.c @@ -359,6 +359,9 @@ credentials_status_info(struct spotifywebapi_status_info *info) strncpy(info->required_scope, spotify_scope, (sizeof(info->required_scope) - 1)); } + info->client_id = spotify_client_id; + info->client_secret = spotify_client_secret; + CHECK_ERR(L_SPOTIFY, pthread_mutex_unlock(&spotify_credentials_lock)); } diff --git a/src/library/spotify_webapi.h b/src/library/spotify_webapi.h index 32a50ad5..0b834f7b 100644 --- a/src/library/spotify_webapi.h +++ b/src/library/spotify_webapi.h @@ -33,6 +33,8 @@ struct spotifywebapi_status_info char country[3]; // ISO 3166-1 alpha-2 country code char granted_scope[250]; char required_scope[250]; + const char *client_id; + const char *client_secret; }; struct spotifywebapi_access_token