BackgroundAudio: Switch to a heap allocated buffer.

This commit is contained in:
Henrik Rydgård committed 2020-08-03 10:43:26 +02:00
1 parent 6f02844b5b
commit e13b53e02c
2 files changed
+18 -2

No files matched your search

+9 -1
View File
@@ -226,6 +226,14 @@ private:
BackgroundAudio g_BackgroundAudio;
BackgroundAudio::BackgroundAudio() {
buffer = new int[BUFSIZE]();
}
BackgroundAudio::~BackgroundAudio() {
delete[] buffer;
}
void BackgroundAudio::Clear(bool hard) {
if (!hard) {
fadingOut = true;
@@ -276,7 +284,7 @@ int BackgroundAudio::Play() {
double now = time_now();
if (at3Reader) {
int sz = lastPlaybackTime <= 0.0 ? 44100 / 60 : (int)((now - lastPlaybackTime) * 44100);
sz = std::min((int)ARRAY_SIZE(buffer) / 2, sz);
sz = std::min(BUFSIZE / 2, sz);
if (sz >= 16) {
if (at3Reader->Read(buffer, sz)) {
if (!fadingOut) {