audiocodex: no shared music instances

This commit is contained in:
minjaesong
2023-12-03 16:29:14 +09:00
parent ff56acab93
commit 7798c46db3
4 changed files with 13 additions and 16 deletions

View File

@@ -92,8 +92,6 @@ class MixerTrackProcessor(val bufferSize: Int, val rate: Int, val track: Terraru
// fetch deviceBufferSize amount of sample from the disk
if (track.trackType != TrackType.MASTER && track.trackType != TrackType.BUS && track.streamPlaying) {
streamBuf.fetchBytes {
// FIXME THIS IS NOT THREAD SAFE: trying to play different audio too fast too much, shits happen
// OR somehow make sfx memory-streamable
try {
val bytesRead = track.currentTrack?.gdxMusic?.forceInvoke<Int>("read", arrayOf(it))
if (bytesRead == null || bytesRead <= 0) { // some class (namely Mp3) may return 0 instead of negative value