Skip to content

Commit

Permalink
Removing semaphore
Browse files Browse the repository at this point in the history
SDL 3.1.3 crashes when locking semaphore's in fluidsynth so this is removed.  Mutex's are fine, but it hated these timeouts.  No big deal really, it is mostly for stability rather than a criticality.
  • Loading branch information
atsb committed Oct 6, 2024
1 parent c94d317 commit 764c5f4
Showing 1 changed file with 1 addition and 39 deletions.
40 changes: 1 addition & 39 deletions src/engine/i_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,6 @@ static SDL_Mutex* lock = NULL;
#define MUTEX_LOCK() SDL_LockMutex(lock);
#define MUTEX_UNLOCK() SDL_UnlockMutex(lock);

//
// Semaphore stuff
//

static SDL_Semaphore* semaphore;

// 20120205 villsa - bool to determine if sequencer is ready or not
static int seqready = 0;

Expand Down Expand Up @@ -728,16 +722,13 @@ static int Signal_StopAll(doomseq_t* seq) {
channel_t* c;
int i;

if (SDL_WaitSemaphoreTimeout(semaphore, -1) == 0) {
for (i = 0; i < MIDI_CHANNELS; i++) {
c = &playlist[i];

if (c->song) {
Chan_RemoveTrackFromPlaylist(seq, c);
}
}
SDL_SignalSemaphore(semaphore);
}

Seq_SetStatus(seq, SEQ_SIGNAL_READY);
return 1;
Expand All @@ -764,11 +755,8 @@ static int Signal_Pause(doomseq_t* seq) {
int i;
channel_t* c;

if (SDL_WaitSemaphoreTimeout(semaphore, -1) == 0) {
for (i = 0; i < MIDI_CHANNELS; i++) {
c = &playlist[i];
}
SDL_SignalSemaphore(semaphore);
}

Seq_SetStatus(seq, SEQ_SIGNAL_READY);
Expand All @@ -785,11 +773,8 @@ static int Signal_Resume(doomseq_t* seq) {
int i;
channel_t* c;

if (SDL_WaitSemaphoreTimeout(semaphore, -1) == 0) {
for (i = 0; i < MIDI_CHANNELS; i++) {
c = &playlist[i];
}
SDL_SignalSemaphore(semaphore);
}

Seq_SetStatus(seq, SEQ_SIGNAL_READY);
Expand All @@ -801,12 +786,10 @@ static int Signal_Resume(doomseq_t* seq) {
//

static int Signal_UpdateGain(doomseq_t* seq) {
if (SDL_WaitSemaphoreTimeout(semaphore, -1) == 0) {

Seq_SetGain(seq);

SDL_SignalSemaphore(semaphore);
}


Seq_SetStatus(seq, SEQ_SIGNAL_READY);
return 1;
Expand Down Expand Up @@ -958,7 +941,6 @@ static void Seq_RunSong(doomseq_t* seq, int msecs) {

seq->playtime = msecs;

if (SDL_WaitSemaphoreTimeout(semaphore, -1) == 0) {
for (i = 0; i < MIDI_CHANNELS; i++) {
chan = &playlist[i];

Expand All @@ -972,8 +954,6 @@ static void Seq_RunSong(doomseq_t* seq, int msecs) {
else {
Chan_RunSong(seq, chan, msecs);
}
}
SDL_SignalSemaphore(semaphore);
}
}

Expand Down Expand Up @@ -1173,15 +1153,6 @@ void I_InitSequencer(void) {
return;
}

//
// init semaphore
//
semaphore = SDL_CreateSemaphore(1);
if (semaphore == NULL) {
CON_Warnf("I_InitSequencer: failed to create semaphore");
return;
}

dmemset(&doomseq, 0, sizeof(doomseq_t));

//
Expand Down Expand Up @@ -1437,7 +1408,6 @@ void I_StartMusic(int mus_id) {
return;
}

if (SDL_WaitSemaphoreTimeout(semaphore, -1) == 0) {
song = &doomseq.songs[mus_id];
for (i = 0; i < song->ntracks; i++) {
chan = Song_AddTrackToPlaylist(&doomseq, song, &song->tracks[i]);
Expand All @@ -1447,8 +1417,6 @@ void I_StartMusic(int mus_id) {
}

chan->volume = doomseq.musicvolume;
}
SDL_SignalSemaphore(semaphore);
}

// [Immorpher] Re-establish linear sound interpolation
Expand All @@ -1470,7 +1438,6 @@ void I_StopSound(sndsrc_t* origin, int sfx_id) {
return;
}

if (SDL_WaitSemaphoreTimeout(semaphore, -1) == 0) {
song = &doomseq.songs[sfx_id];
for (i = 0; i < MIDI_CHANNELS; i++) {
c = &playlist[i];
Expand All @@ -1479,8 +1446,6 @@ void I_StopSound(sndsrc_t* origin, int sfx_id) {
c->stop = true;
}
}
SDL_SignalSemaphore(semaphore);
}
}

//
Expand All @@ -1500,7 +1465,6 @@ void I_StartSound(int sfx_id, sndsrc_t* origin, int volume, int pan, int reverb)
return;
}

if (SDL_WaitSemaphoreTimeout(semaphore, -1) == 0) {
song = &doomseq.songs[sfx_id];
for (i = 0; i < song->ntracks; i++) {
chan = Song_AddTrackToPlaylist(&doomseq, song, &song->tracks[i]);
Expand All @@ -1513,8 +1477,6 @@ void I_StartSound(int sfx_id, sndsrc_t* origin, int volume, int pan, int reverb)
chan->pan = (byte)(pan >> 1);
chan->origin = origin;
chan->depth = reverb;
}
SDL_SignalSemaphore(semaphore);
}

// [Immorpher] Re-establish linear sound interpolation
Expand Down

0 comments on commit 764c5f4

Please sign in to comment.