changeset 138:70baf29577d8

Added default sample format.
author Ryan C. Gordon <icculus@icculus.org>
date Mon, 15 Oct 2001 18:04:49 +0000
parents e3f4767d6037
children b4bbaf0d588f
files decoders/midi.c
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/decoders/midi.c	Fri Oct 12 17:31:46 2001 +0000
+++ b/decoders/midi.c	Mon Oct 15 18:04:49 2001 +0000
@@ -126,8 +126,18 @@
     int fd2[2];
     pid_t pid;
 
-        /* TiMidity does all the conversions we need. */
-    memcpy(&sample->actual, &sample->desired, sizeof (Sound_AudioInfo));
+        /*
+         * Use the desired format if available, or pick sensible defaults.
+         * TiMidity does all the conversions we need.
+         */
+    if (sample->desired.rate == 0)
+    {
+        sample->actual.channels = 2;
+        sample->actual.rate = 44100;
+        sample->actual.format = AUDIO_S16SYS;
+    } /* if */
+    else
+        memcpy(&sample->actual, &sample->desired, sizeof (Sound_AudioInfo));
     sample->flags = SOUND_SAMPLEFLAG_NONE;
 
     if (pipe(fd1) < 0 || pipe(fd2) < 0)