Drastically simplify getaiff.
authorTimo Korvola <tkorvola@iki.fi>
Sat, 3 Mar 2018 12:54:30 +0000 (14:54 +0200)
committerDavid Griffith <dave@661.org>
Sun, 11 Mar 2018 11:48:50 +0000 (04:48 -0700)
Axe all conversion code (which was complicated and likely buggy)
and let SDL_mixer take care of everything.

src/sdl/Makefile
src/sdl/sf_aiffwav.c
src/sdl/sf_sound.c

index d8f5a5a8d2d759ebd7d1aee54e3dae53eb0afbde..c0ca1fe069a0753f42a65f20be54a9ab2a2fced7 100644 (file)
@@ -5,7 +5,7 @@ SDL_PKGS ?= libpng libjpeg libsdl SDL_mixer freetype2 zlib
 CFLAGS += `pkg-config $(SDL_PKGS) --cflags`
 ARFLAGS = rvU
 
-SOURCES = sf_aiffwav.c sf_fonts.c sf_msg_en.c sf_resource.c sf_util.c \
+SOURCES = sf_fonts.c sf_msg_en.c sf_resource.c sf_util.c \
        sf_deffont.c sf_ftype.c sf_osfdlg.c sf_sig.c sf_video.c \
        sf_font3.c sf_images.c sf_sound.c generic.c
 
index b79a839d3746a6b31a9bf5a4ef684750df5d9280..8b9c8e39ae3ad0414ebbfc5563d0c4be8c3c1ff0 100644 (file)
@@ -4,6 +4,8 @@
 // as libmikmod only reads WAV samples
 //
 
+//XXX Dead code, whole file.
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
index dea4d9981834f8cb611c5ee661a6cd134ee87db8..0e61644f1e690198065171ace183b5968dc47e24 100644 (file)
@@ -3,6 +3,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <errno.h>
 
 #include "sf_frotz.h"
 #include "../blorb/blorblow.h"
@@ -190,23 +191,15 @@ static void startmodule()
 static EFFECT *getaiff( FILE *f, size_t pos, int len, int num)
   {
   EFFECT *res;
-  void * data; int size;
 
   res = new_effect(SFX_TYPE,num);
-  if (!res) return res;
-
-  if (sf_aiffwav(f,pos,&data,&size)==0)
-       {
-       res->sam = Mix_LoadWAV_RW(SDL_RWFromMem( data, size),0);
-       if (data) free(data);
-       }
-
-  if (!res->sam)
-       {
-//printf("Sample_LoadGeneric failure: %s\n",MikMod_strerror(MikMod_errno));
-       res->destroy(res);
-       return NULL;
-       }
+  if (!res) return NULL;
+  if (fseek(f, pos, SEEK_SET)
+      || !(res->sam = Mix_LoadWAV_RW(SDL_RWFromFP(f, false), 1))) {
+      os_warn("Read error on audio data: %s", strerror(errno));
+      res->destroy(res);
+      return NULL;
+  }
 //printf("AIFF loaded\n");
   return res;
   }