shithub: pt2-clone

Download patch

ref: e9d55ca62cfd5be0160c4c825710aa44f2196686
parent: 4b8681a19cf2b9e77e819be02b4d18c14346e567
author: Olav Sørensen <olav.sorensen@live.no>
date: Fri Oct 14 13:49:31 EDT 2022

Just some sanity checking

--- a/src/pt2_audio.c
+++ b/src/pt2_audio.c
@@ -320,28 +320,31 @@
 		tickTime64Frac = audLatencyPerfValFrac;
 	}
 
-	moduleChannel_t *ch = song->channels;
-	paulaVoice_t *v = paula;
-	syncedChannel_t *sc = chSyncData.channels;
-
-	for (int32_t i = 0; i < PAULA_VOICES; i++, ch++, sc++, v++)
+	if (song != NULL)
 	{
-		sc->flags = v->syncFlags | ch->syncFlags;
-		ch->syncFlags = v->syncFlags = 0; // clear sync flags
+		moduleChannel_t *ch = song->channels;
+		paulaVoice_t *v = paula;
+		syncedChannel_t *sc = chSyncData.channels;
 
-		sc->volume = v->syncVolume;
-		sc->period = v->syncPeriod;
-		sc->triggerData = v->syncTriggerData;
-		sc->triggerLength = v->syncTriggerLength;
-		sc->newData = v->AUD_LC;
-		sc->newLength = v->AUD_LEN * 2;
-		sc->vuVolume = ch->syncVuVolume;
-		sc->analyzerVolume = ch->syncAnalyzerVolume;
-		sc->analyzerPeriod = ch->syncAnalyzerPeriod;
-	}
+		for (int32_t i = 0; i < PAULA_VOICES; i++, ch++, sc++, v++)
+		{
+			sc->flags = v->syncFlags | ch->syncFlags;
+			ch->syncFlags = v->syncFlags = 0; // clear sync flags
 
-	chSyncData.timestamp = tickTime64;
-	chQueuePush(chSyncData);
+			sc->volume = v->syncVolume;
+			sc->period = v->syncPeriod;
+			sc->triggerData = v->syncTriggerData;
+			sc->triggerLength = v->syncTriggerLength;
+			sc->newData = v->AUD_LC;
+			sc->newLength = v->AUD_LEN * 2;
+			sc->vuVolume = ch->syncVuVolume;
+			sc->analyzerVolume = ch->syncAnalyzerVolume;
+			sc->analyzerPeriod = ch->syncAnalyzerPeriod;
+		}
+
+		chSyncData.timestamp = tickTime64;
+		chQueuePush(chSyncData);
+	}
 
 	tickTime64 += tickTimeLen;
 	tickTime64Frac += tickTimeLenFrac;