DEADSOFTWARE

menu: remove data field from menu_t
[flatwaifu.git] / src / openal / sound.c
index 9dfca1919e106311a6c894bc3a3a0d656b229492..f4f07b9b6e91112d15b1b154dad7e8b4bcfa4df3 100644 (file)
@@ -14,7 +14,7 @@
 #  include <AL/alc.h>
 #endif
 
-#include <SDL.h> // SDL_BuildAudioCVT SDL_ConvertAudio
+#include "SDL.h" // SDL_BuildAudioCVT SDL_ConvertAudio
 #include <assert.h>
 #include <stdlib.h> // malloc
 #include <string.h> // memcpy
@@ -41,11 +41,7 @@ typedef struct openal_channel {
   ALuint source;
 } openal_channel;
 
-short snd_vol;
-short mus_vol;
-char music_random;
-int music_time;
-int music_fade;
+static short snd_vol;
 
 static ALCdevice *device;
 static ALCcontext *context;
@@ -53,40 +49,92 @@ static ALuint sources[MAX_CHANNELS];
 
 /* Music */
 
-void S_initmusic (void) {
+const cfg_t *MUS_args (void) {
+  return NULL;
+}
+
+const cfg_t *MUS_conf (void) {
+  return NULL;
+}
 
+const menu_t *MUS_menu (void) {
+  return NULL;
 }
 
-void S_donemusic (void) {
+void MUS_init (void) {
 
 }
 
-void S_startmusic (int time) {
+void MUS_done (void) {
 
 }
 
-void S_stopmusic (void) {
+void MUS_start (int time) {
 
 }
 
-void S_volumemusic (int v) {
+void MUS_stop (void) {
 
 }
 
-void F_loadmus (char n[8]) {
+void MUS_volume (int v) {
 
 }
 
-void F_freemus (void) {
+void MUS_load (char n[8]) {
 
 }
 
-void S_updatemusic (void) {
+void MUS_free (void) {
+
+}
+
+void MUS_update (void) {
 
 }
 
 /* Sound */
 
+static int sound_menu_handler (menu_msg_t *msg, const menu_t *m, void *data, int i) {
+  static int cur;
+  enum { VOLUME, __NUM__ };
+  static const simple_menu_t sm = {
+    GM_BIG, "Sound", NULL,
+    {
+      { "Volume", NULL },
+    }
+  };
+  if (i == VOLUME) {
+    switch (msg->type) {
+      case GM_GETENTRY: return GM_init_int0(msg, GM_SCROLLER, 0, 0, 0);
+      case GM_GETINT: return GM_init_int(msg, snd_vol, 0, 128, 8);
+      case GM_SETINT: S_volume(msg->integer.i); return 1;
+    }
+  }
+  return simple_menu_handler(msg, i, __NUM__, &sm, &cur);
+}
+
+const menu_t *S_menu (void) {
+  static const menu_t m = { sound_menu_handler };
+  return &m;
+}
+
+const cfg_t *S_args (void) {
+  static const cfg_t args[] = {
+    { "sndvol", &snd_vol, Y_WORD },
+    { NULL, NULL, 0 }
+  };
+  return args;
+}
+
+const cfg_t *S_conf (void) {
+  static const cfg_t conf[] = {
+    { "sound_volume", &snd_vol, Y_WORD },
+    { NULL, NULL, 0 }
+  };
+  return conf;
+}
+
 static void convert_this_ext (Uint32 src_format, int src_chan, int src_rate, Uint32 dst_format, int dst_chan, int dst_rate, const void *buf, int len, void **maxbuf, int *maxlen) {
   SDL_AudioCVT cvt;
   *maxlen = 0;
@@ -183,7 +231,7 @@ void S_free (snd_t *s) {
   ALint h;
   openal_snd *snd = (openal_snd*)s;
   if (snd != NULL) {
-    assert(snd->base.tag = TAG_OAL1);
+    assert(snd->base.tag == TAG_OAL1);
     if (context != NULL) {
       for (i = 0; i < MAX_CHANNELS; i++) {
         alGetSourcei(sources[i], AL_BUFFER, &h);