Reference iTunes playlist by name hash rather than native playlist id

This commit is contained in:
Ron Pedde 2006-11-27 00:00:00 +00:00
parent 27492139d9
commit 9239e0ad36
3 changed files with 19 additions and 13 deletions

View File

@ -80,8 +80,8 @@ static int rend_addtorunloop(dns_service_discovery_ref client) {
else { else {
CFMachPortContext context = { 0, 0, NULL, NULL, NULL }; CFMachPortContext context = { 0, 0, NULL, NULL, NULL };
Boolean shouldFreeInfo; Boolean shouldFreeInfo;
CFMachPortRef cfMachPort=CFMachPortCreateWithPort(kCFAllocatorDefault, CFMachPortRef cfMachPort=CFMachPortCreateWithPort(kCFAllocatorDefault,
port, rend_handler, port, rend_handler,
&context, &shouldFreeInfo); &context, &shouldFreeInfo);
CFRunLoopSourceRef rls=CFMachPortCreateRunLoopSource(NULL,cfMachPort,0); CFRunLoopSourceRef rls=CFMachPortCreateRunLoopSource(NULL,cfMachPort,0);
@ -154,7 +154,7 @@ void rend_add_text(char *buffer, char *string) {
/* /*
* rend_callback * 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. * message waiting to be processed.
*/ */
void rend_callback(void *info) { void rend_callback(void *info) {
@ -207,8 +207,8 @@ void rend_callback(void *info) {
rend_stoprunloop(); rend_stoprunloop();
break; break;
case REND_MSG_TYPE_STATUS: case REND_MSG_TYPE_STATUS:
DPRINTF(E_DBG,L_REND,"Status inquiry -- returning 0\n"); DPRINTF(E_DBG,L_REND,"Status inquiry -- returning 1\n");
rend_send_response(0); /* success */ rend_send_response(1); /* success */
break; break;
default: default:
break; break;
@ -237,7 +237,7 @@ int rend_private_init(char *user) {
CFRunLoopAddSource(CFRunLoopGetCurrent(),rend_rls,kCFRunLoopDefaultMode); CFRunLoopAddSource(CFRunLoopGetCurrent(),rend_rls,kCFRunLoopDefaultMode);
DPRINTF(E_DBG,L_REND,"Starting polling thread\n"); DPRINTF(E_DBG,L_REND,"Starting polling thread\n");
if(pthread_create(&rend_tid,NULL,rend_pipe_monitor,NULL)) { if(pthread_create(&rend_tid,NULL,rend_pipe_monitor,NULL)) {
DPRINTF(E_FATAL,L_REND,"Could not start thread. Terminating\n"); DPRINTF(E_FATAL,L_REND,"Could not start thread. Terminating\n");
/* should kill parent, too */ /* should kill parent, too */

View File

@ -933,8 +933,14 @@ int scan_xml_playlists_section(int action, char *info) {
current_id=0; current_id=0;
if(dont_scan == 0) { if(dont_scan == 0) {
DPRINTF(E_DBG,L_SCAN,"Creating playlist for %s\n",current_name); 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 */ /* delete the old one first */
/* FIXME: Error handling */ /* FIXME: Error handling */
native_plid = util_djb_hash_str(current_name);
pm3u = db_fetch_playlist(NULL,scan_xml_file,native_plid); pm3u = db_fetch_playlist(NULL,scan_xml_file,native_plid);
if(pm3u) { if(pm3u) {
db_delete_playlist(NULL,pm3u->id); db_delete_playlist(NULL,pm3u->id);

View File

@ -15,7 +15,7 @@
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
//#include <iconv.h> //#include <iconv.h>
#include "daapd.h" #include "daapd.h"
#include "err.h" #include "err.h"
@ -81,7 +81,7 @@ int util_utf16toutf8_len(unsigned char *utf16, int len) {
while(src+2 <= utf16 + len) { while(src+2 <= utf16 + len) {
temp_dword = src[1] << 8 | src[0]; temp_dword = src[1] << 8 | src[0];
if((temp_dword & 0xFC00) == 0xD800) { if((temp_dword & 0xFC00) == 0xD800) {
src += 2; src += 2;
if(src + 2 <= utf16 + len) { 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... * convert utf16 string to utf8. This is a bit naive, but...
* Since utf-8 can't expand past 4 bytes per code point, and * 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'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 * Probably it could be more efficiently calculated, but this will
* always work. Besides, these are small strings, and will be freed * 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; w1 += 0x10000;
} }
// now encode the original code point in utf-8 // now encode the original code point in utf-8
if (w1 < 0x80) { if (w1 < 0x80) {
*dst++ = w1; *dst++ = w1;
bytes=0; 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); DPRINTF(E_LOG,L_MISC,"Cannot convert %s to utf16; E2BIG (%d vs %d)\n",utf8,new_len,dlen);
return FALSE; return FALSE;
} }
dst=utf16; dst=utf16;
while(src < utf8 + len) { while(src < utf8 + len) {
@ -286,7 +286,7 @@ unsigned char *util_utf16touft8_alloc(unsigned char *utf16, int len) {
utf32 = *src; utf32 = *src;
break; break;
case 1: case 1:
utf32 = ((src[0] & 0x1F) << 6) | utf32 = ((src[0] & 0x1F) << 6) |
(src[1] & 0x3F); (src[1] & 0x3F);
break; break;
case 2: case 2:
@ -315,7 +315,7 @@ unsigned char *util_utf16touft8_alloc(unsigned char *utf16, int len) {
*dst++ = temp_word & 0xFF; *dst++ = temp_word & 0xFF;
*dst++ = (temp_word & 0xFF00) >> 8; *dst++ = (temp_word & 0xFF00) >> 8;
} }
src += (trailing_bytes + 1); src += (trailing_bytes + 1);
} }