mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 00:40:13 +00:00
audio testcard: error on WAV reading error
If WAV is used, error if size is 0 - it doesn't make any case to continue and it will fil on floating point exception, anyways.
This commit is contained in:
@@ -331,7 +331,12 @@ static void * audio_cap_testcard_init(struct module *parent, const char *cfg)
|
||||
unsigned int samples = wav_read(read_to, s->total_samples, wav, &metadata);
|
||||
int bytes = samples * (metadata.bits_per_sample / 8) * metadata.ch_count;
|
||||
if (samples != s->total_samples) {
|
||||
LOG(LOG_LEVEL_WARNING) << MOD_NAME << "Warning: premature end of WAV file (" << bytes << " read, " << metadata.data_size << " expected)!\n";
|
||||
LOG(samples > 0 ? LOG_LEVEL_WARNING : LOG_LEVEL_ERROR) << MOD_NAME << "Warning: premature end of WAV file (" << bytes << " read, " << metadata.data_size << " expected)!\n";
|
||||
if (samples == 0) {
|
||||
fclose(wav);
|
||||
delete s;
|
||||
return NULL;
|
||||
}
|
||||
s->total_samples = samples;
|
||||
}
|
||||
fclose(wav);
|
||||
|
||||
@@ -311,10 +311,10 @@ private:
|
||||
};
|
||||
|
||||
#define LOG(level) \
|
||||
if (level <= log_level) Logger(level).Get()
|
||||
if ((level) <= log_level) Logger(level).Get()
|
||||
|
||||
#define LOG_ONCE(level, id, msg) \
|
||||
if (level <= log_level) Logger(level).once(id, msg)
|
||||
if ((level) <= log_level) Logger(level).once(id, msg)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user