mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Return an error for MOut on a stereo stream.
It seems like it won't downmix, it returns an error.
This commit is contained in:
parent
feada0ee65
commit
58afdfac60
1 changed files with 63 additions and 17 deletions
|
@ -59,6 +59,7 @@
|
|||
#define ATRAC_ERROR_INCORRECT_READ_SIZE 0x80630013
|
||||
#define ATRAC_ERROR_BAD_SAMPLE 0x80630015
|
||||
#define ATRAC_ERROR_ADD_DATA_IS_TOO_BIG 0x80630018
|
||||
#define ATRAC_ERROR_NOT_MONO 0x80630019
|
||||
#define ATRAC_ERROR_NO_LOOP_INFORMATION 0x80630021
|
||||
#define ATRAC_ERROR_SECOND_BUFFER_NOT_NEEDED 0x80630022
|
||||
#define ATRAC_ERROR_BUFFER_IS_EMPTY 0x80630023
|
||||
|
@ -1533,43 +1534,73 @@ int sceAtracIsSecondBufferNeeded(int atracID) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int sceAtracSetMOutHalfwayBuffer(int atracID, u32 MOutHalfBuffer, u32 readSize, u32 MOutHalfBufferSize) {
|
||||
int sceAtracSetMOutHalfwayBuffer(int atracID, u32 buffer, u32 readSize, u32 bufferSize) {
|
||||
Atrac *atrac = getAtrac(atracID);
|
||||
if (!atrac) {
|
||||
ERROR_LOG(ME, "sceAtracSetMOutHalfwayBuffer(%i, %08x, %08x, %08x): bad atrac ID", atracID, MOutHalfBuffer, readSize, MOutHalfBufferSize);
|
||||
ERROR_LOG(ME, "sceAtracSetMOutHalfwayBuffer(%i, %08x, %08x, %08x): bad atrac ID", atracID, buffer, readSize, bufferSize);
|
||||
return ATRAC_ERROR_BAD_ATRACID;
|
||||
}
|
||||
|
||||
INFO_LOG(ME, "sceAtracSetMOutHalfwayBuffer(%i, %08x, %08x, %08x)", atracID, MOutHalfBuffer, readSize, MOutHalfBufferSize);
|
||||
if (readSize > MOutHalfBufferSize)
|
||||
INFO_LOG(ME, "sceAtracSetMOutHalfwayBuffer(%i, %08x, %08x, %08x)", atracID, buffer, readSize, bufferSize);
|
||||
if (readSize > bufferSize)
|
||||
return ATRAC_ERROR_INCORRECT_READ_SIZE;
|
||||
|
||||
int ret = 0;
|
||||
if (atrac != NULL) {
|
||||
atrac->first.addr = MOutHalfBuffer;
|
||||
atrac->first.addr = buffer;
|
||||
atrac->first.size = readSize;
|
||||
ret = atrac->Analyze();
|
||||
if (ret < 0) {
|
||||
ERROR_LOG_REPORT(ME, "sceAtracSetMOutHalfwayBuffer(%i, %08x, %08x, %08x): bad data", atracID, MOutHalfBuffer, readSize, MOutHalfBufferSize);
|
||||
ERROR_LOG_REPORT(ME, "sceAtracSetMOutHalfwayBuffer(%i, %08x, %08x, %08x): bad data", atracID, buffer, readSize, bufferSize);
|
||||
return ret;
|
||||
}
|
||||
atrac->atracOutputChannels = 1;
|
||||
ret = _AtracSetData(atracID, MOutHalfBuffer, MOutHalfBufferSize);
|
||||
if (atrac->atracChannels != 1) {
|
||||
ERROR_LOG_REPORT(ME, "sceAtracSetMOutHalfwayBuffer(%i, %08x, %08x, %08x): not mono data", atracID, buffer, readSize, bufferSize);
|
||||
ret = ATRAC_ERROR_NOT_MONO;
|
||||
// It seems it still sets the data.
|
||||
atrac->atracOutputChannels = 2;
|
||||
_AtracSetData(atrac, buffer, bufferSize);
|
||||
return ret;
|
||||
} else {
|
||||
atrac->atracOutputChannels = 1;
|
||||
ret = _AtracSetData(atracID, buffer, bufferSize);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
u32 sceAtracSetMOutData(int atracID, u32 buffer, u32 bufferSize) {
|
||||
INFO_LOG(ME, "sceAtracSetMOutData(%i, %08x, %08x)", atracID, buffer, bufferSize);
|
||||
Atrac *atrac = getAtrac(atracID);
|
||||
if (!atrac) {
|
||||
ERROR_LOG(ME, "sceAtracSetMOutData(%i, %08x, %08x): bad atrac ID", atracID, buffer, bufferSize);
|
||||
return ATRAC_ERROR_BAD_ATRACID;
|
||||
}
|
||||
|
||||
// This doesn't seem to be part of any available libatrac3plus library.
|
||||
WARN_LOG_REPORT(ME, "sceAtracSetMOutData(%i, %08x, %08x)", atracID, buffer, bufferSize);
|
||||
|
||||
// TODO: What is the proper error code here?
|
||||
int ret = 0;
|
||||
if (atrac != NULL) {
|
||||
atrac->first.addr = buffer;
|
||||
atrac->first.size = bufferSize;
|
||||
// TODO: Error code for bad data (probably yes)?
|
||||
atrac->Analyze();
|
||||
atrac->atracOutputChannels = 1;
|
||||
ret = _AtracSetData(atracID, buffer, bufferSize);
|
||||
ret = atrac->Analyze();
|
||||
if (ret < 0) {
|
||||
ERROR_LOG_REPORT(ME, "sceAtracSetMOutData(%i, %08x, %08x): bad data", atracID, buffer, bufferSize);
|
||||
return ret;
|
||||
}
|
||||
if (atrac->atracChannels != 1) {
|
||||
ERROR_LOG_REPORT(ME, "sceAtracSetMOutData(%i, %08x, %08x): not mono data", atracID, buffer, bufferSize);
|
||||
ret = ATRAC_ERROR_NOT_MONO;
|
||||
// It seems it still sets the data.
|
||||
atrac->atracOutputChannels = 2;
|
||||
_AtracSetData(atrac, buffer, bufferSize);
|
||||
// Not sure of the real delay time.
|
||||
return ret;
|
||||
} else {
|
||||
atrac->atracOutputChannels = 1;
|
||||
ret = _AtracSetData(atracID, buffer, bufferSize);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -1583,8 +1614,17 @@ int sceAtracSetMOutDataAndGetID(u32 buffer, u32 bufferSize) {
|
|||
Atrac *atrac = new Atrac();
|
||||
atrac->first.addr = buffer;
|
||||
atrac->first.size = bufferSize;
|
||||
// TODO: Error code for bad data (probably yes)?
|
||||
atrac->Analyze();
|
||||
int ret = atrac->Analyze();
|
||||
if (ret < 0) {
|
||||
ERROR_LOG_REPORT(ME, "sceAtracSetMOutDataAndGetID(%08x, %08x): bad data", buffer, bufferSize);
|
||||
delete atrac;
|
||||
return ret;
|
||||
}
|
||||
if (atrac->atracChannels != 1) {
|
||||
ERROR_LOG_REPORT(ME, "sceAtracSetMOutDataAndGetID(%08x, %08x): not mono data", buffer, bufferSize);
|
||||
delete atrac;
|
||||
return ATRAC_ERROR_NOT_MONO;
|
||||
}
|
||||
atrac->atracOutputChannels = 1;
|
||||
int atracID = createAtrac(atrac, codecType);
|
||||
if (atracID < 0) {
|
||||
|
@ -1592,8 +1632,9 @@ int sceAtracSetMOutDataAndGetID(u32 buffer, u32 bufferSize) {
|
|||
delete atrac;
|
||||
return atracID;
|
||||
}
|
||||
INFO_LOG(ME, "%d=sceAtracSetMOutDataAndGetID(%08x, %08x)", atracID, buffer, bufferSize);
|
||||
int ret = _AtracSetData(atracID, buffer, bufferSize, true);
|
||||
// This doesn't seem to be part of any available libatrac3plus library.
|
||||
WARN_LOG_REPORT(ME, "%d=sceAtracSetMOutDataAndGetID(%08x, %08x)", atracID, buffer, bufferSize);
|
||||
ret = _AtracSetData(atracID, buffer, bufferSize, true);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
return atracID;
|
||||
|
@ -1618,6 +1659,11 @@ int sceAtracSetMOutHalfwayBufferAndGetID(u32 halfBuffer, u32 readSize, u32 halfB
|
|||
delete atrac;
|
||||
return ret;
|
||||
}
|
||||
if (atrac->atracChannels != 1) {
|
||||
ERROR_LOG_REPORT(ME, "sceAtracSetMOutHalfwayBufferAndGetID(%08x, %08x, %08x): not mono data", halfBuffer, readSize, halfBufferSize);
|
||||
delete atrac;
|
||||
return ATRAC_ERROR_NOT_MONO;
|
||||
}
|
||||
atrac->atracOutputChannels = 1;
|
||||
int atracID = createAtrac(atrac, codecType);
|
||||
if (atracID < 0) {
|
||||
|
|
Loading…
Add table
Reference in a new issue