Support -nosound option for movie playbacks

This commit is contained in:
Louis Gombert 2024-07-11 00:33:15 +02:00
parent 87f6ef009f
commit 998e834068
3 changed files with 10 additions and 7 deletions

View File

@ -75,7 +75,8 @@ void MVE_rmEndMovie(MVESTREAM *mve);
void MVE_getVideoSpec(MVE_videoSpec *vSpec);
void MVE_sndInit(int x);
// Initialize MVE sound. Set `enable` to false if sound should not be enabled.
void MVE_sndInit(const bool enable);
void MVE_ioCallbacks(mve_cb_Read io_read);
void MVE_memCallbacks(mve_cb_Alloc mem_alloc, mve_cb_Free mem_free);

View File

@ -202,7 +202,7 @@ static int play_audio_handler(unsigned char major, unsigned char minor, unsigned
static int audio_data_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) {
#ifdef AUDIO
static const int selected_chan = 1;
if (snd_ds->IsInitialized()) {
if (snd_ds && snd_ds->IsInitialized()) {
int chan = get_ushort(data + 2);
if (chan & selected_chan) {
if (major == MVE_OPCODE_AUDIOFRAMEDATA) {
@ -471,11 +471,12 @@ void MVE_rmEndMovie(MVESTREAM *mve) {
void MVE_rmHoldMovie() { timer_started = 0; }
void MVE_sndInit(int x) {
void MVE_sndInit(const bool enable) {
#ifdef AUDIO
if (x == -1)
mve_audio_enabled = 0;
else
if (enable) {
mve_audio_enabled = 1;
} else {
mve_audio_enabled = 0;
}
#endif
}

View File

@ -18,6 +18,7 @@
#include <cstring>
#include "args.h"
#include "movie.h"
#include "mvelib.h"
#include "pserror.h"
@ -479,7 +480,7 @@ void mve_ClearRect(int16_t x1, int16_t y1, int16_t x2, int16_t y2) {
#ifndef NO_MOVIES
bool mve_InitSound() {
MVE_sndInit(1);
MVE_sndInit(FindArg("-nosound") == 0);
return true;
}