Mercurial > audlegacy-plugins
comparison src/madplug/decoder.c @ 793:98cdc39031f9 trunk
[svn] - add sanity check for open audio parameters.
| author | yaz |
|---|---|
| date | Wed, 07 Mar 2007 06:16:04 -0800 |
| parents | 2b2313fc1ddc |
| children | 93dbfe1f0cd0 |
comparison
equal
deleted
inserted
replaced
| 792:2b2313fc1ddc | 793:98cdc39031f9 |
|---|---|
| 206 memcpy(buffer, stream.this_frame, remainder); | 206 memcpy(buffer, stream.this_frame, remainder); |
| 207 len = input_get_data(info, buffer + remainder, | 207 len = input_get_data(info, buffer + remainder, |
| 208 BUFFER_SIZE - remainder); | 208 BUFFER_SIZE - remainder); |
| 209 | 209 |
| 210 if (len <= 0) { | 210 if (len <= 0) { |
| 211 g_message("scan_file: len <= 0! len = %d\n", len); | 211 #ifdef DEBUG |
| 212 g_message("scan_file: len <= 0! len = %d", len); | |
| 213 #endif | |
| 212 break; | 214 break; |
| 213 } | 215 } |
| 214 | 216 |
| 215 mad_stream_buffer(&stream, buffer, len + remainder); | 217 mad_stream_buffer(&stream, buffer, len + remainder); |
| 216 | 218 |
| 409 } | 411 } |
| 410 | 412 |
| 411 #ifdef DEBUG | 413 #ifdef DEBUG |
| 412 g_message("decode: fmt = %d freq = %d channels = %d", info->fmt, info->freq, info->channels); | 414 g_message("decode: fmt = %d freq = %d channels = %d", info->fmt, info->freq, info->channels); |
| 413 #endif | 415 #endif |
| 416 // sanity check. | |
| 417 if(info->fmt < FMT_U8 || info->fmt > FMT_S16_NE) | |
| 418 return NULL; | |
| 419 if(info->freq < 0) // not sure about maximum frequency. --yaz | |
| 420 return NULL; | |
| 421 if(info->channels < 1 || info->channels > 2) | |
| 422 return NULL; | |
| 423 | |
| 414 if (!info->playback->output->open_audio(info->fmt, info->freq, info->channels)) { | 424 if (!info->playback->output->open_audio(info->fmt, info->freq, info->channels)) { |
| 415 g_mutex_lock(pb_mutex); | 425 g_mutex_lock(pb_mutex); |
| 416 info->playback->error = TRUE; | 426 info->playback->error = TRUE; |
| 417 info->playback->eof = 1; | 427 info->playback->eof = 1; |
| 418 g_mutex_unlock(pb_mutex); | 428 g_mutex_unlock(pb_mutex); |
