From c7a385b9b160e6e2dd1aae37d6327d0da2f96789 Mon Sep 17 00:00:00 2001 From: Ron Pedde Date: Sat, 26 Aug 2006 04:14:17 +0000 Subject: [PATCH] Add sample rate from wma files, closing #166 --- src/scan-mp3.c | 2 ++ src/scan-wma.c | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/scan-mp3.c b/src/scan-mp3.c index 1ac25ec1..3cc05080 100644 --- a/src/scan-mp3.c +++ b/src/scan-mp3.c @@ -819,6 +819,8 @@ int scan_mp3_get_mp3fileinfo(char *file, MP3FILE *pmp3) { return FALSE; } + file_size = pmp3->file_size; + memset((void*)&fi,0x00,sizeof(fi)); if(fread(buffer,1,sizeof(buffer),infile) != sizeof(buffer)) { diff --git a/src/scan-wma.c b/src/scan-wma.c index dc65fdf0..3e5342a7 100644 --- a/src/scan-wma.c +++ b/src/scan-wma.c @@ -29,7 +29,6 @@ #include #include - #include "mp3-scanner.h" #include "restart.h" #include "err.h" @@ -377,7 +376,8 @@ int wma_parse_stream_properties(int fd, int size, MP3FILE *pmp3) { int wma_parse_audio_media(int fd, int size, MP3FILE *pmp3) { unsigned short int codec; - if(size < 2) + + if(size < 18) return TRUE; /* we'll leave it wma. will work or not! */ if(!wma_file_read_short(fd,&codec)) { @@ -401,6 +401,11 @@ int wma_parse_audio_media(int fd, int size, MP3FILE *pmp3) { break; } + /* might as well get the sample rate while we are at it */ + lseek(fd,2,SEEK_CUR); + if(!wma_file_read_int(fd,(unsigned int *)&pmp3->samplerate)) + return FALSE; + return TRUE; }