|
From: <ny...@us...> - 2007-01-26 10:09:27
|
Revision: 285
http://svn.sourceforge.net/pmplib/?rev=285&view=rev
Author: nyaochi
Date: 2007-01-26 02:09:27 -0800 (Fri, 26 Jan 2007)
Log Message:
-----------
[pmp_iriverplus3]
- Fixed a bug of database construction without a playlist.
Modified Paths:
--------------
trunk/pmplib/lib/pmp/pmp.c
trunk/pmplib/lib/pmp_iriverplus3/dat.c
trunk/pmplib/lib/pmp_iriverplus3/idx.c
trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c
Modified: trunk/pmplib/lib/pmp/pmp.c
===================================================================
--- trunk/pmplib/lib/pmp/pmp.c 2007-01-26 07:57:06 UTC (rev 284)
+++ trunk/pmplib/lib/pmp/pmp.c 2007-01-26 10:09:27 UTC (rev 285)
@@ -65,11 +65,13 @@
void pmplib_records_finish(pmp_music_record_t* records, int num_records)
{
- int i;
- for (i = 0;i < num_records;++i) {
- pmplib_record_finish(&records[i]);
+ if (records) {
+ int i;
+ for (i = 0;i < num_records;++i) {
+ pmplib_record_finish(&records[i]);
+ }
+ ucs2free(records);
}
- ucs2free(records);
}
result_t pmplib_records_clone(pmp_music_record_t* dst, const pmp_music_record_t* src, int num_records)
@@ -110,11 +112,13 @@
void pmplib_playlists_finish(pmp_playlist_t* playlists, int num_playlists)
{
- int i;
- for (i = 0;i < num_playlists;++i) {
- pmplib_playlist_finish(&playlists[i]);
+ if (playlists) {
+ int i;
+ for (i = 0;i < num_playlists;++i) {
+ pmplib_playlist_finish(&playlists[i]);
+ }
+ ucs2free(playlists);
}
- ucs2free(playlists);
}
void pmplib_playlists_clone(pmp_playlist_t* dst, const pmp_playlist_t* src, int num_playlists)
Modified: trunk/pmplib/lib/pmp_iriverplus3/dat.c
===================================================================
--- trunk/pmplib/lib/pmp_iriverplus3/dat.c 2007-01-26 07:57:06 UTC (rev 284)
+++ trunk/pmplib/lib/pmp_iriverplus3/dat.c 2007-01-26 10:09:27 UTC (rev 285)
@@ -364,6 +364,7 @@
if (dat) {
dat_list_init(&dat->objects);
dat_list_init(&dat->musics);
+ dat_list_init(&dat->references);
}
return dat;
}
@@ -372,6 +373,7 @@
{
dat_list_finish(&dat->objects);
dat_list_finish(&dat->musics);
+ dat_list_finish(&dat->references);
free(dat);
}
@@ -472,24 +474,30 @@
long buffer_size = 0;
uint8_t* buffer = NULL;
+ /* Initialize the number of pages as zero. */
dic->header.num_dat_pages = 0;
+ dic->objects.dat_page = 0;
+ dic->music.dat_page = 0;
+ dic->references.dat_page = 0;
memset(&ph, 0, sizeof(ph));
/* Write Objects page(s) */
- i = 0;
- dic->objects.dat_page = page = (dic->header.num_dat_pages + 1);
- while (page) {
- buffer_size = PAGESIZE * page;
- buffer = (uint8_t*)realloc(buffer, sizeof(uint8_t) * buffer_size);
- memset(buffer + PAGESIZE * (page - 1), 0, PAGESIZE);
+ if (0 < dat->objects.num_entries) {
+ i = 0;
+ dic->objects.dat_page = page = (dic->header.num_dat_pages + 1);
+ while (page) {
+ buffer_size = PAGESIZE * page;
+ buffer = (uint8_t*)realloc(buffer, sizeof(uint8_t) * buffer_size);
+ memset(buffer + PAGESIZE * (page - 1), 0, PAGESIZE);
- ph.next_page = page + 1;
- dat_list_write(&dat->objects, i, &ph, buffer, PAGESIZE * (page - 1));
+ ph.next_page = page + 1;
+ dat_list_write(&dat->objects, i, &ph, buffer, PAGESIZE * (page - 1));
- i += ph.num_entries;
- dic->header.num_dat_pages += 1;
- page = ph.next_page;
+ i += ph.num_entries;
+ dic->header.num_dat_pages += 1;
+ page = ph.next_page;
+ }
}
/* Clear filepath and filename */
@@ -501,40 +509,47 @@
}
/* Write Music page(s) */
- i = 0;
- dic->music.dat_page = page = (dic->header.num_dat_pages+1);
- while (page) {
- buffer_size = PAGESIZE * page;
- buffer = (uint8_t*)realloc(buffer, sizeof(uint8_t) * buffer_size);
- memset(buffer + PAGESIZE * (page - 1), 0, PAGESIZE);
+ if (0 < dat->musics.num_entries) {
+ i = 0;
+ dic->music.dat_page = page = (dic->header.num_dat_pages+1);
+ while (page) {
+ buffer_size = PAGESIZE * page;
+ buffer = (uint8_t*)realloc(buffer, sizeof(uint8_t) * buffer_size);
+ memset(buffer + PAGESIZE * (page - 1), 0, PAGESIZE);
- ph.next_page = page + 1;
- dat_list_write(&dat->musics, i, &ph, buffer, PAGESIZE * (page - 1));
+ ph.next_page = page + 1;
+ dat_list_write(&dat->musics, i, &ph, buffer, PAGESIZE * (page - 1));
- i += ph.num_entries;
- dic->header.num_dat_pages += 1;
- page = ph.next_page;
+ i += ph.num_entries;
+ dic->header.num_dat_pages += 1;
+ page = ph.next_page;
+ }
}
/* Write References page(s) */
- i = 0;
- dic->references.dat_page = page = (dic->header.num_dat_pages+1);
- while (page) {
- buffer_size = PAGESIZE * page;
- buffer = (uint8_t*)realloc(buffer, sizeof(uint8_t) * buffer_size);
- memset(buffer + PAGESIZE * (page - 1), 0, PAGESIZE);
+ if (0 < dat->references.num_entries) {
+ i = 0;
+ dic->references.dat_page = page = (dic->header.num_dat_pages+1);
+ while (page) {
+ buffer_size = PAGESIZE * page;
+ buffer = (uint8_t*)realloc(buffer, sizeof(uint8_t) * buffer_size);
+ memset(buffer + PAGESIZE * (page - 1), 0, PAGESIZE);
- ph.next_page = page + 1;
- dat_list_write(&dat->references, i, &ph, buffer, PAGESIZE * (page - 1));
+ ph.next_page = page + 1;
+ dat_list_write(&dat->references, i, &ph, buffer, PAGESIZE * (page - 1));
- i += ph.num_entries;
- dic->header.num_dat_pages += 1;
- page = ph.next_page;
+ i += ph.num_entries;
+ dic->header.num_dat_pages += 1;
+ page = ph.next_page;
+ }
}
- if (fwrite(buffer, 1, buffer_size, fpo) != buffer_size) {
- free(buffer);
- return 1;
+ /* Write out the pages to the file. */
+ if (buffer && buffer_size > 0) {
+ if (fwrite(buffer, 1, buffer_size, fpo) != buffer_size) {
+ free(buffer);
+ return 1;
+ }
}
free(buffer);
Modified: trunk/pmplib/lib/pmp_iriverplus3/idx.c
===================================================================
--- trunk/pmplib/lib/pmp_iriverplus3/idx.c 2007-01-26 07:57:06 UTC (rev 284)
+++ trunk/pmplib/lib/pmp_iriverplus3/idx.c 2007-01-26 10:09:27 UTC (rev 285)
@@ -736,15 +736,21 @@
/* Convert the byte order of values in AVL trees. */
for (i = 0;i < dic->music.num_indices;++i) {
uint32_t idx_root = dic_get_idxroot(dic, IP3DBIDX_MUSIC, i);
- to_be_avltree(idx->avl, idx_root, &dic->music, i, 0);
+ if (idx_root) {
+ to_be_avltree(idx->avl, idx_root, &dic->music, i, 0);
+ }
}
for (i = 0;i < dic->references.num_indices;++i) {
uint32_t idx_root = dic_get_idxroot(dic, IP3DBIDX_REFERENCES, i);
- to_be_avltree(idx->avl, idx_root, &dic->references, i, 0);
+ if (idx_root) {
+ to_be_avltree(idx->avl, idx_root, &dic->references, i, 0);
+ }
}
for (i = 0;i < dic->objects.num_indices;++i) {
uint32_t idx_root = dic_get_idxroot(dic, IP3DBIDX_OBJECTS, i);
- to_be_avltree(idx->avl, idx_root, &dic->objects, i, 0);
+ if (idx_root) {
+ to_be_avltree(idx->avl, idx_root, &dic->objects, i, 0);
+ }
}
/* Read the whole data at a time. */
Modified: trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c
===================================================================
--- trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-26 07:57:06 UTC (rev 284)
+++ trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-26 10:09:27 UTC (rev 285)
@@ -201,7 +201,7 @@
{
"samsung_yh925", "Samsung", "YH-925",
5, "UM",
- "1.61", "1.61",
+ "1.58", "1.61",
"SYSTEM\\FW_YH925.mi4", "System\\DATA\\PP5000.HDR",
".mp3\0.wma\0",
{PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, 0, 0, 0, 0},
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|