You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
(2) |
Apr
(4) |
May
(6) |
Jun
(56) |
Jul
(101) |
Aug
(14) |
Sep
|
Oct
(1) |
Nov
|
Dec
(40) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(66) |
Feb
(106) |
Mar
(1) |
Apr
(2) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
(10) |
Oct
(7) |
Nov
|
Dec
|
2008 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ny...@us...> - 2007-01-25 02:29:25
|
Revision: 275 http://svn.sourceforge.net/pmplib/?rev=275&view=rev Author: nyaochi Date: 2007-01-24 18:29:25 -0800 (Wed, 24 Jan 2007) Log Message: ----------- Synchronize pmp_iriverplus3 with the latest API spec. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/common/database.c trunk/pmplib/include/pmp.h trunk/pmplib/lib/pmp/pmp.c trunk/pmplib/lib/pmp_iriverplus3/ip3db.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c Modified: trunk/pmplib/frontend/easypmp/common/database.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/database.c 2007-01-24 23:07:42 UTC (rev 274) +++ trunk/pmplib/frontend/easypmp/common/database.c 2007-01-25 02:29:25 UTC (rev 275) @@ -211,7 +211,7 @@ if (begin + 1 == end) { // If the time stamps are identical, let us skip this file. if (old_records[begin].ts_update == timestamp) { - pmp_record_copy(record, &old_records[begin]); + pmp_record_clone(record, &old_records[begin]); is_skipping = 1; } } Modified: trunk/pmplib/include/pmp.h =================================================================== --- trunk/pmplib/include/pmp.h 2007-01-24 23:07:42 UTC (rev 274) +++ trunk/pmplib/include/pmp.h 2007-01-25 02:29:25 UTC (rev 275) @@ -416,7 +416,10 @@ PMPAPI void pmp_record_init(pmp_music_record_t* record); PMPAPI void pmp_record_finish(pmp_music_record_t* record); -PMPAPI result_t pmp_record_copy(pmp_music_record_t* dst, const pmp_music_record_t* src); +PMPAPI result_t pmp_record_clone(pmp_music_record_t* dst, const pmp_music_record_t* src); +PMPAPI void pmp_records_finish(pmp_music_record_t* records, int num_records); +PMPAPI result_t pmp_records_clone(pmp_music_record_t* dst, const pmp_music_record_t* src, int num_records); + PMPAPI uint32_t pmp_interlocked_increment(uint32_t* count); PMPAPI uint32_t pmp_interlocked_decrement(uint32_t* count); Modified: trunk/pmplib/lib/pmp/pmp.c =================================================================== --- trunk/pmplib/lib/pmp/pmp.c 2007-01-24 23:07:42 UTC (rev 274) +++ trunk/pmplib/lib/pmp/pmp.c 2007-01-25 02:29:25 UTC (rev 275) @@ -51,7 +51,7 @@ pmp_record_init(record); } -result_t pmp_record_copy(pmp_music_record_t* dst, const pmp_music_record_t* src) +result_t pmp_record_clone(pmp_music_record_t* dst, const pmp_music_record_t* src) { memcpy(dst, src, sizeof(*src)); dst->filename = src->filename ? ucs2dup(src->filename) : NULL; @@ -63,6 +63,23 @@ return 0; } +void pmp_records_finish(pmp_music_record_t* records, int num_records) +{ + int i; + for (i = 0;i < num_records;++i) { + pmp_record_finish(&records[i]); + } + ucs2free(records); +} + +result_t pmp_records_clone(pmp_music_record_t* dst, const pmp_music_record_t* src, int num_records) +{ + int i; + for (i = 0;i < num_records;++i) { + pmp_record_clone(&dst[i], &src[i]); + } +} + void pmp_playlist_init(pmp_playlist_t* playlist) { memset(playlist, 0, sizeof(*playlist)); Modified: trunk/pmplib/lib/pmp_iriverplus3/ip3db.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/ip3db.c 2007-01-24 23:07:42 UTC (rev 274) +++ trunk/pmplib/lib/pmp_iriverplus3/ip3db.c 2007-01-25 02:29:25 UTC (rev 275) @@ -36,7 +36,6 @@ #include "dic.h" #include "dat.h" #include "idx.h" -#include "plp.h" void ip3db_variant_init(ip3db_variant_t* var, int type) { Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-24 23:07:42 UTC (rev 274) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-25 02:29:25 UTC (rev 275) @@ -91,7 +91,7 @@ typedef struct { ip3db_t ip3db; - ip3db_music_record_t* records; + pmp_music_record_t* records; int num_records; ip3db_playlist_t* playlists; int num_playlists; @@ -103,11 +103,13 @@ static result_t pmp_close(pmp_t* pmp); static result_t pmp_create_instance_music(pmp_t* pmp, pmp_music_t** ptr_pmpdb); -static uint32_t pmpmusic_release(pmp_music_t* pmpdb); -static result_t pmpmusic_set_records(pmp_music_t* pmpdb, const pmp_music_record_t* records, uint32_t num_records); -static result_t pmpmusic_get_records(pmp_music_t* pmpdb, pmp_music_record_t* records, uint32_t* num_records); -static result_t pmpmusic_dump(pmp_music_t* pmpdb, FILE *fp, int level); -static result_t pmpmusic_set_playlists(pmp_music_t* pmpdb, const pmp_playlist_t* playlists, uint32_t num_playlists); +static uint32_t pmpmusic_release(pmp_music_t* music); +static uint32_t pmpmusic_open(pmp_music_t* music); +static uint32_t pmpmusic_close(pmp_music_t* music); +static result_t pmpmusic_set_records(pmp_music_t* music, const pmp_music_record_t* records, uint32_t num_records); +static result_t pmpmusic_get_records(pmp_music_t* music, pmp_music_record_t* records, uint32_t* num_records); +static result_t pmpmusic_dump(pmp_music_t* music, FILE *fp, int level); +static result_t pmpmusic_set_playlists(pmp_music_t* music, const pmp_playlist_t* playlists, uint32_t num_playlists); #define COMP(a, b) ((a)>(b))-((a)<(b)) @@ -404,15 +406,16 @@ static result_t pmp_open(pmp_t* pmp, uint32_t flag) { result_t ret = 0; + + // Set the open flag. pmp->flag = flag; - if (pmp->flag & PMPOF_MUSIC_DB_READ) { - ucs2char_t dat[MAX_PATH], dic[MAX_PATH], idx[MAX_PATH]; - pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmp->music->instance; + // Open the music database. + ret = pmpmusic_open(pmp->music); + if (ret) { + return ret; + } - set_filenames(dat, dic, idx, pmp); - return ip3db_read(&pmpmi->ip3db, dat, dic, idx); - } return 0; } @@ -420,23 +423,12 @@ { result_t ret = 0; - // Music database/playlist. - if (pmp->flag & PMPOF_MUSIC_DB_WRITE || pmp->flag & PMPOF_MUSIC_PL_WRITE) { - ucs2char_t dat[MAX_PATH], dic[MAX_PATH], idx[MAX_PATH]; - pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmp->music->instance; + // Close the music database. + ret = pmpmusic_close(pmp->music); + if (ret) { + return ret; + } - // Register records (and playlists) to the database. - if (pmp->flag & PMPOF_MUSIC_PL_WRITE) { - ip3db_set(&pmpmi->ip3db, pmpmi->records, pmpmi->num_records, pmpmi->playlists, pmpmi->num_playlists); - } else { - ip3db_set(&pmpmi->ip3db, pmpmi->records, pmpmi->num_records, NULL, 0); - } - - // Write out the music database. - set_filenames(dat, dic, idx, pmp); - ret = ip3db_write(&pmpmi->ip3db, dat, dic, idx); - - } return 0; } @@ -474,18 +466,160 @@ - static uint32_t pmpmusic_release(pmp_music_t* music) { pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; ip3db_finish(&pmpmi->ip3db); - free(pmpmi->records); + pmp_records_finish(pmpmi->records, pmpmi->num_records); free(pmpmi->playlists); free(pmpmi); free(music); return 0; } +static uint32_t pmpmusic_open(pmp_music_t* music) +{ + result_t ret = 0; + pmp_t* pmp = music->pmp; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; + + // Free the existing records. + pmp_records_finish(pmpmi->records, pmpmi->num_records); + pmpmi->records = 0; + pmpmi->num_records = 0; + + // Open the music database if necessary. + if (pmp->flag & PMPOF_MUSIC_DB_READ) { + int i; + ucs2char_t dat[MAX_PATH], dic[MAX_PATH], idx[MAX_PATH]; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmp->music->instance; + + // Read the music database. + set_filenames(dat, dic, idx, pmp); + ret = ip3db_read(&pmpmi->ip3db, dat, dic, idx); + if (ret) { + return ret; + } + + // The number of music records. + pmpmi->num_records = ip3db_num_records(&pmpmi->ip3db); + + // Allocate an array of the records. + pmpmi->records = (pmp_music_record_t*)malloc(sizeof(pmp_music_record_t) * pmpmi->num_records); + + // Convert IP3DB records to a pmp_music_record_t array. + for (i = 0;i < pmpmi->num_records;++i) { + const ip3db_variant_t* src = (const ip3db_variant_t*)ip3db_get_record(&pmpmi->ip3db, i); + pmp_music_record_t* dst = &pmpmi->records[i]; + size_t length = 0; + + pmp_record_init(dst); + + length = ucs2len(pmp->info.path_to_root); + length += ucs2len(src[IP3DBF_MUSIC_FILEPATH].value.str); + length += ucs2len(src[IP3DBF_MUSIC_FILENAME].value.str); + dst->filename = (ucs2char_t*)ucs2malloc(sizeof(ucs2char_t) * (length+1)); + ucs2cpy(dst->filename, pmp->info.path_to_root); + ucs2cat(dst->filename, src[IP3DBF_MUSIC_FILEPATH].value.str+1); + ucs2cat(dst->filename, src[IP3DBF_MUSIC_FILENAME].value.str); + filepath_backslash(dst->filename); + + dst->title = ucs2dup(src[IP3DBF_MUSIC_TITLE].value.str); + dst->artist = ucs2dup(src[IP3DBF_MUSIC_ARTIST].value.str); + dst->album = ucs2dup(src[IP3DBF_MUSIC_ALBUM].value.str); + dst->genre = ucs2dup(src[IP3DBF_MUSIC_GENRE].value.str); + dst->date = ucs2dup(src[IP3DBF_MUSIC_ORGRELEASEDATE].value.str); + switch (src[IP3DBF_MUSIC_FILEFORMAT].value.word) { + case 0: + dst->codec = PMPCODEC_MPEGLAYER3; + break; + case 3: + dst->codec = PMPCODEC_VORBIS; + break; + case 5: + dst->codec = PMPCODEC_WMA; + break; + } + dst->track_number = src[IP3DBF_MUSIC_TRACKNUMBER].value.word; + dst->bitrate = src[IP3DBF_MUSIC_BITRATE].value.dword; + dst->duration = src[IP3DBF_MUSIC_DURATION].value.dword; + dst->ts_update = src[IP3DBF_MUSIC_CLUSA].value.dword; + dst->rating = src[IP3DBF_MUSIC_RATING].value.word; + } + } + + return 0; +} + +static uint32_t pmpmusic_close(pmp_music_t* music) +{ + result_t ret = 0; + pmp_t* pmp = music->pmp; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; + + if (pmp->flag & PMPOF_MUSIC_DB_WRITE) { + int i; + ucs2char_t dat[MAX_PATH], dic[MAX_PATH], idx[MAX_PATH]; + ip3db_music_record_t* records = NULL; + + // Allocate an array of music records. + records = (ip3db_music_record_t*)malloc(sizeof(ip3db_music_record_t) * pmpmi->num_records); + + // Build an array of IP3DB records. + for (i = 0;i < pmpmi->num_records;++i) { + const pmp_music_record_t* src = &pmpmi->records[i]; + ip3db_variant_t* dst = records[i]; + + ip3db_record_init(&pmpmi->ip3db, &records[i]); + ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILEPATH], filepath_skipdrive(src->filename, pmp->info.path_to_root)); + filepath_remove_filespec(dst[IP3DBF_MUSIC_FILEPATH].value.str); + filepath_addslash(dst[IP3DBF_MUSIC_FILEPATH].value.str); + filepath_slash(dst[IP3DBF_MUSIC_FILEPATH].value.str); + ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILENAME], filepath_skippath(src->filename)); + ip3db_variant_set_str(&dst[IP3DBF_MUSIC_ARTIST], src->artist); + ip3db_variant_set_str(&dst[IP3DBF_MUSIC_ALBUM], src->album); + ip3db_variant_set_str(&dst[IP3DBF_MUSIC_GENRE], src->genre); + 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); + 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_CLUSA], src->ts_update); + ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_UID], (uint32_t)i+1); + } + + // Register records (and playlists) to the database. + if (pmp->flag & PMPOF_MUSIC_PL_WRITE) { + ip3db_set(&pmpmi->ip3db, records, pmpmi->num_records, pmpmi->playlists, pmpmi->num_playlists); + } else { + ip3db_set(&pmpmi->ip3db, records, pmpmi->num_records, NULL, 0); + } + + // Write out the music database. + set_filenames(dat, dic, idx, pmp); + ret = ip3db_write(&pmpmi->ip3db, dat, dic, idx); + + // Free IP3DB records. + for (i = 0;i < pmpmi->num_records;++i) { + ip3db_record_finish(&pmpmi->ip3db, &records[i]); + } + free(records); + } + + return 0; +} + static ucs2char_t* _filepath_removeslash(ucs2char_t* path) { size_t length = ucs2len(path)-1; @@ -496,111 +630,36 @@ return (path + length); } -static result_t pmpmusic_set_records(pmp_music_t* pmpdb, const pmp_music_record_t* records, uint32_t num_records) +static result_t pmpmusic_set_records(pmp_music_t* music, const pmp_music_record_t* records, uint32_t num_records) { - uint32_t i; - pmp_t* pmp = pmpdb->pmp; - pmp_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; - pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmpdb->instance; + pmp_t* pmp = music->pmp; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; /* Free records attached to pmpmi. */ - for (i = 0;i < (uint32_t)pmpmi->num_records;++i) { - ip3db_record_finish(&pmpmi->ip3db, &pmpmi->records[i]); - } - free(pmpmi->records); + pmp_records_finish(pmpmi->records, pmpmi->num_records); /* Allocate new records. */ - pmpmi->records = (ip3db_music_record_t*)malloc(sizeof(ip3db_music_record_t) * num_records); + pmpmi->records = (pmp_music_record_t*)ucs2malloc(sizeof(pmp_music_record_t) * num_records); pmpmi->num_records = num_records; + pmp_records_clone(pmpmi->records, records, num_records); - for (i = 0;i < num_records;++i) { - const pmp_music_record_t* src = &records[i]; - ip3db_variant_t* dst = pmpmi->records[i]; - - ip3db_record_init(&pmpmi->ip3db, &pmpmi->records[i]); - ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILEPATH], filepath_skipdrive(src->filename, pmp->info.path_to_root)); - filepath_remove_filespec(dst[IP3DBF_MUSIC_FILEPATH].value.str); - filepath_addslash(dst[IP3DBF_MUSIC_FILEPATH].value.str); - filepath_slash(dst[IP3DBF_MUSIC_FILEPATH].value.str); - ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILENAME], filepath_skippath(src->filename)); - ip3db_variant_set_str(&dst[IP3DBF_MUSIC_ARTIST], src->artist); - ip3db_variant_set_str(&dst[IP3DBF_MUSIC_ALBUM], src->album); - ip3db_variant_set_str(&dst[IP3DBF_MUSIC_GENRE], src->genre); - 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); - 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_CLUSA], src->ts_update); - ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_UID], (uint32_t)i+1); - - } return 0; } -static result_t pmpmusic_get_records(pmp_music_t* pmpdb, pmp_music_record_t* records, uint32_t* num_records) +static result_t pmpmusic_get_records(pmp_music_t* music, pmp_music_record_t* records, uint32_t* num_records) { - pmp_t* pmp = pmpdb->pmp; - pmp_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; - pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmpdb->instance; - ucs2char_t *path_to_root = alloca(sizeof(ucs2char_t) * (ucs2len(pmp->info.path_to_root)+1)); - int i, n = ip3db_num_records(&pmpmi->ip3db); + pmp_t* pmp = music->pmp; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; if (!records) { - *num_records = (uint32_t)n; + *num_records = pmpmi->num_records; return 0; + } else if (*num_records == pmpmi->num_records) { + pmp_records_clone(records, pmpmi->records, pmpmi->num_records); + return 0; + } else { + return PMPDBE_INSUFFICIENT; } - - for (i = 0;i < n;++i) { - const ip3db_variant_t* src = (const ip3db_variant_t*)ip3db_get_record(&pmpmi->ip3db, i); - pmp_music_record_t* dst = &records[i]; - size_t length = 0; - - pmp_record_init(dst); - - length = ucs2len(pmp->info.path_to_root); - length += ucs2len(src[IP3DBF_MUSIC_FILEPATH].value.str); - length += ucs2len(src[IP3DBF_MUSIC_FILENAME].value.str); - dst->filename = (ucs2char_t*)ucs2malloc(sizeof(ucs2char_t) * (length+1)); - ucs2cpy(dst->filename, pmp->info.path_to_root); - ucs2cat(dst->filename, src[IP3DBF_MUSIC_FILEPATH].value.str+1); - ucs2cat(dst->filename, src[IP3DBF_MUSIC_FILENAME].value.str); - filepath_backslash(dst->filename); - - dst->title = ucs2dup(src[IP3DBF_MUSIC_TITLE].value.str); - dst->artist = ucs2dup(src[IP3DBF_MUSIC_ARTIST].value.str); - dst->album = ucs2dup(src[IP3DBF_MUSIC_ALBUM].value.str); - dst->genre = ucs2dup(src[IP3DBF_MUSIC_GENRE].value.str); - dst->date = ucs2dup(src[IP3DBF_MUSIC_ORGRELEASEDATE].value.str); - switch (src[IP3DBF_MUSIC_FILEFORMAT].value.word) { - case 0: - dst->codec = PMPCODEC_MPEGLAYER3; - break; - case 3: - dst->codec = PMPCODEC_VORBIS; - break; - case 5: - dst->codec = PMPCODEC_WMA; - break; - } - dst->track_number = src[IP3DBF_MUSIC_TRACKNUMBER].value.word; - dst->bitrate = src[IP3DBF_MUSIC_BITRATE].value.dword; - dst->duration = src[IP3DBF_MUSIC_DURATION].value.dword; - dst->ts_update = src[IP3DBF_MUSIC_CLUSA].value.dword; - dst->rating = src[IP3DBF_MUSIC_RATING].value.word; - } - return 0; } static result_t pmpmusic_dump(pmp_music_t* music, FILE *fp, int level) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-24 23:07:42
|
Revision: 274 http://svn.sourceforge.net/pmplib/?rev=274&view=rev Author: nyaochi Date: 2007-01-24 15:07:42 -0800 (Wed, 24 Jan 2007) Log Message: ----------- Document set_records and get_records functions in pmp_music_t. Modified Paths: -------------- trunk/pmplib/include/pmp.h Modified: trunk/pmplib/include/pmp.h =================================================================== --- trunk/pmplib/include/pmp.h 2007-01-24 10:26:45 UTC (rev 273) +++ trunk/pmplib/include/pmp.h 2007-01-24 23:07:42 UTC (rev 274) @@ -205,6 +205,7 @@ /** * The root interface for portable media device. + * * This structure represents the basic interface that is common to any * portal media devices. It defines several member variables and pure * virtual functions to access the implementation for the target device. @@ -216,13 +217,15 @@ struct tag_pmp_t { /** * Pointer for the internal use. - * This member variable is reserved for the internal use of the - * library. Do not modify the value. + * + * This member variable is reserved for the internal use of the library. + * Do not modify the value. */ void* instance; /** * Reference counter. + * * This member variable is reserved for the library to manage the * reference counter. Do not modify the value directly. Call * member functions add_ref() and release() to increase and @@ -232,6 +235,7 @@ /** * Open flags. + * * This member variable is reserved for the library to store the * flags specified in open() function. Do not modify the value. */ @@ -308,12 +312,92 @@ ucs2char_t **entries; } pmp_playlist_t; +/** + * Interface for organizing music files. + * + * This interface is responsible for several operations relevant to music + * files in a portable media device. The major operations are: + * - setting a list of music records for building a music database + * - getting a list of music records from the existing music database + * - dumping the existing music database in a text format + * - setting a list of music files for generating + * - getting a list of music playlists used by the device + * + * You cannot create an instance of this structure by yourself. Access + * pmp_t::music member to obtain this interface. + */ struct tag_pmp_music_t { + /** + * Pointer for the internal use. + * + * This member variable is reserved for the internal use of the library. + * Do not modify the value. + */ void* instance; + + /** + * The pointer to pmp_t interface. + * + * @assert + * @code this->pmp->music == this @endcode + */ pmp_t* pmp; + /** + * Set a list of music records. + * + * This function sets a list of music records that provide a complete + * information about all music files on a device. Based on this list, + * PMPlib will build a music database on the device. + * + * This function does not write out any content on the player immediately + * for the following reason. Some portable devices manage a music database + * and playlists separately, but some integrate playlist information into + * a music database. In the latter case, PMPlib cannot build a music + * database until a definitive list of playlists is obtained. In order to + * support various devices in a unified interface, this function reserves + * a future update of the music database; a database update is prolonged + * until the device is closed by pmp->close() call. + * + * @param music The pointer to the pmp_music_t interface. + * @param records An array of music records. + * @param num_records The number of elements in \a records array. + * @retval result_t The status code after this operation. + * + * @assert + * @code music != NULL @endcode + * @code records != NULL @endcode + */ result_t (*set_records)(pmp_music_t* music, const pmp_music_record_t* records, uint32_t num_records); + + /** + * Get a list of music records. + * + * This function gets the list of music records in the existing music + * database or set by \a set_records call. + * + * If the argument \a records is NULL, this function returns the number of + * music records to the variable whose address is specified by the + * argument \a num_records. You can use this for determining the size of + * array \a records necessary to obtain all records from this function. + * + * If the argument \a records is not NULL, this function copies the + * current music records to the array whose address is specified by the + * argument \a records and whose size is specified by the variable + * pointed by the argument \a num_records. + * + * @param music The pointer to the pmp_music_t interface. + * @param records An array of music records. + * @param num_records The pointer to the variable presenting the number + * of elements in \a records array. + * @retval result_t The status code after this operation. + * + * @assert + * @code music != NULL @endcode + * @code num_records != NULL @endcode + */ result_t (*get_records)(pmp_music_t* music, pmp_music_record_t* records, uint32_t* num_records); + result_t (*set_playlists)(pmp_music_t* music, const pmp_playlist_t* playlists, uint32_t num_playlists); result_t (*get_playlists)(pmp_music_t* music, pmp_playlist_t* playlists, uint32_t* num_playlists); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-24 10:26:46
|
Revision: 273 http://svn.sourceforge.net/pmplib/?rev=273&view=rev Author: nyaochi Date: 2007-01-24 02:26:45 -0800 (Wed, 24 Jan 2007) Log Message: ----------- Removed the generation routine for *.plp files from pmp_iriverplus3 since it's unnecessary. Modified Paths: -------------- trunk/pmplib/lib/pmp_iriverplus3/ip3db.c trunk/pmplib/lib/pmp_iriverplus3/ip3db.h trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.vcproj Removed Paths: ------------- trunk/pmplib/lib/pmp_iriverplus3/plp.c Modified: trunk/pmplib/lib/pmp_iriverplus3/ip3db.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/ip3db.c 2007-01-18 19:44:24 UTC (rev 272) +++ trunk/pmplib/lib/pmp_iriverplus3/ip3db.c 2007-01-24 10:26:45 UTC (rev 273) @@ -278,22 +278,3 @@ dst->entries[i] = ucs2dup(src->entries[i]); } } - -int ip3db_write_playlists(ip3db_t* db, const ip3db_playlist_t* playlists, int num_playlists, const ucs2char_t *path_to_root) -{ - int i; - - for (i = 0;i < num_playlists;++i) { - ucs2char_t filename[MAX_PATH]; - const ip3db_playlist_t* pl = &playlists[i]; - - ucs2cpy(filename, path_to_root); - ucs2cat(filename, pl->filepath + 1); - ucs2cat(filename, pl->filename); - filepath_backslash(filename); - - plp_write(db, filename, pl->entries, pl->num_entries, path_to_root); - } - - return 0; -} Modified: trunk/pmplib/lib/pmp_iriverplus3/ip3db.h =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/ip3db.h 2007-01-18 19:44:24 UTC (rev 272) +++ trunk/pmplib/lib/pmp_iriverplus3/ip3db.h 2007-01-24 10:26:45 UTC (rev 273) @@ -211,8 +211,6 @@ ip3db_music_record_t* ip3db_get_record(ip3db_t* db, int i); result_t ip3db_dump(ip3db_t* db, FILE *fpo); -int ip3db_write_playlists(ip3db_t* db, const ip3db_playlist_t* playlists, int num_playlists, const ucs2char_t *path_to_root); - void ip3db_record_init(ip3db_t* db, ip3db_music_record_t* record); void ip3db_record_finish(ip3db_t* db, ip3db_music_record_t* record); Deleted: trunk/pmplib/lib/pmp_iriverplus3/plp.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/plp.c 2007-01-18 19:44:24 UTC (rev 272) +++ trunk/pmplib/lib/pmp_iriverplus3/plp.c 2007-01-24 10:26:45 UTC (rev 273) @@ -1,120 +0,0 @@ -/* - * Playlist reader/writer for iriver E10. - * - * Copyright (c) 2005-2006 Nyaochi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif/*HAVE_CONFIG_H*/ - -#include <os.h> -#include <stdio.h> -#include <stdlib.h> -#include <ucs2char.h> -#include <filepath.h> - -#include "serialize.h" -#include "util.h" -#include "ip3db.h" -#include "dat.h" - -static uint32_t findfile(ip3db_t* db, const ucs2char_t *filename, const ucs2char_t *path_to_root) -{ - int i; - const ucs2char_t *filepart = filepath_skippath(filename); - const ucs2char_t *pathfile = filepath_skipdrive(filename, path_to_root); - ucs2char_t *pathname = alloca(sizeof(ucs2char_t) * (ucs2len(pathfile) + 1)); - - ucs2cpy(pathname, pathfile); - filepath_remove_filespec(pathname); - filepath_addslash(pathname); - filepath_slash(pathname); - - for (i = 0;i < db->dat->musics.num_entries;++i) { - dat_entry_t* entry = &db->dat->musics.entries[i]; - if (ucs2icmp(entry->fields[IP3DBF_MUSIC_FILENAME].value.str, filepart) == 0 && - ucs2icmp(entry->fields[IP3DBF_MUSIC_FILEPATH].value.str, pathname) == 0) { - return entry->fields[IP3DBF_MUSIC_UID].value.dword; - } - } - return 0; -} - -int plp_write( - ip3db_t* db, - const ucs2char_t *filename, - ucs2char_t* const mediafiles[], - int num_mediafiles, - const ucs2char_t *path_to_root - ) -{ - int i; - FILE *fp = NULL; - uint32_t* uids = NULL; - uint32_t num_uids = 0; - - for (i = 0;i < num_mediafiles;i++) { - if (mediafiles[i][0]) { - uint32_t uid = 0; - ucs2char_t mediafile[MAX_PATH]; - ucs2cpy(mediafile, mediafiles[i]); - - uid = findfile(db, mediafile, path_to_root); - if (uid <= 0) { - goto error_exit; - } - - uids = realloc(uids, sizeof(uint32_t) * (num_uids+1)); - if (!uids) { - goto error_exit; - } - uids[num_uids++] = uid; - } - } - - fp = ucs2fopen(filename, "wb"); - if (fp) { - size_t size = sizeof(uint32_t) + sizeof(uint32_t) * num_uids; - uint8_t* buffer = (uint8_t*)malloc(size); - uint8_t* p = buffer; - - if (!buffer) { - goto error_exit; - } - - p += serialize_uint32le(p, &num_uids, 1); - for (i = 0;i < (int)num_uids;++i) { - p += serialize_uint32le(p, &uids[i], 1); - } - fwrite(buffer, 1, size, fp); - free(buffer); - fclose(fp); - } else { - return -1; - } - - free(uids); - return 0; - -error_exit: - free(uids); - return -1; -} Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-18 19:44:24 UTC (rev 272) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-24 10:26:45 UTC (rev 273) @@ -432,9 +432,6 @@ ip3db_set(&pmpmi->ip3db, pmpmi->records, pmpmi->num_records, NULL, 0); } - // Write out the playlist first. - ip3db_write_playlists(&pmpmi->ip3db, pmpmi->playlists, pmpmi->num_playlists, pmp->info.path_to_root); - // Write out the music database. set_filenames(dat, dic, idx, pmp); ret = ip3db_write(&pmpmi->ip3db, dat, dic, idx); Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.vcproj =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.vcproj 2007-01-18 19:44:24 UTC (rev 272) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.vcproj 2007-01-24 10:26:45 UTC (rev 273) @@ -193,10 +193,6 @@ > </File> <File - RelativePath=".\plp.c" - > - </File> - <File RelativePath=".\pmp_iriverplus3.c" > </File> @@ -231,10 +227,6 @@ > </File> <File - RelativePath=".\plp.h" - > - </File> - <File RelativePath=".\serialize.h" > </File> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-18 19:44:37
|
Revision: 272 http://svn.sourceforge.net/pmplib/?rev=272&view=rev Author: nyaochi Date: 2007-01-18 11:44:24 -0800 (Thu, 18 Jan 2007) Log Message: ----------- Improved page handling for db.dat. This revision is not stable yet, but it could generate multiple continuous Object pages successfully. Although this revision does not work without a playlist, my time is up. Modified Paths: -------------- trunk/pmplib/lib/pmp_iriverplus3/dat.c trunk/pmplib/lib/pmp_iriverplus3/dic.c trunk/pmplib/lib/pmp_iriverplus3/dic.h trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c Modified: trunk/pmplib/lib/pmp_iriverplus3/dat.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dat.c 2007-01-18 17:34:30 UTC (rev 271) +++ trunk/pmplib/lib/pmp_iriverplus3/dat.c 2007-01-18 19:44:24 UTC (rev 272) @@ -377,7 +377,7 @@ int dat_read(dat_t* dat, const dic_t* dic, FILE *fpi) { - uint32_t i = 0; + uint32_t i = 0, page = 0; page_header_t ph; long buffer_size = 0; uint8_t* buffer = NULL; @@ -392,9 +392,10 @@ dat_list_finish(&dat->objects); /* Read Objects page(s) */ - dat_list_read(&dat->objects, &ph, &dic->objects, buffer, PAGESIZE * 0); - while (ph.next_page) { - dat_list_read(&dat->objects, &ph, &dic->objects, buffer, PAGESIZE * (ph.next_page - 1)); + page = dic->objects.dat_page; + while (page) { + dat_list_read(&dat->objects, &ph, &dic->objects, buffer, PAGESIZE * (page - 1)); + page = ph.next_page; } /* Construct Object UID -> dat->objects[i] mapping table. */ @@ -405,9 +406,10 @@ dat_list_finish(&dat->musics); /* Read Music page(s) */ - dat_list_read(&dat->musics, &ph, &dic->music, buffer, PAGESIZE * 1); - while (ph.next_page) { - dat_list_read(&dat->musics, &ph, &dic->music, buffer, PAGESIZE * (ph.next_page - 1)); + page = dic->music.dat_page; + while (page) { + dat_list_read(&dat->musics, &ph, &dic->music, buffer, PAGESIZE * (page - 1)); + page = ph.next_page; } /* Set filename and pathname fields. */ @@ -452,10 +454,11 @@ } } - /* Read Music page(s) */ - dat_list_read(&dat->references, &ph, &dic->references, buffer, PAGESIZE * 2); - while (ph.next_page) { - dat_list_read(&dat->references, &ph, &dic->references, buffer, PAGESIZE * (ph.next_page - 1)); + /* Read References page(s) */ + page = dic->references.dat_page; + while (page) { + dat_list_read(&dat->references, &ph, &dic->references, buffer, PAGESIZE * (page - 1)); + page = ph.next_page; } free(buffer); @@ -464,29 +467,29 @@ int dat_write(dat_t* dat, dic_t* dic, FILE *fpo) { - uint32_t i = 0; + uint32_t i = 0, page = 0; page_header_t ph; - long buffer_size = PAGESIZE * 3; - uint8_t* buffer = (uint8_t*)calloc(buffer_size, sizeof(uint8_t)); + long buffer_size = 0; + uint8_t* buffer = NULL; - if (!buffer) { - return 1; - } + dic->header.num_dat_pages = 0; + memset(&ph, 0, sizeof(ph)); + /* Write Objects page(s) */ i = 0; - memset(&ph, 0, sizeof(ph)); - ph.next_page = 3; - dat_list_write(&dat->objects, i, &ph, buffer, PAGESIZE * 0); - dic->header.num_dat_pages = 1; - while (ph.next_page) { - uint32_t page = ph.next_page++; + 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)); + i += ph.num_entries; - dat_list_write(&dat->objects, i, &ph, buffer, PAGESIZE * (page - 1)); dic->header.num_dat_pages += 1; + page = ph.next_page; } /* Clear filepath and filename */ @@ -499,36 +502,36 @@ /* Write Music page(s) */ i = 0; - ph.next_page = dic->header.num_dat_pages + 2; - dat_list_write(&dat->musics, i, &ph, buffer, PAGESIZE * 1); - dic->header.num_dat_pages += 1; - while (ph.next_page) { - uint32_t page = ph.next_page++; + 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)); + i += ph.num_entries; - dat_list_write(&dat->musics, i, &ph, buffer, PAGESIZE * (page - 1)); dic->header.num_dat_pages += 1; + page = ph.next_page; } /* Write References page(s) */ i = 0; - memset(&ph, 0, sizeof(ph)); - ph.next_page = dic->header.num_dat_pages + 2; - dat_list_write(&dat->references, i, &ph, buffer, PAGESIZE * 2); - dic->header.num_dat_pages += 1; - while (ph.next_page) { - uint32_t page = ph.next_page++; + 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)); + i += ph.num_entries; - dat_list_write(&dat->references, i, &ph, buffer, PAGESIZE * (page - 1)); dic->header.num_dat_pages += 1; + page = ph.next_page; } - if (fwrite(buffer, 1, buffer_size, fpo) != buffer_size) { free(buffer); return 1; Modified: trunk/pmplib/lib/pmp_iriverplus3/dic.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dic.c 2007-01-18 17:34:30 UTC (rev 271) +++ trunk/pmplib/lib/pmp_iriverplus3/dic.c 2007-01-18 19:44:24 UTC (rev 272) @@ -117,22 +117,65 @@ for (i = 0;i < list->num_fields;++i) { dic_field_finish(&list->fields[i]); } + free(list->name); free(list->fields); } static void dic_table_dump(dic_table_t* list, FILE *fp) { int i; + + fprints(fp, "%s = {\n", list->name); + fprintf(fp, " unknown0: 0x%08X\n", list->unknown0); + fprintf(fp, " next: 0x%08X\n", list->next); + fprintf(fp, " unknown1: 0x%08X\n", list->unknown1); + fprintf(fp, " dat_page: 0x%08X\n", list->dat_page); + fprintf(fp, " offset_fields: 0x%08X\n", list->offset_fields); + fprintf(fp, " offset_indices: 0x%08X\n", list->offset_indices); + for (i = 0;i < list->num_fields;++i) { const dic_field_t* entry = &list->fields[i]; fprintf(fp, " FIELD %d = {\n", i); dic_field_dump(entry, fp); fprintf(fp, " }\n"); } + + fprintf(fp, "}\n"); } +static size_t dic_table_serialize(uint8_t* buffer, uint32_t start, dic_table_t* list, int is_storing) +{ + uint32_t i, next; + uint8_t *p = buffer + start; + p += serialize_uint32be(p, &list->unknown0, is_storing); + p += serialize_uint32be(p, &list->next, is_storing); + p += serialize_uint32be(p, &list->unknown1, is_storing); + p += serialize_uint32be(p, &list->dat_page, is_storing); + p += serialize_uint32be(p, &list->offset_fields, is_storing); + p += serialize_uint32be(p, &list->offset_indices, is_storing); + if (is_storing) { + p += (serialize_ucs2be_string_var(p, list->name, is_storing) + 1) * sizeof(ucs2char_t); + } else { + p += (serialize_ucs2be_string_var_alloc(p, &list->name) + 1) * sizeof(ucs2char_t); + } + next = list->offset_fields; + for (i = 0;i < list->num_fields;++i) { + dic_field_serialize(buffer + next, &list->fields[i], is_storing); + next = list->fields[i].next; + } + + for (i = 0;i < list->num_indices;++i) { + uint32_t offset = list->indices[i].offset + sizeof(uint32_t) * 2; + serialize_uint32be(buffer + offset, &list->indices[i].idx_root, is_storing); + } + + return (size_t)(p - (buffer + start)); +} + + + dic_t* dic_new() { uint8_t* dic_template = NULL; @@ -203,7 +246,6 @@ static int dic_serialize(dic_t* dic, uint8_t* buffer, int is_storing) { - int i; uint32_t next = 0; uint8_t* p = buffer; @@ -212,54 +254,19 @@ p += serialize_uint32be(p, &dic->header.num_idx_pages, is_storing); p += serialize_uint32be(p, &dic->header.unknown1, is_storing); - next = 0x0000003C; - for (i = 0;i < dic->music.num_fields;++i) { - dic_field_serialize(buffer + next, &dic->music.fields[i], is_storing); - next = dic->music.fields[i].next; - } + dic_table_serialize(buffer, 0x0018, &dic->music, is_storing); + dic_table_serialize(buffer, 0x0736, &dic->references, is_storing); + dic_table_serialize(buffer, 0x0972, &dic->objects, is_storing); - next = 0x00000764; - for (i = 0;i < dic->references.num_fields;++i) { - dic_field_serialize(buffer + next, &dic->references.fields[i], is_storing); - next = dic->references.fields[i].next; - } - - next = 0x0000099A; - for (i = 0;i < dic->objects.num_fields;++i) { - dic_field_serialize(buffer + next, &dic->objects.fields[i], is_storing); - next = dic->objects.fields[i].next; - } - - for (i = 0;i < dic->music.num_indices;++i) { - uint32_t offset = dic->music.indices[i].offset + sizeof(uint32_t) * 2; - serialize_uint32be(buffer + offset, &dic->music.indices[i].idx_root, is_storing); - } - - for (i = 0;i < dic->references.num_indices;++i) { - uint32_t offset = dic->references.indices[i].offset + sizeof(uint32_t) * 2; - serialize_uint32be(buffer + offset, &dic->references.indices[i].idx_root, is_storing); - } - - for (i = 0;i < dic->objects.num_indices;++i) { - uint32_t offset = dic->objects.indices[i].offset + sizeof(uint32_t) * 2; - serialize_uint32be(buffer + offset, &dic->objects.indices[i].idx_root, is_storing); - } - return 0; } void dic_dump(dic_t* dic, FILE *fp) { fprintf(fp, "===== db.dic =====\n"); - fprintf(fp, "MUSIC = {\n"); dic_table_dump(&dic->music, fp); - fprintf(fp, "}\n"); - fprintf(fp, "REFERENCES = {\n"); dic_table_dump(&dic->references, fp); - fprintf(fp, "}\n"); - fprintf(fp, "OBJECTS = {\n"); dic_table_dump(&dic->objects, fp); - fprintf(fp, "}\n"); fprintf(fp, "\n"); } Modified: trunk/pmplib/lib/pmp_iriverplus3/dic.h =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dic.h 2007-01-18 17:34:30 UTC (rev 271) +++ trunk/pmplib/lib/pmp_iriverplus3/dic.h 2007-01-18 19:44:24 UTC (rev 272) @@ -45,6 +45,14 @@ } dic_index_t; typedef struct { + uint32_t unknown0; + uint32_t next; + uint32_t unknown1; + uint32_t dat_page; + uint32_t offset_fields; + uint32_t offset_indices; + ucs2char_t* name; + int num_fields; dic_field_t *fields; int num_indices; Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-18 17:34:30 UTC (rev 271) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-18 19:44:24 UTC (rev 272) @@ -71,7 +71,7 @@ "System\\E10.SYS", "System\\db.dat", "System\\db.dic", "System\\db.idx", ".mp3\0.ogg\0.wma\0.wav\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_VORBIS, PMPCODEC_WMA, PMPCODEC_WAV, 0, 0, 0, 0}, - "System\\", "Music2\\", "Playlists\\", + "System\\", "", "Playlists\\", ".plp", }, { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-18 17:34:30
|
Revision: 271 http://svn.sourceforge.net/pmplib/?rev=271&view=rev Author: nyaochi Date: 2007-01-18 09:34:30 -0800 (Thu, 18 Jan 2007) Log Message: ----------- Experimental code for generating iriver E10 playlists. Playlists for iriver E10 are actually stored in the database: *.plp files are found to be dummy. Although I had to change a DWORD value in db.dic, the playlists worked on my player. I still need to improve dic.c and dat.c to handle large number of files. Modified Paths: -------------- trunk/pmplib/lib/pmp_iriverplus3/dat.c trunk/pmplib/lib/pmp_iriverplus3/dat.h trunk/pmplib/lib/pmp_iriverplus3/dic.c trunk/pmplib/lib/pmp_iriverplus3/dic.h trunk/pmplib/lib/pmp_iriverplus3/idx.c trunk/pmplib/lib/pmp_iriverplus3/ip3db.h trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c Modified: trunk/pmplib/lib/pmp_iriverplus3/dat.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dat.c 2007-01-18 15:06:25 UTC (rev 270) +++ trunk/pmplib/lib/pmp_iriverplus3/dat.c 2007-01-18 17:34:30 UTC (rev 271) @@ -452,6 +452,12 @@ } } + /* Read Music page(s) */ + dat_list_read(&dat->references, &ph, &dic->references, buffer, PAGESIZE * 2); + while (ph.next_page) { + dat_list_read(&dat->references, &ph, &dic->references, buffer, PAGESIZE * (ph.next_page - 1)); + } + free(buffer); return 0; } @@ -460,7 +466,7 @@ { uint32_t i = 0; page_header_t ph; - long buffer_size = PAGESIZE * 2; + long buffer_size = PAGESIZE * 3; uint8_t* buffer = (uint8_t*)calloc(buffer_size, sizeof(uint8_t)); if (!buffer) { @@ -506,6 +512,23 @@ dic->header.num_dat_pages += 1; } + /* Write References page(s) */ + i = 0; + memset(&ph, 0, sizeof(ph)); + ph.next_page = dic->header.num_dat_pages + 2; + dat_list_write(&dat->references, i, &ph, buffer, PAGESIZE * 2); + dic->header.num_dat_pages += 1; + while (ph.next_page) { + uint32_t page = ph.next_page++; + buffer_size = PAGESIZE * page; + buffer = (uint8_t*)realloc(buffer, sizeof(uint8_t) * buffer_size); + memset(buffer + PAGESIZE * (page - 1), 0, PAGESIZE); + i += ph.num_entries; + dat_list_write(&dat->references, i, &ph, buffer, PAGESIZE * (page - 1)); + dic->header.num_dat_pages += 1; + } + + if (fwrite(buffer, 1, buffer_size, fpo) != buffer_size) { free(buffer); return 1; @@ -524,10 +547,39 @@ fprintf(fp, "MUSIC = {\n"); dat_list_dump(&dat->musics, &dic->music, fp); fprintf(fp, "}\n"); + fprintf(fp, "REFERENCES = {\n"); + dat_list_dump(&dat->references, &dic->references, fp); + fprintf(fp, "}\n"); } +static uint32_t findfile(dat_t* dat, const ucs2char_t *filename) +{ + int i; + const ucs2char_t *filepart = NULL; + ucs2char_t *pathname = alloca(sizeof(ucs2char_t) * (ucs2len(filename) + 1)); + + filepart = ucs2rchr(filename, '/'); + if (!filepart) { + filepart = filename; + } else { + filepart++; + } + + ucs2ncpy(pathname, filename, (filepart-filename)); + pathname[filepart-filename] = 0; + + for (i = 0;i < dat->musics.num_entries;++i) { + dat_entry_t* entry = &dat->musics.entries[i]; + if (ucs2icmp(entry->fields[IP3DBF_MUSIC_FILENAME].value.str, filepart) == 0 && + ucs2icmp(entry->fields[IP3DBF_MUSIC_FILEPATH].value.str, pathname) == 0) { + return entry->fields[IP3DBF_MUSIC_UID].value.dword; + } + } + return 0; +} + typedef struct { ucs2char_t* path; uint32_t uid; @@ -624,7 +676,7 @@ return p ? p+1 : NULL; } -void dat_set(dat_t* dat, dic_t* dic, const ip3db_music_record_t* records, int num_records, const ip3db_playlist_t* playlists, int num_playlists) +void dat_set(dat_t* dat, dic_t* dic, const ip3db_music_record_t* records, int num_records, ip3db_playlist_t* playlists, int num_playlists) { /* Procedure: * 1) Construct the object chunk and attach music records with Object UIDs. @@ -659,6 +711,7 @@ static const ucs2char_t ucs2cs_root[] = {'/', 0}; dat_list_t* dato = &dat->objects; dat_list_t* datm = &dat->musics; + dat_list_t* datr = &dat->references; uint32_t num_objects = num_records + num_playlists; object_record_t *objects = (object_record_t*)malloc(sizeof(object_record_t) * num_objects); dircache_t dc; @@ -668,6 +721,7 @@ /* Clear all entries. */ dat_list_finish(dato); dat_list_finish(datm); + dat_list_finish(datr); dat_uidmap_finish(dat->objects_uidmap); /* Append an entry for the root directory. */ @@ -763,18 +817,31 @@ ip3db_variant_set_dword(&entry->fields[IP3DBF_MUSIC_UID], uid); } else if (objects[i].filetype == 4) { /* Playlist file. */ - const ip3db_playlist_t* playlist = &playlists[objects[i].index]; + ip3db_playlist_t* pl = &playlists[objects[i].index]; - uid = dato->num_entries; + pl->uid = dato->num_entries; entry = dat_list_expand(dato); dat_entry_init(entry, &dic->objects); - ip3db_variant_set_dword(&entry->fields[IP3DBF_OBJECTS_UID], uid); + ip3db_variant_set_dword(&entry->fields[IP3DBF_OBJECTS_UID], pl->uid); ip3db_variant_set_dword(&entry->fields[IP3DBF_OBJECTS_PARENTUID], puid); ip3db_variant_set_word(&entry->fields[IP3DBF_OBJECTS_FILETYPE], 4); ip3db_variant_set_str(&entry->fields[IP3DBF_OBJECTS_OBJECTNAME], file); } } + /* Loop for playlists. */ + for (i = 0;i < num_playlists;++i) { + const ip3db_playlist_t* pl = &playlists[i]; + for (j = 0;j < pl->num_entries;++j) { + entry = dat_list_expand(datr); + dat_entry_init(entry, &dic->references); + + ip3db_variant_set_dword(&entry->fields[IP3DBF_REFERENCES_PARENTCLUSTER], pl->uid); + ip3db_variant_set_dword(&entry->fields[IP3DBF_REFERENCES_CHILDCLUSTER], findfile(dat, pl->entries[j])); + ip3db_variant_set_word(&entry->fields[IP3DBF_REFERENCES_FILEFORMAT], 0x3009); + } + } + dircache_finish(&dc); dat->objects_uidmap = dat_uidmap_create(&dat->objects); Modified: trunk/pmplib/lib/pmp_iriverplus3/dat.h =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dat.h 2007-01-18 15:06:25 UTC (rev 270) +++ trunk/pmplib/lib/pmp_iriverplus3/dat.h 2007-01-18 17:34:30 UTC (rev 271) @@ -40,6 +40,7 @@ struct tag_dat_t { dat_list_t objects; dat_list_t musics; + dat_list_t references; sort_index_t* objects_uidmap; }; @@ -48,6 +49,6 @@ int dat_read(dat_t* dat, const dic_t* dic, FILE *fpi); int dat_write(dat_t* dat, dic_t* dic, FILE *fpo); void dat_dump(dat_t* dat, const dic_t* dic, FILE *fp); -void dat_set(dat_t* dat, dic_t* dic, const ip3db_music_record_t* records, int num_records, const ip3db_playlist_t* playlists, int num_playlists); +void dat_set(dat_t* dat, dic_t* dic, const ip3db_music_record_t* records, int num_records, ip3db_playlist_t* playlists, int num_playlists); #endif/*__IP3DB_DAT_H__*/ Modified: trunk/pmplib/lib/pmp_iriverplus3/dic.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dic.c 2007-01-18 15:06:25 UTC (rev 270) +++ trunk/pmplib/lib/pmp_iriverplus3/dic.c 2007-01-18 17:34:30 UTC (rev 271) @@ -57,6 +57,11 @@ {0, 0x043E, {IP3DBF_MUSIC_ALBUM, IP3DBF_MUSIC_TRACKNUMBER, IP3DBF_MUSIC_NONE}}, }; +static dic_index_t references_indices[] = { + {0, 0x0764, {IP3DBF_REFERENCES_PARENTCLUSTER, IP3DBF_REFERENCES_NONE, IP3DBF_REFERENCES_NONE}}, + {0, 0x078C, {IP3DBF_REFERENCES_CHILDCLUSTER, IP3DBF_REFERENCES_NONE, IP3DBF_REFERENCES_NONE}}, +}; + static dic_index_t objects_indices[] = { {0, 0x099A, {IP3DBF_OBJECTS_UID, IP3DBF_MUSIC_NONE, IP3DBF_MUSIC_NONE}}, {0, 0x09F0, {IP3DBF_OBJECTS_FILETYPE, IP3DBF_MUSIC_NONE, IP3DBF_MUSIC_NONE}}, @@ -138,6 +143,11 @@ dic->music.fields = (dic_field_t*)calloc(dic->music.num_fields, sizeof(dic_field_t)); dic->music.num_indices = sizeof(music_indices) / sizeof(music_indices[0]); dic->music.indices = music_indices; + dic_table_init(&dic->references); + dic->references.num_fields = IP3DBF_REFERENCES_LAST; + dic->references.fields = (dic_field_t*)calloc(dic->references.num_fields, sizeof(dic_field_t)); + dic->references.num_indices = sizeof(references_indices) / sizeof(references_indices[0]); + dic->references.indices = references_indices; dic_table_init(&dic->objects); dic->objects.num_fields = IP3DBF_OBJECTS_LAST; dic->objects.fields = (dic_field_t*)calloc(dic->objects.num_fields, sizeof(dic_field_t)); @@ -159,6 +169,7 @@ { if (dic) { dic_table_finish(&dic->music); + dic_table_finish(&dic->references); dic_table_finish(&dic->objects); free(dic->buffer); free(dic); @@ -207,6 +218,12 @@ next = dic->music.fields[i].next; } + next = 0x00000764; + for (i = 0;i < dic->references.num_fields;++i) { + dic_field_serialize(buffer + next, &dic->references.fields[i], is_storing); + next = dic->references.fields[i].next; + } + next = 0x0000099A; for (i = 0;i < dic->objects.num_fields;++i) { dic_field_serialize(buffer + next, &dic->objects.fields[i], is_storing); @@ -218,6 +235,11 @@ serialize_uint32be(buffer + offset, &dic->music.indices[i].idx_root, is_storing); } + for (i = 0;i < dic->references.num_indices;++i) { + uint32_t offset = dic->references.indices[i].offset + sizeof(uint32_t) * 2; + serialize_uint32be(buffer + offset, &dic->references.indices[i].idx_root, is_storing); + } + for (i = 0;i < dic->objects.num_indices;++i) { uint32_t offset = dic->objects.indices[i].offset + sizeof(uint32_t) * 2; serialize_uint32be(buffer + offset, &dic->objects.indices[i].idx_root, is_storing); @@ -231,8 +253,13 @@ fprintf(fp, "===== db.dic =====\n"); fprintf(fp, "MUSIC = {\n"); dic_table_dump(&dic->music, fp); + fprintf(fp, "}\n"); + fprintf(fp, "REFERENCES = {\n"); + dic_table_dump(&dic->references, fp); + fprintf(fp, "}\n"); fprintf(fp, "OBJECTS = {\n"); dic_table_dump(&dic->objects, fp); + fprintf(fp, "}\n"); fprintf(fp, "\n"); } @@ -243,6 +270,9 @@ case IP3DBIDX_MUSIC: indices = dic->music.indices; break; + case IP3DBIDX_REFERENCES: + indices = dic->references.indices; + break; case IP3DBIDX_OBJECTS: indices = dic->objects.indices; break; @@ -261,6 +291,9 @@ case IP3DBIDX_MUSIC: indices = dic->music.indices; break; + case IP3DBIDX_REFERENCES: + indices = dic->references.indices; + break; case IP3DBIDX_OBJECTS: indices = dic->objects.indices; break; @@ -280,6 +313,9 @@ case IP3DBIDX_MUSIC: tbl = &dic->music; break; + case IP3DBIDX_REFERENCES: + tbl = &dic->references; + break; case IP3DBIDX_OBJECTS: tbl = &dic->objects; break; Modified: trunk/pmplib/lib/pmp_iriverplus3/dic.h =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dic.h 2007-01-18 15:06:25 UTC (rev 270) +++ trunk/pmplib/lib/pmp_iriverplus3/dic.h 2007-01-18 17:34:30 UTC (rev 271) @@ -54,6 +54,7 @@ struct tag_dic_t { dic_header_t header; dic_table_t music; + dic_table_t references; dic_table_t objects; uint8_t* buffer; Modified: trunk/pmplib/lib/pmp_iriverplus3/idx.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/idx.c 2007-01-18 15:06:25 UTC (rev 270) +++ trunk/pmplib/lib/pmp_iriverplus3/idx.c 2007-01-18 17:34:30 UTC (rev 271) @@ -700,11 +700,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); - from_be_avltree(idx->avl, idx_root, &dic->music, i, 0); + if (idx_root) { + from_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); + if (idx_root) { + from_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); - from_be_avltree(idx->avl, idx_root, &dic->objects, i, 0); + if (idx_root) { + from_be_avltree(idx->avl, idx_root, &dic->objects, i, 0); + } } return 0; } @@ -728,6 +738,10 @@ uint32_t idx_root = dic_get_idxroot(dic, IP3DBIDX_MUSIC, i); 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); + } 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); @@ -756,6 +770,15 @@ fprintf(fpo, "]\n"); avl_dump(idx->avl, idx_root, &dic->music, i, 0, fpo); } + for (i = 0;i < dic->references.num_indices;++i) { + uint32_t idx_root = dic_get_idxroot(dic, IP3DBIDX_REFERENCES, i); + fprintf(fpo, "["); + dic_repr_index(dic, IP3DBIDX_REFERENCES, i, fpo); + fprintf(fpo, "]\n"); + if (idx_root) { + avl_dump(idx->avl, idx_root, &dic->references, i, 0, fpo); + } + } for (i = 0;i < dic->objects.num_indices;++i) { uint32_t idx_root = dic_get_idxroot(dic, IP3DBIDX_OBJECTS, i); fprintf(fpo, "["); @@ -822,6 +845,12 @@ dic_set_idxroot(dic, IP3DBIDX_MUSIC, index, root); } + for (index = 0;index < dic->references.num_indices;++index) { + uint32_t root = 0; + idx_construct_index(idx, &dic->references, &dat->references, &root, index); + dic_set_idxroot(dic, IP3DBIDX_REFERENCES, index, root); + } + for (index = 0;index < dic->objects.num_indices;++index) { uint32_t root = 0; idx_construct_index(idx, &dic->objects, &dat->objects, &root, index); Modified: trunk/pmplib/lib/pmp_iriverplus3/ip3db.h =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/ip3db.h 2007-01-18 15:06:25 UTC (rev 270) +++ trunk/pmplib/lib/pmp_iriverplus3/ip3db.h 2007-01-18 17:34:30 UTC (rev 271) @@ -57,6 +57,7 @@ ucs2char_t* filename; int num_entries; ucs2char_t **entries; + uint32_t uid; } ip3db_playlist_t; /** @@ -94,6 +95,15 @@ IP3DBF_MUSIC_LAST, }; +enum { + IP3DBF_REFERENCES_NONE = -1, + IP3DBF_REFERENCES_BEGIN = 0, + IP3DBF_REFERENCES_PARENTCLUSTER = 0, + IP3DBF_REFERENCES_CHILDCLUSTER, + IP3DBF_REFERENCES_FILEFORMAT, + IP3DBF_REFERENCES_LAST, +}; + /** * A music record. */ @@ -125,6 +135,7 @@ enum { IP3DBIDX_NONE = -1, IP3DBIDX_MUSIC = 0, + IP3DBIDX_REFERENCES, IP3DBIDX_OBJECTS, IP3DBIDX_LAST, }; @@ -150,6 +161,14 @@ IP3DBIDX_MUSIC_LAST, }; +enum { + IP3DBIDX_REFERENCES_NONE = -1, + IP3DBIDX_REFERENCES_BEGIN = 0, + IP3DBIDX_REFERENCES_PARENTCLUSTER = 0, + IP3DBIDX_REFERENCES_CHILDCLUSTER, + IP3DBIDX_REFERENCES_LAST, +}; + /** * Indices for the object chunk. */ Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-18 15:06:25 UTC (rev 270) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-18 17:34:30 UTC (rev 271) @@ -652,7 +652,11 @@ dst->num_entries = src->num_entries; dst->entries = (ucs2char_t**)ucs2malloc(sizeof(ucs2char_t*) * src->num_entries); for (j = 0;j < src->num_entries;++j) { - dst->entries[j] = ucs2dup(src->entries[j]); + ucs2char_t filename[MAX_PATH]; + + ucs2cpy(filename, filepath_skipdrive(src->entries[j], music->pmp->info.path_to_root)); + filepath_slash(filename); + dst->entries[j] = ucs2dup(filename); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-18 15:06:28
|
Revision: 270 http://svn.sourceforge.net/pmplib/?rev=270&view=rev Author: nyaochi Date: 2007-01-18 07:06:25 -0800 (Thu, 18 Jan 2007) Log Message: ----------- Incremental commit before starting additional E10 database analysis for playlists. Pleylists seem to be integrated in the database although iriver plus 3 generates *.plp file in \Playlists directory. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/common/playlist.c trunk/pmplib/frontend/easypmp/cui/main.c trunk/pmplib/include/pmp.h trunk/pmplib/lib/pmp/pmp.c trunk/pmplib/lib/pmp_iriverplus3/ip3db.c trunk/pmplib/lib/pmp_iriverplus3/ip3db.h trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.vcproj Added Paths: ----------- trunk/pmplib/lib/pmp_iriverplus3/plp.c Removed Paths: ------------- trunk/pmplib/lib/pmp_iriverplus3/playlist.c Modified: trunk/pmplib/frontend/easypmp/common/playlist.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/playlist.c 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/frontend/easypmp/common/playlist.c 2007-01-18 15:06:25 UTC (rev 270) @@ -75,24 +75,24 @@ ) { int result = 0; - /* int i, j, num_succeeded = 0; char *mbs = NULL; - pmp_playlist_t* pmppl = NULL; + pmp_music_t* music = NULL; playlist_mediafile_t* mediafiles = NULL; + pmp_playlist_t* pmppls = NULL; + int num_pmppls = 0; result_t res = 0; callback_data_t cd; + ucs2char_t dstpath[MAX_PATH]; cd.instance = instance; cd.progress = progress; - // Create playlist instance. - res = pmp->create_instance_pl(pmp, &pmppl); - if (!pmppl) { - result = MAKE_PMP_ERROR(res); - goto error_exit; - } + // Query the interface to music. + music = pmp->music; + filepath_combinepath(dstpath, MAX_PATH, pmp->info.path_to_root, pmp->info.path_to_playlist); + // Start playlist processing. if (progress(instance, EASYPMPPLP_START, 0, 0, NULL) != 0) { result = EASYPMPE_CANCEL; @@ -160,11 +160,11 @@ ucs2char_t** contents = NULL; playlist_t* pl = &pls.playlists[k]; ucs2char_t dst[MAX_PATH]; + pmp_playlist_t* pmppl = NULL; // Generate a destination filename. - filepath_combinepath(dst, MAX_PATH, pmp->env.path_to_playlist.path, filepath_skippath(pl->name)); + filepath_combinepath(dst, MAX_PATH, dstpath, filepath_skippath(pl->name)); filepath_remove_extension(dst); - ucs2cat(dst, pmp->env.playlist_ext); // Skipping the existing playlist if (!(opt->verb & MODE_PLAYLIST_RECONVERT)) { @@ -186,7 +186,7 @@ n = playlist_normalize( pl, filepath_skippath(pl->name), - pmp->env.path_to_root.path, + pmp->info.path_to_root, mediafiles, musics->num_elements ); @@ -221,31 +221,32 @@ } } + pmppls = (pmp_playlist_t*)realloc(pmppls, sizeof(pmp_playlist_t) * (num_pmppls+1)); + pmppl = &pmppls[num_pmppls]; + // Allocate a memory block for the contents of the playlist. - contents = (ucs2char_t**)calloc(pl->num_entries, sizeof(ucs2char_t*)); - if (!contents) { + pmppl->entries = (ucs2char_t**)calloc(pl->num_entries, sizeof(ucs2char_t*)); + pmppl->num_entries = pl->num_entries; + pmppl->name = ucs2dup(dst); + + if (!pmppl->entries) { result = EASYPMPE_INSUFFICIENT_MEMORY; goto error_exit; } for (j = 0, n = 0;j < pl->num_entries;++j) { if (pl->entries[j].valid && pl->entries[j].filename[0]) { - contents[n] = ucs2dup(pl->entries[j].filename); + pmppl->entries[n] = ucs2dup(pl->entries[j].filename); ++n; } } - // Write the converted playlist. - pmppl->write(pmppl, dst, contents, n); ++num_succeeded; - - // Free the contents of the playlist. - for (j = 0;j < n;++j) { - ucs2free(contents[j]); - } - free(contents); + ++num_pmppls; } } + music->set_playlists(music, pmppls, num_pmppls); + // Finish playlist conversion. if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_END, num_succeeded, 0, NULL) != 0) { result = EASYPMPE_CANCEL; @@ -259,12 +260,11 @@ } error_exit: + for (i = 0;i < num_pmppls;++i) { + pmp_playlist_finish(&pmppls[i]); + } + free(pmppls); free(mediafiles); - if (pmppl) { - pmppl->release(pmppl); - pmppl = NULL; - } - */ return result; } /** @} */ Modified: trunk/pmplib/frontend/easypmp/cui/main.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/main.c 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/frontend/easypmp/cui/main.c 2007-01-18 15:06:25 UTC (rev 270) @@ -336,6 +336,10 @@ openflag |= PMPOF_MUSIC_DB_READ; } + if (opt.verb & MODE_PLAYLIST) { + openflag |= PMPOF_MUSIC_PL_WRITE; + } + // Open the PMP. ret = pmp->open(pmp, openflag); @@ -394,7 +398,7 @@ free(records); } - pmp->close(pmp, 0); + pmp->close(pmp); pmp->release(pmp); pmplib_finish(pmphelp); option_finish(&opt); Modified: trunk/pmplib/include/pmp.h =================================================================== --- trunk/pmplib/include/pmp.h 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/include/pmp.h 2007-01-18 15:06:25 UTC (rev 270) @@ -271,9 +271,8 @@ /** * Close the PMP device. * @param pmp The pointer to the pmp_t instance. - * @param flag The close flags. */ - result_t (*close)(pmp_t* pmp, uint32_t flag); + result_t (*close)(pmp_t* pmp); }; typedef void pmpdb_readwrite_progress_t(void *instance, uint32_t size, uint32_t total); @@ -304,13 +303,9 @@ typedef struct tag_pmp_music_record_t pmp_music_record_t; typedef struct { - ucs2char_t filename[MAX_PATH]; -} pmp_playlist_entry_t; - -typedef struct { - ucs2char_t name[MAX_PATH]; + ucs2char_t *name; int num_entries; - pmp_playlist_entry_t* entries; + ucs2char_t **entries; } pmp_playlist_t; struct tag_pmp_music_t { @@ -341,11 +336,13 @@ PMPAPI uint32_t pmp_interlocked_increment(uint32_t* count); PMPAPI uint32_t pmp_interlocked_decrement(uint32_t* count); +PMPAPI void pmp_playlist_init(pmp_playlist_t* playlist); +PMPAPI void pmp_playlist_finish(pmp_playlist_t* playlist); +PMPAPI void pmp_playlist_copy(pmp_playlist_t* dst, const pmp_playlist_t* src); - /** * @defgroup pmplib PMPlib Helper API * Modified: trunk/pmplib/lib/pmp/pmp.c =================================================================== --- trunk/pmplib/lib/pmp/pmp.c 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/lib/pmp/pmp.c 2007-01-18 15:06:25 UTC (rev 270) @@ -62,3 +62,30 @@ dst->date = src->date ? ucs2dup(src->date) : NULL; return 0; } + +void pmp_playlist_init(pmp_playlist_t* playlist) +{ + memset(playlist, 0, sizeof(*playlist)); +} + +void pmp_playlist_finish(pmp_playlist_t* playlist) +{ + int i; + for (i = 0;i < playlist->num_entries;++i) { + ucs2free(playlist->entries[i]); + } + ucs2free(playlist->entries); + ucs2free(playlist->name); +} + +void pmp_playlist_copy(pmp_playlist_t* dst, const pmp_playlist_t* src) +{ + int i; + + dst->name = ucs2dup(src->name); + dst->num_entries = src->num_entries; + dst->entries = (ucs2char_t**)ucs2calloc(sizeof(ucs2char_t*) * src->num_entries); + for (i = 0;i < src->num_entries;++i) { + dst->entries[i] = ucs2dup(src->entries[i]); + } +} Modified: trunk/pmplib/lib/pmp_iriverplus3/ip3db.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/ip3db.c 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/lib/pmp_iriverplus3/ip3db.c 2007-01-18 15:06:25 UTC (rev 270) @@ -29,12 +29,14 @@ #include <stdio.h> #include <stdlib.h> #include <ucs2char.h> +#include <filepath.h> #include "util.h" #include "ip3db.h" #include "dic.h" #include "dat.h" #include "idx.h" +#include "plp.h" void ip3db_variant_init(ip3db_variant_t* var, int type) { @@ -247,3 +249,51 @@ ip3db_variant_finish(&var[i]); } } + +void ip3db_playlist_init(ip3db_playlist_t* playlist) +{ + memset(playlist, 0, sizeof(*playlist)); +} + +void ip3db_playlist_finish(ip3db_playlist_t* playlist) +{ + int i; + for (i = 0;i < playlist->num_entries;++i) { + ucs2free(playlist->entries[i]); + } + ucs2free(playlist->entries); + ucs2free(playlist->filepath); + ucs2free(playlist->filename); +} + +void ip3db_playlist_copy(ip3db_playlist_t* dst, const ip3db_playlist_t* src) +{ + int i; + + dst->filepath = ucs2dup(src->filepath); + dst->filename = ucs2dup(src->filename); + dst->num_entries = src->num_entries; + dst->entries = (ucs2char_t**)ucs2calloc(sizeof(ucs2char_t*) * src->num_entries); + for (i = 0;i < src->num_entries;++i) { + dst->entries[i] = ucs2dup(src->entries[i]); + } +} + +int ip3db_write_playlists(ip3db_t* db, const ip3db_playlist_t* playlists, int num_playlists, const ucs2char_t *path_to_root) +{ + int i; + + for (i = 0;i < num_playlists;++i) { + ucs2char_t filename[MAX_PATH]; + const ip3db_playlist_t* pl = &playlists[i]; + + ucs2cpy(filename, path_to_root); + ucs2cat(filename, pl->filepath + 1); + ucs2cat(filename, pl->filename); + filepath_backslash(filename); + + plp_write(db, filename, pl->entries, pl->num_entries, path_to_root); + } + + return 0; +} Modified: trunk/pmplib/lib/pmp_iriverplus3/ip3db.h =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/ip3db.h 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/lib/pmp_iriverplus3/ip3db.h 2007-01-18 15:06:25 UTC (rev 270) @@ -55,6 +55,8 @@ typedef struct { ucs2char_t* filepath; ucs2char_t* filename; + int num_entries; + ucs2char_t **entries; } ip3db_playlist_t; /** @@ -189,15 +191,14 @@ int ip3db_num_records(ip3db_t* db); ip3db_music_record_t* ip3db_get_record(ip3db_t* db, int i); result_t ip3db_dump(ip3db_t* db, FILE *fpo); -int ip3db_playlist_write( - ip3db_t* db, - const ucs2char_t *filename, - ucs2char_t* const mediafiles[], - int num_mediafiles, - const ucs2char_t *path_to_root - ); +int ip3db_write_playlists(ip3db_t* db, const ip3db_playlist_t* playlists, int num_playlists, const ucs2char_t *path_to_root); + void ip3db_record_init(ip3db_t* db, ip3db_music_record_t* record); void ip3db_record_finish(ip3db_t* db, ip3db_music_record_t* record); +void ip3db_playlist_init(ip3db_playlist_t* playlist); +void ip3db_playlist_finish(ip3db_playlist_t* playlist); +void ip3db_playlist_copy(ip3db_playlist_t* dst, const ip3db_playlist_t* src); + #endif /*_IP3DB_IP3DB_H__*/ Deleted: trunk/pmplib/lib/pmp_iriverplus3/playlist.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/playlist.c 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/lib/pmp_iriverplus3/playlist.c 2007-01-18 15:06:25 UTC (rev 270) @@ -1,120 +0,0 @@ -/* - * Playlist reader/writer for iriver E10. - * - * Copyright (c) 2005-2006 Nyaochi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif/*HAVE_CONFIG_H*/ - -#include <os.h> -#include <stdio.h> -#include <stdlib.h> -#include <ucs2char.h> -#include <filepath.h> - -#include "serialize.h" -#include "util.h" -#include "ip3db.h" -#include "dat.h" - -static uint32_t findfile(ip3db_t* db, const ucs2char_t *filename, const ucs2char_t *path_to_root) -{ - int i; - const ucs2char_t *filepart = filepath_skippath(filename); - const ucs2char_t *pathfile = filepath_skipdrive(filename, path_to_root); - ucs2char_t *pathname = alloca(sizeof(ucs2char_t) * (ucs2len(pathfile) + 1)); - - ucs2cpy(pathname, pathfile); - filepath_remove_filespec(pathname); - filepath_addslash(pathname); - filepath_slash(pathname); - - for (i = 0;i < db->dat->musics.num_entries;++i) { - dat_entry_t* entry = &db->dat->musics.entries[i]; - if (ucs2icmp(entry->fields[IP3DBF_MUSIC_FILENAME].value.str, filepart) == 0 && - ucs2icmp(entry->fields[IP3DBF_MUSIC_FILEPATH].value.str, pathname) == 0) { - return entry->fields[IP3DBF_MUSIC_UID].value.dword; - } - } - return 0; -} - -int ip3db_playlist_write( - ip3db_t* db, - const ucs2char_t *filename, - ucs2char_t* const mediafiles[], - int num_mediafiles, - const ucs2char_t *path_to_root - ) -{ - int i; - FILE *fp = NULL; - uint32_t* uids = NULL; - uint32_t num_uids = 0; - - for (i = 0;i < num_mediafiles;i++) { - if (mediafiles[i][0]) { - uint32_t uid = 0; - ucs2char_t mediafile[MAX_PATH]; - ucs2cpy(mediafile, mediafiles[i]); - - uid = findfile(db, mediafile, path_to_root); - if (uid <= 0) { - goto error_exit; - } - - uids = realloc(uids, sizeof(uint32_t) * (num_uids+1)); - if (!uids) { - goto error_exit; - } - uids[num_uids++] = uid; - } - } - - fp = ucs2fopen(filename, "wb"); - if (fp) { - size_t size = sizeof(uint32_t) + sizeof(uint32_t) * num_uids; - uint8_t* buffer = (uint8_t*)malloc(size); - uint8_t* p = buffer; - - if (!buffer) { - goto error_exit; - } - - p += serialize_uint32le(p, &num_uids, 1); - for (i = 0;i < (int)num_uids;++i) { - p += serialize_uint32le(p, &uids[i], 1); - } - fwrite(buffer, 1, size, fp); - free(buffer); - fclose(fp); - } else { - return -1; - } - - free(uids); - return 0; - -error_exit: - free(uids); - return -1; -} Copied: trunk/pmplib/lib/pmp_iriverplus3/plp.c (from rev 263, trunk/pmplib/lib/pmp_iriverplus3/playlist.c) =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/plp.c (rev 0) +++ trunk/pmplib/lib/pmp_iriverplus3/plp.c 2007-01-18 15:06:25 UTC (rev 270) @@ -0,0 +1,120 @@ +/* + * Playlist reader/writer for iriver E10. + * + * Copyright (c) 2005-2006 Nyaochi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +/* $Id$ */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif/*HAVE_CONFIG_H*/ + +#include <os.h> +#include <stdio.h> +#include <stdlib.h> +#include <ucs2char.h> +#include <filepath.h> + +#include "serialize.h" +#include "util.h" +#include "ip3db.h" +#include "dat.h" + +static uint32_t findfile(ip3db_t* db, const ucs2char_t *filename, const ucs2char_t *path_to_root) +{ + int i; + const ucs2char_t *filepart = filepath_skippath(filename); + const ucs2char_t *pathfile = filepath_skipdrive(filename, path_to_root); + ucs2char_t *pathname = alloca(sizeof(ucs2char_t) * (ucs2len(pathfile) + 1)); + + ucs2cpy(pathname, pathfile); + filepath_remove_filespec(pathname); + filepath_addslash(pathname); + filepath_slash(pathname); + + for (i = 0;i < db->dat->musics.num_entries;++i) { + dat_entry_t* entry = &db->dat->musics.entries[i]; + if (ucs2icmp(entry->fields[IP3DBF_MUSIC_FILENAME].value.str, filepart) == 0 && + ucs2icmp(entry->fields[IP3DBF_MUSIC_FILEPATH].value.str, pathname) == 0) { + return entry->fields[IP3DBF_MUSIC_UID].value.dword; + } + } + return 0; +} + +int plp_write( + ip3db_t* db, + const ucs2char_t *filename, + ucs2char_t* const mediafiles[], + int num_mediafiles, + const ucs2char_t *path_to_root + ) +{ + int i; + FILE *fp = NULL; + uint32_t* uids = NULL; + uint32_t num_uids = 0; + + for (i = 0;i < num_mediafiles;i++) { + if (mediafiles[i][0]) { + uint32_t uid = 0; + ucs2char_t mediafile[MAX_PATH]; + ucs2cpy(mediafile, mediafiles[i]); + + uid = findfile(db, mediafile, path_to_root); + if (uid <= 0) { + goto error_exit; + } + + uids = realloc(uids, sizeof(uint32_t) * (num_uids+1)); + if (!uids) { + goto error_exit; + } + uids[num_uids++] = uid; + } + } + + fp = ucs2fopen(filename, "wb"); + if (fp) { + size_t size = sizeof(uint32_t) + sizeof(uint32_t) * num_uids; + uint8_t* buffer = (uint8_t*)malloc(size); + uint8_t* p = buffer; + + if (!buffer) { + goto error_exit; + } + + p += serialize_uint32le(p, &num_uids, 1); + for (i = 0;i < (int)num_uids;++i) { + p += serialize_uint32le(p, &uids[i], 1); + } + fwrite(buffer, 1, size, fp); + free(buffer); + fclose(fp); + } else { + return -1; + } + + free(uids); + return 0; + +error_exit: + free(uids); + return -1; +} Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-18 15:06:25 UTC (rev 270) @@ -71,7 +71,7 @@ "System\\E10.SYS", "System\\db.dat", "System\\db.dic", "System\\db.idx", ".mp3\0.ogg\0.wma\0.wav\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_VORBIS, PMPCODEC_WMA, PMPCODEC_WAV, 0, 0, 0, 0}, - "System\\", "", "Playlists\\", + "System\\", "Music2\\", "Playlists\\", ".plp", }, { @@ -100,7 +100,7 @@ static uint32_t pmp_add_ref(pmp_t* pmp); static uint32_t pmp_release(pmp_t* pmp); static result_t pmp_open(pmp_t* pmp, uint32_t flag); -static result_t pmp_close(pmp_t* pmp, uint32_t flag); +static result_t pmp_close(pmp_t* pmp); static result_t pmp_create_instance_music(pmp_t* pmp, pmp_music_t** ptr_pmpdb); static uint32_t pmpmusic_release(pmp_music_t* pmpdb); @@ -416,17 +416,29 @@ return 0; } -static result_t pmp_close(pmp_t* pmp, uint32_t flag) +static result_t pmp_close(pmp_t* pmp) { result_t ret = 0; - if (pmp->flag & PMPOF_MUSIC_DB_WRITE) { + + // Music database/playlist. + if (pmp->flag & PMPOF_MUSIC_DB_WRITE || pmp->flag & PMPOF_MUSIC_PL_WRITE) { ucs2char_t dat[MAX_PATH], dic[MAX_PATH], idx[MAX_PATH]; pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmp->music->instance; - ip3db_set(&pmpmi->ip3db, pmpmi->records, pmpmi->num_records, pmpmi->playlists, pmpmi->num_playlists); + // Register records (and playlists) to the database. + if (pmp->flag & PMPOF_MUSIC_PL_WRITE) { + ip3db_set(&pmpmi->ip3db, pmpmi->records, pmpmi->num_records, pmpmi->playlists, pmpmi->num_playlists); + } else { + ip3db_set(&pmpmi->ip3db, pmpmi->records, pmpmi->num_records, NULL, 0); + } + // Write out the playlist first. + ip3db_write_playlists(&pmpmi->ip3db, pmpmi->playlists, pmpmi->num_playlists, pmp->info.path_to_root); + + // Write out the music database. set_filenames(dat, dic, idx, pmp); - return ip3db_write(&pmpmi->ip3db, dat, dic, idx); + ret = ip3db_write(&pmpmi->ip3db, dat, dic, idx); + } return 0; } @@ -605,14 +617,44 @@ } } -static result_t pmpmusic_set_playlists(pmp_music_t* pmpmusic, const pmp_playlist_t* playlists, uint32_t num_playlists) +static result_t pmpmusic_set_playlists(pmp_music_t* music, const pmp_playlist_t* playlists, uint32_t num_playlists) { - /* - pmppl_internal_t* pmppli = (pmppl_internal_t*)pmppl->instance; - pmp_internal_t* pmpi = (pmp_internal_t*)pmppl->pmp->instance; - if (ip3db_playlist_write(&pmppli->ip3db, filename, files, num_files, pmpi->env.path_to_root) != 0) { - return PMPPLE_WRITE; + uint32_t i, j; + static const ucs2char_t plp_ext[] = {'.','p','l','p',0}; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; + + // Free playlists attached to pmpmi. + for (i = 0;i < pmpmi->num_playlists;++i) { + ip3db_playlist_finish(&pmpmi->playlists[i]); } - */ + free(pmpmi->playlists); + + // Allocate a new playlists. + pmpmi->playlists = (ip3db_playlist_t*)calloc(num_playlists, sizeof(ip3db_playlist_t)); + pmpmi->num_playlists = num_playlists; + + // Copy the content of the playlists. + for (i = 0;i < num_playlists;++i) { + ucs2char_t filepath[MAX_PATH]; + const pmp_playlist_t* src = &playlists[i]; + ip3db_playlist_t* dst = &pmpmi->playlists[i]; + + ucs2cpy(filepath, src->name); + ucs2cat(filepath, plp_ext); + + dst->filename = ucs2dup(filepath_skippath(filepath)); + + filepath_remove_filespec(filepath); + filepath_addslash(filepath); + dst->filepath = ucs2dup(filepath_skipdrive(filepath, music->pmp->info.path_to_root)); + filepath_slash(dst->filepath); + + dst->num_entries = src->num_entries; + dst->entries = (ucs2char_t**)ucs2malloc(sizeof(ucs2char_t*) * src->num_entries); + for (j = 0;j < src->num_entries;++j) { + dst->entries[j] = ucs2dup(src->entries[j]); + } + } + return 0; } Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.vcproj =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.vcproj 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.vcproj 2007-01-18 15:06:25 UTC (rev 270) @@ -193,7 +193,7 @@ > </File> <File - RelativePath=".\playlist.c" + RelativePath=".\plp.c" > </File> <File @@ -231,6 +231,10 @@ > </File> <File + RelativePath=".\plp.h" + > + </File> + <File RelativePath=".\serialize.h" > </File> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-17 19:24:48
|
Revision: 269 http://svn.sourceforge.net/pmplib/?rev=269&view=rev Author: nyaochi Date: 2007-01-17 11:24:46 -0800 (Wed, 17 Jan 2007) Log Message: ----------- Keep music records in pmp_music_internal_t structure. Modified Paths: -------------- trunk/pmplib/lib/pmp_iriverplus3/dat.c trunk/pmplib/lib/pmp_iriverplus3/dat.h trunk/pmplib/lib/pmp_iriverplus3/ip3db.c trunk/pmplib/lib/pmp_iriverplus3/ip3db.h trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c Modified: trunk/pmplib/lib/pmp_iriverplus3/dat.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dat.c 2007-01-17 18:38:14 UTC (rev 268) +++ trunk/pmplib/lib/pmp_iriverplus3/dat.c 2007-01-17 19:24:46 UTC (rev 269) @@ -624,7 +624,7 @@ return p ? p+1 : NULL; } -void dat_set(dat_t* dat, dic_t* dic, const ip3db_music_record_t* records, int num_records) +void dat_set(dat_t* dat, dic_t* dic, const ip3db_music_record_t* records, int num_records, const ip3db_playlist_t* playlists, int num_playlists) { /* Procedure: * 1) Construct the object chunk and attach music records with Object UIDs. @@ -659,7 +659,7 @@ static const ucs2char_t ucs2cs_root[] = {'/', 0}; dat_list_t* dato = &dat->objects; dat_list_t* datm = &dat->musics; - uint32_t num_objects = num_records; + uint32_t num_objects = num_records + num_playlists; object_record_t *objects = (object_record_t*)malloc(sizeof(object_record_t) * num_objects); dircache_t dc; @@ -680,12 +680,18 @@ dircache_push(&dc, ucs2cs_root, uid_root); /* Sort the records in alphabetical order of their path names. */ - for (i = 0;i < num_objects;++i) { + for (i = 0;i < num_records;++i) { objects[i].filepath = records[i][IP3DBF_MUSIC_FILEPATH].value.str; objects[i].filename = records[i][IP3DBF_MUSIC_FILENAME].value.str; objects[i].filetype = 2; objects[i].index = i; } + for (i = 0;i < num_playlists;++i) { + objects[i+num_records].filepath = playlists[i].filepath; + objects[i+num_records].filename = playlists[i].filename; + objects[i+num_records].filetype = 4; + objects[i+num_records].index = i; + } qsort(objects, num_objects, sizeof(objects[0]), comp_pathname); /* Loop for the records. */ @@ -737,6 +743,7 @@ /* Create a new object for the file name (FileType = 2). */ if (objects[i].filetype == 2) { + /* Music file. */ const ip3db_variant_t* record = records[objects[i].index]; uid = dato->num_entries; @@ -754,6 +761,17 @@ ip3db_variant_clone(&entry->fields[j], &record[j]); } ip3db_variant_set_dword(&entry->fields[IP3DBF_MUSIC_UID], uid); + } else if (objects[i].filetype == 4) { + /* Playlist file. */ + const ip3db_playlist_t* playlist = &playlists[objects[i].index]; + + uid = dato->num_entries; + entry = dat_list_expand(dato); + dat_entry_init(entry, &dic->objects); + ip3db_variant_set_dword(&entry->fields[IP3DBF_OBJECTS_UID], uid); + ip3db_variant_set_dword(&entry->fields[IP3DBF_OBJECTS_PARENTUID], puid); + ip3db_variant_set_word(&entry->fields[IP3DBF_OBJECTS_FILETYPE], 4); + ip3db_variant_set_str(&entry->fields[IP3DBF_OBJECTS_OBJECTNAME], file); } } Modified: trunk/pmplib/lib/pmp_iriverplus3/dat.h =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dat.h 2007-01-17 18:38:14 UTC (rev 268) +++ trunk/pmplib/lib/pmp_iriverplus3/dat.h 2007-01-17 19:24:46 UTC (rev 269) @@ -48,6 +48,6 @@ int dat_read(dat_t* dat, const dic_t* dic, FILE *fpi); int dat_write(dat_t* dat, dic_t* dic, FILE *fpo); void dat_dump(dat_t* dat, const dic_t* dic, FILE *fp); -void dat_set(dat_t* dat, dic_t* dic, const ip3db_music_record_t* records, int num_records); +void dat_set(dat_t* dat, dic_t* dic, const ip3db_music_record_t* records, int num_records, const ip3db_playlist_t* playlists, int num_playlists); #endif/*__IP3DB_DAT_H__*/ Modified: trunk/pmplib/lib/pmp_iriverplus3/ip3db.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/ip3db.c 2007-01-17 18:38:14 UTC (rev 268) +++ trunk/pmplib/lib/pmp_iriverplus3/ip3db.c 2007-01-17 19:24:46 UTC (rev 269) @@ -213,10 +213,10 @@ return 0; } -result_t ip3db_set(ip3db_t* db, const ip3db_music_record_t* records, int num_records) +result_t ip3db_set(ip3db_t* db, const ip3db_music_record_t* records, int num_records, const ip3db_playlist_t* playlists, int num_playlists) { /* Construct records in db->dat from the records. */ - dat_set(db->dat, db->dic, records, num_records); + dat_set(db->dat, db->dic, records, num_records, playlists, num_playlists); return 0; } @@ -238,3 +238,12 @@ ip3db_variant_init(&var[i], db->dic->music.fields[i].type); } } + +void ip3db_record_finish(ip3db_t* db, ip3db_music_record_t* record) +{ + int i; + ip3db_variant_t* var = (ip3db_variant_t*)record; + for (i = 0;i < IP3DBF_MUSIC_LAST;++i) { + ip3db_variant_finish(&var[i]); + } +} Modified: trunk/pmplib/lib/pmp_iriverplus3/ip3db.h =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/ip3db.h 2007-01-17 18:38:14 UTC (rev 268) +++ trunk/pmplib/lib/pmp_iriverplus3/ip3db.h 2007-01-17 19:24:46 UTC (rev 269) @@ -52,6 +52,11 @@ } value; } ip3db_variant_t; +typedef struct { + ucs2char_t* filepath; + ucs2char_t* filename; +} ip3db_playlist_t; + /** * Fields in a music record. */ @@ -180,7 +185,7 @@ void ip3db_finish(ip3db_t* db); result_t ip3db_read(ip3db_t* db, const ucs2char_t* datfn, const ucs2char_t* dicfn, const ucs2char_t* idxfn); result_t ip3db_write(ip3db_t* db, const ucs2char_t* datfn, const ucs2char_t* dicfn, const ucs2char_t* idxfn); -result_t ip3db_set(ip3db_t* db, const ip3db_music_record_t* records, int num_records); +result_t ip3db_set(ip3db_t* db, const ip3db_music_record_t* records, int num_records, const ip3db_playlist_t* playlists, int num_playlists); int ip3db_num_records(ip3db_t* db); ip3db_music_record_t* ip3db_get_record(ip3db_t* db, int i); result_t ip3db_dump(ip3db_t* db, FILE *fpo); @@ -193,5 +198,6 @@ ); void ip3db_record_init(ip3db_t* db, ip3db_music_record_t* record); +void ip3db_record_finish(ip3db_t* db, ip3db_music_record_t* record); #endif /*_IP3DB_IP3DB_H__*/ Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-17 18:38:14 UTC (rev 268) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-17 19:24:46 UTC (rev 269) @@ -89,6 +89,14 @@ const ip3model_descriptor_t* decl; } pmp_internal_t; +typedef struct { + ip3db_t ip3db; + ip3db_music_record_t* records; + int num_records; + ip3db_playlist_t* playlists; + int num_playlists; +} pmp_music_internal_t; + static uint32_t pmp_add_ref(pmp_t* pmp); static uint32_t pmp_release(pmp_t* pmp); static result_t pmp_open(pmp_t* pmp, uint32_t flag); @@ -172,7 +180,7 @@ n++; } info->num_audio_extensions = n; - info->audio_extensions = (ucs2char_t*)ucs2malloc(sizeof(ucs2char_t*) * info->num_audio_extensions); + info->audio_extensions = (ucs2char_t**)ucs2malloc(sizeof(ucs2char_t*) * info->num_audio_extensions); for (n = 0, p = md->extensions;*p;p += (strlen(p)+1)) { info->audio_extensions[n++] = mbsdupucs2(p); } @@ -400,10 +408,10 @@ if (pmp->flag & PMPOF_MUSIC_DB_READ) { ucs2char_t dat[MAX_PATH], dic[MAX_PATH], idx[MAX_PATH]; - ip3db_t* ip3db = (ip3db_t*)pmp->music->instance; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmp->music->instance; set_filenames(dat, dic, idx, pmp); - return ip3db_read(ip3db, dat, dic, idx); + return ip3db_read(&pmpmi->ip3db, dat, dic, idx); } return 0; } @@ -413,19 +421,21 @@ result_t ret = 0; if (pmp->flag & PMPOF_MUSIC_DB_WRITE) { ucs2char_t dat[MAX_PATH], dic[MAX_PATH], idx[MAX_PATH]; - ip3db_t* ip3db = (ip3db_t*)pmp->music->instance; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmp->music->instance; + ip3db_set(&pmpmi->ip3db, pmpmi->records, pmpmi->num_records, pmpmi->playlists, pmpmi->num_playlists); + set_filenames(dat, dic, idx, pmp); - return ip3db_write(ip3db, dat, dic, idx); + return ip3db_write(&pmpmi->ip3db, dat, dic, idx); } return 0; } static result_t pmp_create_instance_music(pmp_t* pmp, pmp_music_t** ptr_music) { - ip3db_t* ip3db = NULL; pmp_music_t* music = NULL; pmp_internal_t* pmpi = (pmp_internal_t*)pmp->instance; + pmp_music_internal_t* pmpmi = NULL; *ptr_music = 0; @@ -434,19 +444,19 @@ return PMPDBE_OUTOFMEMORY; } - ip3db = calloc(1, sizeof(ip3db_t)); - if (!ip3db) { + pmpmi = calloc(1, sizeof(pmp_music_internal_t)); + if (!pmpmi) { free(music); return PMPDBE_OUTOFMEMORY; } - ip3db_init(ip3db); + ip3db_init(&pmpmi->ip3db); music->set_records = pmpmusic_set_records; music->get_records = pmpmusic_get_records; music->dump = pmpmusic_dump; music->set_playlists = pmpmusic_set_playlists; music->pmp = pmp; - music->instance = ip3db; + music->instance = pmpmi; *ptr_music = music; return 0; @@ -456,12 +466,14 @@ -static uint32_t pmpmusic_release(pmp_music_t* pmpmusic) +static uint32_t pmpmusic_release(pmp_music_t* music) { - ip3db_t* ip3db = (ip3db_t*)pmpmusic->instance; - ip3db_finish(ip3db); - free(pmpmusic->instance); - free(pmpmusic); + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; + ip3db_finish(&pmpmi->ip3db); + free(pmpmi->records); + free(pmpmi->playlists); + free(pmpmi); + free(music); return 0; } @@ -479,15 +491,24 @@ { uint32_t i; pmp_t* pmp = pmpdb->pmp; - ip3db_t* ip3db = (ip3db_t*)pmpdb->instance; pmp_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; - ip3db_music_record_t* array = (ip3db_music_record_t*)malloc(sizeof(ip3db_music_record_t) * num_records); + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmpdb->instance; + /* Free records attached to pmpmi. */ + for (i = 0;i < (uint32_t)pmpmi->num_records;++i) { + ip3db_record_finish(&pmpmi->ip3db, &pmpmi->records[i]); + } + free(pmpmi->records); + + /* Allocate new records. */ + pmpmi->records = (ip3db_music_record_t*)malloc(sizeof(ip3db_music_record_t) * num_records); + pmpmi->num_records = num_records; + for (i = 0;i < num_records;++i) { const pmp_music_record_t* src = &records[i]; - ip3db_variant_t* dst = array[i]; + ip3db_variant_t* dst = pmpmi->records[i]; - ip3db_record_init(ip3db, &array[i]); + ip3db_record_init(&pmpmi->ip3db, &pmpmi->records[i]); ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILEPATH], filepath_skipdrive(src->filename, pmp->info.path_to_root)); filepath_remove_filespec(dst[IP3DBF_MUSIC_FILEPATH].value.str); filepath_addslash(dst[IP3DBF_MUSIC_FILEPATH].value.str); @@ -516,18 +537,16 @@ ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_UID], (uint32_t)i+1); } - ip3db_set(ip3db, array, num_records); - free(array); return 0; } static result_t pmpmusic_get_records(pmp_music_t* pmpdb, pmp_music_record_t* records, uint32_t* num_records) { pmp_t* pmp = pmpdb->pmp; - ip3db_t* ip3db = (ip3db_t*)pmpdb->instance; pmp_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmpdb->instance; ucs2char_t *path_to_root = alloca(sizeof(ucs2char_t) * (ucs2len(pmp->info.path_to_root)+1)); - int i, n = ip3db_num_records(ip3db); + int i, n = ip3db_num_records(&pmpmi->ip3db); if (!records) { *num_records = (uint32_t)n; @@ -535,7 +554,7 @@ } for (i = 0;i < n;++i) { - const ip3db_variant_t* src = (const ip3db_variant_t*)ip3db_get_record(ip3db, i); + const ip3db_variant_t* src = (const ip3db_variant_t*)ip3db_get_record(&pmpmi->ip3db, i); pmp_music_record_t* dst = &records[i]; size_t length = 0; @@ -575,14 +594,14 @@ return 0; } -static result_t pmpmusic_dump(pmp_music_t* pmpmusic, FILE *fp, int level) +static result_t pmpmusic_dump(pmp_music_t* music, FILE *fp, int level) { - ip3db_t* ip3db = (ip3db_t*)pmpmusic->instance; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; if (level > 0) { return PMP_NOTIMPLIMENTED; //return ip2db_repr(&pmpdbi->ip2db, fp); } else { - return ip3db_dump(ip3db, fp); + return ip3db_dump(&pmpmi->ip3db, fp); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-17 18:38:17
|
Revision: 268 http://svn.sourceforge.net/pmplib/?rev=268&view=rev Author: nyaochi Date: 2007-01-17 10:38:14 -0800 (Wed, 17 Jan 2007) Log Message: ----------- Preparation for proper playlist conversion for iriver E10. Modified Paths: -------------- trunk/pmplib/lib/pmp_iriverplus3/dat.c Modified: trunk/pmplib/lib/pmp_iriverplus3/dat.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dat.c 2007-01-17 18:00:48 UTC (rev 267) +++ trunk/pmplib/lib/pmp_iriverplus3/dat.c 2007-01-17 18:38:14 UTC (rev 268) @@ -596,18 +596,21 @@ } +typedef struct { + const ucs2char_t* filepath; + const ucs2char_t* filename; + uint8_t filetype; + int index; +} object_record_t; -static int comp_pathname(const void *__x, const void *__y) + +static int comp_pathname(const void *_x, const void *_y) { - const sort_index_t* _x = (const sort_index_t*)__x; - const sort_index_t* _y = (const sort_index_t*)__y; - const ip3db_music_record_t* _xb = (const ip3db_music_record_t*)_x->base; - const ip3db_music_record_t* _yb = (const ip3db_music_record_t*)_y->base; - const ip3db_variant_t* x = _xb[_x->index]; - const ip3db_variant_t* y = _yb[_y->index]; - int ret = ucs2cmp(x[IP3DBF_MUSIC_FILEPATH].value.str, y[IP3DBF_MUSIC_FILEPATH].value.str); + const object_record_t* x = (const object_record_t*)_x; + const object_record_t* y = (const object_record_t*)_y; + int ret = ucs2cmp(x->filepath, y->filepath); if (ret == 0) { - return ucs2cmp(x[IP3DBF_MUSIC_FILENAME].value.str, y[IP3DBF_MUSIC_FILENAME].value.str); + return ucs2cmp(x->filename, y->filename); } else { return ret; } @@ -656,7 +659,8 @@ static const ucs2char_t ucs2cs_root[] = {'/', 0}; dat_list_t* dato = &dat->objects; dat_list_t* datm = &dat->musics; - sort_index_t *si = (sort_index_t*)malloc(sizeof(sort_index_t) * num_records); + uint32_t num_objects = num_records; + object_record_t *objects = (object_record_t*)malloc(sizeof(object_record_t) * num_objects); dircache_t dc; dircache_init(&dc); @@ -676,22 +680,23 @@ dircache_push(&dc, ucs2cs_root, uid_root); /* Sort the records in alphabetical order of their path names. */ - for (i = 0;i < num_records;++i) { - si[i].base = records; - si[i].index = i; + for (i = 0;i < num_objects;++i) { + objects[i].filepath = records[i][IP3DBF_MUSIC_FILEPATH].value.str; + objects[i].filename = records[i][IP3DBF_MUSIC_FILENAME].value.str; + objects[i].filetype = 2; + objects[i].index = i; } - qsort(si, num_records, sizeof(si[0]), comp_pathname); + qsort(objects, num_objects, sizeof(objects[0]), comp_pathname); /* Loop for the records. */ - for (i = 0;i < num_records;++i) { + for (i = 0;i < num_objects;++i) { /* * Split a path name into two parts: a prefix that have already been * registered in the Object table: and a postfix that is being registered * as Object records. */ - 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; + const ucs2char_t* path = objects[i].filepath; + const ucs2char_t* file = objects[i].filename; 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 */ @@ -731,21 +736,25 @@ } /* Create a new object for the file name (FileType = 2). */ - uid = dato->num_entries; - entry = dat_list_expand(dato); - dat_entry_init(entry, &dic->objects); - ip3db_variant_set_dword(&entry->fields[IP3DBF_OBJECTS_UID], uid); - ip3db_variant_set_dword(&entry->fields[IP3DBF_OBJECTS_PARENTUID], puid); - ip3db_variant_set_word(&entry->fields[IP3DBF_OBJECTS_FILETYPE], 2); - ip3db_variant_set_str(&entry->fields[IP3DBF_OBJECTS_OBJECTNAME], file); + if (objects[i].filetype == 2) { + const ip3db_variant_t* record = records[objects[i].index]; - /* Create a music record with UID referring to the file name. */ - entry = dat_list_expand(datm); - dat_entry_init(entry, &dic->music); - for (j = 0;j < entry->num_fields;++j) { - ip3db_variant_clone(&entry->fields[j], &record[j]); + uid = dato->num_entries; + entry = dat_list_expand(dato); + dat_entry_init(entry, &dic->objects); + ip3db_variant_set_dword(&entry->fields[IP3DBF_OBJECTS_UID], uid); + ip3db_variant_set_dword(&entry->fields[IP3DBF_OBJECTS_PARENTUID], puid); + ip3db_variant_set_word(&entry->fields[IP3DBF_OBJECTS_FILETYPE], 2); + ip3db_variant_set_str(&entry->fields[IP3DBF_OBJECTS_OBJECTNAME], file); + + /* Create a music record with UID referring to the file name. */ + entry = dat_list_expand(datm); + dat_entry_init(entry, &dic->music); + for (j = 0;j < entry->num_fields;++j) { + ip3db_variant_clone(&entry->fields[j], &record[j]); + } + ip3db_variant_set_dword(&entry->fields[IP3DBF_MUSIC_UID], uid); } - ip3db_variant_set_dword(&entry->fields[IP3DBF_MUSIC_UID], uid); } dircache_finish(&dc); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-17 18:00:52
|
Revision: 267 http://svn.sourceforge.net/pmplib/?rev=267&view=rev Author: nyaochi Date: 2007-01-17 10:00:48 -0800 (Wed, 17 Jan 2007) Log Message: ----------- Use offset tables in db.dat for reading. It seems that db.dat has abandoned records according to my analysis with iriver plus 3. We cannot read the records sequentially. Modified Paths: -------------- trunk/pmplib/lib/pmp_iriverplus3/dat.c Modified: trunk/pmplib/lib/pmp_iriverplus3/dat.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dat.c 2007-01-17 17:44:42 UTC (rev 266) +++ trunk/pmplib/lib/pmp_iriverplus3/dat.c 2007-01-17 18:00:48 UTC (rev 267) @@ -110,25 +110,11 @@ return size; } -static size_t dat_entry_serialize(dat_entry_t* entry, uint8_t* block, uint8_t* q, uint32_t start, int is_storing) +static size_t dat_entry_serialize(dat_entry_t* entry, uint8_t* block, int is_storing) { int i; uint8_t *p = block; - uint32_t offset; - /* - * Serialize offset address of this entry. - * entry->offset: The offset address in the whole db.dat buffer (e.g., 0x00020123) - * offset (written in db.dat): The one within the chunk (e.g., 0x00000123) - */ - if (is_storing) { - offset = entry->offset - start; - q -= serialize_uint32be(q, &offset, is_storing); - } else { - q -= serialize_uint32be(q, &offset, is_storing); - entry->offset = offset + start; - } - /* Serialize all fields in this entry. */ for (i = 0;i < entry->num_fields;++i) { ip3db_variant_t* var = &entry->fields[i]; @@ -236,10 +222,14 @@ /* Read the new records. */ for (i = 0;i < header->num_entries;++i) { + uint32_t offset = 0; dat_entry_t* entry = &list->entries[list->num_entries+i]; - entry->offset = (uint32_t)(p - buffer); /* compute the current offset address */ - p += dat_entry_serialize(entry, p, q, start, 0); - q -= sizeof(uint32_t); + + /* Read the offset table. */ + q -= serialize_uint32be(q, &offset, 0); + entry->offset = offset + start; + + p += dat_entry_serialize(entry, buffer + entry->offset, 0); } list->num_entries += header->num_entries; @@ -259,14 +249,18 @@ /* Write records. */ while (i < list->num_entries) { + uint32_t offset = 0; size_t free_space = (size_t)(q-p); dat_entry_t* entry = &list->entries[i]; if (free_space < dat_entry_size(entry)) { break; } entry->offset = (uint32_t)(p - buffer); /* compute the current offset address */ - p += dat_entry_serialize(entry, p, q, start, 1); - q -= sizeof(uint32_t); + + offset = entry->offset - start; + q -= serialize_uint32be(q, &offset, 1); + + p += dat_entry_serialize(entry, p, 1); header->num_entries++; i++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-17 17:44:44
|
Revision: 266 http://svn.sourceforge.net/pmplib/?rev=266&view=rev Author: nyaochi Date: 2007-01-17 09:44:42 -0800 (Wed, 17 Jan 2007) Log Message: ----------- Incremental commit before fixing a bug. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/common/database.c trunk/pmplib/include/pmp.h Modified: trunk/pmplib/frontend/easypmp/common/database.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/database.c 2007-01-17 16:31:59 UTC (rev 265) +++ trunk/pmplib/frontend/easypmp/common/database.c 2007-01-17 17:44:42 UTC (rev 266) @@ -300,11 +300,11 @@ int database_dump(pmp_t* pmp, FILE *fp, int level) { - pmp_music_t* pmpdb = pmp->music; - if (!pmpdb) { + pmp_music_t* music = pmp->music; + if (!music) { return 1; } - pmpdb->dump(pmpdb, fp, level); + music->dump(music, fp, level); return 0; } Modified: trunk/pmplib/include/pmp.h =================================================================== --- trunk/pmplib/include/pmp.h 2007-01-17 16:31:59 UTC (rev 265) +++ trunk/pmplib/include/pmp.h 2007-01-17 17:44:42 UTC (rev 266) @@ -115,7 +115,6 @@ #define PMPCODEC_WAV PMPFOURCC('W','A','V','E') /**< Microsoft Riff WAVE */ #define PMPMAXCODECS 32 -#define PMPMAXEXT 8 enum { PMPPEF_NONE = 0x0000, @@ -318,9 +317,10 @@ void* instance; pmp_t* pmp; - result_t (*set_records)(pmp_music_t* pmpdb, const pmp_music_record_t* records, uint32_t num_records); - result_t (*get_records)(pmp_music_t* pmpdb, pmp_music_record_t* records, uint32_t* num_records); - result_t (*set_playlists)(pmp_music_t* pmpdb, const pmp_playlist_t* playlists, uint32_t num_playlists); + result_t (*set_records)(pmp_music_t* music, const pmp_music_record_t* records, uint32_t num_records); + result_t (*get_records)(pmp_music_t* music, pmp_music_record_t* records, uint32_t* num_records); + result_t (*set_playlists)(pmp_music_t* music, const pmp_playlist_t* playlists, uint32_t num_playlists); + result_t (*get_playlists)(pmp_music_t* music, pmp_playlist_t* playlists, uint32_t* num_playlists); result_t (*dump)(pmp_music_t* pmpdb, FILE *fp, int level); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-17 16:32:03
|
Revision: 265 http://svn.sourceforge.net/pmplib/?rev=265&view=rev Author: nyaochi Date: 2007-01-17 08:31:59 -0800 (Wed, 17 Jan 2007) Log Message: ----------- Incremental commit. Drastic change of the API. This revision broke playlist conversion for all players, music database construction for all players except for iriver E10. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/common/database.c trunk/pmplib/frontend/easypmp/common/enumerate.c trunk/pmplib/frontend/easypmp/common/playlist.c trunk/pmplib/frontend/easypmp/cui/device.c trunk/pmplib/include/pmp.h trunk/pmplib/lib/pmp/pmp.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c Modified: trunk/pmplib/frontend/easypmp/common/database.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/database.c 2007-01-16 16:38:24 UTC (rev 264) +++ trunk/pmplib/frontend/easypmp/common/database.c 2007-01-17 16:31:59 UTC (rev 265) @@ -111,6 +111,7 @@ int result = 0; uint32_t i; result_t res = 0; + ucs2char_t music_path[MAX_PATH]; pmp_music_t* pmpdb = pmp->music; pmp_music_record_t* records = NULL; pmp_music_record_t* old_records = NULL; @@ -121,6 +122,8 @@ return EASYPMPE_CANCEL; } + filepath_combinepath(music_path, MAX_PATH, pmp->info.path_to_root, pmp->info.path_to_music); + /* * Read the existing database for update processing mode. */ @@ -135,7 +138,7 @@ } // Obtain the number of records in the database. - res = pmpdb->get(pmpdb, NULL, &num_old_records); + res = pmpdb->get_records(pmpdb, NULL, &num_old_records); if (res != 0) { result = MAKE_PMP_ERROR(res); goto error_exit; @@ -149,7 +152,7 @@ } // Obtain the records from the database. - res = pmpdb->get(pmpdb, old_records, &num_old_records); + res = pmpdb->get_records(pmpdb, old_records, &num_old_records); if (res != 0) { result = MAKE_PMP_ERROR(res); goto error_exit; @@ -220,7 +223,7 @@ if (gmi_get( record, filename, - pmp->env.path_to_music.path, + music_path, opt->media_info_source, opt->strip_words, opt->num_strip_words @@ -242,7 +245,7 @@ result = EASYPMPE_CANCEL; goto error_exit; } - res = pmpdb->set(pmpdb, records, fl->num_elements); + res = pmpdb->set_records(pmpdb, records, fl->num_elements); if (res != 0) { result = MAKE_PMP_ERROR(res); goto error_exit; Modified: trunk/pmplib/frontend/easypmp/common/enumerate.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/enumerate.c 2007-01-16 16:38:24 UTC (rev 264) +++ trunk/pmplib/frontend/easypmp/common/enumerate.c 2007-01-17 16:31:59 UTC (rev 265) @@ -39,11 +39,6 @@ #include <easypmp.h> -/** - * \addtogroup common - * @{ - */ - typedef struct { const option_t* opt; easypmp_filelist_t* fl; @@ -54,11 +49,20 @@ static int found_music_file(void *instance, const ucs2char_t* found_path, const ucs2char_t* found_file) { + uint32_t i; enumerate_dat_t* ed = (enumerate_dat_t*)instance; + pmp_t* pmp = ed->pmp; pmp_music_t* pmp_music = ed->pmp->music; easypmp_filelist_t* fl = ed->fl; - if (pmp_music->is_supported_ext(pmp_music, found_file)) { + // Check if the file has an extension supported by the target player. + for (i = 0;i < pmp->info.num_audio_extensions;++i) { + if (filepath_hasext(found_file, pmp->info.audio_extensions[i])) { + break; + } + } + + if (i != pmp->info.num_audio_extensions) { // Supported music file. easypmp_filename_t* new_filename = NULL; @@ -98,12 +102,10 @@ ) { enumerate_dat_t ed; + ucs2char_t music_path[MAX_PATH]; // Decode the music path prefix for system path separators - size_t prefix_length = ucs2len(pmp->env.path_to_music.path); - ucs2char_t *music_path = alloca(sizeof(ucs2char_t) * (prefix_length + 1)); - ucs2cpy(music_path, pmp->env.path_to_music.path); - + filepath_combinepath(music_path, MAX_PATH, pmp->info.path_to_root, pmp->info.path_to_music); filepath_decode(music_path); fl->num_elements = 0; @@ -118,7 +120,7 @@ return find_file( music_path, - pmp->env.path_to_music.flag & PMPPEF_RECURSIVE ? 1 : 0, + pmp->info.music_flag & PMPMF_RECURSIVE ? 1 : 0, found_music_file, &ed ); @@ -172,6 +174,7 @@ { int ret = 0; enumerate_dat_t ed; + ucs2char_t path[MAX_PATH]; fl->num_elements = 0; fl->elements = NULL; @@ -184,17 +187,23 @@ ed.instance = instance; if (opt->verb & MODE_PLAYLIST_PLAYLIST) { + // Decode the playlist path prefix for system path separators + filepath_combinepath(path, MAX_PATH, pmp->info.path_to_root, pmp->info.path_to_playlist); + filepath_decode(path); ret = find_file( - pmp->env.path_to_playlist.path, - pmp->env.path_to_playlist.flag & PMPPEF_RECURSIVE ? 1 : 0, + path, + pmp->info.playlist_flag & PMPPF_RECURSIVE ? 1 : 0, found_playlist_file, &ed ); } if (opt->verb & MODE_PLAYLIST_MUSIC) { + // Decode the playlist path prefix for system path separators + filepath_combinepath(path, MAX_PATH, pmp->info.path_to_root, pmp->info.path_to_music); + filepath_decode(path); ret = find_file( - pmp->env.path_to_music.path, - pmp->env.path_to_music.flag & PMPPEF_RECURSIVE ? 1 : 0, + path, + pmp->info.music_flag & PMPMF_RECURSIVE ? 1 : 0, found_playlist_file, &ed ); @@ -210,5 +219,3 @@ free(fl->elements); memset(fl, 0, sizeof(*fl)); } - -/** @} */ Modified: trunk/pmplib/frontend/easypmp/common/playlist.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/playlist.c 2007-01-16 16:38:24 UTC (rev 264) +++ trunk/pmplib/frontend/easypmp/common/playlist.c 2007-01-17 16:31:59 UTC (rev 265) @@ -75,6 +75,7 @@ ) { int result = 0; + /* int i, j, num_succeeded = 0; char *mbs = NULL; pmp_playlist_t* pmppl = NULL; @@ -263,6 +264,7 @@ pmppl->release(pmppl); pmppl = NULL; } + */ return result; } /** @} */ Modified: trunk/pmplib/frontend/easypmp/cui/device.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/device.c 2007-01-16 16:38:24 UTC (rev 264) +++ trunk/pmplib/frontend/easypmp/cui/device.c 2007-01-17 16:31:59 UTC (rev 265) @@ -59,19 +59,17 @@ void device_show_information(pmp_t* pmp, FILE *fp) { - fprintf(fp, "Device identifier: %s\n", pmp->decl.id); - fprintf(fp, " Manufacturer: %s\n", pmp->decl.manufacturer); - fprintf(fp, " Product name: %s\n", pmp->decl.name); - fprintf(fp, " Firmware mode: %s\n", pmp->decl.mode); - fprintf(fp, " Firmware version: %s\n", pmp->decl.version); - fprintf(fp, " Firmware range: %s to %s\n", pmp->decl.min_version, pmp->decl.max_version); - fprintf(fp, " Default language: %s\n", pmp->decl.language); + fprintf(fp, "Device identifier: %s\n", pmp->info.decl.id); + fprintf(fp, " Manufacturer: %s\n", pmp->info.decl.manufacturer); + fprintf(fp, " Product name: %s\n", pmp->info.decl.name); + fprintf(fp, " Firmware mode: %s\n", pmp->info.decl.mode); + fprintf(fp, " Firmware version: %s\n", pmp->info.decl.version); + fprintf(fp, " Firmware range: %s to %s\n", pmp->info.decl.min_version, pmp->info.decl.max_version); + fprintf(fp, " Default language: %s\n", pmp->info.decl.language); - fprints(fp, " Root directory: %s\n", pmp->env.path_to_root.path); - device_show_path(fp, " Music directory: %s\n", pmp->env.path_to_music.path); - device_show_path(fp, " Playlist directory: %s\n", pmp->env.path_to_playlist.path); - - fprints(fp, " Playlist extension: %s\n", pmp->env.playlist_ext); + fprints(fp, " Root directory: %s\n", pmp->info.path_to_root); + device_show_path(fp, " Music directory: %s\n", pmp->info.path_to_music); + device_show_path(fp, " Playlist directory: %s\n", pmp->info.path_to_playlist); } static void enumerate_devid_callback(void *instance, const char *devid) Modified: trunk/pmplib/include/pmp.h =================================================================== --- trunk/pmplib/include/pmp.h 2007-01-16 16:38:24 UTC (rev 264) +++ trunk/pmplib/include/pmp.h 2007-01-17 16:31:59 UTC (rev 265) @@ -53,7 +53,6 @@ */ struct tag_pmp_t; typedef struct tag_pmp_t pmp_t; struct tag_pmp_music_t; typedef struct tag_pmp_music_t pmp_music_t; -struct tag_pmp_playlist_t; typedef struct tag_pmp_playlist_t pmp_playlist_t; /** * Error codes. @@ -109,11 +108,15 @@ #define PMPFOURCC(a, b, c, d) \ ((uint32_t)(a) << 24 | (uint32_t)(b) << 16 | (uint32_t)(c) << 8 | (uint32_t)(d)) +#define PMPCODEC_NONE PMPFOURCC(' ',' ',' ',' ') #define PMPCODEC_MPEGLAYER3 PMPFOURCC('M','P','1','3') /**< MPEG Audio Layer III */ #define PMPCODEC_WMA PMPFOURCC('W','M','A',' ') /**< Windows Media Audio */ #define PMPCODEC_VORBIS PMPFOURCC('O','V','1',' ') /**< Ogg Vorbis */ #define PMPCODEC_WAV PMPFOURCC('W','A','V','E') /**< Microsoft Riff WAVE */ +#define PMPMAXCODECS 32 +#define PMPMAXEXT 8 + enum { PMPPEF_NONE = 0x0000, PMPPEF_SUPPORT = 0x0001, @@ -121,11 +124,19 @@ PMPPEF_RECURSIVE = 0x0004, }; -typedef struct { - int flag; - ucs2char_t path[MAX_PATH]; -} pmp_pathenv_t; +enum { + PMPMF_NONE = 0x0000, + PMPMF_SUPPORT = 0x0001, + PMPMF_RECURSIVE = 0x0002, +}; +enum { + PMPPF_NONE = 0x0000, + PMPPF_SUPPORT = 0x0001, + PMPPF_RECURSIVE = 0x0002, +}; + + /** Maximum size, in chars, of a device description. */ #define PMP_DECLSIZE (128) /** Unavailable field of a device description. */ @@ -133,7 +144,7 @@ /** * PMP device decription. - * This structure stores information about a PMP device. An PMP device driver + * This structure stores information about a PMP device. A PMP device driver * should fill these fields properly so that an application can obtain the * information about the device. An empty value represents the uncertainity * of the field value at this stage. The value ::PMP_DECLUNAVAIL (\c "***") @@ -160,18 +171,39 @@ /** * PMP device environment. - * This structure stores + * This structure stores information about predefined paths, capability, */ typedef struct { - pmp_pathenv_t path_to_root; /**< Path to the root directory */ - pmp_pathenv_t path_to_music; /**< Path to the music files */ - pmp_pathenv_t path_to_playlist; /**< Path to the playlist files */ - pmp_pathenv_t path_to_photo; /**< Path to the photo files */ - ucs2char_t playlist_ext[MAX_PATH]; -} pmp_device_environment_t; + /** Path to the root directory of the player. */ + ucs2char_t path_to_root[MAX_PATH]; + /** Relative path to the system directory from the root. */ + ucs2char_t path_to_system[MAX_PATH]; + /** Relative path to the music directory from the root. */ + ucs2char_t path_to_music[MAX_PATH]; + /** Relative path to the playlist directory from the root. */ + ucs2char_t path_to_playlist[MAX_PATH]; + /** Music flags. */ + uint32_t music_flag; + /** Playlist flags. */ + uint32_t playlist_flag; + /** Number of elements in \a audio_codecs array. */ + uint32_t num_audio_codecs; + /** Array of PMPFOURCC values corresponding to the supported audio codecs. */ + uint32_t* audio_codecs; + /** Number of elements in \a audio_extensions array. */ + uint32_t num_audio_extensions; + /** Array of ucs2char_t string values for audio file extensions. */ + ucs2char_t** audio_extensions; + + /** Description about the device. */ + const pmp_device_description_t decl; +} pmp_device_information_t; + + + /** * The root interface for portable media device. * This structure represents the basic interface that is common to any @@ -206,12 +238,10 @@ */ uint32_t flag; - pmp_device_description_t decl; - /** - * Portable media device environment. + * PMP device decription. */ - pmp_device_environment_t env; + pmp_device_information_t info; /** * The pointer to pmp_music_t interface. @@ -220,7 +250,7 @@ /** * Increment the reference counter. - * @param pmp Ths pointer to the pmp_t instance. + * @param pmp The pointer to the pmp_t instance. */ uint32_t (*add_ref)(pmp_t* pmp); @@ -228,14 +258,23 @@ * Decrement the reference counter. * If the reference counter becomes zero after this decrement, * this function will destroy the pmp_t instance. - * @param pmp Ths pointer to the pmp_t instance. + * @param pmp The pointer to the pmp_t instance. */ uint32_t (*release)(pmp_t* pmp); + /** + * Open the PMP device. + * @param pmp The pointer to the pmp_t instance. + * @param flag The open flags. + */ result_t (*open)(pmp_t* pmp, uint32_t flag); + + /** + * Close the PMP device. + * @param pmp The pointer to the pmp_t instance. + * @param flag The close flags. + */ result_t (*close)(pmp_t* pmp, uint32_t flag); - - result_t (*create_instance_pl)(pmp_t* pmp, pmp_playlist_t** pmppl); }; typedef void pmpdb_readwrite_progress_t(void *instance, uint32_t size, uint32_t total); @@ -265,30 +304,28 @@ }; typedef struct tag_pmp_music_record_t pmp_music_record_t; +typedef struct { + ucs2char_t filename[MAX_PATH]; +} pmp_playlist_entry_t; + +typedef struct { + ucs2char_t name[MAX_PATH]; + int num_entries; + pmp_playlist_entry_t* entries; +} pmp_playlist_t; + struct tag_pmp_music_t { void* instance; pmp_t* pmp; - result_t (*set)(pmp_music_t* pmpdb, const pmp_music_record_t* records, uint32_t num_records); - result_t (*get)(pmp_music_t* pmpdb, pmp_music_record_t* records, uint32_t* num_records); + result_t (*set_records)(pmp_music_t* pmpdb, const pmp_music_record_t* records, uint32_t num_records); + result_t (*get_records)(pmp_music_t* pmpdb, pmp_music_record_t* records, uint32_t* num_records); + result_t (*set_playlists)(pmp_music_t* pmpdb, const pmp_playlist_t* playlists, uint32_t num_playlists); result_t (*dump)(pmp_music_t* pmpdb, FILE *fp, int level); - - int (*is_supported_codec)(pmp_music_t* pmpdb, uint32_t codec); - int (*is_supported_ext)(pmp_music_t* pmpdb, const ucs2char_t* filename); }; -struct tag_pmp_playlist_t { - void* instance; - uint32_t ref_count; - pmp_t* pmp; - uint32_t (*add_ref)(pmp_playlist_t* pmppl); - uint32_t (*release)(pmp_playlist_t* pmppl); - - result_t (*write)(pmp_playlist_t* pmppl, const ucs2char_t* filename, ucs2char_t * const files[], uint32_t num_files); -}; - typedef result_t (*pmp_create_t)(pmp_t** pmp, const ucs2char_t* path_to_device, const char *devid); /** @@ -303,7 +340,6 @@ PMPAPI result_t pmp_record_copy(pmp_music_record_t* dst, const pmp_music_record_t* src); PMPAPI uint32_t pmp_interlocked_increment(uint32_t* count); PMPAPI uint32_t pmp_interlocked_decrement(uint32_t* count); -PMPAPI void pmp_copy_environment(pmp_device_environment_t* dst, const pmp_device_environment_t* src); Modified: trunk/pmplib/lib/pmp/pmp.c =================================================================== --- trunk/pmplib/lib/pmp/pmp.c 2007-01-16 16:38:24 UTC (rev 264) +++ trunk/pmplib/lib/pmp/pmp.c 2007-01-17 16:31:59 UTC (rev 265) @@ -62,8 +62,3 @@ dst->date = src->date ? ucs2dup(src->date) : NULL; return 0; } - -void pmp_copy_environment(pmp_device_environment_t* dst, const pmp_device_environment_t* src) -{ - memcpy(dst, src, sizeof(*src)); -} Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-16 16:38:24 UTC (rev 264) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-17 16:31:59 UTC (rev 265) @@ -56,6 +56,9 @@ const char *dat_filename; const char *dic_filename; const char *idx_filename; + const char *extensions; + uint32_t codecs[8]; + const char *path_to_system; const char *path_to_music; const char *path_to_playlist; const char *playlist_ext; @@ -63,154 +66,155 @@ static const ip3model_descriptor_t g_model_descriptions[] = { { - "iriver_e10_ums_1.00-1.04", "iriver", "E10 UMS", "UM", - "1.00", "1.04", + "iriver_e10_ums_1.0-1.4", "iriver", "E10 UMS", "UM", + "1.0", "1.4", "System\\E10.SYS", "System\\db.dat", "System\\db.dic", "System\\db.idx", - "", "Playlists\\", + ".mp3\0.ogg\0.wma\0.wav\0", + {PMPCODEC_MPEGLAYER3, PMPCODEC_VORBIS, PMPCODEC_WMA, PMPCODEC_WAV, 0, 0, 0, 0}, + "System\\", "", "Playlists\\", ".plp", }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, + {0, 0, 0, 0, 0, 0, 0, 0}, NULL, NULL, NULL, }, }; typedef struct { - char id[128]; - char name[128]; - char mode[128]; - char language[128]; - char version[128]; - - ucs2char_t path_to_root[MAX_PATH]; - ucs2char_t path_to_music[MAX_PATH]; - ucs2char_t path_to_playlist[MAX_PATH]; - ucs2char_t sys_filename[MAX_PATH]; - ucs2char_t dat_filename[MAX_PATH]; - ucs2char_t dic_filename[MAX_PATH]; - ucs2char_t idx_filename[MAX_PATH]; - ucs2char_t playlist_ext[MAX_PATH]; -} ip3_environment_t; - - -typedef struct { - ip3_environment_t env; + const ip3model_descriptor_t* decl; } pmp_internal_t; -typedef struct { - ip3db_t ip3db; -} pmpdb_internal_t; - -typedef struct { - ip3db_t ip3db; -} pmppl_internal_t; - - static uint32_t pmp_add_ref(pmp_t* pmp); static uint32_t pmp_release(pmp_t* pmp); static result_t pmp_open(pmp_t* pmp, uint32_t flag); static result_t pmp_close(pmp_t* pmp, uint32_t flag); -static result_t pmp_create_instance_db(pmp_t* pmp, pmp_music_t** ptr_pmpdb); -static result_t pmp_create_instance_pl(pmp_t* pmp, pmp_playlist_t** ptr_pmppl); +static result_t pmp_create_instance_music(pmp_t* pmp, pmp_music_t** ptr_pmpdb); -static uint32_t pmpdb_release(pmp_music_t* pmpdb); -static result_t pmpdb_read(pmp_music_t* pmpdb); -static result_t pmpdb_write(pmp_music_t* pmpdb); -static result_t pmpdb_set(pmp_music_t* pmpdb, const pmp_music_record_t* records, uint32_t num_records); -static result_t pmpdb_get(pmp_music_t* pmpdb, pmp_music_record_t* records, uint32_t* num_records); -static result_t pmpdb_dump(pmp_music_t* pmpdb, FILE *fp, int level); -static int pmpdb_is_supported_codec(pmp_music_t* pmpdb, uint32_t codec); -static int pmpdb_is_supported_ext(pmp_music_t* pmpdb, const ucs2char_t* filename); +static uint32_t pmpmusic_release(pmp_music_t* pmpdb); +static result_t pmpmusic_set_records(pmp_music_t* pmpdb, const pmp_music_record_t* records, uint32_t num_records); +static result_t pmpmusic_get_records(pmp_music_t* pmpdb, pmp_music_record_t* records, uint32_t* num_records); +static result_t pmpmusic_dump(pmp_music_t* pmpdb, FILE *fp, int level); +static result_t pmpmusic_set_playlists(pmp_music_t* pmpdb, const pmp_playlist_t* playlists, uint32_t num_playlists); -static uint32_t pmppl_add_ref(pmp_playlist_t* pmppl); -static uint32_t pmppl_release(pmp_playlist_t* pmppl); -static result_t pmppl_write(pmp_playlist_t* pmppl, const ucs2char_t* filename, ucs2char_t* const files[], uint32_t num_files); +#define COMP(a, b) ((a)>(b))-((a)<(b)) -static void set_environment( - ip3_environment_t* env, +static char* strip(char *str) +{ + char *p = str + strlen(str) - 1; + while (*str && isspace(*str)) { + str++; + } + while (str <= p && isspace(*p)) { + *p-- = 0; + } + return str; +} + +static const char *strcpy_if_empty(char *dst, const char *src) +{ + return *dst ? dst : strcpy(dst, src); +} + +static void set_device_info( + const char *id, + const ucs2char_t* path_to_device, const ip3model_descriptor_t* md, - const ucs2char_t* path_to_device + pmp_device_information_t* info ) { + uint32_t n; + const char *p = NULL; ucs2char_t* ucs2 = NULL; + pmp_device_description_t* decl = (pmp_device_description_t*)&info->decl; - ucs2cpy(env->path_to_root, path_to_device); + strcpy_if_empty(decl->id, id); + strcpy_if_empty(decl->manufacturer, md->manufacturer); + strcpy_if_empty(decl->name, md->name); + strcpy_if_empty(decl->mode, md->mode); + //strcpy_if_empty(decl->language, md->language); + //strcpy_if_empty(decl->version, md->version); + strcpy_if_empty(decl->min_version, md->min_version); + strcpy_if_empty(decl->max_version, md->max_version); - ucs2cpy(env->path_to_music, path_to_device); - filepath_addslash(env->path_to_music); + ucs2cpy(info->path_to_root, path_to_device); + + ucs2 = mbsdupucs2(md->path_to_system); + ucs2cpy(info->path_to_system, ucs2); + ucs2free(ucs2); + ucs2 = mbsdupucs2(md->path_to_music); - ucs2cat(env->path_to_music, ucs2); + ucs2cpy(info->path_to_music, ucs2); ucs2free(ucs2); - ucs2cpy(env->path_to_playlist, path_to_device); - filepath_addslash(env->path_to_playlist); ucs2 = mbsdupucs2(md->path_to_playlist); - ucs2cat(env->path_to_playlist, ucs2); + ucs2cpy(info->path_to_playlist, ucs2); ucs2free(ucs2); - ucs2cpy(env->sys_filename, path_to_device); - filepath_addslash(env->sys_filename); - ucs2 = mbsdupucs2(md->sys_filename); - ucs2cat(env->sys_filename, ucs2); - ucs2free(ucs2); + info->music_flag = PMPMF_SUPPORT | PMPMF_RECURSIVE; + info->playlist_flag = PMPPF_SUPPORT; - ucs2cpy(env->dat_filename, path_to_device); - filepath_addslash(env->dat_filename); - ucs2 = mbsdupucs2(md->dat_filename); - ucs2cat(env->dat_filename, ucs2); - ucs2free(ucs2); + // Audio codecs. + for (n = 0;md->codecs[n];++n) ; + info->num_audio_codecs = n; + info->audio_codecs = (uint32_t*)ucs2malloc(sizeof(uint32_t) * info->num_audio_codecs); + for (n = 0;n < info->num_audio_codecs;++n) { + info->audio_codecs[n] = md->codecs[n]; + } - ucs2cpy(env->dic_filename, path_to_device); - filepath_addslash(env->dic_filename); - ucs2 = mbsdupucs2(md->dic_filename); - ucs2cat(env->dic_filename, ucs2); - ucs2free(ucs2); + // Obtain the number of extensions separated by '\0' characters. + for (n = 0, p = md->extensions;*p;p += (strlen(p)+1)) { + n++; + } + info->num_audio_extensions = n; + info->audio_extensions = (ucs2char_t*)ucs2malloc(sizeof(ucs2char_t*) * info->num_audio_extensions); + for (n = 0, p = md->extensions;*p;p += (strlen(p)+1)) { + info->audio_extensions[n++] = mbsdupucs2(p); + } - ucs2cpy(env->idx_filename, path_to_device); - filepath_addslash(env->idx_filename); - ucs2 = mbsdupucs2(md->idx_filename); - ucs2cat(env->idx_filename, ucs2); - ucs2free(ucs2); - ucs2 = mbsdupucs2(md->playlist_ext); - ucs2cat(env->playlist_ext, ucs2); - ucs2free(ucs2); } -static int match_model( - const char *id, - const ucs2char_t* path_to_device, - const ip3model_descriptor_t* md, - ip3_environment_t* env - ) +static void free_device_info(pmp_device_information_t* info) { - memset(env, 0, sizeof(*env)); - - if (!id || strcmp(md->id, id) != 0) { - return 0; + uint32_t i; + for (i = 0;i < info->num_audio_extensions;++i) { + ucs2free(info->audio_extensions[i]); } - - set_environment(env, md, path_to_device); - return 1; + ucs2free(info->audio_codecs); + ucs2free(info->audio_extensions); + memset(info, 0, sizeof(*info)); } -static char* strip(char *str) +static void set_filenames(ucs2char_t *dat, ucs2char_t *dic, ucs2char_t *idx, pmp_t *pmp) { - char *p = str + strlen(str) - 1; - while (*str && isspace(*str)) { - str++; - } - while (str <= p && isspace(*p)) { - *p-- = 0; - } - return str; + ucs2char_t* ucs2 = NULL; + pmp_internal_t* pmpi = (pmp_internal_t*)pmp->instance; + + ucs2cpy(dat, pmp->info.path_to_root); + filepath_addslash(dat); + ucs2 = mbsdupucs2(pmpi->decl->dat_filename); + ucs2cat(dat, ucs2); + ucs2free(ucs2); + + ucs2cpy(dic, pmp->info.path_to_root); + filepath_addslash(dic); + ucs2 = mbsdupucs2(pmpi->decl->dic_filename); + ucs2cat(dic, ucs2); + ucs2free(ucs2); + + ucs2cpy(idx, pmp->info.path_to_root); + filepath_addslash(idx); + ucs2 = mbsdupucs2(pmpi->decl->idx_filename); + ucs2cat(idx, ucs2); + ucs2free(ucs2); } -#define COMP(a, b) ((a)>(b))-((a)<(b)) static int compare_version(const char *x, const char *y) { @@ -234,19 +238,23 @@ static int detect_model( const ucs2char_t* path_to_device, const ip3model_descriptor_t* md, - ip3_environment_t* env + pmp_device_information_t* ptr_info ) { ucs2char_t* ucs2 = NULL; ucs2char_t filename[MAX_PATH]; + pmp_device_description_t decl; - memset(env, 0, sizeof(*env)); + memset(&decl, 0, sizeof(decl)); + // filename = "${path_to_device}/${md->sys_filename}" ucs2cpy(filename, path_to_device); filepath_addslash(filename); ucs2 = mbsdupucs2(md->sys_filename); ucs2cat(filename, ucs2); ucs2free(ucs2); + + // Check the existence of the system file. if (filepath_file_exists(filename)) { int match = 1; char line[128]; @@ -259,32 +267,25 @@ char *p = strip(line); if (p[0] == '[' && line[strlen(p)-1] == ']') { p[strlen(p)-1] = 0; - strcpy(env->name, p+1); + strcpy(decl.name, p+1); } else if (strncmp(p, "version = ", 10) == 0) { - /* They are too stupid to describe version "1.04" as "1.4" */ - if (strlen(p+10) == 3 && p[11] == '.') { - env->version[0] = p[10]; - env->version[1] = p[11]; - env->version[2] = '0'; - env->version[3] = p[12]; - env->version[4] = 0; - } else { - strcpy(env->version, p+10); - } + strcpy(decl.version, p+10); } else if (strncmp(p, "language = ", 11) == 0) { - strcpy(env->language, p+11); + strcpy(decl.language, p+11); } else if (strncmp(p, "mode = ", 7) == 0) { - strcpy(env->mode, p+7); + strcpy(decl.mode, p+7); } } + fclose(fp); - match &= (strcmp(env->mode, md->mode) == 0); - match &= (compare_version(md->min_version, env->version) <= 0); - match &= (compare_version(env->version, md->max_version) <= 0); + // Test the compability of the device. + match &= (strcmp(decl.mode, md->mode) == 0); + match &= (compare_version(md->min_version, decl.version) <= 0); + match &= (compare_version(decl.version, md->max_version) <= 0); if (match) { - set_environment(env, md, path_to_device); + memcpy((pmp_device_description_t*)&ptr_info->decl, &decl, sizeof(decl)); return 1; } } @@ -308,25 +309,32 @@ pmp_t* pmp = NULL; pmp_internal_t* pmpi = NULL; const ip3model_descriptor_t* md = NULL; - ip3_environment_t env; - pmp_device_environment_t* pmpenv = NULL; + pmp_device_information_t info; + // Initialize device information. + memset(&info, 0, sizeof(info)); + + // Return a NULL pointer by default. *ptr_pmp = 0; // Find a suitable model for the device. md = g_model_descriptions; for (;md->id;++md) { - if (detect_model(path_to_device, md, &env)) { - if (!id || !id[0]) { + if (id && *id) { + // Match the device identifier. + if (strcmp(md->id, id) == 0) { + // This will fill some members in decl. + detect_model(path_to_device, md, &info); + set_device_info(id, path_to_device, md, &info); break; } - if (strcmp(md->id, id) == 0) { + } else { + // Detect the model automatically. + if (detect_model(path_to_device, md, &info)) { + set_device_info(md->id, path_to_device, md, &info); break; } } - if (match_model(id, path_to_device, md, &env)) { - break; - } } if (!md->id) { return PMP_DEVICENOTFOUND; @@ -342,7 +350,6 @@ pmp->release = pmp_release; pmp->open = pmp_open; pmp->close = pmp_close; - pmp->create_instance_pl = pmp_create_instance_pl; pmp->add_ref(pmp); // Allocate the internal variables. @@ -351,32 +358,14 @@ free(pmp); return PMPDBE_OUTOFMEMORY; } - pmp->instance = pmpi; + pmpi->decl = md; // Initialize the internal variables. - memcpy(&pmpi->env, &env, sizeof(env)); + pmp->instance = pmpi; + memcpy((pmp_device_information_t*)&pmp->info, &info, sizeof(info)); - // Initialize the (exportable) env. - strcpy(pmp->decl.id, md->id); - strcpy(pmp->decl.manufacturer, md->manufacturer); - strcpy(pmp->decl.name, md->name); - strcpy(pmp->decl.mode, md->mode); - strcpy(pmp->decl.language, pmpi->env.language); - strcpy(pmp->decl.version, pmpi->env.version); - strcpy(pmp->decl.min_version, md->min_version); - strcpy(pmp->decl.max_version, md->max_version); - - pmpenv = &pmp->env; - pmpenv->path_to_root.flag = PMPPEF_SUPPORT | PMPPEF_CONSTANT; - ucs2cpy(pmpenv->path_to_root.path, pmpi->env.path_to_root); - pmpenv->path_to_music.flag = PMPPEF_SUPPORT | PMPPEF_RECURSIVE; - ucs2cpy(pmpenv->path_to_music.path, pmpi->env.path_to_music); - pmpenv->path_to_playlist.flag = PMPPEF_SUPPORT; - ucs2cpy(pmpenv->path_to_playlist.path, pmpi->env.path_to_playlist); - ucs2cpy(pmpenv->playlist_ext, pmpi->env.playlist_ext); - // Create music instance. - ret = pmp_create_instance_db(pmp, &pmp->music); + ret = pmp_create_instance_music(pmp, &pmp->music); if (ret != 0) { pmp_release(pmp); return ret; @@ -396,7 +385,8 @@ { uint32_t count = pmp_interlocked_decrement(&pmp->ref_count); if (count == 0) { - pmpdb_release(pmp->music); + pmpmusic_release(pmp->music); + free_device_info(&pmp->info); free(pmp->instance); free(pmp); } @@ -409,10 +399,11 @@ pmp->flag = flag; if (pmp->flag & PMPOF_MUSIC_DB_READ) { - ret = pmpdb_read(pmp->music); - if (ret != 0) { - return ret; - } + ucs2char_t dat[MAX_PATH], dic[MAX_PATH], idx[MAX_PATH]; + ip3db_t* ip3db = (ip3db_t*)pmp->music->instance; + + set_filenames(dat, dic, idx, pmp); + return ip3db_read(ip3db, dat, dic, idx); } return 0; } @@ -421,76 +412,43 @@ { result_t ret = 0; if (pmp->flag & PMPOF_MUSIC_DB_WRITE) { - ret = pmpdb_write(pmp->music); - if (ret != 0) { - return ret; - } - } - return 0; -} + ucs2char_t dat[MAX_PATH], dic[MAX_PATH], idx[MAX_PATH]; + ip3db_t* ip3db = (ip3db_t*)pmp->music->instance; -static result_t pmp_create_instance_db(pmp_t* pmp, pmp_music_t** ptr_pmpdb) -{ - pmp_music_t* pmpdb = NULL; - pmp_internal_t* pmpi = (pmp_internal_t*)pmp->instance; - pmpdb_internal_t* pmpdbi = NULL; - - *ptr_pmpdb = 0; - - pmpdb = calloc(1, sizeof(pmp_music_t)); - if (!pmpdb) { - return PMPDBE_OUTOFMEMORY; + set_filenames(dat, dic, idx, pmp); + return ip3db_write(ip3db, dat, dic, idx); } - - pmpdb->set = pmpdb_set; - pmpdb->get = pmpdb_get; - pmpdb->dump = pmpdb_dump; - pmpdb->is_supported_codec = pmpdb_is_supported_codec; - pmpdb->is_supported_ext = pmpdb_is_supported_ext; - - pmpdbi = calloc(1, sizeof(pmpdb_internal_t)); - if (!pmpdbi) { - free(pmpdb); - return PMPDBE_OUTOFMEMORY; - } - ip3db_init(&pmpdbi->ip3db); - - pmpdb->pmp = pmp; - pmpdb->instance = pmpdbi; - - *ptr_pmpdb = pmpdb; return 0; } -static result_t pmp_create_instance_pl(pmp_t* pmp, pmp_playlist_t** ptr_pmppl) +static result_t pmp_create_instance_music(pmp_t* pmp, pmp_music_t** ptr_music) { + ip3db_t* ip3db = NULL; + pmp_music_t* music = NULL; pmp_internal_t* pmpi = (pmp_internal_t*)pmp->instance; - pmp_playlist_t* pmppl = NULL; - pmppl_internal_t* pmppli = NULL; - *ptr_pmppl = 0; + *ptr_music = 0; - pmppl = calloc(1, sizeof(pmp_playlist_t)); - if (!pmppl) { + music = calloc(1, sizeof(pmp_music_t)); + if (!music) { return PMPDBE_OUTOFMEMORY; } - pmppl->add_ref = pmppl_add_ref; - pmppl->release = pmppl_release; - pmppl->write = pmppl_write; - - pmppli = calloc(1, sizeof(pmppl_internal_t)); - if (!pmppli) { - free(pmppl); + ip3db = calloc(1, sizeof(ip3db_t)); + if (!ip3db) { + free(music); return PMPDBE_OUTOFMEMORY; } - ip3db_init(&pmppli->ip3db); - ip3db_read(&pmppli->ip3db, pmpi->env.dat_filename, pmpi->env.dic_filename, pmpi->env.idx_filename); + ip3db_init(ip3db); - pmppl->pmp = pmp; - pmppl->instance = pmppli; + music->set_records = pmpmusic_set_records; + music->get_records = pmpmusic_get_records; + music->dump = pmpmusic_dump; + music->set_playlists = pmpmusic_set_playlists; + music->pmp = pmp; + music->instance = ip3db; - *ptr_pmppl = pmppl; + *ptr_music = music; return 0; } @@ -498,39 +456,15 @@ -static uint32_t pmpdb_release(pmp_music_t* pmpdb) +static uint32_t pmpmusic_release(pmp_music_t* pmpmusic) { - pmpdb_internal_t* pmpdbi = (pmpdb_internal_t*)pmpdb->instance; - ip3db_finish(&pmpdbi->ip3db); - free(pmpdb->instance); - free(pmpdb); + ip3db_t* ip3db = (ip3db_t*)pmpmusic->instance; + ip3db_finish(ip3db); + free(pmpmusic->instance); + free(pmpmusic); return 0; } -static result_t pmpdb_read(pmp_music_t* pmpdb) -{ - pmpdb_internal_t* pmpdbi = (pmpdb_internal_t*)pmpdb->instance; - pmp_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; - return ip3db_read( - &pmpdbi->ip3db, - pmpi->env.dat_filename, - pmpi->env.dic_filename, - pmpi->env.idx_filename - ); -} - -static result_t pmpdb_write(pmp_music_t* pmpdb) -{ - pmpdb_internal_t* pmpdbi = (pmpdb_internal_t*)pmpdb->instance; - pmp_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; - return ip3db_write( - &pmpdbi->ip3db, - pmpi->env.dat_filename, - pmpi->env.dic_filename, - pmpi->env.idx_filename - ); -} - static ucs2char_t* _filepath_removeslash(ucs2char_t* path) { size_t length = ucs2len(path)-1; @@ -541,10 +475,11 @@ return (path + length); } -static result_t pmpdb_set(pmp_music_t* pmpdb, const pmp_music_record_t* records, uint32_t num_records) +static result_t pmpmusic_set_records(pmp_music_t* pmpdb, const pmp_music_record_t* records, uint32_t num_records) { - int i; - pmpdb_internal_t* pmpdbi = (pmpdb_internal_t*)pmpdb->instance; + uint32_t i; + pmp_t* pmp = pmpdb->pmp; + ip3db_t* ip3db = (ip3db_t*)pmpdb->instance; pmp_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; ip3db_music_record_t* array = (ip3db_music_record_t*)malloc(sizeof(ip3db_music_record_t) * num_records); @@ -552,8 +487,8 @@ const pmp_music_record_t* src = &records[i]; ip3db_variant_t* dst = array[i]; - ip3db_record_init(&pmpdbi->ip3db, &array[i]); - ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILEPATH], filepath_skipdrive(src->filename, pmpi->env.path_to_root)); + ip3db_record_init(ip3db, &array[i]); + ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILEPATH], filepath_skipdrive(src->filename, pmp->info.path_to_root)); filepath_remove_filespec(dst[IP3DBF_MUSIC_FILEPATH].value.str); filepath_addslash(dst[IP3DBF_MUSIC_FILEPATH].value.str); filepath_slash(dst[IP3DBF_MUSIC_FILEPATH].value.str); @@ -581,18 +516,18 @@ ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_UID], (uint32_t)i+1); } - ip3db_set(&pmpdbi->ip3db, array, num_records); + ip3db_set(ip3db, array, num_records); free(array); return 0; } -static result_t pmpdb_get(pmp_music_t* pmpdb, pmp_music_record_t* records, uint32_t* num_records) +static result_t pmpmusic_get_records(pmp_music_t* pmpdb, pmp_music_record_t* records, uint32_t* num_records) { - pmpdb_internal_t* pmpdbi = (pmpdb_internal_t*)pmpdb->instance; + pmp_t* pmp = pmpdb->pmp; + ip3db_t* ip3db = (ip3db_t*)pmpdb->instance; pmp_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; - ucs2char_t *path_to_root = alloca(sizeof(ucs2char_t) * (ucs2len(pmpi->env.path_to_root)+1)); - ip3db_t* db = &pmpdbi->ip3db; - int i, n = ip3db_num_records(db); + ucs2char_t *path_to_root = alloca(sizeof(ucs2char_t) * (ucs2len(pmp->info.path_to_root)+1)); + int i, n = ip3db_num_records(ip3db); if (!records) { *num_records = (uint32_t)n; @@ -600,17 +535,17 @@ } for (i = 0;i < n;++i) { - const ip3db_variant_t* src = (const ip3db_variant_t*)ip3db_get_record(db, i); + const ip3db_variant_t* src = (const ip3db_variant_t*)ip3db_get_record(ip3db, i); pmp_music_record_t* dst = &records[i]; size_t length = 0; pmp_record_init(dst); - length = ucs2len(pmpi->env.path_to_root); + length = ucs2len(pmp->info.path_to_root); length += ucs2len(src[IP3DBF_MUSIC_FILEPATH].value.str); length += ucs2len(src[IP3DBF_MUSIC_FILENAME].value.str); dst->filename = (ucs2char_t*)ucs2malloc(sizeof(ucs2char_t) * (length+1)); - ucs2cpy(dst->filename, pmpi->env.path_to_root); + ucs2cpy(dst->filename, pmp->info.path_to_root); ucs2cat(dst->filename, src[IP3DBF_MUSIC_FILEPATH].value.str+1); ucs2cat(dst->filename, src[IP3DBF_MUSIC_FILENAME].value.str); filepath_backslash(dst->filename); @@ -640,65 +575,25 @@ return 0; } -static result_t pmpdb_dump(pmp_music_t* pmpdb, FILE *fp, int level) +static result_t pmpmusic_dump(pmp_music_t* pmpmusic, FILE *fp, int level) { - pmpdb_internal_t* pmpdbi = (pmpdb_internal_t*)pmpdb->instance; + ip3db_t* ip3db = (ip3db_t*)pmpmusic->instance; if (level > 0) { return PMP_NOTIMPLIMENTED; //return ip2db_repr(&pmpdbi->ip2db, fp); } else { - return ip3db_dump(&pmpdbi->ip3db, fp); + return ip3db_dump(ip3db, fp); } } -static int pmpdb_is_supported_codec(pmp_music_t* pmpdb, uint32_t codec) +static result_t pmpmusic_set_playlists(pmp_music_t* pmpmusic, const pmp_playlist_t* playlists, uint32_t num_playlists) { - return ( - (codec == PMPCODEC_MPEGLAYER3) || - (codec == PMPCODEC_WMA) || - (codec == PMPCODEC_VORBIS) - ) ? 1 : 0; -} - -static int pmpdb_is_supported_ext(pmp_music_t* pmpdb, const ucs2char_t* filename) -{ - static const ucs2char_t ucs2cs_mp3[] = {'.','m','p','3',0}; - static const ucs2char_t ucs2cs_wma[] = {'.','w','m','a',0}; - static const ucs2char_t ucs2cs_ogg[] = {'.','o','g','g',0}; - - return ( - filepath_hasext(filename, ucs2cs_mp3) || - filepath_hasext(filename, ucs2cs_wma) || - filepath_hasext(filename, ucs2cs_ogg) - ) ? 1 : 0; -} - - - - - -static uint32_t pmppl_add_ref(pmp_playlist_t* pmppl) -{ - return pmp_interlocked_increment(&pmppl->ref_count); -} - -static uint32_t pmppl_release(pmp_playlist_t* pmppl) -{ - uint32_t count = pmp_interlocked_decrement(&pmppl->ref_count); - if (count == 0) { - pmppl_internal_t* pmppli = (pmppl_internal_t*)pmppl->instance; - free(pmppl->instance); - free(pmppl); - } - return count; -} - -static result_t pmppl_write(pmp_playlist_t* pmppl, const ucs2char_t* filename, ucs2char_t* const files[], uint32_t num_files) -{ + /* pmppl_internal_t* pmppli = (pmppl_internal_t*)pmppl->instance; pmp_internal_t* pmpi = (pmp_internal_t*)pmppl->pmp->instance; if (ip3db_playlist_write(&pmppli->ip3db, filename, files, num_files, pmpi->env.path_to_root) != 0) { return PMPPLE_WRITE; } + */ return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-16 16:38:31
|
Revision: 264 http://svn.sourceforge.net/pmplib/?rev=264&view=rev Author: nyaochi Date: 2007-01-16 08:38:24 -0800 (Tue, 16 Jan 2007) Log Message: ----------- Rename pmp_environment_t to pmp_device_environment_t Modified Paths: -------------- trunk/pmplib/include/pmp.h trunk/pmplib/lib/pmp/pmp.c trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c Modified: trunk/pmplib/include/pmp.h =================================================================== --- trunk/pmplib/include/pmp.h 2007-01-12 18:07:26 UTC (rev 263) +++ trunk/pmplib/include/pmp.h 2007-01-16 16:38:24 UTC (rev 264) @@ -126,16 +126,21 @@ ucs2char_t path[MAX_PATH]; } pmp_pathenv_t; -enum { - PMP_DECLSIZE = 128, -}; +/** Maximum size, in chars, of a device description. */ +#define PMP_DECLSIZE (128) +/** Unavailable field of a device description. */ +#define PMP_DECLUNAVAIL ("***") /** * PMP device decription. - * This structure stores information about a PMP device. + * This structure stores information about a PMP device. An PMP device driver + * should fill these fields properly so that an application can obtain the + * information about the device. An empty value represents the uncertainity + * of the field value at this stage. The value ::PMP_DECLUNAVAIL (\c "***") + * implies the unavailability of the field value for the device. */ typedef struct { - /** Device identifier (e.g., "iriver_e10_ums_1.00-1.04"). */ + /** Device identifier (e.g., "iriver_e10_ums_1.0-1.4"). */ char id[PMP_DECLSIZE]; /** Manufacturer (e.g., "iriver"). */ char manufacturer[PMP_DECLSIZE]; @@ -153,13 +158,17 @@ char max_version[PMP_DECLSIZE]; } pmp_device_description_t; +/** + * PMP device environment. + * This structure stores + */ typedef struct { pmp_pathenv_t path_to_root; /**< Path to the root directory */ pmp_pathenv_t path_to_music; /**< Path to the music files */ pmp_pathenv_t path_to_playlist; /**< Path to the playlist files */ pmp_pathenv_t path_to_photo; /**< Path to the photo files */ ucs2char_t playlist_ext[MAX_PATH]; -} pmp_environment_t; +} pmp_device_environment_t; @@ -202,7 +211,7 @@ /** * Portable media device environment. */ - pmp_environment_t env; + pmp_device_environment_t env; /** * The pointer to pmp_music_t interface. @@ -294,7 +303,7 @@ PMPAPI result_t pmp_record_copy(pmp_music_record_t* dst, const pmp_music_record_t* src); PMPAPI uint32_t pmp_interlocked_increment(uint32_t* count); PMPAPI uint32_t pmp_interlocked_decrement(uint32_t* count); -PMPAPI void pmp_copy_environment(pmp_environment_t* dst, const pmp_environment_t* src); +PMPAPI void pmp_copy_environment(pmp_device_environment_t* dst, const pmp_device_environment_t* src); Modified: trunk/pmplib/lib/pmp/pmp.c =================================================================== --- trunk/pmplib/lib/pmp/pmp.c 2007-01-12 18:07:26 UTC (rev 263) +++ trunk/pmplib/lib/pmp/pmp.c 2007-01-16 16:38:24 UTC (rev 264) @@ -63,7 +63,7 @@ return 0; } -void pmp_copy_environment(pmp_environment_t* dst, const pmp_environment_t* src) +void pmp_copy_environment(pmp_device_environment_t* dst, const pmp_device_environment_t* src) { memcpy(dst, src, sizeof(*src)); } Modified: trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-01-12 18:07:26 UTC (rev 263) +++ trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-01-16 16:38:24 UTC (rev 264) @@ -298,7 +298,7 @@ pmp_internal_t* pmpi = NULL; const ip2model_descriptor_t* md = NULL; ip2_environment_t env; - pmp_environment_t* pmpenv = NULL; + pmp_device_environment_t* pmpenv = NULL; *ptr_pmp = 0; Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-12 18:07:26 UTC (rev 263) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-16 16:38:24 UTC (rev 264) @@ -309,7 +309,7 @@ pmp_internal_t* pmpi = NULL; const ip3model_descriptor_t* md = NULL; ip3_environment_t env; - pmp_environment_t* pmpenv = NULL; + pmp_device_environment_t* pmpenv = NULL; *ptr_pmp = 0; Modified: trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c =================================================================== --- trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-01-12 18:07:26 UTC (rev 263) +++ trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-01-16 16:38:24 UTC (rev 264) @@ -128,7 +128,7 @@ result_t ret = 0; pmp_t* pmp = NULL; pmp_internal_t* pmpi = NULL; - pmp_environment_t* pmpenv = NULL; + pmp_device_environment_t* pmpenv = NULL; *ptr_pmp = 0; @@ -208,10 +208,10 @@ break; } strcpy(pmp->decl.mode, "UM"); - strcpy(pmp->decl.language, "N/A"); - strcpy(pmp->decl.version, "Unknown"); - strcpy(pmp->decl.max_version, "N/A"); - strcpy(pmp->decl.min_version, "N/A"); + strcpy(pmp->decl.language, PMP_DECLUNAVAIL); + strcpy(pmp->decl.version, PMP_DECLUNAVAIL); + strcpy(pmp->decl.max_version, PMP_DECLUNAVAIL); + strcpy(pmp->decl.min_version, PMP_DECLUNAVAIL); // Set enviroments. pmpenv = &pmp->env; Modified: trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-12 18:07:26 UTC (rev 263) +++ trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-16 16:38:24 UTC (rev 264) @@ -361,7 +361,7 @@ pmp_internal_t* pmpi = NULL; const pp1model_descriptor_t* md = NULL; pp1_environment_t env; - pmp_environment_t* pmpenv = NULL; + pmp_device_environment_t* pmpenv = NULL; // Initialize. *ptr_pmp = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-12 18:07:32
|
Revision: 263 http://svn.sourceforge.net/pmplib/?rev=263&view=rev Author: nyaochi Date: 2007-01-12 10:07:26 -0800 (Fri, 12 Jan 2007) Log Message: ----------- Add pmp_device_description_t::manufacturer field. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/cui/device.c trunk/pmplib/include/pmp.h trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c Modified: trunk/pmplib/frontend/easypmp/cui/device.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/device.c 2007-01-12 17:43:13 UTC (rev 262) +++ trunk/pmplib/frontend/easypmp/cui/device.c 2007-01-12 18:07:26 UTC (rev 263) @@ -60,6 +60,7 @@ void device_show_information(pmp_t* pmp, FILE *fp) { fprintf(fp, "Device identifier: %s\n", pmp->decl.id); + fprintf(fp, " Manufacturer: %s\n", pmp->decl.manufacturer); fprintf(fp, " Product name: %s\n", pmp->decl.name); fprintf(fp, " Firmware mode: %s\n", pmp->decl.mode); fprintf(fp, " Firmware version: %s\n", pmp->decl.version); Modified: trunk/pmplib/include/pmp.h =================================================================== --- trunk/pmplib/include/pmp.h 2007-01-12 17:43:13 UTC (rev 262) +++ trunk/pmplib/include/pmp.h 2007-01-12 18:07:26 UTC (rev 263) @@ -126,14 +126,31 @@ ucs2char_t path[MAX_PATH]; } pmp_pathenv_t; +enum { + PMP_DECLSIZE = 128, +}; + +/** + * PMP device decription. + * This structure stores information about a PMP device. + */ typedef struct { - char id[128]; /**< Device identifier. */ - char name[128]; /**< Device name. */ - char mode[128]; /**< Firmware mode. */ - char language[128]; /**< Firmware language. */ - char version[128]; /**< Firmware version. */ - char min_version[128]; /**< Minimum firmware version. */ - char max_version[128]; /**< Maximum firmware version. */ + /** Device identifier (e.g., "iriver_e10_ums_1.00-1.04"). */ + char id[PMP_DECLSIZE]; + /** Manufacturer (e.g., "iriver"). */ + char manufacturer[PMP_DECLSIZE]; + /** Model name (e.g., "E10"). */ + char name[PMP_DECLSIZE]; + /** Firmware mode (e.g., "UM"). */ + char mode[PMP_DECLSIZE]; + /** Firmware default language (e.g., "JP"). */ + char language[PMP_DECLSIZE]; + /** Firmware version (e.g., "1.4"). */ + char version[PMP_DECLSIZE]; + /** Minimum firmware version (e.g., "1.0"). */ + char min_version[PMP_DECLSIZE]; + /** Maximum firmware version (e.g., "1.4"). */ + char max_version[PMP_DECLSIZE]; } pmp_device_description_t; typedef struct { Modified: trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-01-12 17:43:13 UTC (rev 262) +++ trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-01-12 18:07:26 UTC (rev 263) @@ -46,6 +46,7 @@ typedef struct { const char *id; + const char *manufacturer; const char *name; const char *mode; const char *min_version; @@ -60,21 +61,21 @@ static const ip2model_descriptor_t g_model_descriptions[] = { { - "iriver_h10jr_ums_1.00-1.61", "H10Jr UMS", "UM", + "iriver_h10jr_ums_1.00-1.61", "iriver", "H10Jr UMS", "UM", "1.00", "1.61", "System\\H10_Jr.SYS", "System\\H10_Jr.DAT", "System\\H10_Jr.IDX", "Music\\", "Playlists\\", ".plp", }, { - "iriver_u10_ums_1.00-1.65", "U10 UMS", "UM", + "iriver_u10_ums_1.00-1.65", "iriver", "U10 UMS", "UM", "1.00", "1.65", "System\\U10.SYS", "System\\U10.dat", "System\\U10.idx", "Music\\", "Playlists\\", ".plp", }, { - NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -346,6 +347,7 @@ // Initialize the (exportable) env. strcpy(pmp->decl.id, md->id); + strcpy(pmp->decl.manufacturer, md->manufacturer); strcpy(pmp->decl.name, md->name); strcpy(pmp->decl.mode, md->mode); strcpy(pmp->decl.language, pmpi->env.language); Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-12 17:43:13 UTC (rev 262) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-12 18:07:26 UTC (rev 263) @@ -47,6 +47,7 @@ typedef struct { const char *id; + const char *manufacturer; const char *name; const char *mode; const char *min_version; @@ -62,14 +63,14 @@ static const ip3model_descriptor_t g_model_descriptions[] = { { - "iriver_e10_ums_1.00-1.04", "E10 UMS", "UM", + "iriver_e10_ums_1.00-1.04", "iriver", "E10 UMS", "UM", "1.00", "1.04", "System\\E10.SYS", "System\\db.dat", "System\\db.dic", "System\\db.idx", "", "Playlists\\", ".plp", }, { - NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -357,6 +358,7 @@ // Initialize the (exportable) env. strcpy(pmp->decl.id, md->id); + strcpy(pmp->decl.manufacturer, md->manufacturer); strcpy(pmp->decl.name, md->name); strcpy(pmp->decl.mode, md->mode); strcpy(pmp->decl.language, pmpi->env.language); Modified: trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c =================================================================== --- trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-01-12 17:43:13 UTC (rev 262) +++ trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-01-12 18:07:26 UTC (rev 263) @@ -198,11 +198,13 @@ switch (model) { case MODEL_IRIVER_H100: strcpy(pmp->decl.id, MODELID_H100); - strcpy(pmp->decl.name, "iRiver H100 series"); + strcpy(pmp->decl.manufacturer, "iriver"); + strcpy(pmp->decl.name, "H100 series"); break; case MODEL_IRIVER_H300: strcpy(pmp->decl.id, MODELID_H300); - strcpy(pmp->decl.name, "iRiver H300 series"); + strcpy(pmp->decl.manufacturer, "iriver"); + strcpy(pmp->decl.name, "H300 series"); break; } strcpy(pmp->decl.mode, "UM"); Modified: trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-12 17:43:13 UTC (rev 262) +++ trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-12 18:07:26 UTC (rev 263) @@ -47,6 +47,7 @@ typedef struct { const char *id; + const char *manufacturer; const char *name; uint32_t capacity; const char *mode; @@ -63,7 +64,7 @@ static const pp1model_descriptor_t g_model_descriptions[] = { { - "iriver_h10_5/6gb_ums_2.04-2.53", "H10 5GB/6GB UMS", + "iriver_h10_5/6gb_ums_2.04-2.53", "iriver", "H10 5GB/6GB UMS", 5, "UM", "2.04", "2.53", "System\\H10.mi4", "System\\DATA\\H10DB.hdr", "Media\\Music\\", "Media\\Playlist\\", @@ -71,7 +72,7 @@ hdr_init_h10_5gb_ums_0205_0253, iriver_h10_parse_model }, { - "iriver_h10pure_5/6gb_ums_2.04-2.51", "H10Pure 5GB/6GB UMS", + "iriver_h10pure_5/6gb_ums_2.04-2.51", "iriver", "H10Pure 5GB/6GB UMS", 5, "UM", "2.04", "2.51", "System\\H10_5GP.mi4", "System\\DATA\\H10DB.hdr", "Media\\Music\\", "Media\\Playlist\\", @@ -79,7 +80,7 @@ hdr_init_h10_5gb_ums_0205_0253, iriver_h10_parse_model }, { - "iriver_h10_5/6gb_mtp_2.03-2.10", "H10 5GB/6GB MTP", + "iriver_h10_5/6gb_mtp_2.03-2.10", "iriver", "H10 5GB/6GB MTP", 5, "MT", "2.03", "2.10", "System\\H10.mi4", "System\\DATA\\H10DB.hdr", "Music\\", "Playlists\\", @@ -87,7 +88,7 @@ hdr_init_h10_5gb_mtp_0203_0210, iriver_h10_parse_model }, { - "iriver_h10pure_5/6gb_mtp_2.03-2.10", "H10Pure 5GB/6GB MTP", + "iriver_h10pure_5/6gb_mtp_2.03-2.10", "iriver", "H10Pure 5GB/6GB MTP", 5, "MT", "2.03", "2.10", "System\\H10EMP.mi4", "System\\DATA\\H10DB.hdr", "Music\\", "Playlists\\", @@ -95,7 +96,7 @@ hdr_init_h10_5gb_mtp_0203_0210, iriver_h10_parse_model }, { - "iriver_h10_5/6gb_mtp_2.51", "H10 5GB/6GB MTP", + "iriver_h10_5/6gb_mtp_2.51", "iriver", "H10 5GB/6GB MTP", 5, "MT", "2.51", "2.51", "System\\H10.mi4", "System\\DATA\\H10DB.hdr", "Music\\", "Playlists\\", @@ -103,7 +104,7 @@ hdr_init_h10_5gb_mtp_0251, iriver_h10_parse_model }, { - "iriver_h10pure_5/6gb_mtp_2.51", "H10Pure 5GB/6GB MTP", + "iriver_h10pure_5/6gb_mtp_2.51", "iriver", "H10Pure 5GB/6GB MTP", 5, "MT", "2.51", "2.51", "System\\H10EMP.mi4", "System\\DATA\\H10DB.hdr", "Music\\", "Playlists\\", @@ -111,7 +112,7 @@ hdr_init_h10_5gb_mtp_0251, iriver_h10_parse_model }, { - "iriver_h10_20gb_mtp_1.00-1.02", "H10 20GB MTP", + "iriver_h10_20gb_mtp_1.00-1.02", "iriver", "H10 20GB MTP", 20, "MT", "1.00", "1.02", "System\\H10_20GC.mi4", "System\\DATA\\H10DB.hdr", "Music\\", "Playlists\\", @@ -119,7 +120,7 @@ hdr_init_h10_20gb_mtp_0100_0102, iriver_h10_parse_model }, { - "iriver_h10_20gb_mtp_2.51", "H10 20GB MTP", + "iriver_h10_20gb_mtp_2.51", "iriver", "H10 20GB MTP", 20, "MT", "2.51", "2.51", "System\\H10_20GC.mi4", "System\\DATA\\H10DB.hdr", "Music\\", "Playlists\\", @@ -127,7 +128,7 @@ hdr_init_h10_20gb_mtp_0251, iriver_h10_parse_model }, { - "medion_mdjuke220", "MEDION MDJUKE220", + "medion_mdjuke220", "MEDION", "MDJUKE220", 20, "UM", "1.4.2", "1.4.2", "SYSTEM\\JUKEBOX.mi4", "SYSTEM\\DATA\\PP5000.HDR", "MyJukeBox\\MUSIC\\", "MyJukeBox\\Playlist\\", @@ -135,7 +136,7 @@ hdr_init_medion_mdjuke220, medion_mdjuke220_parse_model }, { - "medion_mdjuke440", "MEDION MDJUKE440", + "medion_mdjuke440", "MEDION", "MDJUKE440", 20, "UM", "1.5.5", "1.5.5", "SYSTEM\\JUKEBOX.mi4", "SYSTEM\\DATA\\PP5000.HDR", "MyJukeBox\\MUSIC\\", "MyJukeBox\\Playlist\\", @@ -143,7 +144,7 @@ hdr_init_medion_mdjuke440, medion_mdjuke220_parse_model }, { - "samsung_yh820", "Samsung YH-820", + "samsung_yh820", "Samsung", "YH-820", 5, "UM", "3.00", "3.00", "SYSTEM\\FW_YH820.mi4", "System\\DATA\\PP5000.HDR", "System\\MUSIC\\", "System\\PLAYLIST\\", @@ -151,7 +152,7 @@ hdr_init_samsung_yh820, samsung_parse_model }, { - "samsung_yh920", "Samsung YH-920", + "samsung_yh920", "Samsung", "YH-920", 20, "UM", "5.15", "5.15", "SYSTEM\\FW_YH920.mi4", "System\\DATA\\PP5000.HDR", "System\\MUSIC\\", "System\\PLAYLIST\\", @@ -159,7 +160,7 @@ hdr_init_samsung_yh920, samsung_parse_model }, { - "samsung_yh925", "Samsung YH-925", + "samsung_yh925", "Samsung", "YH-925", 5, "UM", "1.61", "1.61", "SYSTEM\\FW_YH925.mi4", "System\\DATA\\PP5000.HDR", "System\\MUSIC\\", "System\\PLAYLIST\\", @@ -167,7 +168,7 @@ hdr_init_samsung_yh925, samsung_parse_model }, { - "philips_hdd6320", "Philips HDD6320", + "philips_hdd6320", "Philips", "HDD6320", 20, "UM", "5.40", "5.40", "SYSTEM\\FWImage.ebn", "System\\DATA\\PP5000.HDR", "Music\\", "Playlists\\", @@ -175,7 +176,7 @@ hdr_init_philips_hdd6320, philips_hdd6320_parse_model }, { - "msi_megaplayer540", "MSI MEGA PLAYER 540", + "msi_megaplayer540", "MSI", "MEGA PLAYER 540", 8, "UM", "01.00.16", "01.00.16", "SYSTEM\\PP5020.mi4", "System\\DATA\\PP5000.HDR", "MUSIC\\", "Playlists\\", @@ -184,7 +185,7 @@ }, #if 0 { - "sirius_s50", "Sirius S50", + "sirius_s50", "Sirius", "S50", 1, "UM", "0.00", "0.00", "SYSTEM\\config\\sysinfo.cfg", "SYSTEM\\DB\\SONG\\Xena.HDR", "SYSTEM\\MEDIA\\MP3\\", "SYSTEM\\MEDIA\\PLAYLIST\\", @@ -193,7 +194,7 @@ }, #endif { - NULL, NULL, + NULL, NULL, NULL, 0, NULL, 0, 0, NULL, NULL, NULL, NULL, @@ -411,6 +412,7 @@ // Initialize the device description. strcpy(pmp->decl.id, md->id); + strcpy(pmp->decl.manufacturer, md->manufacturer); strcpy(pmp->decl.name, md->name); strcpy(pmp->decl.mode, md->mode); strcpy(pmp->decl.language, pmpi->env.model.language); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-12 17:43:12
|
Revision: 262 http://svn.sourceforge.net/pmplib/?rev=262&view=rev Author: nyaochi Date: 2007-01-12 09:43:13 -0800 (Fri, 12 Jan 2007) Log Message: ----------- Display model names of PortalPlayer devices for -l option. Modified Paths: -------------- trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c Modified: trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-12 17:38:12 UTC (rev 261) +++ trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-12 17:43:13 UTC (rev 262) @@ -411,8 +411,8 @@ // Initialize the device description. strcpy(pmp->decl.id, md->id); - strcpy(pmp->decl.name, pmpi->env.model.name); - strcpy(pmp->decl.mode, pmpi->env.model.mode); + strcpy(pmp->decl.name, md->name); + strcpy(pmp->decl.mode, md->mode); strcpy(pmp->decl.language, pmpi->env.model.language); strcpy(pmp->decl.version, pmpi->env.model.version); strcpy(pmp->decl.min_version, md->min_version); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-12 17:38:13
|
Revision: 261 http://svn.sourceforge.net/pmplib/?rev=261&view=rev Author: nyaochi Date: 2007-01-12 09:38:12 -0800 (Fri, 12 Jan 2007) Log Message: ----------- Implement querying supported firmware ranges. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/cui/device.c trunk/pmplib/include/pmp.h trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c Modified: trunk/pmplib/frontend/easypmp/cui/device.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/device.c 2007-01-12 17:30:24 UTC (rev 260) +++ trunk/pmplib/frontend/easypmp/cui/device.c 2007-01-12 17:38:12 UTC (rev 261) @@ -63,6 +63,7 @@ fprintf(fp, " Product name: %s\n", pmp->decl.name); fprintf(fp, " Firmware mode: %s\n", pmp->decl.mode); fprintf(fp, " Firmware version: %s\n", pmp->decl.version); + fprintf(fp, " Firmware range: %s to %s\n", pmp->decl.min_version, pmp->decl.max_version); fprintf(fp, " Default language: %s\n", pmp->decl.language); fprints(fp, " Root directory: %s\n", pmp->env.path_to_root.path); Modified: trunk/pmplib/include/pmp.h =================================================================== --- trunk/pmplib/include/pmp.h 2007-01-12 17:30:24 UTC (rev 260) +++ trunk/pmplib/include/pmp.h 2007-01-12 17:38:12 UTC (rev 261) @@ -132,6 +132,8 @@ char mode[128]; /**< Firmware mode. */ char language[128]; /**< Firmware language. */ char version[128]; /**< Firmware version. */ + char min_version[128]; /**< Minimum firmware version. */ + char max_version[128]; /**< Maximum firmware version. */ } pmp_device_description_t; typedef struct { Modified: trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-01-12 17:30:24 UTC (rev 260) +++ trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-01-12 17:38:12 UTC (rev 261) @@ -350,6 +350,9 @@ strcpy(pmp->decl.mode, md->mode); strcpy(pmp->decl.language, pmpi->env.language); strcpy(pmp->decl.version, pmpi->env.version); + strcpy(pmp->decl.min_version, md->min_version); + strcpy(pmp->decl.max_version, md->max_version); + pmpenv = &pmp->env; pmpenv->path_to_root.flag = PMPPEF_SUPPORT | PMPPEF_CONSTANT; ucs2cpy(pmpenv->path_to_root.path, pmpi->env.path_to_root); Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-12 17:30:24 UTC (rev 260) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-12 17:38:12 UTC (rev 261) @@ -361,6 +361,9 @@ strcpy(pmp->decl.mode, md->mode); strcpy(pmp->decl.language, pmpi->env.language); strcpy(pmp->decl.version, pmpi->env.version); + strcpy(pmp->decl.min_version, md->min_version); + strcpy(pmp->decl.max_version, md->max_version); + pmpenv = &pmp->env; pmpenv->path_to_root.flag = PMPPEF_SUPPORT | PMPPEF_CONSTANT; ucs2cpy(pmpenv->path_to_root.path, pmpi->env.path_to_root); Modified: trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c =================================================================== --- trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-01-12 17:30:24 UTC (rev 260) +++ trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-01-12 17:38:12 UTC (rev 261) @@ -208,6 +208,8 @@ strcpy(pmp->decl.mode, "UM"); strcpy(pmp->decl.language, "N/A"); strcpy(pmp->decl.version, "Unknown"); + strcpy(pmp->decl.max_version, "N/A"); + strcpy(pmp->decl.min_version, "N/A"); // Set enviroments. pmpenv = &pmp->env; Modified: trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-12 17:30:24 UTC (rev 260) +++ trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-12 17:38:12 UTC (rev 261) @@ -415,6 +415,8 @@ strcpy(pmp->decl.mode, pmpi->env.model.mode); strcpy(pmp->decl.language, pmpi->env.model.language); strcpy(pmp->decl.version, pmpi->env.model.version); + strcpy(pmp->decl.min_version, md->min_version); + strcpy(pmp->decl.max_version, md->max_version); // Initialize the (exportable) env. pmpenv = &pmp->env; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-12 17:30:24
|
Revision: 260 http://svn.sourceforge.net/pmplib/?rev=260&view=rev Author: nyaochi Date: 2007-01-12 09:30:24 -0800 (Fri, 12 Jan 2007) Log Message: ----------- Separate pmp_device_description_t from pmp_environment_t. Modified Paths: -------------- trunk/pmplib/doc/Doxyfile trunk/pmplib/frontend/easypmp/cui/device.c trunk/pmplib/frontend/easypmp/win32gui/preference.h trunk/pmplib/frontend/easypmp/win32gui/processingdlg.h trunk/pmplib/include/pmp.h trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c Modified: trunk/pmplib/doc/Doxyfile =================================================================== --- trunk/pmplib/doc/Doxyfile 2007-01-11 17:11:53 UTC (rev 259) +++ trunk/pmplib/doc/Doxyfile 2007-01-12 17:30:24 UTC (rev 260) @@ -83,10 +83,8 @@ #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = .. -FILE_PATTERNS = *.c \ - *.cpp \ - *.h \ +INPUT = ../include +FILE_PATTERNS = *.h \ *.dox RECURSIVE = YES EXCLUDE = ../libltdl \ Modified: trunk/pmplib/frontend/easypmp/cui/device.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/device.c 2007-01-11 17:11:53 UTC (rev 259) +++ trunk/pmplib/frontend/easypmp/cui/device.c 2007-01-12 17:30:24 UTC (rev 260) @@ -59,13 +59,13 @@ void device_show_information(pmp_t* pmp, FILE *fp) { - fprintf(fp, "Device identifier: %s\n", pmp->env.id); - fprintf(fp, " Product name: %s\n", pmp->env.name); - fprintf(fp, " Firmware mode: %s\n", pmp->env.mode); - fprintf(fp, " Firmware version: %s\n", pmp->env.version); - fprintf(fp, " Default language: %s\n", pmp->env.language); + fprintf(fp, "Device identifier: %s\n", pmp->decl.id); + fprintf(fp, " Product name: %s\n", pmp->decl.name); + fprintf(fp, " Firmware mode: %s\n", pmp->decl.mode); + fprintf(fp, " Firmware version: %s\n", pmp->decl.version); + fprintf(fp, " Default language: %s\n", pmp->decl.language); + fprints(fp, " Root directory: %s\n", pmp->env.path_to_root.path); - device_show_path(fp, " Music directory: %s\n", pmp->env.path_to_music.path); device_show_path(fp, " Playlist directory: %s\n", pmp->env.path_to_playlist.path); Modified: trunk/pmplib/frontend/easypmp/win32gui/preference.h =================================================================== --- trunk/pmplib/frontend/easypmp/win32gui/preference.h 2007-01-11 17:11:53 UTC (rev 259) +++ trunk/pmplib/frontend/easypmp/win32gui/preference.h 2007-01-12 17:30:24 UTC (rev 260) @@ -200,16 +200,16 @@ if (pmp) { strPlayerLocation = UCS2CT(pmp->env.path_to_root.path); - strPlayerIdentifier = A2CT(pmp->env.id); - strPlayerDescription = A2CT(pmp->env.name); + strPlayerIdentifier = A2CT(pmp->decl.id); + strPlayerDescription = A2CT(pmp->decl.name); strPlayerDescription += _T(""); - if (*pmp->env.version) { + if (*pmp->decl.version) { strPlayerDescription += _T(" "); - strPlayerDescription += A2CT(pmp->env.version); + strPlayerDescription += A2CT(pmp->decl.version); } - if (*pmp->env.mode) { + if (*pmp->decl.mode) { strPlayerDescription += _T(" "); - strPlayerDescription += A2CT(pmp->env.mode); + strPlayerDescription += A2CT(pmp->decl.mode); } } else { strPlayerIdentifier = _T(""); Modified: trunk/pmplib/frontend/easypmp/win32gui/processingdlg.h =================================================================== --- trunk/pmplib/frontend/easypmp/win32gui/processingdlg.h 2007-01-11 17:11:53 UTC (rev 259) +++ trunk/pmplib/frontend/easypmp/win32gui/processingdlg.h 2007-01-12 17:30:24 UTC (rev 260) @@ -670,11 +670,11 @@ USES_CONVERSION; write_log(LL_INFO, _T("[Player information]")); - write_log(LL_INFO, _T("Device identifier: %s"), A2CT(pmp->env.id)); - write_log(LL_INFO, _T("Product name: %s"), A2CT(pmp->env.name)); - write_log(LL_TRACE, _T("Firmware mode: %s"), A2CT(pmp->env.mode)); - write_log(LL_INFO, _T("Firmware version: %s"), A2CT(pmp->env.version)); - write_log(LL_TRACE, _T("Default language: %s"), A2CT(pmp->env.language)); + write_log(LL_INFO, _T("Device identifier: %s"), A2CT(pmp->decl.id)); + write_log(LL_INFO, _T("Product name: %s"), A2CT(pmp->decl.name)); + write_log(LL_TRACE, _T("Firmware mode: %s"), A2CT(pmp->decl.mode)); + write_log(LL_INFO, _T("Firmware version: %s"), A2CT(pmp->decl.version)); + write_log(LL_TRACE, _T("Default language: %s"), A2CT(pmp->decl.language)); write_log(LL_TRACE, _T("Root directory: %s"), UCS2CT(pmp->env.path_to_root.path)); write_log(LL_TRACE, _T("Music directory: %s"), UCS2CT(pmp->env.path_to_music.path)); write_log(LL_TRACE, _T("Playlist directory: %s"), UCS2CT(pmp->env.path_to_playlist.path)); Modified: trunk/pmplib/include/pmp.h =================================================================== --- trunk/pmplib/include/pmp.h 2007-01-11 17:11:53 UTC (rev 259) +++ trunk/pmplib/include/pmp.h 2007-01-12 17:30:24 UTC (rev 260) @@ -132,7 +132,9 @@ char mode[128]; /**< Firmware mode. */ char language[128]; /**< Firmware language. */ char version[128]; /**< Firmware version. */ +} pmp_device_description_t; +typedef struct { pmp_pathenv_t path_to_root; /**< Path to the root directory */ pmp_pathenv_t path_to_music; /**< Path to the music files */ pmp_pathenv_t path_to_playlist; /**< Path to the playlist files */ @@ -176,6 +178,8 @@ */ uint32_t flag; + pmp_device_description_t decl; + /** * Portable media device environment. */ @@ -281,14 +285,15 @@ /** * @defgroup pmplib PMPlib Helper API * - * This API provides the utility for selecting a PMPlib driver from a number - * of installed ones. Because the PMPlib project implements a number of - * drivers for different portable media devices, an application must choose - * a suitable driver that matches to the target device. Using this API, an - * application can query a driver suitable for the portable media device - * specified by the mount location (root directory of the device) and/or - * string identifier. An application can also enumerate the string - * identifiers of the drivers installed in the system. + * The PMPlib Helper API provides the utility for choosing a suitable PMPlib + * driver from a number of installed drivers. Because the PMPlib project + * implements a number of drivers for different portable media devices, an + * application must choose a suitable driver that matches to the target + * device. By using this API, an application can query a driver suitable for + * the portable media device specified by the mount location (root directory + * of the device) and/or the string identifier of a driver. An application can + * also enumerate the string identifiers of the drivers available in the + * system. * * An application must call pmplib_init() function to initialize the API * and obtain the pointer to a ::pmplib_t instance that is used for subsequent @@ -353,7 +358,7 @@ * for this API. Call pmplib_init() function to obtain a pointer to this * structure and pmplib_finish() function to terminate this API. Access to * a member in this structure is prohibited since it is reserved for the - * internal use of the library implementation only. + * internal use of the library only. */ typedef struct tag_pmplib_t pmplib_t; @@ -398,11 +403,11 @@ * specified by the mount location and/or identifier, and returns the * interface to the driver (::pmp_t instance). An application must specify * parameter \a path_to_device. If parameter \a id is not \c NULL, this - * function constructs a ::pmp_t instance of the driver with the device - * identifier. If the parameter \a id is \c NULL, this function tries to - * recognize the model of the device based on the content under the location - * (\a path_to_device). If successful, the interface to the driver will be - * returned to the \a pmp argument. + * function obtains the interface to the driver with the device identifier + * specified in \a id parameter. If the parameter \a id is \c NULL, this + * function tries to recognize the model of the device based on the content + * of the files located under \a path_to_device. If successful, the interface + * to the driver will be returned in the \a pmp argument. * * @param pmplib The pointer to the ::pmplib_t instance. * @param path_to_device A UCS-2 string representing the location of the @@ -432,8 +437,7 @@ * @param callback The pointer to the callback function to receive * device identifiers. * @param instance A user-defined instance value. The callback - * function will receive the same value so that it can - * distinguish the caller. + * function will receive the same value. * @retval result_t The status code. * * @assert Modified: trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-01-11 17:11:53 UTC (rev 259) +++ trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-01-12 17:30:24 UTC (rev 260) @@ -345,12 +345,12 @@ memcpy(&pmpi->env, &env, sizeof(env)); // Initialize the (exportable) env. + strcpy(pmp->decl.id, md->id); + strcpy(pmp->decl.name, md->name); + strcpy(pmp->decl.mode, md->mode); + strcpy(pmp->decl.language, pmpi->env.language); + strcpy(pmp->decl.version, pmpi->env.version); pmpenv = &pmp->env; - strcpy(pmpenv->id, md->id); - strcpy(pmpenv->name, md->name); - strcpy(pmpenv->mode, md->mode); - strcpy(pmpenv->language, pmpi->env.language); - strcpy(pmpenv->version, pmpi->env.version); pmpenv->path_to_root.flag = PMPPEF_SUPPORT | PMPPEF_CONSTANT; ucs2cpy(pmpenv->path_to_root.path, pmpi->env.path_to_root); pmpenv->path_to_music.flag = PMPPEF_SUPPORT | PMPPEF_RECURSIVE; Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-11 17:11:53 UTC (rev 259) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-12 17:30:24 UTC (rev 260) @@ -356,12 +356,12 @@ memcpy(&pmpi->env, &env, sizeof(env)); // Initialize the (exportable) env. + strcpy(pmp->decl.id, md->id); + strcpy(pmp->decl.name, md->name); + strcpy(pmp->decl.mode, md->mode); + strcpy(pmp->decl.language, pmpi->env.language); + strcpy(pmp->decl.version, pmpi->env.version); pmpenv = &pmp->env; - strcpy(pmpenv->id, md->id); - strcpy(pmpenv->name, md->name); - strcpy(pmpenv->mode, md->mode); - strcpy(pmpenv->language, pmpi->env.language); - strcpy(pmpenv->version, pmpi->env.version); pmpenv->path_to_root.flag = PMPPEF_SUPPORT | PMPPEF_CONSTANT; ucs2cpy(pmpenv->path_to_root.path, pmpi->env.path_to_root); pmpenv->path_to_music.flag = PMPPEF_SUPPORT | PMPPEF_RECURSIVE; Modified: trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c =================================================================== --- trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-01-11 17:11:53 UTC (rev 259) +++ trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-01-12 17:30:24 UTC (rev 260) @@ -197,17 +197,17 @@ // Set model information. switch (model) { case MODEL_IRIVER_H100: - strcpy(pmp->env.id, MODELID_H100); - strcpy(pmp->env.name, "iRiver H100 series"); + strcpy(pmp->decl.id, MODELID_H100); + strcpy(pmp->decl.name, "iRiver H100 series"); break; case MODEL_IRIVER_H300: - strcpy(pmp->env.id, MODELID_H300); - strcpy(pmp->env.name, "iRiver H300 series"); + strcpy(pmp->decl.id, MODELID_H300); + strcpy(pmp->decl.name, "iRiver H300 series"); break; } - strcpy(pmp->env.mode, "UM"); - strcpy(pmp->env.language, "N/A"); - pmp->env.version[0] = 0; // Unknown version + strcpy(pmp->decl.mode, "UM"); + strcpy(pmp->decl.language, "N/A"); + strcpy(pmp->decl.version, "Unknown"); // Set enviroments. pmpenv = &pmp->env; Modified: trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-11 17:11:53 UTC (rev 259) +++ trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-12 17:30:24 UTC (rev 260) @@ -408,14 +408,16 @@ // Initialize the internal variables. memcpy(&pmpi->env, &env, sizeof(env)); - + + // Initialize the device description. + strcpy(pmp->decl.id, md->id); + strcpy(pmp->decl.name, pmpi->env.model.name); + strcpy(pmp->decl.mode, pmpi->env.model.mode); + strcpy(pmp->decl.language, pmpi->env.model.language); + strcpy(pmp->decl.version, pmpi->env.model.version); + // Initialize the (exportable) env. pmpenv = &pmp->env; - strcpy(pmpenv->id, md->id); - strcpy(pmpenv->name, pmpi->env.model.name); - strcpy(pmpenv->mode, pmpi->env.model.mode); - strcpy(pmpenv->language, pmpi->env.model.language); - strcpy(pmpenv->version, pmpi->env.model.version); pmpenv->path_to_root.flag = PMPPEF_SUPPORT | PMPPEF_CONSTANT; ucs2cpy(pmpenv->path_to_root.path, pmpi->env.path_to_root); pmpenv->path_to_music.flag = PMPPEF_SUPPORT | PMPPEF_RECURSIVE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-11 17:11:58
|
Revision: 259 http://svn.sourceforge.net/pmplib/?rev=259&view=rev Author: nyaochi Date: 2007-01-11 09:11:53 -0800 (Thu, 11 Jan 2007) Log Message: ----------- Duration field is not in DWORD but in UCS-2 string. Modified Paths: -------------- trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c Modified: trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c 2007-01-10 15:50:55 UTC (rev 258) +++ trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c 2007-01-11 17:11:53 UTC (rev 259) @@ -46,7 +46,7 @@ PP1DB_DATFIELD_FORMAT, // @3: (INT) PP1DB_DATFIELD_BITRATE, // @4: (INT) PP1DB_DATFIELD_SAMPLERATE, // @5: (INT) - PP1DB_DATFIELD_DURATION, // @6: (INT) + PP1DB_DATFIELD_DURATION, // @6: (STR) PP1DB_DATFIELD_ARTIST, // @7: (STR) PP1DB_DATFIELD_ALBUM, // @8: (STR) PP1DB_DATFIELD_GENRE, // @9: (STR) @@ -66,7 +66,7 @@ fprintf(fp, " media_type: %d\n", record->fields[PP1DB_DATFIELD_FORMAT].value.dword); fprintf(fp, " bitrate: %d\n", record->fields[PP1DB_DATFIELD_BITRATE].value.dword); fprintf(fp, " samplerate: %d\n", record->fields[PP1DB_DATFIELD_SAMPLERATE].value.dword); - fprintf(fp, " duration: %d\n", record->fields[PP1DB_DATFIELD_DURATION].value.dword); + fprints(fp, " duration: %s\n", record->fields[PP1DB_DATFIELD_DURATION].value.str); fprints(fp, " artist: %s\n", record->fields[PP1DB_DATFIELD_ARTIST].value.str); fprints(fp, " album: %s\n", record->fields[PP1DB_DATFIELD_ALBUM].value.str); fprints(fp, " genre: %s\n", record->fields[PP1DB_DATFIELD_GENRE].value.str); @@ -80,6 +80,7 @@ { static const ucs2char_t ucs2cs_unknown[] = {0}; static const ucs2char_t ucs2cs_empty[] = {0}; + ucs2char_t tmp[128]; // Set fields. dst->status = 0; @@ -92,7 +93,8 @@ dst->fields[PP1DB_DATFIELD_FORMAT].value.dword = 0; dst->fields[PP1DB_DATFIELD_BITRATE].value.dword = src->bitrate; dst->fields[PP1DB_DATFIELD_SAMPLERATE].value.dword = src->sample_rate; - dst->fields[PP1DB_DATFIELD_DURATION].value.dword = src->duration; + itoucs2(src->duration, tmp, 10); + dst->fields[PP1DB_DATFIELD_DURATION].value.str = ucs2dup(tmp); dst->fields[PP1DB_DATFIELD_ARTIST].value.str = ucs2dup(src->artist ? src->artist : ucs2cs_unknown); dst->fields[PP1DB_DATFIELD_ALBUM].value.str = ucs2dup(src->album ? src->album : ucs2cs_unknown); dst->fields[PP1DB_DATFIELD_GENRE].value.str = ucs2dup(src->genre ? src->genre : ucs2cs_unknown); @@ -127,8 +129,7 @@ dst->bitrate = src->fields[PP1DB_DATFIELD_BITRATE].value.dword; dst->sample_rate = src->fields[PP1DB_DATFIELD_SAMPLERATE].value.dword; - dst->duration = src->fields[PP1DB_DATFIELD_DURATION].value.dword; - + dst->duration = ucs2toi(src->fields[PP1DB_DATFIELD_DURATION].value.str); dst->artist = ucs2dup(src->fields[PP1DB_DATFIELD_ARTIST].value.str); dst->album = ucs2dup(src->fields[PP1DB_DATFIELD_ALBUM].value.str); dst->genre = ucs2dup(src->fields[PP1DB_DATFIELD_GENRE].value.str); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-10 15:50:57
|
Revision: 258 http://svn.sourceforge.net/pmplib/?rev=258&view=rev Author: nyaochi Date: 2007-01-10 07:50:55 -0800 (Wed, 10 Jan 2007) Log Message: ----------- Added MSI MEGA PLAYER 540 support for POSIX environments. Modified Paths: -------------- trunk/pmplib/lib/pmp_portalplayer1/Makefile.am Modified: trunk/pmplib/lib/pmp_portalplayer1/Makefile.am =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/Makefile.am 2007-01-10 15:49:27 UTC (rev 257) +++ trunk/pmplib/lib/pmp_portalplayer1/Makefile.am 2007-01-10 15:50:55 UTC (rev 258) @@ -26,6 +26,7 @@ model_sirius_s50.c \ model_samsung.c \ model_philips_hdd6320.c \ + model_msi_megaplayer.c \ pmp_portalplayer1.c portalplayer1_la_LDFLAGS = \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-10 15:49:27
|
Revision: 257 http://svn.sourceforge.net/pmplib/?rev=257&view=rev Author: nyaochi Date: 2007-01-10 07:49:27 -0800 (Wed, 10 Jan 2007) Log Message: ----------- - Update some comments for PortalPlayer firmware images. - Implement the automatic model detection for MSI MEGA PLAYER 540. Modified Paths: -------------- trunk/pmplib/lib/pmp_portalplayer1/model_iriver_h10.c trunk/pmplib/lib/pmp_portalplayer1/model_medion_mdjuke220.c trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c trunk/pmplib/lib/pmp_portalplayer1/model_samsung.c Modified: trunk/pmplib/lib/pmp_portalplayer1/model_iriver_h10.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/model_iriver_h10.c 2007-01-10 15:21:11 UTC (rev 256) +++ trunk/pmplib/lib/pmp_portalplayer1/model_iriver_h10.c 2007-01-10 15:49:27 UTC (rev 257) @@ -181,6 +181,8 @@ int iriver_h10_parse_model(const ucs2char_t* firmware, pp1model_t* model) { /* + iriver H10 5GB (UMS) 2.53 + ADDRESS 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF ------------------------------------------------------------------------------ 00000200 DD 03 00 EA CA 03 00 EA 0E F0 B0 E1 CE 03 00 EA ................ Modified: trunk/pmplib/lib/pmp_portalplayer1/model_medion_mdjuke220.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/model_medion_mdjuke220.c 2007-01-10 15:21:11 UTC (rev 256) +++ trunk/pmplib/lib/pmp_portalplayer1/model_medion_mdjuke220.c 2007-01-10 15:49:27 UTC (rev 257) @@ -161,6 +161,28 @@ int medion_mdjuke220_parse_model(const ucs2char_t* firmware, pp1model_t* model) { + /* + Medion MDJUKE 220 1.4.2 + + ADDRESS 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF + ------------------------------------------------------------------------------ + 00000200 88 05 00 EA 75 05 00 EA 0E F0 B0 E1 79 05 00 EA ....u.......y... + 00000210 7E 05 00 EA FE FF FF EA 66 05 00 EA 5C 05 00 EA ~.......f...\... + 00000220 70 6F 72 74 61 6C 70 6C 61 79 65 72 00 30 2E 30 portalplayer.0.0 + 00000230 C0 00 22 59 4C 00 CA 43 00 00 00 00 00 00 00 00 .."YL..C........ + 00000240 50 50 35 30 32 30 41 46 2D 30 35 2E 31 31 2D 50 PP5020AF-05.11-P + 00000250 50 30 37 2D 30 35 2E 31 31 2D 4D 47 30 31 2D 30 P07-05.11-MG01-0 + 00000260 31 2E 30 30 2D 44 54 00 4D 44 4A 55 4B 45 32 31 1.00-DT.MDJUKE21 + 00000270 35 2F 32 32 30 00 00 00 31 2E 34 2E 32 00 00 00 5/220...1.4.2... + 00000280 44 69 67 69 74 61 6C 20 4D 65 64 69 61 20 50 6C Digital Media Pl + 00000290 61 74 66 6F 72 6D 00 00 43 6F 70 79 72 69 67 68 atform..Copyrigh + 000002A0 74 28 63 29 20 31 39 39 39 20 2D 20 32 30 30 33 t(c) 1999 - 2003 + 000002B0 20 50 6F 72 74 61 6C 50 6C 61 79 65 72 2C 20 49 PortalPlayer, I + 000002C0 6E 63 2E 20 20 41 6C 6C 20 72 69 67 68 74 73 20 nc. All rights + 000002D0 72 65 73 65 72 76 65 64 2E 00 00 00 00 00 00 00 reserved........ + 000002E0 00 01 00 00 EC 00 00 00 4C 59 22 00 80 10 A0 E1 ........LY"..... + 000002F0 80 04 A0 E1 A0 08 B0 E1 7D 20 E0 E3 21 2C 82 E0 ........} ..!,.. + */ FILE *fp = ucs2fopen(firmware, "rb"); if (fp) { char line[0x81], *p = NULL, *q = NULL, *e = line + 0x80; Modified: trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c 2007-01-10 15:21:11 UTC (rev 256) +++ trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c 2007-01-10 15:49:27 UTC (rev 257) @@ -155,6 +155,8 @@ int megaplayer_parse_model(const ucs2char_t* firmware, pp1model_t* model) { /* + MSI MEGA PLAYER 540 01.00.16 + ADDRESS 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF ------------------------------------------------------------------------------ 00000200 27 04 00 EA 14 04 00 EA 0E F0 B0 E1 18 04 00 EA '............... @@ -176,17 +178,17 @@ */ FILE *fp = ucs2fopen(firmware, "rb"); if (fp) { - char line[33], *p = NULL, *q = NULL; - memset(line, 0, sizeof(line)); + char buff[129], *p = NULL, *q = NULL; + memset(buff, 0, sizeof(buff)); // Seek to the firmware information. - if (fseek(fp, 0x0220, SEEK_SET) != 0) { + if (fseek(fp, 0x0240, SEEK_SET) != 0) { fclose(fp); return 0; } // Read the firmware information. - if (fread(line, sizeof(char), 32, fp) != 32) { + if (fread(buff, sizeof(char), 128, fp) != 128) { fclose(fp); return 0; } @@ -194,30 +196,16 @@ // Close the firmware. fclose(fp); - // Obtain the model name. - strcpy(model->name, "Samsung "); - strcat(model->name, line); - p = line + strlen(line) + 1; - - // Obtain firmware version. - q = strchr(p, ' '); - if (q) { - *q = 0; - } else { + // Match the identifier string. + if (strncmp(buff, "PP5020AF-05.22-PP07-05.22-MN05-", 31) != 0) { return 0; } - strcpy(model->version, p); - p = q+1; - - // Obtain the country code? - q = strchr(p, 0xC0); - if (q) { - *q = 0; - } else { - return 0; - } - strcpy(model->language, p); + // Obtain the model name. + strcpy(model->name, "MSI MEGA PLAYER 540"); + memset(model->version, 0, sizeof(model->version)); + strncpy(model->version, buff+0x1F, 8); + strcpy(model->language, ""); strcpy(model->mode, "UM"); return 1; Modified: trunk/pmplib/lib/pmp_portalplayer1/model_samsung.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/model_samsung.c 2007-01-10 15:21:11 UTC (rev 256) +++ trunk/pmplib/lib/pmp_portalplayer1/model_samsung.c 2007-01-10 15:49:27 UTC (rev 257) @@ -166,6 +166,28 @@ int samsung_parse_model(const ucs2char_t* firmware, pp1model_t* model) { + /* + Samsung YH-925 1.61 + + ADDRESS 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF + ------------------------------------------------------------------------------ + 00000200 EB 03 00 EA D8 03 00 EA 0E F0 B0 E1 DC 03 00 EA ................ + 00000210 E1 03 00 EA FE FF FF EA C9 03 00 EA BF 03 00 EA ................ + 00000220 59 48 2D 39 32 35 00 31 2E 36 31 20 43 41 C0 00 YH-925.1.61 CA.. + 00000230 00 00 32 2C C4 00 07 BA 00 00 00 00 00 00 00 00 ..2,............ + 00000240 50 50 35 30 32 30 41 46 2D 30 35 2E 31 31 2D 53 PP5020AF-05.11-S + 00000250 4D 30 35 2D 30 32 2E 31 33 2D 47 53 30 31 2D 30 M05-02.13-GS01-0 + 00000260 31 2E 30 30 2D 44 54 00 32 30 30 34 2E 31 31 2E 1.00-DT.2004.11. + 00000270 32 32 00 00 28 42 75 69 6C 64 20 33 38 29 00 00 22..(Build 38).. + 00000280 44 69 67 69 74 61 6C 20 4D 65 64 69 61 20 50 6C Digital Media Pl + 00000290 61 74 66 6F 72 6D 00 00 43 6F 70 79 72 69 67 68 atform..Copyrigh + 000002A0 74 28 63 29 20 31 39 39 39 20 2D 20 32 30 30 33 t(c) 1999 - 2003 + 000002B0 20 50 6F 72 74 61 6C 50 6C 61 79 65 72 2C 20 49 PortalPlayer, I + 000002C0 6E 63 2E 20 20 41 6C 6C 20 72 69 67 68 74 73 20 nc. All rights + 000002D0 72 65 73 65 72 76 65 64 2E 00 00 00 00 00 00 00 reserved........ + 000002E0 00 01 00 00 EC 00 00 00 C4 2C 32 00 00 10 A0 E1 .........,2..... + 000002F0 40 25 A0 E3 00 20 81 E5 01 00 A0 E3 0E F0 A0 E1 @%... .......... + */ FILE *fp = ucs2fopen(firmware, "rb"); if (fp) { char line[33], *p = NULL, *q = NULL; @@ -209,7 +231,6 @@ return 0; } strcpy(model->language, p); - strcpy(model->mode, "UM"); return 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-10 15:21:13
|
Revision: 256 http://svn.sourceforge.net/pmplib/?rev=256&view=rev Author: nyaochi Date: 2007-01-10 07:21:11 -0800 (Wed, 10 Jan 2007) Log Message: ----------- Comment MSI MEGA PLAYER 540 firmware image. Modified Paths: -------------- trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c Modified: trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c 2007-01-10 15:19:32 UTC (rev 255) +++ trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c 2007-01-10 15:21:11 UTC (rev 256) @@ -154,6 +154,26 @@ int megaplayer_parse_model(const ucs2char_t* firmware, pp1model_t* model) { + /* + ADDRESS 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF + ------------------------------------------------------------------------------ + 00000200 27 04 00 EA 14 04 00 EA 0E F0 B0 E1 18 04 00 EA '............... + 00000210 1D 04 00 EA FE FF FF EA 05 04 00 EA FB 03 00 EA ................ + 00000220 70 6F 72 74 61 6C 70 6C 61 79 65 72 00 30 2E 30 portalplayer.0.0 + 00000230 C0 00 39 7F 20 00 CA 66 00 00 00 00 00 00 00 00 ..9. ..f........ + 00000240 50 50 35 30 32 30 41 46 2D 30 35 2E 32 32 2D 50 PP5020AF-05.22-P + 00000250 50 30 37 2D 30 35 2E 32 32 2D 4D 4E 30 35 2D 30 P07-05.22-MN05-0 + 00000260 31 2E 30 30 2E 31 36 2D 44 54 00 00 32 30 30 35 1.00.16-DT..2005 + 00000270 2E 30 33 2E 31 36 00 00 28 42 75 69 6C 64 20 31 .03.16..(Build 1 + 00000280 32 39 29 00 44 69 67 69 74 61 6C 20 4D 65 64 69 29).Digital Medi + 00000290 61 20 50 6C 61 74 66 6F 72 6D 00 00 43 6F 70 79 a Platform..Copy + 000002A0 72 69 67 68 74 28 63 29 20 31 39 39 39 20 2D 20 right(c) 1999 - + 000002B0 32 30 30 33 20 50 6F 72 74 61 6C 50 6C 61 79 65 2003 PortalPlaye + 000002C0 72 2C 20 49 6E 63 2E 20 20 41 6C 6C 20 72 69 67 r, Inc. All rig + 000002D0 68 74 73 20 72 65 73 65 72 76 65 64 2E 00 00 00 hts reserved.... + 000002E0 00 01 00 00 EC 00 00 00 20 7F 39 00 00 10 A0 E1 ........ .9..... + 000002F0 40 25 A0 E3 00 20 81 E5 01 00 A0 E3 0E F0 A0 E1 @%... .......... + */ FILE *fp = ucs2fopen(firmware, "rb"); if (fp) { char line[33], *p = NULL, *q = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-10 15:19:36
|
Revision: 255 http://svn.sourceforge.net/pmplib/?rev=255&view=rev Author: nyaochi Date: 2007-01-10 07:19:32 -0800 (Wed, 10 Jan 2007) Log Message: ----------- Added a comment the firmware image of iriver H10. Modified Paths: -------------- trunk/pmplib/lib/pmp_portalplayer1/model_iriver_h10.c Modified: trunk/pmplib/lib/pmp_portalplayer1/model_iriver_h10.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/model_iriver_h10.c 2007-01-10 15:17:58 UTC (rev 254) +++ trunk/pmplib/lib/pmp_portalplayer1/model_iriver_h10.c 2007-01-10 15:19:32 UTC (rev 255) @@ -180,6 +180,26 @@ int iriver_h10_parse_model(const ucs2char_t* firmware, pp1model_t* model) { + /* + ADDRESS 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF + ------------------------------------------------------------------------------ + 00000200 DD 03 00 EA CA 03 00 EA 0E F0 B0 E1 CE 03 00 EA ................ + 00000210 D3 03 00 EA FE FF FF EA BB 03 00 EA B1 03 00 EA ................ + 00000220 70 6F 72 74 61 6C 70 6C 61 79 65 72 00 30 2E 30 portalplayer.0.0 + 00000230 C0 00 3D 03 14 00 94 CC 00 00 00 00 00 00 00 00 ..=............. + 00000240 50 50 35 30 32 30 41 46 2D 30 32 2E 35 33 2D 4B PP5020AF-02.53-K + 00000250 4F 52 2D 55 4D 2D 44 54 00 00 00 00 32 30 30 35 OR-UM-DT....2005 + 00000260 2E 30 35 2E 32 36 00 00 28 42 75 69 6C 64 20 31 .05.26..(Build 1 + 00000270 32 39 2E 35 29 00 00 00 44 69 67 69 74 61 6C 20 29.5)...Digital + 00000280 4D 65 64 69 61 20 50 6C 61 74 66 6F 72 6D 00 00 Media Platform.. + 00000290 43 6F 70 79 72 69 67 68 74 28 63 29 20 31 39 39 Copyright(c) 199 + 000002A0 39 20 2D 20 32 30 30 33 20 50 6F 72 74 61 6C 50 9 - 2003 PortalP + 000002B0 6C 61 79 65 72 2C 20 49 6E 63 2E 20 20 41 6C 6C layer, Inc. All + 000002C0 20 72 69 67 68 74 73 20 72 65 73 65 72 76 65 64 rights reserved + 000002D0 2E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 000002E0 00 01 00 00 EC 00 00 00 14 03 3D 00 00 10 A0 E1 ..........=..... + 000002F0 40 25 A0 E3 00 20 81 E5 01 00 A0 E3 0E F0 A0 E1 @%... .......... + */ FILE *fp = ucs2fopen(firmware, "rb"); if (fp) { char line[29], *p = NULL, *q = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-10 15:18:01
|
Revision: 254 http://svn.sourceforge.net/pmplib/?rev=254&view=rev Author: nyaochi Date: 2007-01-10 07:17:58 -0800 (Wed, 10 Jan 2007) Log Message: ----------- Fixed some spellings. Modified Paths: -------------- trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c Modified: trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c 2007-01-10 15:09:58 UTC (rev 253) +++ trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c 2007-01-10 15:17:58 UTC (rev 254) @@ -1,5 +1,5 @@ /* - * MSI Megaplayer specific routines and header templates. + * MSI MEGA PLAYER specific routines and header templates. * * Copyright (c) 2005-2007 Nyaochi * @@ -236,7 +236,7 @@ {8, 12, 268, 524, 528, 532, 536, 544, 1056, 1568, 2080, 2592, 2596, 2600, 0, 0, 0, 0, 0, 0}; -/********** MSI Megaplayer 540 **********/ +/********** MSI MEGA PLAYER 540 **********/ static hdr_template_t hdrtmpl_megaplayer540 = { 0, 0, "System\\DATA\\PP5000.DAT", 0, "System\\DATA\\PP5000.HDR", 0x00000A2C, 0, 0, 14, hdrtmpl_fd_megaplayer540, Modified: trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-10 15:09:58 UTC (rev 253) +++ trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-10 15:17:58 UTC (rev 254) @@ -175,10 +175,10 @@ hdr_init_philips_hdd6320, philips_hdd6320_parse_model }, { - "msi_megaplayer540", "MSI Megaplayer 540", + "msi_megaplayer540", "MSI MEGA PLAYER 540", 8, "UM", - "5.40", "5.40", - "SYSTEM\\PP5020.mi4", "System\\DATA\\PP5000.HDR", "Music\\", "Playlists\\", + "01.00.16", "01.00.16", + "SYSTEM\\PP5020.mi4", "System\\DATA\\PP5000.HDR", "MUSIC\\", "Playlists\\", ".pla", hdr_init_msi_megaplayer540, megaplayer_parse_model }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-10 15:10:03
|
Revision: 253 http://svn.sourceforge.net/pmplib/?rev=253&view=rev Author: nyaochi Date: 2007-01-10 07:09:58 -0800 (Wed, 10 Jan 2007) Log Message: ----------- MSI Mega Player 540 support. Modified Paths: -------------- trunk/pmplib/lib/pmp_portalplayer1/hdr.c trunk/pmplib/lib/pmp_portalplayer1/hdr_template.h trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.vcproj Added Paths: ----------- trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c Modified: trunk/pmplib/lib/pmp_portalplayer1/hdr.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/hdr.c 2007-01-08 09:01:37 UTC (rev 252) +++ trunk/pmplib/lib/pmp_portalplayer1/hdr.c 2007-01-10 15:09:58 UTC (rev 253) @@ -65,7 +65,6 @@ for (i = 0;i < hdr->param.max_fields;i++) { p += field_descriptor_serialize(p, &hdr->fd[i], is_storing); } - for (i = 0;i < hdr->param.padding_size;i++) { uint8_t c = 0; p += serialize_uint8(p, &c, is_storing); Modified: trunk/pmplib/lib/pmp_portalplayer1/hdr_template.h =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/hdr_template.h 2007-01-08 09:01:37 UTC (rev 252) +++ trunk/pmplib/lib/pmp_portalplayer1/hdr_template.h 2007-01-10 15:09:58 UTC (rev 253) @@ -71,10 +71,12 @@ int hdr_init_samsung_yh925(hdr_t* hdr); int hdr_init_sirius_s50(hdr_t* hdr); int hdr_init_philips_hdd6320(hdr_t* hdr); +int hdr_init_msi_megaplayer540(hdr_t* hdr); int iriver_h10_parse_model(const ucs2char_t* firmware, pp1model_t* model); int medion_mdjuke220_parse_model(const ucs2char_t* firmware, pp1model_t* model); int samsung_parse_model(const ucs2char_t* firmware, pp1model_t* model); int philips_hdd6320_parse_model(const ucs2char_t* firmware, pp1model_t* model); +int megaplayer_parse_model(const ucs2char_t* firmware, pp1model_t* model); #endif/*__HDR_TEMPLATE_H__*/ Added: trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c (rev 0) +++ trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c 2007-01-10 15:09:58 UTC (rev 253) @@ -0,0 +1,251 @@ +/* + * MSI Megaplayer specific routines and header templates. + * + * Copyright (c) 2005-2007 Nyaochi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +/* $Id$ */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif/*HAVE_CONFIG_H*/ +#ifdef HAVE_STRING_H +#include <string.h> +#endif/*HAVE_STRING_H*/ + +#include <os.h> +#include <stdio.h> +#include <stdlib.h> +#include <ucs2char.h> +#include <filepath.h> + +#include "serialize.h" +#include "util.h" +#include "pp1db.h" +#include "hdr_template.h" + +enum { + PP1DB_DATFIELD_UNKNOWN2 = 0,// @0: (INT) + PP1DB_DATFIELD_PATHNAME, // @1: (STR) + PP1DB_DATFIELD_FILENAME, // @2: (STR) + PP1DB_DATFIELD_FORMAT, // @3: (INT) + PP1DB_DATFIELD_BITRATE, // @4: (INT) + PP1DB_DATFIELD_SAMPLERATE, // @5: (INT) + PP1DB_DATFIELD_DURATION, // @6: (INT) + PP1DB_DATFIELD_ARTIST, // @7: (STR) + PP1DB_DATFIELD_ALBUM, // @8: (STR) + PP1DB_DATFIELD_GENRE, // @9: (STR) + PP1DB_DATFIELD_TITLE, // @10: (STR) + PP1DB_DATFIELD_TRACKNUMBER, // @11: (INT) + PP1DB_DATFIELD_YEAR, // @12: (INT) + PP1DB_DATFIELD_FILESIZE, // @13: (INT) +}; + +static void dat_repr(const dat_t* record, FILE *fp) +{ + fprintf(fp, " inactive: %d\n", record->status); + fprintf(fp, " unknown1: %d\n", record->unknown1); + fprintf(fp, " unknown2: %d\n", record->fields[PP1DB_DATFIELD_UNKNOWN2].value.dword); + fprints(fp, " file_path: %s\n", record->fields[PP1DB_DATFIELD_PATHNAME].value.str); + fprints(fp, " file_name: %s\n", record->fields[PP1DB_DATFIELD_FILENAME].value.str); + fprintf(fp, " media_type: %d\n", record->fields[PP1DB_DATFIELD_FORMAT].value.dword); + fprintf(fp, " bitrate: %d\n", record->fields[PP1DB_DATFIELD_BITRATE].value.dword); + fprintf(fp, " samplerate: %d\n", record->fields[PP1DB_DATFIELD_SAMPLERATE].value.dword); + fprintf(fp, " duration: %d\n", record->fields[PP1DB_DATFIELD_DURATION].value.dword); + fprints(fp, " artist: %s\n", record->fields[PP1DB_DATFIELD_ARTIST].value.str); + fprints(fp, " album: %s\n", record->fields[PP1DB_DATFIELD_ALBUM].value.str); + fprints(fp, " genre: %s\n", record->fields[PP1DB_DATFIELD_GENRE].value.str); + fprints(fp, " title: %s\n", record->fields[PP1DB_DATFIELD_TITLE].value.str); + fprintf(fp, " number: %d\n", record->fields[PP1DB_DATFIELD_TRACKNUMBER].value.dword); + fprintf(fp, " year: %d\n", record->fields[PP1DB_DATFIELD_YEAR].value.dword); + fprintf(fp, " filesize: %d\n", record->fields[PP1DB_DATFIELD_FILESIZE].value.dword); +} + +static int dat_set(dat_t* dst, const pmp_music_record_t* src, const ucs2char_t* path_to_root) +{ + static const ucs2char_t ucs2cs_unknown[] = {0}; + static const ucs2char_t ucs2cs_empty[] = {0}; + + // Set fields. + dst->status = 0; + dst->unknown1 = 0; + dst->fields[PP1DB_DATFIELD_PATHNAME].value.str = ucs2dup(filepath_skiproot(src->filename, path_to_root)); + filepath_remove_filespec(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str); + filepath_addslash(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str); + filepath_encode(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str); + dst->fields[PP1DB_DATFIELD_FILENAME].value.str = ucs2dup(filepath_skippath(src->filename)); + dst->fields[PP1DB_DATFIELD_FORMAT].value.dword = 0; + dst->fields[PP1DB_DATFIELD_BITRATE].value.dword = src->bitrate; + dst->fields[PP1DB_DATFIELD_SAMPLERATE].value.dword = src->sample_rate; + dst->fields[PP1DB_DATFIELD_DURATION].value.dword = src->duration; + dst->fields[PP1DB_DATFIELD_ARTIST].value.str = ucs2dup(src->artist ? src->artist : ucs2cs_unknown); + dst->fields[PP1DB_DATFIELD_ALBUM].value.str = ucs2dup(src->album ? src->album : ucs2cs_unknown); + dst->fields[PP1DB_DATFIELD_GENRE].value.str = ucs2dup(src->genre ? src->genre : ucs2cs_unknown); + dst->fields[PP1DB_DATFIELD_TITLE].value.str = ucs2dup(src->title ? src->title : dst->fields[PP1DB_DATFIELD_FILENAME].value.str); + dst->fields[PP1DB_DATFIELD_TRACKNUMBER].value.dword = src->track_number; + if (src->date) { + dst->fields[PP1DB_DATFIELD_YEAR].value.dword = ucs2toi(src->date); + } + dst->fields[PP1DB_DATFIELD_FILESIZE].value.dword = src->filesize; + return 0; +} + +static int dat_get(pmp_music_record_t* dst, const dat_t* src, const ucs2char_t* path_to_root) +{ + static const ucs2char_t ucs2cs_mp3[] = {'.','m','p','3',0}; + static const ucs2char_t ucs2cs_wma[] = {'.','w','m','a',0}; + static const ucs2char_t ucs2cs_wav[] = {'.','w','a','v',0}; + ucs2char_t tmp[128]; + size_t length = 0; + + length = ucs2len(path_to_root); + length += ucs2len(src->fields[PP1DB_DATFIELD_PATHNAME].value.str); + length += ucs2len(src->fields[PP1DB_DATFIELD_FILENAME].value.str); + length += 3; + + dst->filename = (ucs2char_t*)ucs2malloc(sizeof(ucs2char_t) * length); + if (dst->filename) { + filepath_combinepath(dst->filename, length, path_to_root, src->fields[PP1DB_DATFIELD_PATHNAME].value.str); + filepath_addslash(dst->filename); + ucs2cat(dst->filename, src->fields[PP1DB_DATFIELD_FILENAME].value.str); + } + + dst->bitrate = src->fields[PP1DB_DATFIELD_BITRATE].value.dword; + dst->sample_rate = src->fields[PP1DB_DATFIELD_SAMPLERATE].value.dword; + dst->duration = src->fields[PP1DB_DATFIELD_DURATION].value.dword; + + dst->artist = ucs2dup(src->fields[PP1DB_DATFIELD_ARTIST].value.str); + dst->album = ucs2dup(src->fields[PP1DB_DATFIELD_ALBUM].value.str); + dst->genre = ucs2dup(src->fields[PP1DB_DATFIELD_GENRE].value.str); + dst->title = ucs2dup(src->fields[PP1DB_DATFIELD_TITLE].value.str); + + // Set codec information according to the file extensions. + if (filepath_hasext(dst->filename, ucs2cs_mp3)) { + dst->codec = PMPCODEC_MPEGLAYER3; + } else if (filepath_hasext(dst->filename, ucs2cs_wma)) { + dst->codec = PMPCODEC_WMA; + } else if (filepath_hasext(dst->filename, ucs2cs_wav)) { + dst->codec = PMPCODEC_WAV; + } + + dst->track_number = src->fields[PP1DB_DATFIELD_TRACKNUMBER].value.dword; + itoucs2(src->fields[PP1DB_DATFIELD_YEAR].value.dword, tmp, 10); + dst->date = ucs2dup(tmp); + dst->filesize = src->fields[PP1DB_DATFIELD_FILESIZE].value.dword; + //dst->ts_update = src->fields[PP1DB_DATFIELD_UNKNOWN4].value.dword; + + return 0; +} + +int megaplayer_parse_model(const ucs2char_t* firmware, pp1model_t* model) +{ + FILE *fp = ucs2fopen(firmware, "rb"); + if (fp) { + char line[33], *p = NULL, *q = NULL; + memset(line, 0, sizeof(line)); + + // Seek to the firmware information. + if (fseek(fp, 0x0220, SEEK_SET) != 0) { + fclose(fp); + return 0; + } + + // Read the firmware information. + if (fread(line, sizeof(char), 32, fp) != 32) { + fclose(fp); + return 0; + } + + // Close the firmware. + fclose(fp); + + // Obtain the model name. + strcpy(model->name, "Samsung "); + strcat(model->name, line); + p = line + strlen(line) + 1; + + // Obtain firmware version. + q = strchr(p, ' '); + if (q) { + *q = 0; + } else { + return 0; + } + strcpy(model->version, p); + p = q+1; + + // Obtain the country code? + q = strchr(p, 0xC0); + if (q) { + *q = 0; + } else { + return 0; + } + strcpy(model->language, p); + + strcpy(model->mode, "UM"); + + return 1; + } else { + return 0; + } +} + + + + +static fd_template_t hdrtmpl_fd_megaplayer540[] = { + {0x0000F001, 2, 4, 0, 0, 1, 0, 0, "System\\DATA\\PP...@DE...x"}, + {0x0000F002, 1, 128, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_FPTH.idx"}, + {0x0000F003, 1, 128, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_FNAM.idx"}, + {0x0000F00A, 2, 4, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_FRMT.idx"}, + {0x0000F005, 2, 4, 0, 0, 0, 0, 0, ""}, + {0x0000F006, 2, 4, 0, 0, 0, 0, 0, ""}, + {0x0000F007, 1, 4, 0, 0, 0, 0, 0, ""}, + {0x0000003C, 1, 256, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_TPE1.idx"}, + {0x0000001C, 1, 256, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_TALB.idx"}, + {0x0000001F, 1, 256, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_TCON.idx"}, + {0x0000002E, 1, 256, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_TIT2.idx"}, + {0x00000043, 2, 4, 0, 0, 0, 0, 0, ""}, + {0x0000004E, 2, 4, 0, 0, 0, 0, 0, ""}, + {0x0000F009, 2, 4, 0, 0, 0, 0, 0, ""}, + {0x00000000, 0, 0, 0, 0, 0, 0, 0, ""}, + {0x00000000, 0, 0, 0, 0, 0, 0, 0, ""}, + {0x00000000, 0, 0, 0, 0, 0, 0, 0, ""}, + {0x00000000, 0, 0, 0, 0, 0, 0, 0, ""}, + {0x00000000, 0, 0, 0, 0, 0, 0, 0, ""}, + {0x00000000, 0, 0, 0, 0, 0, 0, 0, ""}, +}; + +static uint32_t hdrtmpl_max_dat_field_size_megaplayer540[] = + {8, 12, 268, 524, 528, 532, 536, 544, 1056, 1568, 2080, 2592, 2596, 2600, 0, 0, 0, 0, 0, 0}; + + +/********** MSI Megaplayer 540 **********/ +static hdr_template_t hdrtmpl_megaplayer540 = { + 0, 0, "System\\DATA\\PP5000.DAT", 0, "System\\DATA\\PP5000.HDR", 0x00000A2C, 0, 0, 14, + hdrtmpl_fd_megaplayer540, + hdrtmpl_max_dat_field_size_megaplayer540, + 0, 0, + {100020, 20, 2000, 0, 0, dat_repr, dat_set, dat_get}, +}; + +int hdr_init_msi_megaplayer540(hdr_t* hdr) +{ + return apply_template(hdr, &hdrtmpl_megaplayer540); +} Property changes on: trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-08 09:01:37 UTC (rev 252) +++ trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-10 15:09:58 UTC (rev 253) @@ -174,6 +174,14 @@ ".pla", hdr_init_philips_hdd6320, philips_hdd6320_parse_model }, + { + "msi_megaplayer540", "MSI Megaplayer 540", + 8, "UM", + "5.40", "5.40", + "SYSTEM\\PP5020.mi4", "System\\DATA\\PP5000.HDR", "Music\\", "Playlists\\", + ".pla", + hdr_init_msi_megaplayer540, megaplayer_parse_model + }, #if 0 { "sirius_s50", "Sirius S50", Modified: trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.vcproj =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.vcproj 2007-01-08 09:01:37 UTC (rev 252) +++ trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.vcproj 2007-01-10 15:09:58 UTC (rev 253) @@ -218,6 +218,10 @@ > </File> <File + RelativePath=".\model_msi_megaplayer.c" + > + </File> + <File RelativePath=".\model_philips_hdd6320.c" > </File> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-08 09:01:39
|
Revision: 252 http://svn.sourceforge.net/pmplib/?rev=252&view=rev Author: nyaochi Date: 2007-01-08 01:01:37 -0800 (Mon, 08 Jan 2007) Log Message: ----------- - Documentation for PMPlib Helper API (pmplib_*). - Define @default and @assert paragraphs in Doxyfile Modified Paths: -------------- trunk/pmplib/doc/Doxyfile trunk/pmplib/include/pmp.h trunk/pmplib/lib/pmp/pmp.c Modified: trunk/pmplib/doc/Doxyfile =================================================================== --- trunk/pmplib/doc/Doxyfile 2007-01-07 19:38:17 UTC (rev 251) +++ trunk/pmplib/doc/Doxyfile 2007-01-08 09:01:37 UTC (rev 252) @@ -34,7 +34,8 @@ INHERIT_DOCS = YES SEPARATE_MEMBER_PAGES = NO TAB_SIZE = 8 -ALIASES = +ALIASES = "assert=\par Assertions:\n" \ + "default=\par Default Value:\n" OPTIMIZE_OUTPUT_FOR_C = YES OPTIMIZE_OUTPUT_JAVA = NO BUILTIN_STL_SUPPORT = NO Modified: trunk/pmplib/include/pmp.h =================================================================== --- trunk/pmplib/include/pmp.h 2007-01-07 19:38:17 UTC (rev 251) +++ trunk/pmplib/include/pmp.h 2007-01-08 09:01:37 UTC (rev 252) @@ -28,12 +28,26 @@ #define PMPAPI __declspec(dllexport) #else #define PMPAPI -#endif +#endif/*PMP_EXPORTS*/ #ifdef __cplusplus extern "C" { #endif/*__cplusplus*/ + +/** + * @mainpage PMPlib API Documentation + * + * @section intro Introduction + * + * This is the documentation for the PMPlib API. + */ + +/** + * \addtogroup pmp PMPlib APIs + * @{ + */ + /* * Forward structure declarations. */ @@ -129,7 +143,14 @@ /** - * The root interface for a portable media device. + * The root interface for portable media device. + * This structure represents the basic interface that is common to any + * portal media devices. It defines several member variables and pure + * virtual functions to access the implementation for the target device. + * Use pmplib_create() function to obtain the instance suitable for a + * specific device. + * + * @see pmplib_create */ struct tag_pmp_t { /** @@ -237,6 +258,11 @@ }; typedef result_t (*pmp_create_t)(pmp_t** pmp, const ucs2char_t* path_to_device, const char *devid); + +/** + * Prototype for the callback function for receiving device identifiers. + * + */ typedef void (*pmp_enumerate_devid_callback_t)(void *instance, const char *devid); typedef result_t (*pmp_enumerate_devid_t)(pmp_enumerate_devid_callback_t callback, void *instance); @@ -245,20 +271,186 @@ PMPAPI result_t pmp_record_copy(pmp_music_record_t* dst, const pmp_music_record_t* src); PMPAPI uint32_t pmp_interlocked_increment(uint32_t* count); PMPAPI uint32_t pmp_interlocked_decrement(uint32_t* count); +PMPAPI void pmp_copy_environment(pmp_environment_t* dst, const pmp_environment_t* src); -struct tag_pmplib_t; typedef struct tag_pmplib_t pmplib_t; + + + + +/** + * @defgroup pmplib PMPlib Helper API + * + * This API provides the utility for selecting a PMPlib driver from a number + * of installed ones. Because the PMPlib project implements a number of + * drivers for different portable media devices, an application must choose + * a suitable driver that matches to the target device. Using this API, an + * application can query a driver suitable for the portable media device + * specified by the mount location (root directory of the device) and/or + * string identifier. An application can also enumerate the string + * identifiers of the drivers installed in the system. + * + * An application must call pmplib_init() function to initialize the API + * and obtain the pointer to a ::pmplib_t instance that is used for subsequent + * calls of the API. + * The application can query an interface to a PMPlib driver by using + * pmplib_create() function. A list of installed device identifiers is + * obtained by receiving callback notifications invoked by + * pmplib_enumerate_devid() function. The application must terminate this + * API by calling pmplib_finish() function. + * + * This is an example of querying an interface to the driver that matches to + * the device connected to the mount point (Win32 path "D:\"): + * + * @code + * #include <ucs2char.h> + * #include <pmp.h> + * + * int main(int argc, char *argv[]) + * { + * result_t ret = 0; + * pmp_t* pmp = NULL; + * pmplib_t* pmplib = NULL; + * static const ucs2char_t path[] = {'D',':','\\',0}; + * + * // Initialize the PMPlib Helper API. + * if ((ret = pmplib_init(&pmplib)) != 0) { + * // Failed to initialize the API. + * goto error_exit; + * } + * + * // Query an interface to the PMPlib driver suitable for the path. + * if ((ret = pmplib_create(pmplib, &pmp, path, NULL)) != 0) { + * // Failed to find a suitable driver. + * goto error_exit; + * } + * + * // Processing with the driver. + * ... + * + * // Release the driver. + * pmp->release(pmp); + * + * // Terminate the helper API. + * pmplib_finish(pmplib); + * return 0; + * + * error_exit: + * // Error handling. + * ... + * return 1; + * } + * @endcode + * + * @{ + */ + +struct tag_pmplib_t; + +/** + * The structure for the PMPlib Helper API. + * An application should use a pointer to this structure as a handle value + * for this API. Call pmplib_init() function to obtain a pointer to this + * structure and pmplib_finish() function to terminate this API. Access to + * a member in this structure is prohibited since it is reserved for the + * internal use of the library implementation only. + */ +typedef struct tag_pmplib_t pmplib_t; + +/** + * Initialize the PMPlib helper library. + * + * This function loads the drivers installed in the system to prepare them. + * + * @retval ptr_pmplib The pointer to the buffer to receive the pointer + * to the ::pmplib_t instance initialized by this + * function. + * @retval result_t The status code. + * + * @assert + * @code ptr_pmplib != NULL @endcode + * + * @note + * Call this function before using any other functions in this API. + */ PMPAPI result_t pmplib_init(pmplib_t** ptr_pmplib); +/** + * Uninitialize the PMPlib helper library. + * + * This function detatch the drivers loaded by pmplib_init() function. + * + * @param pmplib The pointer to the ::pmplib_t instance. + * @retval result_t The status code. + * + * @assert + * @code ptr_pmplib != NULL @endcode + * + * @note + * Call this function to terminate this API. + */ PMPAPI result_t pmplib_finish(pmplib_t* pmplib); -PMPAPI result_t pmplib_create(pmplib_t* pmplib, pmp_t** pmp, const ucs2char_t* path_to_device, const char *id); +/** + * Query a driver and create a ::pmp_t instance. + * + * This function queries the driver suitable for the portable media device + * specified by the mount location and/or identifier, and returns the + * interface to the driver (::pmp_t instance). An application must specify + * parameter \a path_to_device. If parameter \a id is not \c NULL, this + * function constructs a ::pmp_t instance of the driver with the device + * identifier. If the parameter \a id is \c NULL, this function tries to + * recognize the model of the device based on the content under the location + * (\a path_to_device). If successful, the interface to the driver will be + * returned to the \a pmp argument. + * + * @param pmplib The pointer to the ::pmplib_t instance. + * @param path_to_device A UCS-2 string representing the location of the + * target device. This parameter cannot be \c NULL. + * @param id A C-string representing the device identifier of + * the target device. If this argument is \c NULL, + * this function tries to recognize the model of the + * device based on the location (\a path_to_device). + * @retval ptr_pmp The pointer to the buffer to receive the pointer + * to the driver interface (::pmp_t instance). + * @retval result_t The status code. + * + * @assert + * @code pmplib != NULL @endcode + * @code ptr_pmp != NULL @endcode + * @code path_to_device != NULL @endcode + */ +PMPAPI result_t pmplib_create(pmplib_t* pmplib, pmp_t** ptr_pmp, const ucs2char_t* path_to_device, const char *id); +/** + * Enumerate device identifiers of the installed drivers. + * + * This function enumerates the device identifiers of the installed drivers, + * and invokes the \a callback function for each identifier. + * + * @param pmplib The pointer to the ::pmplib_t instance. + * @param callback The pointer to the callback function to receive + * device identifiers. + * @param instance A user-defined instance value. The callback + * function will receive the same value so that it can + * distinguish the caller. + * @retval result_t The status code. + * + * @assert + * @code pmplib != NULL @endcode + * @code callback != NULL @endcode + */ PMPAPI result_t pmplib_enumerate_devid(pmplib_t* pmplib, pmp_enumerate_devid_callback_t callback, void *instance); -PMPAPI void pmplib_copy_environment(pmp_environment_t* dst, const pmp_environment_t* src); +/** + * @} + */ +/** + * @} + */ + #ifdef __cplusplus } #endif/*__cplusplus*/ Modified: trunk/pmplib/lib/pmp/pmp.c =================================================================== --- trunk/pmplib/lib/pmp/pmp.c 2007-01-07 19:38:17 UTC (rev 251) +++ trunk/pmplib/lib/pmp/pmp.c 2007-01-08 09:01:37 UTC (rev 252) @@ -63,7 +63,7 @@ return 0; } -void pmplib_copy_environment(pmp_environment_t* dst, const pmp_environment_t* src) +void pmp_copy_environment(pmp_environment_t* dst, const pmp_environment_t* src) { memcpy(dst, src, sizeof(*src)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-07 19:38:17
|
Revision: 251 http://svn.sourceforge.net/pmplib/?rev=251&view=rev Author: nyaochi Date: 2007-01-07 11:38:17 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Oops, I forgot to uncomment the line for console_clearln(). Modified Paths: -------------- trunk/pmplib/frontend/easypmp/cui/util.c Modified: trunk/pmplib/frontend/easypmp/cui/util.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/util.c 2007-01-07 19:36:24 UTC (rev 250) +++ trunk/pmplib/frontend/easypmp/cui/util.c 2007-01-07 19:38:17 UTC (rev 251) @@ -78,7 +78,7 @@ *p++ = ' '; ucs2cpy(p, msg); - //console_clearln(fp); + console_clearln(fp); console_println(fp, str, 0); return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |