From 3ddda26eefd601a4ae3a85a29e8689ad9cd08c0f Mon Sep 17 00:00:00 2001 From: Sacha Date: Mon, 28 Oct 2013 15:33:02 +1000 Subject: [PATCH] Increase audio buffer size by a factor of 5. Helps with audio in some games. --- base/BlackberryAudio.h | 8 ++++---- base/QtMain.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/base/BlackberryAudio.h b/base/BlackberryAudio.h index 7bbba1609c..6938955245 100644 --- a/base/BlackberryAudio.h +++ b/base/BlackberryAudio.h @@ -56,7 +56,7 @@ private: size_t frames_ready; alGetSourcei(source, AL_SOURCE_STATE, &state); if (state != AL_PLAYING) { - frames_ready = NativeMix((short*)stream, SAMPLE_SIZE); + frames_ready = NativeMix((short*)stream, 5*SAMPLE_SIZE); } else frames_ready = 0; @@ -68,10 +68,10 @@ private: alSourcei(source, AL_BUFFER, buffer); alSourcePlay(source); // TODO: Maybe this could get behind? - usleep((1000000 * frames_ready) / AUDIO_FREQ); + usleep((1000000 * SAMPLE_SIZE) / AUDIO_FREQ); } else - usleep(100000); + usleep(10000); } } ALCdevice *alcDevice; @@ -79,7 +79,7 @@ private: ALenum state; ALuint buffer; ALuint source; - char stream[4*SAMPLE_SIZE]; + char stream[20*SAMPLE_SIZE]; pthread_t thread_handle; }; #endif diff --git a/base/QtMain.h b/base/QtMain.h index d4f9a09e4e..cb41a33ed6 100644 --- a/base/QtMain.h +++ b/base/QtMain.h @@ -208,7 +208,7 @@ public slots: fmt.setSampleSize(AUDIO_SAMPLESIZE); fmt.setByteOrder(QAudioFormat::LittleEndian); fmt.setSampleType(QAudioFormat::SignedInt); - mixlen = 2*AUDIO_CHANNELS*AUDIO_SAMPLES; + mixlen = 5*2*AUDIO_CHANNELS*AUDIO_SAMPLES; mixbuf = (char*)malloc(mixlen); output = new QAudioOutput(fmt); output->setBufferSize(mixlen); @@ -220,7 +220,7 @@ public slots: protected: void timerEvent(QTimerEvent *) { memset(mixbuf, 0, mixlen); - size_t frames = NativeMix((short *)mixbuf, AUDIO_SAMPLES); + size_t frames = NativeMix((short *)mixbuf, 5*AUDIO_SAMPLES); if (frames > 0) feed->write(mixbuf, sizeof(short) * 2 * frames); }