Skip to content
This repository has been archived by the owner on May 7, 2023. It is now read-only.

Commit

Permalink
Fixed an issue with volume limiter for EQ
Browse files Browse the repository at this point in the history
  • Loading branch information
GrapheneCt authored Jul 5, 2020
1 parent 79d7c61 commit 0bfcf0b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
38 changes: 24 additions & 14 deletions source/audio/vitaaudiolib.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include <psp2/kernel/threadmgr.h>
#include <psp2/kernel/clib.h>
#include <psp2/apputil.h>

#include "vitaaudiolib.h"
#include "utils.h"
#include "config.h"

static int audio_ready = 0;
static short vitaAudioSoundBuffer[2][VITA_NUM_AUDIO_SAMPLES][2];
Expand All @@ -11,19 +13,6 @@ static volatile int audio_terminate = 0;

extern SceUID event_flag_uid;

void vitaAudioSetVolume(int left, int right) {

int vol[2] = { left, right };

if (vol[0] > SCE_AUDIO_OUT_MAX_VOL)
vol[0] = SCE_AUDIO_OUT_MAX_VOL;

if (vol[1] > SCE_AUDIO_OUT_MAX_VOL)
vol[1] = SCE_AUDIO_OUT_MAX_VOL;

sceAudioOutSetVolume(vitaAudioStatus.handle, SCE_AUDIO_VOLUME_FLAG_L_CH | SCE_AUDIO_VOLUME_FLAG_R_CH, vol);
}

void vitaAudioSetChannelCallback(vitaAudioCallback_t callback, void *userdata) {
volatile VITA_audio_channelinfo *pci = &vitaAudioStatus;

Expand All @@ -36,6 +25,7 @@ void vitaAudioSetChannelCallback(vitaAudioCallback_t callback, void *userdata) {
static int vitaAudioChannelThread(unsigned int args, void *argp) {
volatile int bufidx = 0;
void *bufptr;
int vol[2];

while (audio_terminate == 0) {
sceKernelWaitEventFlag(event_flag_uid, FLAG_ELEVENMPVA_IS_DECODER_USED, SCE_KERNEL_EVF_WAITMODE_AND, NULL, NULL);
Expand All @@ -51,8 +41,28 @@ static int vitaAudioChannelThread(unsigned int args, void *argp) {
*(ptr++) = 0;
}

if (audio_ready)
if (audio_ready) {
sceAppUtilSystemParamGetInt(9, &vol[0]);

if (config.eq_volume) {
if (config.eq_mode == 0) {
vol[1] = vol[0];
sceAudioOutSetVolume(vitaAudioStatus.handle, SCE_AUDIO_VOLUME_FLAG_L_CH | SCE_AUDIO_VOLUME_FLAG_R_CH, vol);
}
else {
vol[0] = vol[0] / 2;
vol[1] = vol[0];
sceAudioOutSetVolume(vitaAudioStatus.handle, SCE_AUDIO_VOLUME_FLAG_L_CH | SCE_AUDIO_VOLUME_FLAG_R_CH, vol);
}
}
else {
vol[1] = vol[0];
sceAudioOutSetVolume(vitaAudioStatus.handle, SCE_AUDIO_VOLUME_FLAG_L_CH | SCE_AUDIO_VOLUME_FLAG_R_CH, vol);
}

sceAudioOutSetVolume(vitaAudioStatus.handle, SCE_AUDIO_VOLUME_FLAG_L_CH | SCE_AUDIO_VOLUME_FLAG_R_CH, vol);
sceAudioOutOutput(vitaAudioStatus.handle, bufptr);
}
bufidx = (bufidx ? 0 : 1);
}

Expand Down
13 changes: 1 addition & 12 deletions source/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,6 @@ int Utils_AppStatusWatchdog(SceSize argc, void* argv) {
break;
}

//check volume

sceAppUtilSystemParamGetInt(9, &vol);

if (config.eq_volume) {
if (config.eq_mode == 0)
vitaAudioSetVolume(vol, vol);
else
vitaAudioSetVolume(vol / 2, vol / 2);
}

//check notifications

if (config.notify_mode > 0) {
Expand Down Expand Up @@ -183,7 +172,7 @@ int Utils_AppStatusWatchdog(SceSize argc, void* argv) {
sceClibPrintf("LPDDR2: %f MB\n", budget_info.freeLPDDR2 / 1024.0 / 1024.0);*/
#endif

sceKernelDelayThread(100 * 1000);
sceKernelDelayThread(10 * 1000);
}

return 0;
Expand Down

0 comments on commit 0bfcf0b

Please sign in to comment.