@@ -247,6 +247,11 @@ void AudioService::addTrack(const wchar_t *pFilePath)
247247 monitor.detach ();
248248 }
249249
250+ FMOD_RESULT result = pSystem->update ();
251+ if (result)
252+ {
253+ pMainWindow->showMessageBox ( true , std::string (" AudioService::addTrack::FMOD::System::update() failed. Error: " ) + std::string (FMOD_ErrorString (result)) );
254+ }
250255
251256 mtxThreadLoadAddTrack.unlock ();
252257}
@@ -429,6 +434,12 @@ void AudioService::playTrack(size_t iTrackIndex, bool bDontLockMutex)
429434 pMainWindow->showMessageBox (false , " Something went wrong and we could not play the track." );
430435 }
431436
437+ FMOD_RESULT result = pSystem->update ();
438+ if (result)
439+ {
440+ pMainWindow->showMessageBox ( true , std::string (" AudioService::playTrack::FMOD::System::update() failed. Error: " ) + std::string (FMOD_ErrorString (result)) );
441+ }
442+
432443 pMainWindow->setPlayingOnTrack (iCurrentlyPlayingTrackIndex);
433444 }
434445 else
@@ -458,6 +469,13 @@ void AudioService::setTrackPos(unsigned int graphPos)
458469 }
459470 }
460471
472+ FMOD_RESULT result;
473+ result = pSystem->update ();
474+ if (result)
475+ {
476+ pMainWindow->showMessageBox ( true , std::string (" AudioService::setTrackPos::FMOD::System::update() failed. Error: " ) + std::string (FMOD_ErrorString (result)) );
477+ }
478+
461479 mtxTracksVec.unlock ();
462480}
463481
@@ -483,6 +501,13 @@ void AudioService::pauseTrack()
483501 }
484502 }
485503
504+ FMOD_RESULT result;
505+ result = pSystem->update ();
506+ if (result)
507+ {
508+ pMainWindow->showMessageBox ( true , std::string (" AudioService::pauseTrack::FMOD::System::update() failed. Error: " ) + std::string (FMOD_ErrorString (result)) );
509+ }
510+
486511 mtxTracksVec.unlock ();
487512}
488513
@@ -619,6 +644,13 @@ void AudioService::removeTrack(size_t iTrackIndex)
619644 delete tracks[iTrackIndex];
620645 tracks.erase ( tracks.begin () + iTrackIndex );
621646
647+ FMOD_RESULT result;
648+ result = pSystem->update ();
649+ if (result)
650+ {
651+ pMainWindow->showMessageBox ( true , std::string (" AudioService::removeTrack::FMOD::System::update() failed. Error: " ) + std::string (FMOD_ErrorString (result)) );
652+ }
653+
622654 mtxGetCurrentDrawingIndex.unlock ();
623655 }
624656 else
@@ -1076,6 +1108,12 @@ void AudioService::monitorTrack()
10761108 // The track is ended, play next
10771109 tracks[iCurrentlyPlayingTrackIndex]->reCreateTrack (fCurrentVolume );
10781110
1111+ FMOD_RESULT result = pSystem->update ();
1112+ if (result)
1113+ {
1114+ pMainWindow->showMessageBox (true , std::string (" AudioService::monitorTrack::FMOD::System::update() failed. Error: " ) + FMOD_ErrorString (result));
1115+ }
1116+
10791117 if (bRepeatTrack)
10801118 {
10811119 // Or not
@@ -1104,6 +1142,8 @@ void AudioService::monitorTrack()
11041142 }
11051143 }
11061144
1145+ pSystem->update ();
1146+
11071147 mtxTracksVec.unlock ();
11081148
11091149 std::this_thread::sleep_for (std::chrono::milliseconds (MONITOR_TRACK_INTERVAL_MS));
@@ -1116,6 +1156,16 @@ void AudioService::drawGraph(size_t* iTrackIndex)
11161156 bDrawing = true ;
11171157
11181158
1159+ // default: 16384
1160+ // "If FMOD_TIMEUNIT_RAWBYTES is used, the memory allocated is two times the size passed in, because fmod allocates a double buffer."
1161+ // 131072 * 2 = 256 kB (x8 times bigger than default) to speed up our graph draw (to speed up our readData() calls)
1162+ FMOD_RESULT fresult = pSystem->setStreamBufferSize (131072 , FMOD_TIMEUNIT_RAWBYTES);
1163+ if (fresult)
1164+ {
1165+ pMainWindow->showMessageBox ( true , std::string (" AudioService::AudioService::FMOD::System::setStreamBufferSize() failed. Error: " ) + std::string (FMOD_ErrorString (fresult)) );
1166+ }
1167+
1168+
11191169 pMainWindow->clearGraph ();
11201170
11211171 // this value combines 'iSamplesInOne' samples in one to store less points for graph in memory
@@ -1185,6 +1235,16 @@ void AudioService::drawGraph(size_t* iTrackIndex)
11851235
11861236 mtxGetCurrentDrawingIndex.unlock ();
11871237
1238+
1239+
1240+ // set to default: 16384
1241+ fresult = pSystem->setStreamBufferSize (16384 , FMOD_TIMEUNIT_RAWBYTES);
1242+ if (fresult)
1243+ {
1244+ pMainWindow->showMessageBox ( true , std::string (" AudioService::AudioService::FMOD::System::setStreamBufferSize() failed. Error: " ) + std::string (FMOD_ErrorString (fresult)) );
1245+ }
1246+
1247+
11881248 bDrawing = false ;
11891249 mtxDrawGraph.unlock ();
11901250}
0 commit comments