From: <ny...@us...> - 2006-12-28 05:46:52
|
Revision: 216 http://svn.sourceforge.net/pmplib/?rev=216&view=rev Author: nyaochi Date: 2006-12-27 21:46:51 -0800 (Wed, 27 Dec 2006) Log Message: ----------- - Fixed a bug in dircache. - Set proper FileFormat IDs for MP3, OggVorbis, and WMA. Modified Paths: -------------- trunk/pmplib/lib/pmp_iriverplus3/dat.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c Modified: trunk/pmplib/lib/pmp_iriverplus3/dat.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dat.c 2006-12-28 05:09:07 UTC (rev 215) +++ trunk/pmplib/lib/pmp_iriverplus3/dat.c 2006-12-28 05:46:51 UTC (rev 216) @@ -350,6 +350,15 @@ memset(dc, 0, sizeof(*dc)); } +static void dircache_finish(dircache_t* dc) +{ + int i; + for (i = 0;i < dc->max_elems;++i) { + ucs2free(dc->elems[i].path); + } + free(dc->elems); +} + static void dircache_push(dircache_t* dc, const ucs2char_t* path, uint32_t uid) { dircache_element_t* elem = NULL; @@ -368,11 +377,12 @@ static void dircache_pop(dircache_t* dc, int i) { - ++i; + int n = ++i; for (;i < dc->num_elems;++i) { ucs2free(dc->elems[i].path); memset(&dc->elems[i], 0, sizeof(dc->elems[0])); } + dc->num_elems = n; } static int dircache_findprefix(dircache_t* dc, const ucs2char_t* path) @@ -490,13 +500,13 @@ const ip3db_variant_t* record = records[si[i].index]; const ucs2char_t* path = record[IP3DBF_MUSIC_FILEPATH].value.str; const ucs2char_t* file = record[IP3DBF_MUSIC_FILENAME].value.str; - int i = dircache_findprefix(&dc, path); - const dircache_element_t* com = dircache_get(&dc, i); + int k = dircache_findprefix(&dc, path); + const dircache_element_t* com = dircache_get(&dc, k); const ucs2char_t* p = path + ucs2len(com->path); /* the prefix */ uint32_t puid = com->uid; /* the UID of the parent directory of the postfix */ /* Discard directory portions that do not share a prefix with the target. */ - dircache_pop(&dc, i); + dircache_pop(&dc, k); /* Create objects one by one for the directory portions in the postfix. */ while (p && *p) { @@ -545,4 +555,6 @@ } ip3db_variant_set_dword(&entry->fields[IP3DBF_MUSIC_UID], uid); } + + dircache_finish(&dc); } Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2006-12-28 05:09:07 UTC (rev 215) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2006-12-28 05:46:51 UTC (rev 216) @@ -554,10 +554,21 @@ ip3db_variant_set_str(&dst[IP3DBF_MUSIC_TITLE], src->title); ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_DURATION], src->duration); ip3db_variant_set_word(&dst[IP3DBF_MUSIC_RATING], (uint16_t)src->rating); - ip3db_variant_set_word(&dst[IP3DBF_MUSIC_FILEFORMAT], 3); + switch (src->codec) { + case PMPCODEC_MPEGLAYER3: + ip3db_variant_set_word(&dst[IP3DBF_MUSIC_FILEFORMAT], 0); + break; + case PMPCODEC_VORBIS: + ip3db_variant_set_word(&dst[IP3DBF_MUSIC_FILEFORMAT], 3); + break; + case PMPCODEC_WMA: + ip3db_variant_set_word(&dst[IP3DBF_MUSIC_FILEFORMAT], 5); + break; + } ip3db_variant_set_word(&dst[IP3DBF_MUSIC_TRACKNUMBER], (uint16_t)src->track_number); ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_BITRATE], src->bitrate); ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_UID], (uint32_t)i+1); + } ip3db_set(&pmpdbi->ip3db, array, num_records); free(array); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |