static Tuple * wv_probe_for_tuple(const char * filename, VFSFile * fd) { WavpackContext *ctx; Tuple *tu; char error[1024]; ctx = WavpackOpenFileInputEx(&wv_readers, fd, NULL, error, OPEN_TAGS, 0); if (ctx == NULL) return NULL; AUDDBG("starting probe of %p\n", (void *) fd); vfs_rewind(fd); tu = tuple_new_from_filename(filename); vfs_rewind(fd); tag_tuple_read(tu, fd); tuple_set_int(tu, FIELD_LENGTH, NULL, ((uint64_t) WavpackGetNumSamples(ctx) * 1000) / (uint64_t) WavpackGetSampleRate(ctx)); tuple_set_str(tu, FIELD_CODEC, NULL, "WavPack"); char * quality = wv_get_quality (ctx); tuple_set_str (tu, FIELD_QUALITY, NULL, quality); str_unref (quality); WavpackCloseFile(ctx); AUDDBG("returning tuple %p for file %p\n", (void *) tu, (void *) fd); return tu; }
static void httpd_handle_vfs_send_header (void) { PASTE_RESET (); PASTE_P (httpd_header_200); vfs_size_t len = vfs_size (STATE->u.vfs.fd); if (len > 0) { /* send content-length header */ PASTE_P (httpd_header_length); PASTE_LEN (len); } /* Check whether the file is gzip compressed. */ unsigned char buf[READ_AHEAD_LEN]; #ifndef VFS_TEENSY if (VFS_HAVE_FUNC (STATE->u.vfs.fd, fseek)) { #endif /* not VFS_TEENSY, inlined files are always gzip'd */ /* Rewind stream first, might be a rexmit */ vfs_rewind (STATE->u.vfs.fd); vfs_read (STATE->u.vfs.fd, buf, READ_AHEAD_LEN); vfs_rewind (STATE->u.vfs.fd); #ifndef VFS_TEENSY } else goto no_gzip; if (buf[0] == 0x1f && buf[1] == 0x8b) #endif /* not VFS_TEENSY, inlined files are always gzip'd */ PASTE_P (httpd_header_gzip); #ifdef MIME_SUPPORT PASTE_PF (PSTR ("Content-Type: %S\n\n"), httpd_mimetype_detect (buf)); PASTE_SEND (); return; #endif /* MIME_SUPPORT */ #ifndef VFS_TEENSY no_gzip: #endif /* not VFS_TEENSY, inlined files are always gzip'd */ if (STATE->u.vfs.content_type == 'X') PASTE_P (httpd_header_ct_xhtml); else if (STATE->u.vfs.content_type == 'S') PASTE_P (httpd_header_ct_css); else PASTE_P (httpd_header_ct_html); PASTE_SEND (); }
static gboolean update_song_tuple(const Tuple * tuple, VFSFile *file) { #if _AUD_PLUGIN_VERSION < 38 #define vfs_get_filename(file) g_filename_from_uri(file->uri, NULL, NULL) #define tuple_get_str tuple_get_string #define str_unref(s) const char *s; #else char *s; #endif /* read file */ const char *filename = vfs_get_filename(file); unsigned char module[ASAPInfo_MAX_MODULE_LENGTH]; int module_len = load_module(filename, file, module); ASAPInfo *info; int year; ByteWriter bw; gboolean ok; if (module_len <= 0) return FALSE; info = ASAPInfo_New(); if (info == NULL) return FALSE; if (!ASAPInfo_Load(info, filename, module, module_len)) { ASAPInfo_Delete(info); return FALSE; } /* apply new tags */ s = tuple_get_str(tuple, FIELD_ARTIST, NULL); if (s != NULL) { if (!ASAPInfo_SetAuthor(info, s)) { str_unref(s); ASAPInfo_Delete(info); return FALSE; } str_unref(s); } else ASAPInfo_SetAuthor(info, ""); s = tuple_get_str(tuple, FIELD_TITLE, NULL); if (s != NULL) { if (!ASAPInfo_SetTitle(info, s)) { str_unref(s); ASAPInfo_Delete(info); return FALSE; } str_unref(s); } else ASAPInfo_SetTitle(info, ""); year = tuple_get_int(tuple, FIELD_YEAR, NULL); if (year == 0) year = -1; /* check if year changed so that we don't lose other date parts */ if (year != ASAPInfo_GetYear(info)) { if (year <= 0) ASAPInfo_SetDate(info, ""); else { char d[16]; sprintf(d, "%d", year); ASAPInfo_SetDate(info, d); } } /* write file */ vfs_rewind(file); bw.obj = file; bw.func = write_byte; ok = ASAPWriter_Write(filename, bw, info, module, module_len, TRUE) && vfs_ftruncate(file, vfs_ftell(file)) == 0; ASAPInfo_Delete(info); return ok; }