Merge pull request #489 from Lgt2x/mve-no-sound

Support -nosound option for movie playbacks
This commit is contained in:
Azamat H. Hackimov 2024-07-19 13:41:41 +03:00 committed by GitHub
commit f78bd57a81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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_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_ioCallbacks(mve_cb_Read io_read);
void MVE_memCallbacks(mve_cb_Alloc mem_alloc, mve_cb_Free mem_free); 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) { static int audio_data_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) {
#ifdef AUDIO #ifdef AUDIO
static const int selected_chan = 1; static const int selected_chan = 1;
if (snd_ds->IsInitialized()) { if (snd_ds && snd_ds->IsInitialized()) {
int chan = get_ushort(data + 2); int chan = get_ushort(data + 2);
int size = get_ushort(data + 4); int size = get_ushort(data + 4);
if (chan & selected_chan) { if (chan & selected_chan) {
@ -470,11 +470,12 @@ void MVE_rmEndMovie(MVESTREAM *mve) {
void MVE_rmHoldMovie() { timer_started = 0; } void MVE_rmHoldMovie() { timer_started = 0; }
void MVE_sndInit(int x) { void MVE_sndInit(const bool enable) {
#ifdef AUDIO #ifdef AUDIO
if (x == -1) if (enable) {
mve_audio_enabled = 0;
else
mve_audio_enabled = 1; mve_audio_enabled = 1;
} else {
mve_audio_enabled = 0;
}
#endif #endif
} }

View File

@ -18,6 +18,7 @@
#include <cstring> #include <cstring>
#include "args.h"
#include "movie.h" #include "movie.h"
#include "mvelib.h" #include "mvelib.h"
#include "pserror.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 #ifndef NO_MOVIES
bool mve_InitSound() { bool mve_InitSound() {
MVE_sndInit(1); MVE_sndInit(FindArg("-nosound") == 0);
return true; return true;
} }