read fmt chunks properly

This commit is contained in:
Bill Currie 2003-04-10 22:03:55 +00:00
parent 5e98c762ed
commit 722c55391e
3 changed files with 28 additions and 2 deletions

View file

@ -56,8 +56,8 @@ typedef struct riff_d_cue_s {
typedef struct riff_d_format_s {
unsigned short format_tag;
unsigned short channels;
unsigned samples_pre_sec;
unsigned byte_per_sec;
unsigned samples_per_sec;
unsigned bytes_per_sec;
unsigned short align;
} riff_d_format_t;

View file

@ -312,6 +312,18 @@ riff_read (QFile *f)
chunk = &list->ck;
}
break;
case RIFF_CASE ('f','m','t',' '):
{
riff_format_t *fmt;
fmt = malloc (sizeof (riff_format_t) + ck.len);
fmt->ck = ck;
if (!Rread (f, fmt->fdata, ck.len)) {
free (fmt);
} else {
chunk = &fmt->ck;
}
}
break;
case RIFF_CASE ('d','a','t','a'):
{
riff_data_t *data = malloc (sizeof (riff_data_t));
@ -455,6 +467,9 @@ riff_free (riff_t *riff)
list = (riff_list_t *) *ck;
free_list (list);
break;
case RIFF_CASE ('f','m','t',' '):
free (*ck);
break;
default:
data = (riff_data_t *) *ck;
if (data->data)

View file

@ -27,6 +27,17 @@ main (int argc, char **argv)
sample_count = -1;
for (ck = riff->chunks; *ck; ck++) {
RIFF_SWITCH ((*ck)->name) {
case RIFF_CASE ('f', 'm', 't', ' '):
/*{
riff_format_t *_fmt = (riff_format_t *) *ck;
riff_d_format_t *fmt = (riff_d_format_t *) _fmt->fdata;
printf ("fmt.format_tag = %d\n", fmt->format_tag);
printf ("fmt.channels = %d\n", fmt->channels);
printf ("fmt.samples_per_sec = %d\n", fmt->samples_per_sec);
printf ("fmt.bytes_per_sec = %d\n", fmt->bytes_per_sec);
printf ("fmt.align = %d\n", fmt->align);
}*/
break;
case RIFF_CASE ('c', 'u', 'e', ' '):
{
riff_cue_t *cue = (riff_cue_t *)*ck;