mirror of
https://github.com/holub/mame
synced 2025-04-22 00:11:58 +03:00
more chdcd.c errormessage enhancements / adapted error messages for emu/sound/samples.c / fixed GCC compile (nw)
This commit is contained in:
parent
7b9cc374ef
commit
614fa9b9f4
@ -462,14 +462,20 @@ bool samples_device::read_wav_sample(emu_file &file, sample_t &sample)
|
||||
UINT32 filesize;
|
||||
offset += file.read(&filesize, 4);
|
||||
if (offset < 8)
|
||||
{
|
||||
mame_printf_warning("Unexpected size offset %u (%s)\n", offset, file.filename());
|
||||
return false;
|
||||
}
|
||||
filesize = LITTLE_ENDIANIZE_INT32(filesize);
|
||||
|
||||
// read the RIFF file type and make sure it's a WAVE file
|
||||
char buf[32];
|
||||
offset += file.read(buf, 4);
|
||||
if (offset < 12)
|
||||
{
|
||||
mame_printf_warning("Unexpected WAVE offset %u (%s)\n", offset, file.filename());
|
||||
return false;
|
||||
}
|
||||
if (memcmp(&buf[0], "WAVE", 4) != 0)
|
||||
return false;
|
||||
|
||||
@ -487,7 +493,10 @@ bool samples_device::read_wav_sample(emu_file &file, sample_t &sample)
|
||||
file.seek(length, SEEK_CUR);
|
||||
offset += length;
|
||||
if (offset >= filesize)
|
||||
{
|
||||
mame_printf_warning("Could not find fmt tag (%s)\n", file.filename());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// read the format -- make sure it is PCM
|
||||
@ -495,13 +504,19 @@ bool samples_device::read_wav_sample(emu_file &file, sample_t &sample)
|
||||
offset += file.read(&temp16, 2);
|
||||
temp16 = LITTLE_ENDIANIZE_INT16(temp16);
|
||||
if (temp16 != 1)
|
||||
{
|
||||
mame_printf_warning("unsupported format %u - only PCM is supported (%s)\n", temp16, file.filename());
|
||||
return false;
|
||||
}
|
||||
|
||||
// number of channels -- only mono is supported
|
||||
offset += file.read(&temp16, 2);
|
||||
temp16 = LITTLE_ENDIANIZE_INT16(temp16);
|
||||
if (temp16 != 1)
|
||||
{
|
||||
mame_printf_warning("unsupported number of channels %u - only mono is supported (%s)\n", temp16, file.filename());
|
||||
return false;
|
||||
}
|
||||
|
||||
// sample rate
|
||||
UINT32 rate;
|
||||
@ -516,7 +531,10 @@ bool samples_device::read_wav_sample(emu_file &file, sample_t &sample)
|
||||
offset += file.read(&bits, 2);
|
||||
bits = LITTLE_ENDIANIZE_INT16(bits);
|
||||
if (bits != 8 && bits != 16)
|
||||
{
|
||||
mame_printf_warning("unsupported bits/sample %u - only 8 and 16 are supported (%s)\n", bits, file.filename());
|
||||
return false;
|
||||
}
|
||||
|
||||
// seek past any extra data
|
||||
file.seek(length - 16, SEEK_CUR);
|
||||
@ -535,12 +553,18 @@ bool samples_device::read_wav_sample(emu_file &file, sample_t &sample)
|
||||
file.seek(length, SEEK_CUR);
|
||||
offset += length;
|
||||
if (offset >= filesize)
|
||||
{
|
||||
mame_printf_warning("Could not find data tag (%s)\n", file.filename());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// if there was a 0 length data block, we're done
|
||||
if (length == 0)
|
||||
{
|
||||
mame_printf_warning("empty data block (%s)\n", file.filename());
|
||||
return false;
|
||||
}
|
||||
|
||||
// fill in the sample data
|
||||
sample.frequency = rate;
|
||||
|
@ -164,7 +164,7 @@ static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs)
|
||||
if (offset < 4)
|
||||
{
|
||||
osd_close(file);
|
||||
printf("ERROR: unexpected RIFF offset %lu (%s)\n", actual, filename);
|
||||
printf("ERROR: unexpected RIFF offset %lu (%s)\n", offset, filename);
|
||||
return 0;
|
||||
}
|
||||
if (memcmp(&buf[0], "RIFF", 4) != 0)
|
||||
@ -180,7 +180,7 @@ static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs)
|
||||
if (offset < 8)
|
||||
{
|
||||
osd_close(file);
|
||||
printf("ERROR: unexpected size offset %lu (%s)\n", actual, filename);
|
||||
printf("ERROR: unexpected size offset %lu (%s)\n", offset, filename);
|
||||
return 0;
|
||||
}
|
||||
filesize = LITTLE_ENDIANIZE_INT32(filesize);
|
||||
@ -191,13 +191,13 @@ static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs)
|
||||
if (offset < 12)
|
||||
{
|
||||
osd_close(file);
|
||||
printf("ERROR: unexpected WAVE offset %lu (%s)\n", actual, filename);
|
||||
printf("ERROR: unexpected WAVE offset %lu (%s)\n", offset, filename);
|
||||
return 0;
|
||||
}
|
||||
if (memcmp(&buf[0], "WAVE", 4) != 0)
|
||||
{
|
||||
osd_close(file);
|
||||
printf("ERROR:could not find WAVE header (%s)\n", filename);
|
||||
printf("ERROR: could not find WAVE header (%s)\n", filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs)
|
||||
if (offset >= filesize)
|
||||
{
|
||||
osd_close(file);
|
||||
printf("ERROR:could not find fmt tag (%s)\n", filename);
|
||||
printf("ERROR: could not find fmt tag (%s)\n", filename);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -297,7 +297,10 @@ static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs)
|
||||
|
||||
/* if there was a 0 length data block, we're done */
|
||||
if (length == 0)
|
||||
{
|
||||
printf("ERROR: empty data block (%s)\n", filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*dataoffs = offset;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user