aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
Diffstat (limited to 'backends')
-rw-r--r--backends/platform/psp/audio.cpp30
-rw-r--r--backends/platform/psp/audio.h6
-rw-r--r--backends/platform/psp/osys_psp.cpp2
-rw-r--r--backends/platform/psp/thread.h8
4 files changed, 12 insertions, 34 deletions
diff --git a/backends/platform/psp/audio.cpp b/backends/platform/psp/audio.cpp
index 2afc62d450..bf1fb9ab41 100644
--- a/backends/platform/psp/audio.cpp
+++ b/backends/platform/psp/audio.cpp
@@ -79,7 +79,6 @@ bool PspAudio::open(uint32 freq, uint32 numOfChannels, uint32 numOfSamples, call
_bufferSize = numOfSamples * numOfChannels * sizeof(uint16); // should be the right size to send the app
_callback = callback;
_userData = userData;
- _emptyBuffers = NUM_BUFFERS - 1; // because we'll increase in the beginning
_bufferToFill = 0;
_bufferToPlay = 0;
@@ -122,10 +121,7 @@ int PspAudio::thread(SceSize, void *__this) {
};
// The real thread function
-void PspAudio::audioThread() {
- bool isPlaying = false;
- int remainingSamples = 0;
-
+void PspAudio::audioThread() {
assert(_callback);
PSP_DEBUG_PRINT_FUNC("audio thread started\n");
@@ -138,29 +134,13 @@ void PspAudio::audioThread() {
PSP_DEBUG_PRINT("audio thread unpaused\n");
}
- // check if the audio is playing
- remainingSamples = sceAudioGetChannelRestLen(_pspChannel);
- if (remainingSamples < 0) {
- PSP_ERROR("failed to get remaining samples\n");
- return;
- }
- isPlaying = remainingSamples ? true : false;
-
PSP_DEBUG_PRINT("remaining samples[%d]\n", remainingSamples);
- if (!isPlaying) {
- _emptyBuffers++;
- }
-
- while (_emptyBuffers) { // we have some empty buffers
- PSP_DEBUG_PRINT("filling buffer[%d]. empty buffers[%d]\n", _bufferToFill, _emptyBuffers);
- _callback(_userData, _buffers[_bufferToFill], _bufferSize); // ask mixer to fill in
- nextBuffer(_bufferToFill);
- _emptyBuffers--;
- break;
- }
+ PSP_DEBUG_PRINT("filling buffer[%d]\n", _bufferToFill);
+ _callback(_userData, _buffers[_bufferToFill], _bufferSize); // ask mixer to fill in
+ nextBuffer(_bufferToFill);
- PSP_DEBUG_PRINT("playing buffer[%d]. empty buffers[%d]\n", _bufferToPlay, _emptyBuffers);
+ PSP_DEBUG_PRINT("playing buffer[%d].\n", _bufferToPlay);
playBuffer();
nextBuffer(_bufferToPlay);
} // while _init
diff --git a/backends/platform/psp/audio.h b/backends/platform/psp/audio.h
index 97e2391319..603f8f6bfc 100644
--- a/backends/platform/psp/audio.h
+++ b/backends/platform/psp/audio.h
@@ -35,8 +35,8 @@ public:
typedef void (* callbackFunc)(void *userData, byte *samples, int len);
PspAudio() : _pspChannel(0),
_numOfChannels(0), _numOfSamples(0), _callback(0),
- _bufferToPlay(0), _bufferToFill(0), _emptyBuffers(NUM_BUFFERS),
- _init(false), _paused(true), _stoppedPlayingOnceFlag(true) {
+ _bufferToPlay(0), _bufferToFill(0),
+ _init(false), _paused(true) {
for (int i=0; i<NUM_BUFFERS; i++)
_buffers[i] = 0;
}
@@ -62,10 +62,8 @@ private:
int _bufferToPlay; // the next buffer to output
int _bufferToFill;
int _bufferSize;
- int _emptyBuffers;
bool _init; // flag for initialization
bool _paused;
- bool _stoppedPlayingOnceFlag; // used to make sure we know when the playing stopped
};
#endif /* PSP_AUDIO_H */
diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp
index ed7fb2d3cf..a36ae1847f 100644
--- a/backends/platform/psp/osys_psp.cpp
+++ b/backends/platform/psp/osys_psp.cpp
@@ -49,7 +49,7 @@
#include "backends/platform/psp/trace.h"
-//#define USE_PSP_AUDIO
+#define USE_PSP_AUDIO
#define SAMPLES_PER_SEC 44100
diff --git a/backends/platform/psp/thread.h b/backends/platform/psp/thread.h
index 9ed3a2e2dc..e83eead68e 100644
--- a/backends/platform/psp/thread.h
+++ b/backends/platform/psp/thread.h
@@ -38,15 +38,15 @@ public:
enum ThreadPriority {
PRIORITY_MAIN_THREAD = 36,
- PRIORITY_AUDIO_THREAD = 35, // We'll alternate between this and main thread priority
PRIORITY_TIMER_THREAD = 30,
- PRIORITY_POWER_THREAD = 20,
- PRIORITY_DISPLAY_THREAD = 17
+ PRIORITY_AUDIO_THREAD = 25, // must be higher than timer or we get stuttering
+ PRIORITY_POWER_THREAD = 20, // quite a light thread
+ PRIORITY_DISPLAY_THREAD = 17 // very light thread for callbacks only
};
enum StackSizes {
STACK_AUDIO_THREAD = 16 * 1024,
- STACK_TIMER_THREAD = 16 * 1024,
+ STACK_TIMER_THREAD = 32 * 1024,
STACK_DISPLAY_THREAD = 2 * 1024,
STACK_POWER_THREAD = 4 * 1024
};