Previous 199869 Revisions Next

r20105 Sunday 6th January, 2013 at 14:52:40 UTC by Oliver Stöneberg
more chdcd.c errormessage enhancements / adapted error messages for emu/sound/samples.c / fixed GCC compile (nw)
[src/emu/sound]samples.c
[src/lib/util]chdcd.c

trunk/src/lib/util/chdcd.c
r20104r20105
164164   if (offset < 4)
165165   {
166166      osd_close(file);
167      printf("ERROR: unexpected RIFF offset %lu (%s)\n", actual, filename);
167      printf("ERROR: unexpected RIFF offset %lu (%s)\n", offset, filename);
168168      return 0;
169169   }
170170   if (memcmp(&buf[0], "RIFF", 4) != 0)
r20104r20105
180180   if (offset < 8)
181181   {
182182      osd_close(file);
183      printf("ERROR: unexpected size offset %lu (%s)\n", actual, filename);
183      printf("ERROR: unexpected size offset %lu (%s)\n", offset, filename);
184184      return 0;
185185   }
186186   filesize = LITTLE_ENDIANIZE_INT32(filesize);
r20104r20105
191191   if (offset < 12)
192192   {
193193      osd_close(file);
194      printf("ERROR: unexpected WAVE offset %lu (%s)\n", actual, filename);
194      printf("ERROR: unexpected WAVE offset %lu (%s)\n", offset, filename);
195195      return 0;
196196   }
197197   if (memcmp(&buf[0], "WAVE", 4) != 0)
198198   {
199199      osd_close(file);
200      printf("ERROR:could not find WAVE header (%s)\n", filename);
200      printf("ERROR: could not find WAVE header (%s)\n", filename);
201201      return 0;
202202   }
203203
r20104r20105
217217      if (offset >= filesize)
218218      {
219219         osd_close(file);
220         printf("ERROR:could not find fmt tag (%s)\n", filename);
220         printf("ERROR: could not find fmt tag (%s)\n", filename);
221221         return 0;
222222      }
223223   }
r20104r20105
297297
298298   /* if there was a 0 length data block, we're done */
299299   if (length == 0)
300   {
301      printf("ERROR: empty data block (%s)\n", filename);
300302      return 0;
303   }
301304
302305   *dataoffs = offset;
303306
trunk/src/emu/sound/samples.c
r20104r20105
462462   UINT32 filesize;
463463   offset += file.read(&filesize, 4);
464464   if (offset < 8)
465   {
466      mame_printf_warning("Unexpected size offset %u (%s)\n", offset, file.filename());
465467      return false;
468   }
466469   filesize = LITTLE_ENDIANIZE_INT32(filesize);
467470
468471   // read the RIFF file type and make sure it's a WAVE file
469472   char buf[32];
470473   offset += file.read(buf, 4);
471474   if (offset < 12)
475   {
476      mame_printf_warning("Unexpected WAVE offset %u (%s)\n", offset, file.filename());
472477      return false;
478   }
473479   if (memcmp(&buf[0], "WAVE", 4) != 0)
474480      return false;
475481
r20104r20105
487493      file.seek(length, SEEK_CUR);
488494      offset += length;
489495      if (offset >= filesize)
496      {
497         mame_printf_warning("Could not find fmt tag (%s)\n", file.filename());
490498         return false;
499      }
491500   }
492501
493502   // read the format -- make sure it is PCM
r20104r20105
495504   offset += file.read(&temp16, 2);
496505   temp16 = LITTLE_ENDIANIZE_INT16(temp16);
497506   if (temp16 != 1)
507   {
508      mame_printf_warning("unsupported format %u - only PCM is supported (%s)\n", temp16, file.filename());
498509      return false;
510   }
499511
500512   // number of channels -- only mono is supported
501513   offset += file.read(&temp16, 2);
502514   temp16 = LITTLE_ENDIANIZE_INT16(temp16);
503515   if (temp16 != 1)
516   {
517      mame_printf_warning("unsupported number of channels %u - only mono is supported (%s)\n", temp16, file.filename());
504518      return false;
519   }
505520
506521   // sample rate
507522   UINT32 rate;
r20104r20105
516531   offset += file.read(&bits, 2);
517532   bits = LITTLE_ENDIANIZE_INT16(bits);
518533   if (bits != 8 && bits != 16)
534   {
535      mame_printf_warning("unsupported bits/sample %u - only 8 and 16 are supported (%s)\n", bits, file.filename());
519536      return false;
537   }
520538
521539   // seek past any extra data
522540   file.seek(length - 16, SEEK_CUR);
r20104r20105
535553      file.seek(length, SEEK_CUR);
536554      offset += length;
537555      if (offset >= filesize)
556      {
557         mame_printf_warning("Could not find data tag (%s)\n", file.filename());
538558         return false;
559      }
539560   }
540561
541562   // if there was a 0 length data block, we're done
542563   if (length == 0)
564   {
565      mame_printf_warning("empty data block (%s)\n", file.filename());
543566      return false;
567   }
544568
545569   // fill in the sample data
546570   sample.frequency = rate;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team