aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/psp/audio.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backends/platform/psp/audio.cpp')
-rw-r--r--backends/platform/psp/audio.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/backends/platform/psp/audio.cpp b/backends/platform/psp/audio.cpp
index e540733162..d7487b0c1a 100644
--- a/backends/platform/psp/audio.cpp
+++ b/backends/platform/psp/audio.cpp
@@ -23,10 +23,10 @@
*
*/
-#include <pspthreadman.h>
+#include <pspthreadman.h>
#include <pspaudio.h>
-
-#include "common/scummsys.h"
+
+#include "common/scummsys.h"
#include "backends/platform/psp/audio.h"
//#define __PSP_DEBUG_FUNCS__ /* For debugging function calls */
@@ -39,37 +39,37 @@ bool PspAudio::open(uint32 freq, uint32 numOfChannels, uint32 numOfSamples, call
if (_init) {
PSP_ERROR("audio device already initialized\n");
return true;
- }
+ }
- PSP_DEBUG_PRINT("freq[%d], numOfChannels[%d], numOfSamples[%d], callback[%p], userData[%x]\n",
+ PSP_DEBUG_PRINT("freq[%d], numOfChannels[%d], numOfSamples[%d], callback[%p], userData[%x]\n",
freq, numOfChannels, numOfSamples, callback, (uint32)userData);
-
+
numOfSamples = PSP_AUDIO_SAMPLE_ALIGN(numOfSamples);
uint32 bufLen = numOfSamples * numOfChannels * NUM_BUFFERS * sizeof(uint16);
-
+
PSP_DEBUG_PRINT("total buffer size[%d]\n", bufLen);
-
+
_buffers[0] = (byte *)memalign(64, bufLen);
if (!_buffers[0]) {
PSP_ERROR("failed to allocate memory for audio buffers\n");
return false;
}
memset(_buffers[0], 0, bufLen); // clean the buffer
-
+
// Fill in the rest of the buffer pointers
byte *pBuffer = _buffers[0];
for (int i = 1; i < NUM_BUFFERS; i++) {
pBuffer += numOfSamples * numOfChannels * sizeof(uint16);
_buffers[i] = pBuffer;
}
-
+
// Reserve a HW channel for our audio
_pspChannel = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, numOfSamples, numOfChannels == 2 ? PSP_AUDIO_FORMAT_STEREO : PSP_AUDIO_FORMAT_MONO);
if (_pspChannel < 0) {
PSP_ERROR("failed to reserve audio channel\n");
return false;
}
-
+
PSP_DEBUG_PRINT("reserved channel[%d] for audio\n", _pspChannel);
// Save our data
@@ -80,17 +80,17 @@ bool PspAudio::open(uint32 freq, uint32 numOfChannels, uint32 numOfSamples, call
_userData = userData;
_bufferToFill = 0;
_bufferToPlay = 0;
-
+
_init = true;
_paused = true; // start in paused mode
-
+
threadCreateAndStart("audioThread", PRIORITY_AUDIO_THREAD, STACK_AUDIO_THREAD); // start the consumer thread
-
+
return true;
}
// The real thread function
-void PspAudio::threadFunction() {
+void PspAudio::threadFunction() {
assert(_callback);
PSP_DEBUG_PRINT_FUNC("audio thread started\n");
@@ -108,12 +108,12 @@ void PspAudio::threadFunction() {
PSP_DEBUG_PRINT("filling buffer[%d]\n", _bufferToFill);
_callback(_userData, _buffers[_bufferToFill], _bufferSize); // ask mixer to fill in data
nextBuffer(_bufferToFill);
-
+
PSP_DEBUG_PRINT("playing buffer[%d].\n", _bufferToPlay);
playBuffer();
nextBuffer(_bufferToPlay);
} // while _init
-
+
// destroy everything
free(_buffers[0]);
sceAudioChRelease(_pspChannel);
@@ -136,7 +136,7 @@ inline bool PspAudio::playBuffer() {
ret = sceAudioOutputBlocking(_pspChannel, PSP_AUDIO_VOLUME_MAX, _buffers[_bufferToPlay]);
else
ret = sceAudioOutputPannedBlocking(_pspChannel, PSP_AUDIO_VOLUME_MAX, PSP_AUDIO_VOLUME_MAX, _buffers[_bufferToPlay]);
-
+
if (ret < 0) {
PSP_ERROR("failed to output audio. Error[%d]\n", ret);
return false;
@@ -146,5 +146,5 @@ inline bool PspAudio::playBuffer() {
void PspAudio::close() {
PSP_DEBUG_PRINT("close has been called ***************\n");
- _init = false;
+ _init = false;
}