-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #201 from unknownbrackets/audio2-release
Test reserve/release for SRC/Output2
- Loading branch information
Showing
10 changed files
with
280 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
TARGETS = threads release reserve | ||
EXTRA_OBJS = ../sceaudio/audio-imports.o | ||
|
||
COMMON_DIR = ../../../common | ||
include $(COMMON_DIR)/common.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <common.h> | ||
#include <pspaudio.h> | ||
#include <pspthreadman.h> | ||
|
||
static u16 data[128]; | ||
|
||
extern "C" int main(int argc, char *argv[]) { | ||
checkpointNext("Output2"); | ||
checkpoint(" Reserve: %08x", sceAudioOutput2Reserve(64)); | ||
checkpoint(" OutputBlocking: %08x", sceAudioOutput2OutputBlocking(0x7fff, data)); | ||
checkpoint(" Release: %08x", sceAudioOutput2Release()); | ||
sceKernelDelayThread(1000); | ||
checkpoint(" Release (after 1ms): %08x", sceAudioOutput2Release()); | ||
sceKernelDelayThread(1000); | ||
checkpoint(" Release (after 2ms): %08x", sceAudioOutput2Release()); | ||
checkpoint(" Release (again): %08x", sceAudioOutput2Release()); | ||
|
||
checkpointNext("SRC"); | ||
checkpoint(" Reserve: %08x", sceAudioSRCChReserve(64, 44100, 2)); | ||
checkpoint(" OutputBlocking: %08x", sceAudioSRCOutputBlocking(0x7fff, data)); | ||
checkpoint(" Release: %08x", sceAudioSRCChRelease()); | ||
sceKernelDelayThread(1000); | ||
checkpoint(" Release (after 1ms): %08x", sceAudioSRCChRelease()); | ||
sceKernelDelayThread(1000); | ||
checkpoint(" Release (after 2ms): %08x", sceAudioSRCChRelease()); | ||
checkpoint(" Release (again): %08x", sceAudioSRCChRelease()); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[x] Output2 | ||
[x] Reserve: 00000000 | ||
[x] OutputBlocking: 00000040 | ||
[x] Release: 80268002 | ||
[r] Release (after 1ms): 80268002 | ||
[r] Release (after 2ms): 00000000 | ||
[x] Release (again): 80260008 | ||
|
||
[x] SRC | ||
[x] Reserve: 00000000 | ||
[x] OutputBlocking: 00000040 | ||
[x] Release: 80268002 | ||
[r] Release (after 1ms): 80268002 | ||
[r] Release (after 2ms): 00000000 | ||
[x] Release (again): 80260008 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#include <common.h> | ||
#include <pspaudio.h> | ||
#include <pspthreadman.h> | ||
|
||
static void test2Reserve(const char *title, int samples) { | ||
int result = sceAudioOutput2Reserve(samples); | ||
if (result >= 0) { | ||
sceAudioOutput2Release(); | ||
} | ||
checkpoint("%s: %08x", title, result); | ||
} | ||
|
||
static void testSRCReserve(const char *title, int samples, int freq, int fmt) { | ||
int result = sceAudioSRCChReserve(samples, freq, fmt); | ||
if (result >= 0) { | ||
sceAudioSRCChRelease(); | ||
} | ||
checkpoint("%s: %08x", title, result); | ||
} | ||
|
||
extern "C" int main(int argc, char *argv[]) { | ||
checkpointNext("Output2"); | ||
sceAudioOutput2Reserve(17); | ||
checkpoint(" Twice: %08x", sceAudioOutput2Reserve(17)); | ||
sceAudioOutput2Release(); | ||
|
||
test2Reserve(" Zero", 0); | ||
test2Reserve(" Negative", -1); | ||
static const int sampleCounts[] = { 16, 17, 18, 2048, 2049, 4110, 4111, 4112, 8222, 0x80000000 | 4111, 0x40000000 | 4111, 0x80000000 | 16, 0x80000000 | 17 }; | ||
for (size_t i = 0; i < ARRAY_SIZE(sampleCounts); ++i) { | ||
char temp[256]; | ||
sprintf(temp, " %d samples", sampleCounts[i]); | ||
test2Reserve(temp, sampleCounts[i]); | ||
} | ||
|
||
checkpointNext("SRC"); | ||
sceAudioSRCChReserve(17, 44100, 2); | ||
checkpoint(" SRC Twice: %08x", sceAudioSRCChReserve(17, 44100, 2)); | ||
sceAudioSRCChRelease(); | ||
|
||
checkpointNext("SRC samples"); | ||
testSRCReserve(" Zero SRC samples", 0, 44100, 2); | ||
testSRCReserve(" Negative SRC samples", -1, 44100, 2); | ||
for (size_t i = 0; i < ARRAY_SIZE(sampleCounts); ++i) { | ||
char temp[256]; | ||
sprintf(temp, " %d SRC samples", sampleCounts[i]); | ||
testSRCReserve(temp, sampleCounts[i], 44100, 2); | ||
} | ||
|
||
checkpointNext("SRC frequencies"); | ||
testSRCReserve(" Zero frequency", 64, 0, 2); | ||
testSRCReserve(" Negative frequency", 64, -1, 2); | ||
static const int freqs[] = { 1, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 4000, 40000, 88200, 64000, 360000, 0x80000000 | 44100 }; | ||
for (size_t i = 0; i < ARRAY_SIZE(freqs); ++i) { | ||
char temp[256]; | ||
sprintf(temp, " %d frequency", freqs[i]); | ||
testSRCReserve(temp, 64, freqs[i], 2); | ||
} | ||
|
||
checkpointNext("SRC formats"); | ||
testSRCReserve(" Zero format", 64, 0, 0); | ||
testSRCReserve(" Negative format", 64, 0, -2); | ||
static const int formats[] = { 1, 2, 3, 4, 5, 8, 0x80000002 }; | ||
for (size_t i = 0; i < ARRAY_SIZE(formats); ++i) { | ||
char temp[256]; | ||
sprintf(temp, " %d format", formats[i]); | ||
testSRCReserve(temp, 64, 0, formats[i]); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
[x] Output2 | ||
[x] Twice: 80268002 | ||
[x] Zero: 80000104 | ||
[x] Negative: 80000104 | ||
[x] 16 samples: 80000104 | ||
[x] 17 samples: 00000000 | ||
[x] 18 samples: 00000000 | ||
[x] 2048 samples: 00000000 | ||
[x] 2049 samples: 00000000 | ||
[x] 4110 samples: 00000000 | ||
[x] 4111 samples: 00000000 | ||
[x] 4112 samples: 80000104 | ||
[x] 8222 samples: 80000104 | ||
[x] -2147479537 samples: 00000000 | ||
[x] 1073745935 samples: 80000104 | ||
[x] -2147483632 samples: 80000104 | ||
[x] -2147483631 samples: 00000000 | ||
|
||
[x] SRC | ||
[x] SRC Twice: 80268002 | ||
|
||
[x] SRC samples | ||
[x] Zero SRC samples: 80000104 | ||
[x] Negative SRC samples: 80000104 | ||
[x] 16 SRC samples: 80000104 | ||
[x] 17 SRC samples: 00000000 | ||
[x] 18 SRC samples: 00000000 | ||
[x] 2048 SRC samples: 00000000 | ||
[x] 2049 SRC samples: 00000000 | ||
[x] 4110 SRC samples: 00000000 | ||
[x] 4111 SRC samples: 00000000 | ||
[x] 4112 SRC samples: 80000104 | ||
[x] 8222 SRC samples: 80000104 | ||
[x] -2147479537 SRC samples: 00000000 | ||
[x] 1073745935 SRC samples: 80000104 | ||
[x] -2147483632 SRC samples: 80000104 | ||
[x] -2147483631 SRC samples: 00000000 | ||
|
||
[x] SRC frequencies | ||
[x] Zero frequency: 00000000 | ||
[x] Negative frequency: 8026000a | ||
[x] 1 frequency: 8026000a | ||
[x] 48000 frequency: 00000000 | ||
[x] 44100 frequency: 00000000 | ||
[x] 32000 frequency: 00000000 | ||
[x] 24000 frequency: 00000000 | ||
[x] 22050 frequency: 00000000 | ||
[x] 16000 frequency: 00000000 | ||
[x] 12000 frequency: 00000000 | ||
[x] 11025 frequency: 00000000 | ||
[x] 8000 frequency: 00000000 | ||
[x] 4000 frequency: 8026000a | ||
[x] 40000 frequency: 8026000a | ||
[x] 88200 frequency: 8026000a | ||
[x] 64000 frequency: 8026000a | ||
[x] 360000 frequency: 8026000a | ||
[x] -2147439548 frequency: 8026000a | ||
|
||
[x] SRC formats | ||
[x] Zero format: 80000104 | ||
[x] Negative format: 80000104 | ||
[x] 1 format: 80000104 | ||
[x] 2 format: 00000000 | ||
[x] 3 format: 80000104 | ||
[x] 4 format: 80000003 | ||
[x] 5 format: 80000104 | ||
[x] 8 format: 80000104 | ||
[x] -2147483646 format: 80000104 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#include <common.h> | ||
#include <pspaudio.h> | ||
#include <pspthreadman.h> | ||
|
||
enum MsgType { | ||
MSG_RESERVE, | ||
MSG_RELEASE, | ||
MSG_QUIT, | ||
}; | ||
|
||
struct Msg { | ||
Msg(MsgType ty, int i1 = 0) { | ||
memset(&header, 0, sizeof(header)); | ||
type = ty; | ||
int1 = i1; | ||
} | ||
|
||
SceKernelMsgPacket header; | ||
MsgType type; | ||
int int1; | ||
}; | ||
|
||
struct ThreadInfo { | ||
int thnum; | ||
SceUID mbox; | ||
}; | ||
|
||
int threadFunc(SceSize args, void *argp) { | ||
ThreadInfo *info = (ThreadInfo *)argp; | ||
Msg *msg; | ||
|
||
while (sceKernelReceiveMbx(info->mbox, (void **)&msg, NULL) == 0) { | ||
switch (msg->type) { | ||
case MSG_QUIT: | ||
info->mbox = 0; | ||
break; | ||
|
||
case MSG_RESERVE: | ||
checkpoint(" [%d] Reserve: %08x", info->thnum, sceAudioOutput2Reserve(msg->int1)); | ||
break; | ||
|
||
case MSG_RELEASE: | ||
checkpoint(" [%d] Release: %08x", info->thnum, sceAudioOutput2Release()); | ||
break; | ||
|
||
default: | ||
checkpoint(" [%d] Unknown msg type %d", info->thnum, msg->type); | ||
break; | ||
} | ||
|
||
delete msg; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
extern "C" int main(int argc, char *argv[]) { | ||
SceUID thread1 = sceKernelCreateThread("thread1", &threadFunc, 0x1a, 0x1000, 0, NULL); | ||
SceUID thread2 = sceKernelCreateThread("thread2", &threadFunc, 0x1a, 0x1000, 0, NULL); | ||
|
||
ThreadInfo info1 = { 1 }; | ||
info1.mbox = sceKernelCreateMbx("mbx1", 0, NULL); | ||
ThreadInfo info2 = { 2 }; | ||
info2.mbox = sceKernelCreateMbx("mbx2", 0, NULL); | ||
|
||
sceKernelStartThread(thread1, sizeof(ThreadInfo), &info1); | ||
sceKernelStartThread(thread2, sizeof(ThreadInfo), &info2); | ||
|
||
sceKernelSendMbx(info1.mbox, new Msg(MSG_RESERVE, 0x100)); | ||
sceKernelSendMbx(info2.mbox, new Msg(MSG_RESERVE, 0x800)); | ||
|
||
sceKernelSendMbx(info1.mbox, new Msg(MSG_RELEASE)); | ||
sceKernelSendMbx(info2.mbox, new Msg(MSG_RELEASE)); | ||
|
||
sceKernelSendMbx(info1.mbox, new Msg(MSG_RESERVE, 0x100)); | ||
sceKernelSendMbx(info2.mbox, new Msg(MSG_RELEASE)); | ||
sceKernelSendMbx(info2.mbox, new Msg(MSG_RESERVE, 0x800)); | ||
sceKernelSendMbx(info1.mbox, new Msg(MSG_RELEASE)); | ||
|
||
sceKernelSendMbx(info1.mbox, new Msg(MSG_QUIT)); | ||
sceKernelSendMbx(info2.mbox, new Msg(MSG_QUIT)); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[x] [1] Reserve: 00000000 | ||
[x] [2] Reserve: 80268002 | ||
[x] [1] Release: 00000000 | ||
[x] [2] Release: 80260008 | ||
[x] [1] Reserve: 00000000 | ||
[x] [2] Release: 00000000 | ||
[x] [2] Reserve: 00000000 | ||
[x] [1] Release: 00000000 |
Binary file not shown.