diff --git a/base/BlackberryAudio.h b/base/BlackberryAudio.h index 4911be23d3..6856c5aaaf 100644 --- a/base/BlackberryAudio.h +++ b/base/BlackberryAudio.h @@ -11,7 +11,8 @@ #include "base/NativeApp.h" -#define SAMPLE_SIZE 44100 +#define AUDIO_FREQ 44100 +#define SAMPLE_SIZE 2048 class BlackberryAudio { public: @@ -53,22 +54,23 @@ private: { size_t frames_ready; alGetSourcei(source, AL_SOURCE_STATE, &state); - if (state != AL_PLAYING) - frames_ready = NativeMix(stream, SAMPLE_SIZE / 2); + if (state != AL_PLAYING) { + frames_ready = NativeMix((short*)stream, SAMPLE_SIZE); + } else frames_ready = 0; if (frames_ready > 0) { const size_t bytes_ready = frames_ready * sizeof(short) * 2; alSourcei(source, AL_BUFFER, 0); - alBufferData(buffer, AL_FORMAT_STEREO16, stream, bytes_ready, SAMPLE_SIZE); + alBufferData(buffer, AL_FORMAT_STEREO16, stream, bytes_ready, AUDIO_FREQ); alSourcei(source, AL_BUFFER, buffer); alSourcePlay(source); // TODO: Maybe this could get behind? - usleep((1000000 * frames_ready) / SAMPLE_SIZE); + usleep((1000000 * frames_ready) / AUDIO_FREQ); } else - usleep(100); + usleep(100000); } } ALCdevice *alcDevice; @@ -76,7 +78,7 @@ private: ALenum state; ALuint buffer; ALuint source; - short stream[SAMPLE_SIZE]; + char stream[4*SAMPLE_SIZE]; pthread_t thread_handle; }; #endif diff --git a/base/PCMain.cpp b/base/PCMain.cpp index c40f469581..32d0dcf87b 100644 --- a/base/PCMain.cpp +++ b/base/PCMain.cpp @@ -523,7 +523,7 @@ int main(int argc, char *argv[]) { fmt.freq = 44100; fmt.format = AUDIO_S16; fmt.channels = 2; - fmt.samples = 1024; + fmt.samples = 2048; fmt.callback = &mixaudio; fmt.userdata = (void *)0; diff --git a/base/QtMain.h b/base/QtMain.h index b3509a874c..834eb67ca3 100644 --- a/base/QtMain.h +++ b/base/QtMain.h @@ -193,7 +193,7 @@ public: fmt.setSampleSize(AUDIO_SAMPLESIZE); fmt.setByteOrder(QAudioFormat::LittleEndian); fmt.setSampleType(QAudioFormat::SignedInt); - mixlen = 4*AUDIO_CHANNELS*AUDIO_SAMPLES; + mixlen = 2*AUDIO_CHANNELS*AUDIO_SAMPLES; mixbuf = (char*)malloc(mixlen); output = new QAudioOutput(fmt); output->setBufferSize(mixlen); @@ -214,7 +214,7 @@ public: protected: void timerEvent(QTimerEvent *) { memset(mixbuf, 0, mixlen); - NativeMix((short *)mixbuf, mixlen / 4); + NativeMix((short *)mixbuf, AUDIO_SAMPLES); feed->write(mixbuf, mixlen); } private: