PSP2: Fix audio crackling when buffer is full
This commit is contained in:
parent
50622f9e55
commit
ec4e2e80d9
1
CHANGES
1
CHANGES
@ -101,6 +101,7 @@ Misc:
|
|||||||
Changes from beta 1:
|
Changes from beta 1:
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
- PSP2: Fix audio crackling after fast forward
|
- PSP2: Fix audio crackling after fast forward
|
||||||
|
- PSP2: Fix audio crackling when buffer is full
|
||||||
|
|
||||||
0.6 beta 1: (2018-09-24)
|
0.6 beta 1: (2018-09-24)
|
||||||
- Initial beta for 0.6
|
- Initial beta for 0.6
|
||||||
|
@ -97,18 +97,23 @@ void mPSP2MapKey(struct mInputMap* map, int pspKey, int key) {
|
|||||||
static THREAD_ENTRY _audioThread(void* context) {
|
static THREAD_ENTRY _audioThread(void* context) {
|
||||||
struct mPSP2AudioContext* audio = (struct mPSP2AudioContext*) context;
|
struct mPSP2AudioContext* audio = (struct mPSP2AudioContext*) context;
|
||||||
uint32_t zeroBuffer[PSP2_SAMPLES] = {0};
|
uint32_t zeroBuffer[PSP2_SAMPLES] = {0};
|
||||||
|
void* buffer = zeroBuffer;
|
||||||
int audioPort = sceAudioOutOpenPort(SCE_AUDIO_OUT_PORT_TYPE_MAIN, PSP2_SAMPLES, 48000, SCE_AUDIO_OUT_MODE_STEREO);
|
int audioPort = sceAudioOutOpenPort(SCE_AUDIO_OUT_PORT_TYPE_MAIN, PSP2_SAMPLES, 48000, SCE_AUDIO_OUT_MODE_STEREO);
|
||||||
while (audio->running) {
|
while (audio->running) {
|
||||||
MutexLock(&audio->mutex);
|
MutexLock(&audio->mutex);
|
||||||
void* buffer;
|
if (buffer != zeroBuffer) {
|
||||||
|
// Can only happen in successive iterations
|
||||||
|
audio->samples -= PSP2_SAMPLES;
|
||||||
|
ConditionWake(&audio->cond);
|
||||||
|
}
|
||||||
if (audio->samples >= PSP2_SAMPLES) {
|
if (audio->samples >= PSP2_SAMPLES) {
|
||||||
buffer = &audio->buffer[audio->readOffset];
|
buffer = &audio->buffer[audio->readOffset];
|
||||||
audio->samples -= PSP2_SAMPLES;
|
|
||||||
audio->readOffset += PSP2_SAMPLES;
|
audio->readOffset += PSP2_SAMPLES;
|
||||||
if (audio->readOffset >= PSP2_AUDIO_BUFFER_SIZE) {
|
if (audio->readOffset >= PSP2_AUDIO_BUFFER_SIZE) {
|
||||||
audio->readOffset = 0;
|
audio->readOffset = 0;
|
||||||
}
|
}
|
||||||
ConditionWake(&audio->cond);
|
// Don't mark samples as read until the next loop iteration to prevent
|
||||||
|
// writing to the buffer while being read (see above)
|
||||||
} else {
|
} else {
|
||||||
buffer = zeroBuffer;
|
buffer = zeroBuffer;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user