mirror of
https://github.com/owntone/owntone-server.git
synced 2025-10-29 07:45:04 -04:00
Merge branch 'master' into spotify
This commit is contained in:
commit
c4af7c3ca3
@ -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])
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <fcntl.h>
|
||||
@ -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;
|
||||
|
||||
@ -31,9 +31,9 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
// For file copy
|
||||
// For file copy (fcopyfile currently Mac OSX only)
|
||||
#include <fcntl.h>
|
||||
#if defined(__APPLE__)
|
||||
#if defined(HAVE_FCOPYFILE)
|
||||
#include <copyfile.h>
|
||||
#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
|
||||
}
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user