[Scummvm-cvs-logs] SF.net SVN: scummvm:[49200] scummvm/trunk/backends/platform/psp
bluddy at users.sourceforge.net
bluddy at users.sourceforge.net
Mon May 24 20:20:16 CEST 2010
Revision: 49200
http://scummvm.svn.sourceforge.net/scummvm/?rev=49200&view=rev
Author: bluddy
Date: 2010-05-24 18:20:16 +0000 (Mon, 24 May 2010)
Log Message:
-----------
PSP: to fix the audio, I cleaned up the audio thread and changed the thread priorities.
Modified Paths:
--------------
scummvm/trunk/backends/platform/psp/audio.cpp
scummvm/trunk/backends/platform/psp/audio.h
scummvm/trunk/backends/platform/psp/osys_psp.cpp
scummvm/trunk/backends/platform/psp/thread.h
Modified: scummvm/trunk/backends/platform/psp/audio.cpp
===================================================================
--- scummvm/trunk/backends/platform/psp/audio.cpp 2010-05-24 17:55:23 UTC (rev 49199)
+++ scummvm/trunk/backends/platform/psp/audio.cpp 2010-05-24 18:20:16 UTC (rev 49200)
@@ -79,7 +79,6 @@
_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 @@
};
// 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 @@
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++;
- }
+ PSP_DEBUG_PRINT("filling buffer[%d]\n", _bufferToFill);
+ _callback(_userData, _buffers[_bufferToFill], _bufferSize); // ask mixer to fill in
+ nextBuffer(_bufferToFill);
- 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("playing buffer[%d]. empty buffers[%d]\n", _bufferToPlay, _emptyBuffers);
+ PSP_DEBUG_PRINT("playing buffer[%d].\n", _bufferToPlay);
playBuffer();
nextBuffer(_bufferToPlay);
} // while _init
Modified: scummvm/trunk/backends/platform/psp/audio.h
===================================================================
--- scummvm/trunk/backends/platform/psp/audio.h 2010-05-24 17:55:23 UTC (rev 49199)
+++ scummvm/trunk/backends/platform/psp/audio.h 2010-05-24 18:20:16 UTC (rev 49200)
@@ -35,8 +35,8 @@
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 @@
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 */
Modified: scummvm/trunk/backends/platform/psp/osys_psp.cpp
===================================================================
--- scummvm/trunk/backends/platform/psp/osys_psp.cpp 2010-05-24 17:55:23 UTC (rev 49199)
+++ scummvm/trunk/backends/platform/psp/osys_psp.cpp 2010-05-24 18:20:16 UTC (rev 49200)
@@ -49,7 +49,7 @@
#include "backends/platform/psp/trace.h"
-//#define USE_PSP_AUDIO
+#define USE_PSP_AUDIO
#define SAMPLES_PER_SEC 44100
Modified: scummvm/trunk/backends/platform/psp/thread.h
===================================================================
--- scummvm/trunk/backends/platform/psp/thread.h 2010-05-24 17:55:23 UTC (rev 49199)
+++ scummvm/trunk/backends/platform/psp/thread.h 2010-05-24 18:20:16 UTC (rev 49200)
@@ -38,15 +38,15 @@
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
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list