mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-25 14:45:55 -05:00
Reference iTunes playlist by name hash rather than native playlist id
This commit is contained in:
parent
27492139d9
commit
9239e0ad36
@ -80,8 +80,8 @@ static int rend_addtorunloop(dns_service_discovery_ref client) {
|
||||
else {
|
||||
CFMachPortContext context = { 0, 0, NULL, NULL, NULL };
|
||||
Boolean shouldFreeInfo;
|
||||
CFMachPortRef cfMachPort=CFMachPortCreateWithPort(kCFAllocatorDefault,
|
||||
port, rend_handler,
|
||||
CFMachPortRef cfMachPort=CFMachPortCreateWithPort(kCFAllocatorDefault,
|
||||
port, rend_handler,
|
||||
&context, &shouldFreeInfo);
|
||||
|
||||
CFRunLoopSourceRef rls=CFMachPortCreateRunLoopSource(NULL,cfMachPort,0);
|
||||
@ -154,7 +154,7 @@ void rend_add_text(char *buffer, char *string) {
|
||||
/*
|
||||
* rend_callback
|
||||
*
|
||||
* This gets called from the main thread when there is a
|
||||
* This gets called from the main thread when there is a
|
||||
* message waiting to be processed.
|
||||
*/
|
||||
void rend_callback(void *info) {
|
||||
@ -207,8 +207,8 @@ void rend_callback(void *info) {
|
||||
rend_stoprunloop();
|
||||
break;
|
||||
case REND_MSG_TYPE_STATUS:
|
||||
DPRINTF(E_DBG,L_REND,"Status inquiry -- returning 0\n");
|
||||
rend_send_response(0); /* success */
|
||||
DPRINTF(E_DBG,L_REND,"Status inquiry -- returning 1\n");
|
||||
rend_send_response(1); /* success */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -237,7 +237,7 @@ int rend_private_init(char *user) {
|
||||
CFRunLoopAddSource(CFRunLoopGetCurrent(),rend_rls,kCFRunLoopDefaultMode);
|
||||
|
||||
DPRINTF(E_DBG,L_REND,"Starting polling thread\n");
|
||||
|
||||
|
||||
if(pthread_create(&rend_tid,NULL,rend_pipe_monitor,NULL)) {
|
||||
DPRINTF(E_FATAL,L_REND,"Could not start thread. Terminating\n");
|
||||
/* should kill parent, too */
|
||||
|
@ -933,8 +933,14 @@ int scan_xml_playlists_section(int action, char *info) {
|
||||
current_id=0;
|
||||
if(dont_scan == 0) {
|
||||
DPRINTF(E_DBG,L_SCAN,"Creating playlist for %s\n",current_name);
|
||||
/* we won't actually use the iTunes pl_id, as it seems
|
||||
* to change for no good reason. We'll hash the name,
|
||||
* instead. */
|
||||
|
||||
/* delete the old one first */
|
||||
/* FIXME: Error handling */
|
||||
native_plid = util_djb_hash_str(current_name);
|
||||
|
||||
pm3u = db_fetch_playlist(NULL,scan_xml_file,native_plid);
|
||||
if(pm3u) {
|
||||
db_delete_playlist(NULL,pm3u->id);
|
||||
|
14
src/util.c
14
src/util.c
@ -15,7 +15,7 @@
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
//#include <iconv.h>
|
||||
//#include <iconv.h>
|
||||
|
||||
#include "daapd.h"
|
||||
#include "err.h"
|
||||
@ -81,7 +81,7 @@ int util_utf16toutf8_len(unsigned char *utf16, int len) {
|
||||
|
||||
while(src+2 <= utf16 + len) {
|
||||
temp_dword = src[1] << 8 | src[0];
|
||||
|
||||
|
||||
if((temp_dword & 0xFC00) == 0xD800) {
|
||||
src += 2;
|
||||
if(src + 2 <= utf16 + len) {
|
||||
@ -107,7 +107,7 @@ int util_utf16toutf8_len(unsigned char *utf16, int len) {
|
||||
* convert utf16 string to utf8. This is a bit naive, but...
|
||||
* Since utf-8 can't expand past 4 bytes per code point, and
|
||||
* we're converting utf-16, we can't be more than 2n+1 bytes, so
|
||||
* we'll just allocate that much.
|
||||
* we'll just allocate that much.
|
||||
*
|
||||
* Probably it could be more efficiently calculated, but this will
|
||||
* always work. Besides, these are small strings, and will be freed
|
||||
@ -159,7 +159,7 @@ int util_utf16toutf8(unsigned char *utf8, int dlen, unsigned char *utf16, int le
|
||||
w1 += 0x10000;
|
||||
}
|
||||
|
||||
// now encode the original code point in utf-8
|
||||
// now encode the original code point in utf-8
|
||||
if (w1 < 0x80) {
|
||||
*dst++ = w1;
|
||||
bytes=0;
|
||||
@ -265,7 +265,7 @@ unsigned char *util_utf16touft8_alloc(unsigned char *utf16, int len) {
|
||||
DPRINTF(E_LOG,L_MISC,"Cannot convert %s to utf16; E2BIG (%d vs %d)\n",utf8,new_len,dlen);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
dst=utf16;
|
||||
|
||||
while(src < utf8 + len) {
|
||||
@ -286,7 +286,7 @@ unsigned char *util_utf16touft8_alloc(unsigned char *utf16, int len) {
|
||||
utf32 = *src;
|
||||
break;
|
||||
case 1:
|
||||
utf32 = ((src[0] & 0x1F) << 6) |
|
||||
utf32 = ((src[0] & 0x1F) << 6) |
|
||||
(src[1] & 0x3F);
|
||||
break;
|
||||
case 2:
|
||||
@ -315,7 +315,7 @@ unsigned char *util_utf16touft8_alloc(unsigned char *utf16, int len) {
|
||||
*dst++ = temp_word & 0xFF;
|
||||
*dst++ = (temp_word & 0xFF00) >> 8;
|
||||
}
|
||||
|
||||
|
||||
src += (trailing_bytes + 1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user