Increase audio buffer size by a factor of 5. Helps with audio in some games.

This commit is contained in:
Sacha committed 2013-10-28 15:33:02 +10:00
1 parent 11e62f7f3a
commit 3ddda26eef
2 files changed
+6 -6

No files matched your search

+4 -4
View File
@@ -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
+2 -2
View File
@@ -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);
}