From 3e7a3cbfb596fe59956df9fe2ae556303661ad5a Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Tue, 12 May 2009 01:21:53 +0000 Subject: [PATCH] * Add WAV file support. --- Makefile | 2 +- metadata.c | 7 ++++++- scanner.c | 5 +++-- tagutils/tagutils-asf.c | 1 - tagutils/tagutils-mp3.c | 1 - tagutils/tagutils.c | 6 ++++++ tagutils/tagutils.h | 1 + upnphttp.c | 1 + upnpsoap.c | 8 ++++++++ 9 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 2d4e899..2acf208 100644 --- a/Makefile +++ b/Makefile @@ -105,7 +105,7 @@ albumart.o: upnpglobalvars.h albumart.h utils.h image_utils.h sql.h log.h tagutils/misc.o: tagutils/misc.h tagutils/textutils.o: tagutils/misc.h tagutils/textutils.h log.h tagutils/tagutils.o: tagutils/tagutils-asf.c tagutils/tagutils-flc.c tagutils/tagutils-plist.c tagutils/tagutils-misc.c -tagutils/tagutils.o: tagutils/tagutils-aac.c tagutils/tagutils-asf.h tagutils/tagutils-flc.h tagutils/tagutils-mp3.c +tagutils/tagutils.o: tagutils/tagutils-aac.c tagutils/tagutils-asf.h tagutils/tagutils-flc.h tagutils/tagutils-mp3.c tagutils/tagutils-wav.c tagutils/tagutils.o: tagutils/tagutils-ogg.c tagutils/tagutils-aac.h tagutils/tagutils.h tagutils/tagutils-mp3.h tagutils/tagutils-ogg.h log.h image_utils.o: image_utils.h tivo_utils.o: config.h tivo_utils.h diff --git a/metadata.c b/metadata.c index 3214fde..1d76a04 100644 --- a/metadata.c +++ b/metadata.c @@ -178,6 +178,11 @@ GetAudioMetadata(const char * path, char * name) strcpy(type, "flc"); strcpy(mime, "audio/x-flac"); } + else if( ends_with(path, ".wav") ) + { + strcpy(type, "wav"); + strcpy(mime, "audio/x-wav"); + } else { DPRINTF(E_WARN, L_GENERAL, "Unhandled file extension on %s\n", path); @@ -269,7 +274,7 @@ GetAudioMetadata(const char * path, char * name) genre, comment, song.track, - dlna_pn, mime, + dlna_pn, song.mime?song.mime:mime, album_art, album_art?art_dlna_pn:NULL ); freetags(&song); if( dlna_pn ) diff --git a/scanner.c b/scanner.c index 50b2fc2..674ed07 100644 --- a/scanner.c +++ b/scanner.c @@ -67,7 +67,8 @@ is_audio(const char * file) ends_with(file, ".wma") || ends_with(file, ".asf") || ends_with(file, ".fla") || ends_with(file, ".flc") || ends_with(file, ".m4a") || ends_with(file, ".aac") || - ends_with(file, ".mp4") || ends_with(file, ".m4p")); + ends_with(file, ".mp4") || ends_with(file, ".m4p") || + ends_with(file, ".wav")); } int @@ -378,7 +379,7 @@ insert_containers(const char * name, const char *path, const char * refID, const sprintf(last_genreArtist.parentID, "%s$%llX", last_genre.parentID, container>>32); last_genreArtist.objectID = (int)container; strcpy(last_genreArtist.name, artist?artist:"Unknown Artist"); - //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached artist/artist item: %s/%s/%X\n", last_artist.name, last_artist.parentID, last_artist.objectID); + //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached genre/artist item: %s/%s/%X\n", last_genreArtist.name, last_genreArtist.parentID, last_genreArtist.objectID); } sql = sqlite3_mprintf( "INSERT into OBJECTS" " (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETAIL_ID, NAME) " diff --git a/tagutils/tagutils-asf.c b/tagutils/tagutils-asf.c index bea56da..938cec5 100644 --- a/tagutils/tagutils-asf.c +++ b/tagutils/tagutils-asf.c @@ -105,7 +105,6 @@ _asf_read_media_stream(FILE *fp, struct song_metadata *psong, __u32 size) { case WMAV1: case WMAV2: - printf("***** JM: bitrate: %d\n", psong->bitrate); if( psong->bitrate < 193000 ) asprintf(&(psong->dlna_pn), "WMABASE"); else diff --git a/tagutils/tagutils-mp3.c b/tagutils/tagutils-mp3.c index 28af80b..eb532ba 100644 --- a/tagutils/tagutils-mp3.c +++ b/tagutils/tagutils-mp3.c @@ -25,7 +25,6 @@ * This file is derived from mt-daap project. */ -// _get_mp3tags static int _get_mp3tags(char *file, struct song_metadata *psong) { diff --git a/tagutils/tagutils.c b/tagutils/tagutils.c index bb93099..54c6ab9 100644 --- a/tagutils/tagutils.c +++ b/tagutils/tagutils.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include #include @@ -103,6 +105,7 @@ char *winamp_genre[] = { #include "tagutils-ogg.h" #include "tagutils-flc.h" #include "tagutils-asf.h" +#include "tagutils-wav.h" static int _get_tags(char *file, struct song_metadata *psong); static int _get_fileinfo(char *file, struct song_metadata *psong); @@ -124,6 +127,7 @@ static taghandler taghandlers[] = { { "flc", _get_flctags, _get_flcfileinfo }, { "ogg", 0, _get_oggfileinfo }, { "asf", 0, _get_asffileinfo }, + { "wav", _get_wavtags, _get_wavfileinfo }, { NULL, 0 } }; @@ -136,6 +140,7 @@ static taghandler taghandlers[] = { #include "tagutils-ogg.c" #include "tagutils-flc.c" #include "tagutils-asf.c" +#include "tagutils-wav.c" //********************************************************************************* // freetags() @@ -157,6 +162,7 @@ freetags(struct song_metadata *psong) MAYBEFREE(psong->contributor_sort[role]); } MAYBEFREE(psong->grouping); + MAYBEFREE(psong->mime); MAYBEFREE(psong->dlna_pn); MAYBEFREE(psong->tagversion); MAYBEFREE(psong->musicbrainz_albumid); diff --git a/tagutils/tagutils.h b/tagutils/tagutils.h index 7307601..801a084 100644 --- a/tagutils/tagutils.h +++ b/tagutils/tagutils.h @@ -86,6 +86,7 @@ struct song_metadata { int lossless; int blockalignment; + char *mime; // MIME type char *dlna_pn; // DLNA Profile Name char *tagversion; diff --git a/upnphttp.c b/upnphttp.c index 0ce62ed..c33de63 100644 --- a/upnphttp.c +++ b/upnphttp.c @@ -1560,4 +1560,5 @@ SendResp_dlnafile(struct upnphttp * h, char * object) if( !newpid ) _exit(0); #endif + return; } diff --git a/upnpsoap.c b/upnpsoap.c index 939ac08..deb4313 100644 --- a/upnpsoap.c +++ b/upnpsoap.c @@ -535,6 +535,14 @@ callback(void *args, int argc, char **argv, char **azColName) } } } + else if( !(passed_args->flags & FLAG_DLNA) ) + { + if( strncmp(mime, "audio/L16", 9) == 0 ) + { + strcpy(mime+6, "x-wav"); + } + } + ret = snprintf(str_buf, 512, "<item id=\"%s\" parentID=\"%s\" restricted=\"1\"", id, parent); memcpy(passed_args->resp+passed_args->size, &str_buf, ret+1); passed_args->size += ret;