CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Core/HLE/sceAtrac.cpp
Views: 1401
1
// Copyright (c) 2012- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#include <algorithm>
19
20
#include "Common/Serialize/Serializer.h"
21
#include "Common/Serialize/SerializeFuncs.h"
22
#include "Core/HLE/HLE.h"
23
#include "Core/HLE/FunctionWrappers.h"
24
#include "Core/MIPS/MIPS.h"
25
#include "Core/CoreTiming.h"
26
#include "Core/MemMapHelpers.h"
27
#include "Core/Reporting.h"
28
#include "Core/Config.h"
29
#include "Core/Debugger/MemBlockInfo.h"
30
#include "Core/HW/MediaEngine.h"
31
#include "Core/HW/BufferQueue.h"
32
33
#include "Core/HLE/sceKernel.h"
34
#include "Core/HLE/sceUtility.h"
35
#include "Core/HLE/sceKernelMemory.h"
36
#include "Core/HLE/sceAtrac.h"
37
#include "Core/HLE/AtracCtx.h"
38
#include "Core/HLE/AtracCtx2.h"
39
#include "Core/System.h"
40
41
// Notes about sceAtrac buffer management
42
//
43
// sceAtrac decodes from a buffer the game fills, where this buffer is one of:
44
// * Not yet initialized (state NO DATA = 1)
45
// * The entire size of the audio data, and filled with audio data (state ALL DATA LOADED = 2)
46
// * The entire size, but only partially filled so far (state HALFWAY BUFFER = 3)
47
// * Smaller than the audio, sliding without any loop (state STREAMED WITHOUT LOOP = 4)
48
// * Smaller than the audio, sliding with a loop at the end (state STREAMED WITH LOOP AT END = 5)
49
// * Smaller with a second buffer to help with a loop in the middle (state STREAMED WITH SECOND BUF = 6)
50
// * Not managed, decoding using "low level" manual looping etc. (LOW LEVEL = 8)
51
// * Not managed, reserved externally - possibly by sceSas - through low level (RESERVED = 16)
52
//
53
// This buffer is generally filled by sceAtracAddStreamData, and where to fill it is given by
54
// either sceAtracGetStreamDataInfo when continuing to move forwards in the stream of audio data,
55
// or sceAtracGetBufferInfoForResetting when seeking to a specific location in the audio stream.
56
//
57
// State 6 indicates a second buffer is needed. This buffer is used to manage looping correctly.
58
// To determine how to fill it, the game will call sceAtracGetSecondBufferInfo, then after filling
59
// the buffer it will call sceAtracSetSecondBuffer.
60
// The second buffer will just contain the data for the end of loop. The "first" buffer may manage
61
// only the looped portion, or some of the part after the loop (depending on second buf size.)
62
//
63
// Most files will be in RIFF format. It's also possible to load in an OMA/AA3 format file, but
64
// ultimately this will share the same buffer - it's just offset a bit more.
65
//
66
// Low level decoding doesn't use the buffer, and decodes only a single packet at a time.
67
//
68
// Lastly, sceSas has some integration with sceAtrac, which allows setting an Atrac id as
69
// a voice for an SAS core. In this mode, the game will directly modify some of the context,
70
// but will largely only interact using sceSas.
71
//
72
// Note that this buffer is THE view of the audio stream. On a PSP, the firmware does not manage
73
// any cache or separate version of the buffer - at most it manages decode state from earlier in
74
// the buffer.
75
76
static const int atracDecodeDelay = 2300;
77
78
const int PSP_NUM_ATRAC_IDS = 6;
79
static bool atracInited = true;
80
static AtracBase *atracContexts[PSP_NUM_ATRAC_IDS];
81
static u32 atracContextTypes[PSP_NUM_ATRAC_IDS];
82
static int atracLibVersion = 0;
83
static u32 atracLibCrc = 0;
84
85
void __AtracInit() {
86
_assert_(sizeof(SceAtracContext) == 256);
87
88
atracInited = true;
89
memset(atracContexts, 0, sizeof(atracContexts));
90
91
// Start with 2 of each in this order.
92
atracContextTypes[0] = PSP_MODE_AT_3_PLUS;
93
atracContextTypes[1] = PSP_MODE_AT_3_PLUS;
94
atracContextTypes[2] = PSP_MODE_AT_3;
95
atracContextTypes[3] = PSP_MODE_AT_3;
96
atracContextTypes[4] = 0;
97
atracContextTypes[5] = 0;
98
}
99
100
void __AtracShutdown() {
101
for (size_t i = 0; i < ARRAY_SIZE(atracContexts); ++i) {
102
delete atracContexts[i];
103
atracContexts[i] = nullptr;
104
}
105
}
106
107
void __AtracLoadModule(int version, u32 crc) {
108
atracLibVersion = version;
109
atracLibCrc = crc;
110
INFO_LOG(Log::ME, "AtracInit, atracLibVersion 0x%0x, atracLibcrc %x", atracLibVersion, atracLibCrc);
111
}
112
113
void __AtracDoState(PointerWrap &p) {
114
auto s = p.Section("sceAtrac", 1, 2);
115
if (!s)
116
return;
117
118
Do(p, atracInited);
119
for (int i = 0; i < PSP_NUM_ATRAC_IDS; ++i) {
120
bool valid = atracContexts[i] != nullptr;
121
Do(p, valid);
122
if (valid) {
123
DoSubClass<AtracBase, Atrac>(p, atracContexts[i]);
124
} else {
125
delete atracContexts[i];
126
atracContexts[i] = nullptr;
127
}
128
}
129
DoArray(p, atracContextTypes, PSP_NUM_ATRAC_IDS);
130
if (s < 2) {
131
atracLibVersion = 0;
132
atracLibCrc = 0;
133
}
134
else {
135
Do(p, atracLibVersion);
136
Do(p, atracLibCrc);
137
}
138
}
139
140
static AtracBase *allocAtrac(bool forceOld = false) {
141
if (g_Config.bUseNewAtrac && !forceOld) {
142
return new Atrac2();
143
} else {
144
return new Atrac();
145
}
146
}
147
148
static AtracBase *getAtrac(int atracID) {
149
if (atracID < 0 || atracID >= PSP_NUM_ATRAC_IDS) {
150
return nullptr;
151
}
152
AtracBase *atrac = atracContexts[atracID];
153
if (atrac) {
154
atrac->UpdateContextFromPSPMem();
155
}
156
return atrac;
157
}
158
159
static int createAtrac(AtracBase *atrac) {
160
for (int i = 0; i < (int)ARRAY_SIZE(atracContexts); ++i) {
161
if (atracContextTypes[i] == atrac->CodecType() && atracContexts[i] == 0) {
162
atracContexts[i] = atrac;
163
atrac->atracID_ = i;
164
return i;
165
}
166
}
167
return ATRAC_ERROR_NO_ATRACID;
168
}
169
170
static int deleteAtrac(int atracID) {
171
if (atracID >= 0 && atracID < PSP_NUM_ATRAC_IDS) {
172
if (atracContexts[atracID] != nullptr) {
173
delete atracContexts[atracID];
174
atracContexts[atracID] = nullptr;
175
return 0;
176
}
177
}
178
return ATRAC_ERROR_BAD_ATRACID;
179
}
180
181
// Really, allocate an Atrac context of a specific codec type.
182
// Useful to initialize a context for low level decode.
183
static u32 sceAtracGetAtracID(int codecType) {
184
if (codecType != PSP_MODE_AT_3 && codecType != PSP_MODE_AT_3_PLUS) {
185
return hleReportError(Log::ME, ATRAC_ERROR_INVALID_CODECTYPE, "invalid codecType");
186
}
187
188
AtracBase *atrac = allocAtrac();
189
atrac->GetTrackMut().codecType = codecType;
190
int atracID = createAtrac(atrac);
191
if (atracID < 0) {
192
delete atrac;
193
return hleLogError(Log::ME, atracID, "no free ID");
194
}
195
196
return hleLogSuccessInfoI(Log::ME, atracID);
197
}
198
199
static u32 AtracValidateData(const AtracBase *atrac) {
200
if (!atrac) {
201
return hleLogError(Log::ME, ATRAC_ERROR_BAD_ATRACID, "bad atrac ID");
202
} else if (atrac->BufferState() == ATRAC_STATUS_NO_DATA) {
203
return hleLogError(Log::ME, ATRAC_ERROR_NO_DATA, "no data");
204
} else {
205
return 0;
206
}
207
}
208
209
static u32 AtracValidateManaged(const AtracBase *atrac) {
210
if (!atrac) {
211
return hleLogError(Log::ME, ATRAC_ERROR_BAD_ATRACID, "bad atrac ID");
212
} else if (atrac->BufferState() == ATRAC_STATUS_NO_DATA) {
213
return hleLogError(Log::ME, ATRAC_ERROR_NO_DATA, "no data");
214
} else if (atrac->BufferState() == ATRAC_STATUS_LOW_LEVEL) {
215
return hleLogError(Log::ME, ATRAC_ERROR_IS_LOW_LEVEL, "low level stream, can't use");
216
} else if (atrac->BufferState() == ATRAC_STATUS_FOR_SCESAS) {
217
return hleLogError(Log::ME, ATRAC_ERROR_IS_FOR_SCESAS, "SAS stream, can't use");
218
} else {
219
return 0;
220
}
221
}
222
223
// Notifies that more data is (OR will be very soon) available in the buffer.
224
// This implies it has been added to whatever position sceAtracGetStreamDataInfo would indicate.
225
//
226
// The total size of the buffer is atrac->bufferMaxSize_.
227
static u32 sceAtracAddStreamData(int atracID, u32 bytesToAdd) {
228
AtracBase *atrac = getAtrac(atracID);
229
u32 err = AtracValidateManaged(atrac);
230
if (err != 0) {
231
// Already logged.
232
return err;
233
}
234
235
if (atrac->BufferState() == ATRAC_STATUS_ALL_DATA_LOADED) {
236
// Let's avoid spurious warnings. Some games call this with 0 which is pretty harmless.
237
if (bytesToAdd == 0)
238
return hleLogDebug(Log::ME, ATRAC_ERROR_ALL_DATA_LOADED, "stream entirely loaded");
239
return hleLogWarning(Log::ME, ATRAC_ERROR_ALL_DATA_LOADED, "stream entirely loaded");
240
}
241
242
int ret = atrac->AddStreamData(bytesToAdd);
243
if (ret < 0) {
244
return ret;
245
}
246
return hleLogSuccessI(Log::ME, 0);
247
}
248
249
// Note that outAddr being null is completely valid here, used to skip data.
250
static u32 sceAtracDecodeData(int atracID, u32 outAddr, u32 numSamplesAddr, u32 finishFlagAddr, u32 remainAddr) {
251
AtracBase *atrac = getAtrac(atracID);
252
u32 err = AtracValidateData(atrac);
253
if (err != 0) {
254
// Already logged.
255
return err;
256
}
257
258
u32 numSamples = 0;
259
u32 finish = 0;
260
int remains = 0;
261
int ret = atrac->DecodeData(Memory::GetPointerWrite(outAddr), outAddr, &numSamples, &finish, &remains);
262
if (ret != (int)ATRAC_ERROR_BAD_ATRACID && ret != (int)ATRAC_ERROR_NO_DATA) {
263
if (Memory::IsValidAddress(numSamplesAddr))
264
Memory::WriteUnchecked_U32(numSamples, numSamplesAddr);
265
if (Memory::IsValidAddress(finishFlagAddr))
266
Memory::WriteUnchecked_U32(finish, finishFlagAddr);
267
// On error, no remaining frame value is written.
268
if (ret == 0 && Memory::IsValidAddress(remainAddr))
269
Memory::WriteUnchecked_U32(remains, remainAddr);
270
}
271
DEBUG_LOG(Log::ME, "%08x=sceAtracDecodeData(%i, %08x, %08x[%08x], %08x[%08x], %08x[%d])", ret, atracID, outAddr,
272
numSamplesAddr, numSamples,
273
finishFlagAddr, finish,
274
remainAddr, remains);
275
if (!ret) {
276
// decode data successfully, delay thread
277
return hleDelayResult(ret, "atrac decode data", atracDecodeDelay);
278
}
279
return ret;
280
}
281
282
static u32 sceAtracEndEntry() {
283
ERROR_LOG_REPORT(Log::ME, "UNIMPL sceAtracEndEntry()");
284
return 0;
285
}
286
287
// Obtains information about what needs to be in the buffer to seek (or "reset")
288
// Generally called by games right before calling sceAtracResetPlayPosition().
289
static u32 sceAtracGetBufferInfoForResetting(int atracID, int sample, u32 bufferInfoAddr) {
290
auto bufferInfo = PSPPointer<AtracResetBufferInfo>::Create(bufferInfoAddr);
291
292
AtracBase *atrac = getAtrac(atracID);
293
u32 err = AtracValidateManaged(atrac);
294
if (err != 0) {
295
// Already logged.
296
return err;
297
}
298
299
if (!bufferInfo.IsValid()) {
300
return hleReportError(Log::ME, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "invalid buffer, should crash");
301
} else if (atrac->BufferState() == ATRAC_STATUS_STREAMED_LOOP_WITH_TRAILER && atrac->SecondBufferSize() == 0) {
302
return hleReportError(Log::ME, ATRAC_ERROR_SECOND_BUFFER_NEEDED, "no second buffer");
303
} else if ((u32)sample + atrac->GetTrack().firstSampleOffset > (u32)atrac->GetTrack().endSample + atrac->GetTrack().firstSampleOffset) {
304
// NOTE: Above we have to add firstSampleOffset to both sides - we seem to rely on wraparound.
305
return hleLogWarning(Log::ME, ATRAC_ERROR_BAD_SAMPLE, "invalid sample position");
306
} else {
307
atrac->GetResetBufferInfo(bufferInfo, sample);
308
return hleLogSuccessInfoI(Log::ME, 0);
309
}
310
}
311
312
static u32 sceAtracGetBitrate(int atracID, u32 outBitrateAddr) {
313
AtracBase *atrac = getAtrac(atracID);
314
u32 err = AtracValidateData(atrac);
315
if (err != 0) {
316
// Already logged.
317
return err;
318
}
319
320
atrac->GetTrackMut().UpdateBitrate();
321
322
if (Memory::IsValidAddress(outBitrateAddr)) {
323
Memory::WriteUnchecked_U32(atrac->GetTrack().bitrate, outBitrateAddr);
324
return hleLogSuccessI(Log::ME, 0);
325
} else {
326
return hleLogError(Log::ME, 0, "invalid address");
327
}
328
}
329
330
static u32 sceAtracGetChannel(int atracID, u32 channelAddr) {
331
AtracBase *atrac = getAtrac(atracID);
332
u32 err = AtracValidateData(atrac);
333
if (err != 0) {
334
// Already logged.
335
return err;
336
}
337
338
if (Memory::IsValidAddress(channelAddr)){
339
Memory::WriteUnchecked_U32(atrac->GetTrack().channels, channelAddr);
340
return hleLogSuccessI(Log::ME, 0);
341
} else {
342
return hleLogError(Log::ME, 0, "invalid address");
343
}
344
}
345
346
static u32 sceAtracGetLoopStatus(int atracID, u32 loopNumAddr, u32 statusAddr) {
347
AtracBase *atrac = getAtrac(atracID);
348
u32 err = AtracValidateData(atrac);
349
if (err != 0) {
350
// Already logged.
351
return err;
352
}
353
354
if (Memory::IsValidAddress(loopNumAddr))
355
Memory::WriteUnchecked_U32(atrac->LoopNum(), loopNumAddr);
356
// return audio's loopinfo in at3 file
357
if (Memory::IsValidAddress(statusAddr)) {
358
if (atrac->GetTrack().loopinfo.size() > 0)
359
Memory::WriteUnchecked_U32(1, statusAddr);
360
else
361
Memory::WriteUnchecked_U32(0, statusAddr);
362
return hleLogSuccessI(Log::ME, 0);
363
} else {
364
return hleLogError(Log::ME, 0, "invalid address");
365
}
366
}
367
368
static u32 sceAtracGetInternalErrorInfo(int atracID, u32 errorAddr) {
369
AtracBase *atrac = getAtrac(atracID);
370
u32 err = AtracValidateData(atrac);
371
if (err != 0) {
372
// Already logged.
373
return err;
374
}
375
ERROR_LOG(Log::ME, "UNIMPL sceAtracGetInternalErrorInfo(%i, %08x)", atracID, errorAddr);
376
if (Memory::IsValidAddress(errorAddr))
377
Memory::WriteUnchecked_U32(0, errorAddr);
378
return 0;
379
}
380
381
static u32 sceAtracGetMaxSample(int atracID, u32 maxSamplesAddr) {
382
AtracBase *atrac = getAtrac(atracID);
383
u32 err = AtracValidateData(atrac);
384
if (err != 0) {
385
// Already logged.
386
return err;
387
}
388
389
if (Memory::IsValidAddress(maxSamplesAddr)) {
390
Memory::WriteUnchecked_U32(atrac->GetTrack().SamplesPerFrame(), maxSamplesAddr);
391
return hleLogSuccessI(Log::ME, 0);
392
} else {
393
return hleLogError(Log::ME, 0, "invalid address");
394
}
395
}
396
397
static u32 sceAtracGetNextDecodePosition(int atracID, u32 outposAddr) {
398
AtracBase *atrac = getAtrac(atracID);
399
u32 err = AtracValidateData(atrac);
400
if (err != 0) {
401
// Already logged.
402
return err;
403
}
404
405
if (Memory::IsValidAddress(outposAddr)) {
406
if (atrac->CurrentSample() >= atrac->GetTrack().endSample) {
407
Memory::WriteUnchecked_U32(0, outposAddr);
408
return hleLogSuccessI(Log::ME, ATRAC_ERROR_ALL_DATA_DECODED, "all data decoded - beyond endSample");
409
} else {
410
Memory::WriteUnchecked_U32(atrac->CurrentSample(), outposAddr);
411
return hleLogSuccessI(Log::ME, 0);
412
}
413
} else {
414
return hleLogError(Log::ME, 0, "invalid address");
415
}
416
}
417
418
static u32 sceAtracGetNextSample(int atracID, u32 outNAddr) {
419
AtracBase *atrac = getAtrac(atracID);
420
u32 err = AtracValidateData(atrac);
421
if (err != 0) {
422
// Already logged.
423
return err;
424
}
425
if (atrac->CurrentSample() >= atrac->GetTrack().endSample) {
426
if (Memory::IsValidAddress(outNAddr))
427
Memory::WriteUnchecked_U32(0, outNAddr);
428
return hleLogSuccessI(Log::ME, 0, "0 samples left");
429
}
430
431
u32 numSamples = atrac->GetNextSamples();
432
433
if (Memory::IsValidAddress(outNAddr))
434
Memory::WriteUnchecked_U32(numSamples, outNAddr);
435
return hleLogSuccessI(Log::ME, 0, "%d samples left", numSamples);
436
}
437
438
// Obtains the number of frames remaining in the buffer which can be decoded.
439
// When no more data would be needed, this returns a negative number.
440
static u32 sceAtracGetRemainFrame(int atracID, u32 remainAddr) {
441
auto remainingFrames = PSPPointer<u32_le>::Create(remainAddr);
442
443
AtracBase *atrac = getAtrac(atracID);
444
u32 err = AtracValidateManaged(atrac);
445
if (err != 0) {
446
// Already logged.
447
return err;
448
}
449
450
if (!remainingFrames.IsValid()) {
451
// Would crash.
452
return hleReportError(Log::ME, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "invalid remainingFrames pointer");
453
}
454
455
*remainingFrames = atrac->RemainingFrames();
456
return hleLogSuccessI(Log::ME, 0);
457
}
458
459
static u32 sceAtracGetSecondBufferInfo(int atracID, u32 fileOffsetAddr, u32 desiredSizeAddr) {
460
auto fileOffset = PSPPointer<u32_le>::Create(fileOffsetAddr);
461
auto desiredSize = PSPPointer<u32_le>::Create(desiredSizeAddr);
462
463
AtracBase *atrac = getAtrac(atracID);
464
u32 err = AtracValidateManaged(atrac);
465
if (err != 0) {
466
// Already logged.
467
return err;
468
}
469
470
if (!fileOffset.IsValid() || !desiredSize.IsValid()) {
471
// Would crash.
472
return hleReportError(Log::ME, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "invalid addresses");
473
}
474
475
return atrac->GetSecondBufferInfo(fileOffset, desiredSize);
476
}
477
478
static u32 sceAtracGetSoundSample(int atracID, u32 outEndSampleAddr, u32 outLoopStartSampleAddr, u32 outLoopEndSampleAddr) {
479
AtracBase *atrac = getAtrac(atracID);
480
u32 err = AtracValidateManaged(atrac);
481
if (err != 0) {
482
// Already logged.
483
return err;
484
}
485
486
auto outEndSample = PSPPointer<u32_le>::Create(outEndSampleAddr);
487
if (outEndSample.IsValid())
488
*outEndSample = atrac->GetTrack().endSample;
489
auto outLoopStart = PSPPointer<u32_le>::Create(outLoopStartSampleAddr);
490
if (outLoopStart.IsValid())
491
*outLoopStart = atrac->GetTrack().loopStartSample == -1 ? -1 : atrac->GetTrack().loopStartSample - atrac->GetTrack().FirstSampleOffsetFull();
492
auto outLoopEnd = PSPPointer<u32_le>::Create(outLoopEndSampleAddr);
493
if (outLoopEnd.IsValid())
494
*outLoopEnd = atrac->GetTrack().loopEndSample == -1 ? -1 : atrac->GetTrack().loopEndSample - atrac->GetTrack().FirstSampleOffsetFull();
495
496
if (!outEndSample.IsValid() || !outLoopStart.IsValid() || !outLoopEnd.IsValid()) {
497
return hleReportError(Log::ME, 0, "invalid address");
498
}
499
return hleLogSuccessI(Log::ME, 0);
500
}
501
502
// Games call this function to get some info for add more stream data,
503
// such as where the data read from, where the data add to,
504
// and how many bytes are allowed to add.
505
static u32 sceAtracGetStreamDataInfo(int atracID, u32 writePtrAddr, u32 writableBytesAddr, u32 readOffsetAddr) {
506
AtracBase *atrac = getAtrac(atracID);
507
u32 err = AtracValidateManaged(atrac);
508
if (err != 0) {
509
// Already logged.
510
return err;
511
}
512
513
u32 writePtr;
514
u32 writableBytes;
515
u32 readOffset;
516
atrac->GetStreamDataInfo(&writePtr, &writableBytes, &readOffset);
517
518
if (Memory::IsValidAddress(writePtrAddr))
519
Memory::WriteUnchecked_U32(writePtr, writePtrAddr);
520
if (Memory::IsValidAddress(writableBytesAddr))
521
Memory::WriteUnchecked_U32(writableBytes, writableBytesAddr);
522
if (Memory::IsValidAddress(readOffsetAddr))
523
Memory::WriteUnchecked_U32(readOffset, readOffsetAddr);
524
525
return hleLogSuccessI(Log::ME, 0);
526
}
527
528
static u32 sceAtracReleaseAtracID(int atracID) {
529
int result = deleteAtrac(atracID);
530
if (result < 0) {
531
if (atracID >= 0) {
532
return hleLogError(Log::ME, result, "did not exist");
533
} else {
534
return hleLogWarning(Log::ME, result, "did not exist");
535
}
536
}
537
return hleLogSuccessInfoI(Log::ME, result);
538
}
539
540
// This is called when a game wants to seek (or "reset") to a specific position in the audio data.
541
// Normally, sceAtracGetBufferInfoForResetting() is called to determine how to buffer.
542
// The game must add sufficient packets to the buffer in order to complete the seek.
543
static u32 sceAtracResetPlayPosition(int atracID, int sample, int bytesWrittenFirstBuf, int bytesWrittenSecondBuf) {
544
AtracBase *atrac = getAtrac(atracID);
545
u32 err = AtracValidateManaged(atrac);
546
if (err != 0) {
547
// Already logged.
548
return err;
549
}
550
551
if (atrac->BufferState() == ATRAC_STATUS_STREAMED_LOOP_WITH_TRAILER && atrac->SecondBufferSize() == 0) {
552
return hleReportError(Log::ME, ATRAC_ERROR_SECOND_BUFFER_NEEDED, "no second buffer");
553
} else if ((u32)sample + atrac->GetTrack().firstSampleOffset > (u32)atrac->GetTrack().endSample + atrac->GetTrack().firstSampleOffset) {
554
// NOTE: Above we have to add firstSampleOffset to both sides - we seem to rely on wraparound.
555
return hleLogWarning(Log::ME, ATRAC_ERROR_BAD_SAMPLE, "invalid sample position");
556
}
557
558
u32 res = atrac->ResetPlayPosition(sample, bytesWrittenFirstBuf, bytesWrittenSecondBuf);
559
if (res != 0) {
560
// Already logged.
561
return res;
562
}
563
564
return hleDelayResult(hleLogSuccessInfoI(Log::ME, 0), "reset play pos", 3000);
565
}
566
567
static int _AtracSetData(int atracID, u32 buffer, u32 readSize, u32 bufferSize, int outputChannels, bool needReturnAtracID) {
568
AtracBase *atrac = getAtrac(atracID);
569
// Don't use AtracValidateManaged here.
570
if (!atrac)
571
return hleLogError(Log::ME, ATRAC_ERROR_BAD_ATRACID, "invalid atrac ID");
572
int ret = atrac->SetData(buffer, readSize, bufferSize, outputChannels, needReturnAtracID ? atracID : 0);
573
// not sure the real delay time
574
return hleDelayResult(ret, "atrac set data", 100);
575
}
576
577
static u32 sceAtracSetHalfwayBuffer(int atracID, u32 buffer, u32 readSize, u32 bufferSize) {
578
AtracBase *atrac = getAtrac(atracID);
579
// Don't use AtracValidateManaged here.
580
if (!atrac) {
581
return hleLogError(Log::ME, ATRAC_ERROR_BAD_ATRACID, "invalid atrac ID");
582
}
583
584
if (readSize > bufferSize) {
585
return hleLogError(Log::ME, ATRAC_ERROR_INCORRECT_READ_SIZE, "read size too large");
586
}
587
588
int ret = atrac->Analyze(buffer, readSize);
589
if (ret < 0) {
590
// Already logged.
591
return ret;
592
}
593
594
return _AtracSetData(atracID, buffer, readSize, bufferSize, 2, false);
595
}
596
597
static u32 sceAtracSetSecondBuffer(int atracID, u32 secondBuffer, u32 secondBufferSize) {
598
AtracBase *atrac = getAtrac(atracID);
599
u32 err = AtracValidateManaged(atrac);
600
if (err != 0) {
601
// Already logged.
602
return err;
603
}
604
605
return atrac->SetSecondBuffer(secondBuffer, secondBufferSize);
606
}
607
608
static u32 sceAtracSetData(int atracID, u32 buffer, u32 bufferSize) {
609
AtracBase *atrac = getAtrac(atracID);
610
if (!atrac) {
611
return hleLogError(Log::ME, ATRAC_ERROR_BAD_ATRACID, "bad atrac ID");
612
}
613
614
int ret = atrac->Analyze(buffer, bufferSize);
615
if (ret < 0) {
616
// Already logged.
617
return ret;
618
}
619
620
if (atrac->GetTrack().codecType != atracContextTypes[atracID]) {
621
// TODO: Should this not change the buffer size?
622
return hleReportError(Log::ME, ATRAC_ERROR_WRONG_CODECTYPE, "atracID uses different codec type than data");
623
}
624
625
return _AtracSetData(atracID, buffer, bufferSize, bufferSize, 2, false);
626
}
627
628
static int sceAtracSetDataAndGetID(u32 buffer, int bufferSize) {
629
// A large value happens in Tales of VS, and isn't handled somewhere properly as a u32.
630
// It's impossible for it to be that big anyway, so cap it.
631
if (bufferSize < 0) {
632
WARN_LOG(Log::ME, "sceAtracSetDataAndGetID(%08x, %08x): negative bufferSize", buffer, bufferSize);
633
bufferSize = 0x10000000;
634
}
635
636
AtracBase *atrac = allocAtrac();
637
int ret = atrac->Analyze(buffer, bufferSize);
638
if (ret < 0) {
639
// Already logged.
640
delete atrac;
641
return ret;
642
}
643
int atracID = createAtrac(atrac);
644
if (atracID < 0) {
645
delete atrac;
646
return hleLogError(Log::ME, atracID, "no free ID");
647
}
648
649
return _AtracSetData(atracID, buffer, bufferSize, bufferSize, 2, true);
650
}
651
652
static int sceAtracSetHalfwayBufferAndGetID(u32 buffer, u32 readSize, u32 bufferSize) {
653
if (readSize > bufferSize) {
654
return hleLogError(Log::ME, ATRAC_ERROR_INCORRECT_READ_SIZE, "read size too large");
655
}
656
AtracBase *atrac = allocAtrac();
657
int ret = atrac->Analyze(buffer, readSize);
658
if (ret < 0) {
659
// Already logged.
660
delete atrac;
661
return ret;
662
}
663
int atracID = createAtrac(atrac);
664
if (atracID < 0) {
665
delete atrac;
666
return hleLogError(Log::ME, atracID, "no free ID");
667
}
668
return _AtracSetData(atracID, buffer, readSize, bufferSize, 2, true);
669
}
670
671
static u32 sceAtracStartEntry() {
672
ERROR_LOG_REPORT(Log::ME, "UNIMPL sceAtracStartEntry()");
673
return 0;
674
}
675
676
static u32 sceAtracSetLoopNum(int atracID, int loopNum) {
677
AtracBase *atrac = getAtrac(atracID);
678
u32 err = AtracValidateData(atrac);
679
if (err != 0) {
680
// Already logged.
681
return err;
682
}
683
if (atrac->GetTrack().loopinfo.size() == 0) {
684
if (loopNum == -1) {
685
// This is very common and not really a problem.
686
return hleLogDebug(Log::ME, ATRAC_ERROR_NO_LOOP_INFORMATION, "no loop information to write to!");
687
} else {
688
return hleLogError(Log::ME, ATRAC_ERROR_NO_LOOP_INFORMATION, "no loop information to write to!");
689
}
690
}
691
692
atrac->SetLoopNum(loopNum);
693
return hleLogSuccessI(Log::ME, 0);
694
}
695
696
static int sceAtracReinit(int at3Count, int at3plusCount) {
697
for (int i = 0; i < PSP_NUM_ATRAC_IDS; ++i) {
698
if (atracContexts[i] != nullptr) {
699
ERROR_LOG_REPORT(Log::ME, "sceAtracReinit(%d, %d): cannot reinit while IDs in use", at3Count, at3plusCount);
700
return SCE_KERNEL_ERROR_BUSY;
701
}
702
}
703
704
memset(atracContextTypes, 0, sizeof(atracContextTypes));
705
int next = 0;
706
int space = PSP_NUM_ATRAC_IDS;
707
708
// This seems to deinit things. Mostly, it cause a reschedule on next deinit (but -1, -1 does not.)
709
if (at3Count == 0 && at3plusCount == 0) {
710
INFO_LOG(Log::ME, "sceAtracReinit(%d, %d): deinit", at3Count, at3plusCount);
711
atracInited = false;
712
return hleDelayResult(0, "atrac reinit", 200);
713
}
714
715
// First, ATRAC3+. These IDs seem to cost double (probably memory.)
716
// Intentionally signed. 9999 tries to allocate, -1 does not.
717
for (int i = 0; i < at3plusCount; ++i) {
718
space -= 2;
719
if (space >= 0) {
720
atracContextTypes[next++] = PSP_MODE_AT_3_PLUS;
721
}
722
}
723
for (int i = 0; i < at3Count; ++i) {
724
space -= 1;
725
if (space >= 0) {
726
atracContextTypes[next++] = PSP_MODE_AT_3;
727
}
728
}
729
730
// If we ran out of space, we still initialize some, but return an error.
731
int result = space >= 0 ? 0 : (int)SCE_KERNEL_ERROR_OUT_OF_MEMORY;
732
if (atracInited || next == 0) {
733
atracInited = true;
734
return hleLogSuccessInfoI(Log::ME, result);
735
} else {
736
atracInited = true;
737
return hleDelayResult(hleLogSuccessInfoI(Log::ME, result), "atrac reinit", 400);
738
}
739
}
740
741
static int sceAtracGetOutputChannel(int atracID, u32 outputChanPtr) {
742
AtracBase *atrac = getAtrac(atracID);
743
u32 err = AtracValidateData(atrac);
744
if (err != 0) {
745
// Already logged.
746
return err;
747
}
748
if (Memory::IsValidAddress(outputChanPtr)) {
749
Memory::WriteUnchecked_U32(atrac->GetOutputChannels(), outputChanPtr);
750
return hleLogSuccessI(Log::ME, 0);
751
} else {
752
return hleLogError(Log::ME, 0, "invalid address");
753
}
754
}
755
756
static int sceAtracIsSecondBufferNeeded(int atracID) {
757
AtracBase *atrac = getAtrac(atracID);
758
u32 err = AtracValidateManaged(atrac);
759
if (err != 0) {
760
// Already logged.
761
return err;
762
}
763
764
// Note that this returns true whether the buffer is already set or not.
765
int needed = atrac->BufferState() == ATRAC_STATUS_STREAMED_LOOP_WITH_TRAILER ? 1 : 0;
766
return hleLogSuccessI(Log::ME, needed);
767
}
768
769
static int sceAtracSetMOutHalfwayBuffer(int atracID, u32 buffer, u32 readSize, u32 bufferSize) {
770
AtracBase *atrac = getAtrac(atracID);
771
// Don't use AtracValidate* here.
772
if (!atrac) {
773
return hleLogError(Log::ME, ATRAC_ERROR_BAD_ATRACID, "bad atrac ID");
774
}
775
if (readSize > bufferSize) {
776
return hleLogError(Log::ME, ATRAC_ERROR_INCORRECT_READ_SIZE, "read size too large");
777
}
778
779
int ret = atrac->Analyze(buffer, readSize);
780
if (ret < 0) {
781
// Already logged.
782
return ret;
783
}
784
if (atrac->GetTrack().channels != 1) {
785
// It seems it still sets the data.
786
atrac->SetData(buffer, readSize, bufferSize, 2, 0);
787
return hleReportError(Log::ME, ATRAC_ERROR_NOT_MONO, "not mono data");
788
} else {
789
return _AtracSetData(atracID, buffer, readSize, bufferSize, 1, false);
790
}
791
}
792
793
// Note: This doesn't seem to be part of any available libatrac3plus library.
794
static u32 sceAtracSetMOutData(int atracID, u32 buffer, u32 bufferSize) {
795
AtracBase *atrac = getAtrac(atracID);
796
// Don't use AtracValidate* here.
797
if (!atrac) {
798
return hleLogError(Log::ME, ATRAC_ERROR_BAD_ATRACID, "bad atrac ID");
799
}
800
801
int ret = atrac->Analyze(buffer, bufferSize);
802
if (ret < 0) {
803
// Already logged.
804
return ret;
805
}
806
if (atrac->GetTrack().channels != 1) {
807
// It seems it still sets the data.
808
atrac->SetData(buffer, bufferSize, bufferSize, 2, 0);
809
return hleReportError(Log::ME, ATRAC_ERROR_NOT_MONO, "not mono data");
810
} else {
811
return _AtracSetData(atracID, buffer, bufferSize, bufferSize, 1, false);
812
}
813
}
814
815
// Note: This doesn't seem to be part of any available libatrac3plus library.
816
static int sceAtracSetMOutDataAndGetID(u32 buffer, u32 bufferSize) {
817
AtracBase *atrac = allocAtrac();
818
int ret = atrac->Analyze(buffer, bufferSize);
819
if (ret < 0) {
820
// Already logged.
821
delete atrac;
822
return ret;
823
}
824
if (atrac->GetTrack().channels != 1) {
825
delete atrac;
826
return hleReportError(Log::ME, ATRAC_ERROR_NOT_MONO, "not mono data");
827
}
828
int atracID = createAtrac(atrac);
829
if (atracID < 0) {
830
delete atrac;
831
return hleLogError(Log::ME, atracID, "no free ID");
832
}
833
834
return _AtracSetData(atracID, buffer, bufferSize, bufferSize, 1, true);
835
}
836
837
static int sceAtracSetMOutHalfwayBufferAndGetID(u32 buffer, u32 readSize, u32 bufferSize) {
838
if (readSize > bufferSize) {
839
return hleLogError(Log::ME, ATRAC_ERROR_INCORRECT_READ_SIZE, "read size too large");
840
}
841
AtracBase *atrac = allocAtrac();
842
int ret = atrac->Analyze(buffer, readSize);
843
if (ret < 0) {
844
// Already logged.
845
delete atrac;
846
return ret;
847
}
848
if (atrac->GetTrack().channels != 1) {
849
delete atrac;
850
return hleReportError(Log::ME, ATRAC_ERROR_NOT_MONO, "not mono data");
851
}
852
int atracID = createAtrac(atrac);
853
if (atracID < 0) {
854
delete atrac;
855
return hleLogError(Log::ME, atracID, "no free ID");
856
}
857
858
return _AtracSetData(atracID, buffer, readSize, bufferSize, 1, true);
859
}
860
861
static int sceAtracSetAA3DataAndGetID(u32 buffer, u32 bufferSize, u32 fileSize, u32 metadataSizeAddr) {
862
AtracBase *atrac = allocAtrac();
863
int ret = atrac->AnalyzeAA3(buffer, bufferSize, fileSize);
864
if (ret < 0) {
865
// Already logged.
866
delete atrac;
867
return ret;
868
}
869
int atracID = createAtrac(atrac);
870
if (atracID < 0) {
871
delete atrac;
872
return hleLogError(Log::ME, atracID, "no free ID");
873
}
874
875
return _AtracSetData(atracID, buffer, bufferSize, bufferSize, 2, true);
876
}
877
878
static u32 _sceAtracGetContextAddress(int atracID) {
879
AtracBase *atrac = getAtrac(atracID);
880
if (!atrac) {
881
ERROR_LOG(Log::ME, "_sceAtracGetContextAddress(%i): bad atrac id", atracID);
882
return 0;
883
}
884
if (!atrac->context_.IsValid()) {
885
// allocate a new context_
886
u32 contextSize = sizeof(SceAtracContext);
887
// Note that Alloc can increase contextSize to the "grain" size.
888
atrac->context_ = kernelMemory.Alloc(contextSize, false, StringFromFormat("AtracCtx/%d", atracID).c_str());
889
if (atrac->context_.IsValid())
890
Memory::Memset(atrac->context_.ptr, 0, contextSize, "AtracContextClear");
891
WARN_LOG(Log::ME, "%08x=_sceAtracGetContextAddress(%i): allocated new context", atrac->context_.ptr, atracID);
892
}
893
else
894
WARN_LOG(Log::ME, "%08x=_sceAtracGetContextAddress(%i)", atrac->context_.ptr, atracID);
895
atrac->WriteContextToPSPMem();
896
return atrac->context_.ptr;
897
}
898
899
struct At3HeaderMap {
900
u16 bytes;
901
u16 channels;
902
u8 jointStereo;
903
904
bool Matches(const AtracBase *at) const {
905
return bytes == at->GetTrack().BytesPerFrame() && channels == at->GetTrack().channels;
906
}
907
};
908
909
// These should represent all possible supported bitrates (66, 104, and 132 for stereo.)
910
static const At3HeaderMap at3HeaderMap[] = {
911
{ 0x00C0, 1, 0 }, // 132/2 (66) kbps mono
912
{ 0x0098, 1, 0 }, // 105/2 (52.5) kbps mono
913
{ 0x0180, 2, 0 }, // 132 kbps stereo
914
{ 0x0130, 2, 0 }, // 105 kbps stereo
915
// At this size, stereo can only use joint stereo.
916
{ 0x00C0, 2, 1 }, // 66 kbps stereo
917
};
918
919
static int sceAtracLowLevelInitDecoder(int atracID, u32 paramsAddr) {
920
AtracBase *atrac = getAtrac(atracID);
921
if (!atrac) {
922
return hleLogError(Log::ME, ATRAC_ERROR_BAD_ATRACID, "bad atrac ID");
923
}
924
925
if (!Memory::IsValidAddress(paramsAddr)) {
926
// TODO: Returning zero as code was before. Needs testing.
927
return hleReportError(Log::ME, 0, "invalid pointers");
928
}
929
930
bool jointStereo = false;
931
if (atrac->GetTrack().codecType == PSP_MODE_AT_3) {
932
// See if we can match the actual jointStereo value.
933
bool found = false;
934
for (size_t i = 0; i < ARRAY_SIZE(at3HeaderMap); ++i) {
935
if (at3HeaderMap[i].Matches(atrac)) {
936
jointStereo = at3HeaderMap[i].jointStereo;
937
found = true;
938
}
939
}
940
if (!found) {
941
ERROR_LOG_REPORT(Log::ME, "AT3 header map lacks entry for bpf: %i channels: %i", atrac->GetTrack().BytesPerFrame(), atrac->GetTrack().channels);
942
// TODO: Should we return an error code for these values?
943
}
944
}
945
946
atrac->InitLowLevel(paramsAddr, jointStereo);
947
948
const char *codecName = atrac->GetTrack().codecType == PSP_MODE_AT_3 ? "atrac3" : "atrac3+";
949
const char *channelName = atrac->GetTrack().channels == 1 ? "mono" : "stereo";
950
return hleLogSuccessInfoI(Log::ME, 0, "%s %s audio", codecName, channelName);
951
}
952
953
static int sceAtracLowLevelDecode(int atracID, u32 sourceAddr, u32 sourceBytesConsumedAddr, u32 samplesAddr, u32 sampleBytesAddr) {
954
auto srcp = PSPPointer<u8>::Create(sourceAddr);
955
auto srcConsumed = PSPPointer<u32_le>::Create(sourceBytesConsumedAddr);
956
auto outp = PSPPointer<s16>::Create(samplesAddr);
957
auto outWritten = PSPPointer<u32_le>::Create(sampleBytesAddr);
958
959
AtracBase *atrac = getAtrac(atracID);
960
if (!atrac) {
961
return hleLogError(Log::ME, ATRAC_ERROR_BAD_ATRACID, "bad atrac ID");
962
}
963
964
if (!srcp.IsValid() || !srcConsumed.IsValid() || !outp.IsValid() || !outWritten.IsValid()) {
965
// TODO: Returning zero as code was before. Needs testing.
966
return hleReportError(Log::ME, 0, "invalid pointers");
967
}
968
969
int bytesConsumed = 0;
970
int outSamples = 0;
971
int channels = atrac->GetOutputChannels();
972
atrac->Decoder()->Decode(srcp, atrac->GetTrack().BytesPerFrame(), &bytesConsumed, channels, outp, &outSamples);
973
int bytesWritten = outSamples * channels * sizeof(int16_t);
974
*srcConsumed = bytesConsumed;
975
*outWritten = bytesWritten;
976
977
NotifyMemInfo(MemBlockFlags::WRITE, samplesAddr, bytesWritten, "AtracLowLevelDecode");
978
return hleLogDebug(Log::ME, hleDelayResult(0, "low level atrac decode data", atracDecodeDelay));
979
}
980
981
static int sceAtracSetAA3HalfwayBufferAndGetID(u32 buffer, u32 readSize, u32 bufferSize, u32 fileSize) {
982
if (readSize > bufferSize) {
983
return hleLogError(Log::ME, ATRAC_ERROR_INCORRECT_READ_SIZE, "read size too large");
984
}
985
986
AtracBase *atrac = allocAtrac();
987
int ret = atrac->AnalyzeAA3(buffer, readSize, fileSize);
988
if (ret < 0) {
989
// Already logged.
990
delete atrac;
991
return ret;
992
}
993
int atracID = createAtrac(atrac);
994
if (atracID < 0) {
995
delete atrac;
996
return hleLogError(Log::ME, atracID, "no free ID");
997
}
998
999
return _AtracSetData(atracID, buffer, readSize, bufferSize, 2, true);
1000
}
1001
1002
// External interface used by sceSas' AT3 integration.
1003
1004
u32 AtracSasAddStreamData(int atracID, u32 bufPtr, u32 bytesToAdd) {
1005
AtracBase *atrac = getAtrac(atracID);
1006
if (!atrac)
1007
return 0;
1008
return atrac->AddStreamDataSas(bufPtr, bytesToAdd);
1009
}
1010
1011
u32 AtracSasDecodeData(int atracID, u8* outbuf, u32 outbufPtr, u32 *SamplesNum, u32* finish, int *remains) {
1012
AtracBase *atrac = getAtrac(atracID);
1013
if (!atrac)
1014
return 0;
1015
return atrac->DecodeData(outbuf, outbufPtr, SamplesNum, finish, remains);
1016
}
1017
1018
int AtracSasGetIDByContext(u32 contextAddr) {
1019
int atracID = (int)Memory::Read_U32(contextAddr + 0xfc);
1020
// Restored old hack here that forces outputChannels_ to 1, since sceSas expects mono output, unlike normal usage.
1021
// This is for savestate compatibility.
1022
// I think it would be better to simply pass in a 1 as a parameter to atrac->DecodeData in AtracSasDecodeData above.
1023
AtracBase *atrac = getAtrac(atracID);
1024
atrac->SetOutputChannels(1);
1025
return atracID;
1026
}
1027
1028
const HLEFunction sceAtrac3plus[] = {
1029
{0X7DB31251, &WrapU_IU<sceAtracAddStreamData>, "sceAtracAddStreamData", 'x', "ix" },
1030
{0X6A8C3CD5, &WrapU_IUUUU<sceAtracDecodeData>, "sceAtracDecodeData", 'x', "ixppp"},
1031
{0XD5C28CC0, &WrapU_V<sceAtracEndEntry>, "sceAtracEndEntry", 'x', "" },
1032
{0X780F88D1, &WrapU_I<sceAtracGetAtracID>, "sceAtracGetAtracID", 'i', "x" },
1033
{0XCA3CA3D2, &WrapU_IIU<sceAtracGetBufferInfoForResetting>, "sceAtracGetBufferInfoForReseting", 'x', "iix" },
1034
{0XA554A158, &WrapU_IU<sceAtracGetBitrate>, "sceAtracGetBitrate", 'x', "ip" },
1035
{0X31668BAA, &WrapU_IU<sceAtracGetChannel>, "sceAtracGetChannel", 'x', "ip" },
1036
{0XFAA4F89B, &WrapU_IUU<sceAtracGetLoopStatus>, "sceAtracGetLoopStatus", 'x', "ipp" },
1037
{0XE88F759B, &WrapU_IU<sceAtracGetInternalErrorInfo>, "sceAtracGetInternalErrorInfo", 'x', "ip" },
1038
{0XD6A5F2F7, &WrapU_IU<sceAtracGetMaxSample>, "sceAtracGetMaxSample", 'x', "ip" },
1039
{0XE23E3A35, &WrapU_IU<sceAtracGetNextDecodePosition>, "sceAtracGetNextDecodePosition", 'x', "ip" },
1040
{0X36FAABFB, &WrapU_IU<sceAtracGetNextSample>, "sceAtracGetNextSample", 'x', "ip" },
1041
{0X9AE849A7, &WrapU_IU<sceAtracGetRemainFrame>, "sceAtracGetRemainFrame", 'x', "ip" },
1042
{0X83E85EA0, &WrapU_IUU<sceAtracGetSecondBufferInfo>, "sceAtracGetSecondBufferInfo", 'x', "ipp" },
1043
{0XA2BBA8BE, &WrapU_IUUU<sceAtracGetSoundSample>, "sceAtracGetSoundSample", 'x', "ippp" },
1044
{0X5D268707, &WrapU_IUUU<sceAtracGetStreamDataInfo>, "sceAtracGetStreamDataInfo", 'x', "ippp" },
1045
{0X61EB33F5, &WrapU_I<sceAtracReleaseAtracID>, "sceAtracReleaseAtracID", 'x', "i" },
1046
{0X644E5607, &WrapU_IIII<sceAtracResetPlayPosition>, "sceAtracResetPlayPosition", 'x', "iiii" },
1047
{0X3F6E26B5, &WrapU_IUUU<sceAtracSetHalfwayBuffer>, "sceAtracSetHalfwayBuffer", 'x', "ixxx" },
1048
{0X83BF7AFD, &WrapU_IUU<sceAtracSetSecondBuffer>, "sceAtracSetSecondBuffer", 'x', "ixx" },
1049
{0X0E2A73AB, &WrapU_IUU<sceAtracSetData>, "sceAtracSetData", 'x', "ixx" },
1050
{0X7A20E7AF, &WrapI_UI<sceAtracSetDataAndGetID>, "sceAtracSetDataAndGetID", 'i', "xx" },
1051
{0XD1F59FDB, &WrapU_V<sceAtracStartEntry>, "sceAtracStartEntry", 'x', "" },
1052
{0X868120B5, &WrapU_II<sceAtracSetLoopNum>, "sceAtracSetLoopNum", 'x', "ii" },
1053
{0X132F1ECA, &WrapI_II<sceAtracReinit>, "sceAtracReinit", 'x', "ii" },
1054
{0XECA32A99, &WrapI_I<sceAtracIsSecondBufferNeeded>, "sceAtracIsSecondBufferNeeded", 'i', "i" },
1055
{0X0FAE370E, &WrapI_UUU<sceAtracSetHalfwayBufferAndGetID>, "sceAtracSetHalfwayBufferAndGetID", 'i', "xxx" },
1056
{0X2DD3E298, &WrapU_IIU<sceAtracGetBufferInfoForResetting>, "sceAtracGetBufferInfoForResetting", 'x', "iix" },
1057
{0X5CF9D852, &WrapI_IUUU<sceAtracSetMOutHalfwayBuffer>, "sceAtracSetMOutHalfwayBuffer", 'x', "ixxx" },
1058
{0XF6837A1A, &WrapU_IUU<sceAtracSetMOutData>, "sceAtracSetMOutData", 'x', "ixx" },
1059
{0X472E3825, &WrapI_UU<sceAtracSetMOutDataAndGetID>, "sceAtracSetMOutDataAndGetID", 'i', "xx" },
1060
{0X9CD7DE03, &WrapI_UUU<sceAtracSetMOutHalfwayBufferAndGetID>, "sceAtracSetMOutHalfwayBufferAndGetID", 'i', "xxx" },
1061
{0XB3B5D042, &WrapI_IU<sceAtracGetOutputChannel>, "sceAtracGetOutputChannel", 'x', "ip" },
1062
{0X5622B7C1, &WrapI_UUUU<sceAtracSetAA3DataAndGetID>, "sceAtracSetAA3DataAndGetID", 'i', "xxxp" },
1063
{0X5DD66588, &WrapI_UUUU<sceAtracSetAA3HalfwayBufferAndGetID>, "sceAtracSetAA3HalfwayBufferAndGetID", 'i', "xxxx" },
1064
{0X231FC6B7, &WrapU_I<_sceAtracGetContextAddress>, "_sceAtracGetContextAddress", 'x', "i" },
1065
{0X1575D64B, &WrapI_IU<sceAtracLowLevelInitDecoder>, "sceAtracLowLevelInitDecoder", 'x', "ix" },
1066
{0X0C116E1B, &WrapI_IUUUU<sceAtracLowLevelDecode>, "sceAtracLowLevelDecode", 'x', "ixpxp"},
1067
};
1068
1069
void Register_sceAtrac3plus() {
1070
// Two names
1071
RegisterModule("sceATRAC3plus_Library", ARRAY_SIZE(sceAtrac3plus), sceAtrac3plus);
1072
RegisterModule("sceAtrac3plus", ARRAY_SIZE(sceAtrac3plus), sceAtrac3plus);
1073
}
1074
1075