[BACK]Return to midiplay.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / midiplay

Diff for /src/usr.bin/midiplay/Attic/midiplay.c between version 1.2 and 1.3

version 1.2, 2002/02/16 21:27:49 version 1.3, 2002/03/14 06:51:42
Line 265 
Line 265 
         size = 1000;          size = 1000;
         buf = malloc(size);          buf = malloc(size);
         if (buf == 0)          if (buf == 0)
                 errx(1, "malloc() failed\n");                  errx(1, "malloc() failed");
         nread = size;          nread = size;
         tot = 0;          tot = 0;
         for (;;) {          for (;;) {
Line 278 
Line 278 
                 size *= 2;                  size *= 2;
                 buf = realloc(buf, size);                  buf = realloc(buf, size);
                 if (buf == NULL)                  if (buf == NULL)
                         errx(1, "realloc() failed\n");                          errx(1, "realloc() failed");
         }          }
         playdata(buf, tot, name);          playdata(buf, tot, name);
         free(buf);          free(buf);
Line 303 
Line 303 
                 printf("Playing %s (%d bytes) ... \n", name, tot);                  printf("Playing %s (%d bytes) ... \n", name, tot);
   
         if (memcmp(buf, MARK_HEADER, MARK_LEN) != 0) {          if (memcmp(buf, MARK_HEADER, MARK_LEN) != 0) {
                 warnx("Not a MIDI file, missing header\n");                  warnx("Not a MIDI file, missing header");
                 return;                  return;
         }          }
         if (GET32(buf + MARK_LEN) != HEADER_LEN) {          if (GET32(buf + MARK_LEN) != HEADER_LEN) {
                 warnx("Not a MIDI file, bad header\n");                  warnx("Not a MIDI file, bad header");
                 return;                  return;
         }          }
         format = GET16(buf + MARK_LEN + SIZE_LEN);          format = GET16(buf + MARK_LEN + SIZE_LEN);
Line 318 
Line 318 
         if ((divfmt & 0x80) == 0)          if ((divfmt & 0x80) == 0)
                 ticks |= divfmt << 8;                  ticks |= divfmt << 8;
         else          else
                 errx(1, "Absolute time codes not implemented yet\n");                  errx(1, "Absolute time codes not implemented yet");
         if (verbose > 1)          if (verbose > 1)
                 printf("format=%d ntrks=%d divfmt=%x ticks=%d\n",                  printf("format=%d ntrks=%d divfmt=%x ticks=%d\n",
                        format, ntrks, divfmt, ticks);                         format, ntrks, divfmt, ticks);
         if (format != 0 && format != 1) {          if (format != 0 && format != 1) {
                 warnx("Cannnot play MIDI file of type %d\n", format);                  warnx("Cannnot play MIDI file of type %d", format);
                 return;                  return;
         }          }
         if (ntrks == 0)          if (ntrks == 0)
                 return;                  return;
         tracks = malloc(ntrks * sizeof(struct track));          tracks = malloc(ntrks * sizeof(struct track));
         if (tracks == NULL)          if (tracks == NULL)
                 errx(1, "malloc() tracks failed\n");                  errx(1, "malloc() tracks failed");
         for (t = 0; t < ntrks; ) {          for (t = 0; t < ntrks; ) {
                 if (p >= end - MARK_LEN - SIZE_LEN) {                  if (p >= end - MARK_LEN - SIZE_LEN) {
                         warnx("Cannot find track %d\n", t);                          warnx("Cannot find track %d", t);
                         goto ret;                          goto ret;
                 }                  }
                 len = GET32(p + MARK_LEN);                  len = GET32(p + MARK_LEN);
                 if (len > 1000000) { /* a safe guard */                  if (len > 1000000) { /* a safe guard */
                         warnx("Crazy track length\n");                          warnx("Crazy track length");
                         goto ret;                          goto ret;
                 }                  }
                 if (memcmp(p, MARK_TRACK, MARK_LEN) == 0) {                  if (memcmp(p, MARK_TRACK, MARK_LEN) == 0) {
Line 539 
Line 539 
         if (ioctl(fd, SEQUENCER_NRMIDIS, &nmidi) < 0)          if (ioctl(fd, SEQUENCER_NRMIDIS, &nmidi) < 0)
                 err(1, "ioctl(SEQUENCER_NRMIDIS) failed, ");                  err(1, "ioctl(SEQUENCER_NRMIDIS) failed, ");
         if (nmidi == 0)          if (nmidi == 0)
                 errx(1, "Sorry, no MIDI devices available\n");                  errx(1, "Sorry, no MIDI devices available");
         if (listdevs) {          if (listdevs) {
                 for (info.device = 0; info.device < nmidi; info.device++) {                  for (info.device = 0; info.device < nmidi; info.device++) {
                         if (ioctl(fd, SEQUENCER_INFO, &info) < 0)                          if (ioctl(fd, SEQUENCER_INFO, &info) < 0)

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3