Skip to content

Commit

Permalink
added no-sound option
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner committed Sep 26, 2024
1 parent 180c73b commit ce309cd
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion platforms/linux/aarch64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
LIBCARGS_SHA=0fbac1a0c6ebb7ecd72f0d7ae89c2b79eb3a12eb
LIBOPENAL_SHA=d3875f333fb6abe2f39d82caca329414871ae53b
LIBPINMAME_SHA=ee6f88dd04eb84620a8f433d36a50736dac58b1a
LIBPPUC_SHA=1eeea346a88afaef204ff99ffd820774553001d2
LIBPPUC_SHA=09bd5a1cd4bea96fa4964fd791af4acbc5d4b82a
LIBDMDUTIL_SHA=8e110d87edab1b843d97ba831743c79519e07ad8

NUM_PROCS=$(nproc)
Expand Down
2 changes: 1 addition & 1 deletion platforms/linux/x64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
LIBCARGS_SHA=0fbac1a0c6ebb7ecd72f0d7ae89c2b79eb3a12eb
LIBOPENAL_SHA=d3875f333fb6abe2f39d82caca329414871ae53b
LIBPINMAME_SHA=ee6f88dd04eb84620a8f433d36a50736dac58b1a
LIBPPUC_SHA=1eeea346a88afaef204ff99ffd820774553001d2
LIBPPUC_SHA=09bd5a1cd4bea96fa4964fd791af4acbc5d4b82a
LIBDMDUTIL_SHA=8e110d87edab1b843d97ba831743c79519e07ad8

NUM_PROCS=$(nproc)
Expand Down
2 changes: 1 addition & 1 deletion platforms/macos/arm64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
LIBCARGS_SHA=0fbac1a0c6ebb7ecd72f0d7ae89c2b79eb3a12eb
LIBOPENAL_SHA=d3875f333fb6abe2f39d82caca329414871ae53b
LIBPINMAME_SHA=ee6f88dd04eb84620a8f433d36a50736dac58b1a
LIBPPUC_SHA=1eeea346a88afaef204ff99ffd820774553001d2
LIBPPUC_SHA=09bd5a1cd4bea96fa4964fd791af4acbc5d4b82a
LIBDMDUTIL_SHA=8e110d87edab1b843d97ba831743c79519e07ad8

NUM_PROCS=$(sysctl -n hw.ncpu)
Expand Down
2 changes: 1 addition & 1 deletion platforms/macos/x64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
LIBCARGS_SHA=0fbac1a0c6ebb7ecd72f0d7ae89c2b79eb3a12eb
LIBOPENAL_SHA=d3875f333fb6abe2f39d82caca329414871ae53b
LIBPINMAME_SHA=ee6f88dd04eb84620a8f433d36a50736dac58b1a
LIBPPUC_SHA=1eeea346a88afaef204ff99ffd820774553001d2
LIBPPUC_SHA=09bd5a1cd4bea96fa4964fd791af4acbc5d4b82a
LIBDMDUTIL_SHA=8e110d87edab1b843d97ba831743c79519e07ad8

NUM_PROCS=$(sysctl -n hw.ncpu)
Expand Down
43 changes: 27 additions & 16 deletions src/ppuc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ bool opt_debug_switches = false;
bool opt_debug_coils = false;
bool opt_debug_lamps = false;
bool opt_no_serial = false;
bool opt_no_sound = false;
bool opt_serum = false;
bool opt_pup = false;
bool opt_console_display = false;
Expand Down Expand Up @@ -64,6 +65,7 @@ static struct cag_option options[] = {
.access_name = "no-serial",
.value_name = NULL,
.description = "No serial communication to controllers (optional)"},
{.identifier = 'M', .access_name = "no-sound", .value_name = NULL, .description = "Turn off sound (optional)"},
{.identifier = 'u',
.access_letters = "u",
.access_name = "serum",
Expand Down Expand Up @@ -290,6 +292,8 @@ int PINMAMECALLBACK OnAudioAvailable(PinmameAudioInfo* p_audioInfo, const void*

int PINMAMECALLBACK OnAudioUpdated(void* p_buffer, int samples, const void* p_userData)
{
if (opt_no_sound) return 0;

if (_audioQueue.size() >= MAX_AUDIO_QUEUE_SIZE)
{
while (!_audioQueue.empty())
Expand Down Expand Up @@ -416,6 +420,9 @@ int main(int argc, char* argv[])
case 'n':
opt_no_serial = true;
break;
case 'M':
opt_no_sound = true;
break;
case 'u':
opt_serum = true;
break;
Expand Down Expand Up @@ -585,25 +592,29 @@ int main(int argc, char* argv[])
return 1;
}

// Initialize the sound device
const ALCchar* defaultDeviceName = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
ALCdevice* device = alcOpenDevice(defaultDeviceName);
if (!device)
ALCdevice* device;
if (!opt_no_sound)
{
printf("failed to alcOpenDevice for %s\n", defaultDeviceName);
return 1;
}
// Initialize the sound device
const ALCchar* defaultDeviceName = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
device = alcOpenDevice(defaultDeviceName);
if (!device)
{
printf("failed to alcOpenDevice for %s\n", defaultDeviceName);
return 1;
}

ALCcontext* context = alcCreateContext(device, NULL);
if (!context)
{
printf("failed call to alcCreateContext\n");
return 1;
}
ALCcontext* context = alcCreateContext(device, NULL);
if (!context)
{
printf("failed call to alcCreateContext\n");
return 1;
}

alcMakeContextCurrent(context);
alGenSources((ALuint)1, &_audioSource);
alGenBuffers(MAX_AUDIO_BUFFERS, _audioBuffers);
alcMakeContextCurrent(context);
alGenSources((ALuint)1, &_audioSource);
alGenBuffers(MAX_AUDIO_BUFFERS, _audioBuffers);
}

PinmameSetConfig(&config);

Expand Down

0 comments on commit ce309cd

Please sign in to comment.