|
|
@@ -74,8 +74,22 @@ static int wavplay_parse_header(void *file, struct wav_info *info)
|
|
|
if (info->fmt_block.fmt_size > sizeof(struct WAVE_FORMAT_DEF))
|
|
|
RomFileSeek((RomFile *)file, info->fmt_block.fmt_size - sizeof(struct WAVE_FORMAT_DEF), SEEK_CUR);
|
|
|
|
|
|
- if (RomFileRead((RomFile *)file, &(info->data_block), sizeof(struct DATA_BLOCK_DEF)) <= 0)
|
|
|
- goto __exit;
|
|
|
+ max_sub_chunk = 8;
|
|
|
+ while(1)
|
|
|
+ {
|
|
|
+ if (RomFileRead((RomFile *)file, &(info->data_block), sizeof(struct DATA_BLOCK_DEF)) <= 0)
|
|
|
+ goto __exit;
|
|
|
+
|
|
|
+ if(memcmp(info->data_block.data_id, "data", 4) == 0)
|
|
|
+ break; /* "data" sub-chunk fond */
|
|
|
+
|
|
|
+ /* sub-chunk "data" not fond, seek to the next sub-chunk */
|
|
|
+ RomFileSeek((RomFile *)file, info->data_block.data_size, SEEK_CUR);
|
|
|
+
|
|
|
+ /* timeout */
|
|
|
+ if(max_sub_chunk-- <= 0)
|
|
|
+ goto __exit;
|
|
|
+ };
|
|
|
#else
|
|
|
if (ff_fread(&(info->header), sizeof(struct RIFF_HEADER_DEF), 1, (FF_FILE *)file) <= 0)
|
|
|
goto __exit;
|
|
|
@@ -99,8 +113,22 @@ static int wavplay_parse_header(void *file, struct wav_info *info)
|
|
|
if (info->fmt_block.fmt_size > sizeof(struct WAVE_FORMAT_DEF))
|
|
|
ff_fseek((FF_FILE *)file, info->fmt_block.fmt_size - sizeof(struct WAVE_FORMAT_DEF), FF_SEEK_CUR);
|
|
|
|
|
|
- if (ff_fread(&(info->data_block), sizeof(struct DATA_BLOCK_DEF), 1, (FF_FILE *)file) <= 0)
|
|
|
- goto __exit;
|
|
|
+ max_sub_chunk = 8;
|
|
|
+ while(1)
|
|
|
+ {
|
|
|
+ if (ff_fread(&(info->data_block), sizeof(struct DATA_BLOCK_DEF), 1, (FF_FILE *)file) <= 0)
|
|
|
+ goto __exit;
|
|
|
+
|
|
|
+ if(memcmp(info->data_block.data_id, "data", 4) == 0)
|
|
|
+ break; // "data" sub-chunk fond.
|
|
|
+
|
|
|
+ /* sub-chunk "fmt " not fond, seek to the next sub-chunk */
|
|
|
+ ff_fseek((FF_FILE *)file, info->data_block.data_size, FF_SEEK_CUR);
|
|
|
+
|
|
|
+ /* timeout */
|
|
|
+ if(max_sub_chunk-- <= 0)
|
|
|
+ goto __exit;
|
|
|
+ };
|
|
|
#endif
|
|
|
|
|
|
return 0;
|