Don't activate sound subsystem if SOUND_FLAG or OLD_SOUND_FLAG is not set.
authorDavid Griffith <dave@661.org>
Wed, 5 Jun 2019 08:36:39 +0000 (01:36 -0700)
committerDavid Griffith <dave@661.org>
Wed, 5 Jun 2019 08:36:39 +0000 (01:36 -0700)
src/common/err.c
src/common/frotz.h
src/common/setup.h
src/common/sound.c
src/curses/ux_audio.c

index e1c6f1b3c7d68b980eef9b0284749fe179930d9e..296e6023121fd78f9281cdc6706f4847f0c10964 100644 (file)
@@ -62,7 +62,8 @@ static char *err_messages[] = {
     "@move_object called moving object 0",
     "@move_object called moving into object 0",
     "@remove_object called with object 0",
-    "@get_next_prop called with object 0"
+    "@get_next_prop called with object 0",
+    "@play_sound called without SOUND_FLAG or OLD_SOUND_FLAG set"
 };
 
 static void print_long (unsigned long value, int base);
index 09bd0c46af21286ddaa501c57dd72ac3773a5501..3abad433962bbfe0fee2875c0354bfcfe162abf3 100644 (file)
@@ -740,8 +740,9 @@ void        runtime_error (int);
 #define ERR_MOVE_OBJECT_TO_0 30        /* @move_object called moving into object 0 */
 #define ERR_REMOVE_OBJECT_0 31 /* @remove_object called with object 0 */
 #define ERR_GET_NEXT_PROP_0 32 /* @get_next_prop called with object 0 */
-#define ERR_NUM_ERRORS (32)
+#define ERR_PLAY_SOUND 33      /* @play_sound called without SOUND_FLAG or OLD_SOUND_FLAG set */
+#define ERR_NUM_ERRORS (33)
+
 /* There are four error reporting modes: never report errors;
   report only the first time a given error type occurs; report
   every time an error occurs; or treat all errors as fatal
index c2a43eb676e789383ec4b8e2aff8c73298b340b3..e81e5e827b3a082939a0147fecc69d7ee589a983 100644 (file)
@@ -18,6 +18,7 @@ typedef struct frotz_setup_struct {
        int expand_abbreviations;
        int script_cols;
        int sound;
+       int sound_flag;
        int err_report_mode;
 
        char *story_file;
index e5e29e740f516990efbf68033a142713b9e0af9f..7c2e65671d5450efac599f81b63ecb1c8c2dc0d8 100644 (file)
@@ -48,10 +48,13 @@ static bool playing = FALSE;
  */
 void init_sound (void)
 {
-    locked = FALSE;
-    playing = FALSE;
-
-    os_init_sound();
+    if ((h_flags & SOUND_FLAG) || (h_flags & OLD_SOUND_FLAG))  {
+       f_setup.sound_flag = TRUE;
+       locked = FALSE;
+       playing = FALSE;
+       os_init_sound();
+    } else
+       f_setup.sound_flag = FALSE;
 
 } /* init_sound */
 
@@ -155,6 +158,11 @@ void z_sound_effect (void)
     if (zargc < 3)
        volume = 8;
 
+    if (!f_setup.sound_flag) {
+        runtime_error(ERR_PLAY_SOUND);
+        return;
+    }
+
     if (number >= 3 || number == 0) {
 
        locked = TRUE;
index a178ffe769c468990fe7baa7f1cc62cb55f6d367..73a49e6f783e93d0c20e9d4af582c777b8410203 100644 (file)
 
 #include "../blorb/blorb.h"
 #include "../blorb/blorblow.h"
+#include "ux_frotz.h"
 #include "ux_audio.h"
 
+f_setup_t f_setup;
+
 #ifndef NO_SOUND
 
 #include <ao/ao.h>
@@ -777,6 +780,8 @@ os_init_sound(void)
     int err;
     static pthread_attr_t attr;
 
+    if (!f_setup.sound_flag) return;
+
     /*Initialize sound engine*/
     /*audio_log = fopen("audio_log.txt", "w");*/
     /*fprintf(audio_log, "os_init_sound...\n");*/
@@ -833,6 +838,7 @@ os_start_sample(int number, int volume, int repeats, zword eos)
     const float vol = volume_factor(volume);
     sound_stream_t *s = 0;
 
+    if (!f_setup.sound_flag) return;
 
     /*Load resource from BLORB data*/
     if(blorb_map == NULL) return;
@@ -882,6 +888,7 @@ void os_prepare_sample(int id)
 void os_stop_sample(int id)
 {
     /*fprintf(audio_log, "os_stop_sample(%d)...\n", id);*/
+    if (!f_setup.sound_flag) return;
     sound_stop_id(id);
 }