Split GetPointer into two versions, to help with const correctness

This commit is contained in:
Henrik Rydgård committed 2022-07-24 13:26:19 +02:00
1 parent d2a3918f5f
commit e6403d7157
43 files changed
+169 -156

No files matched your search

+3 -3
View File
@@ -805,7 +805,7 @@ int MediaEngine::writeVideoImage(u32 bufferPtr, int frameWidth, int videoPixelMo
return 0;
}
u8 *buffer = Memory::GetPointer(bufferPtr);
u8 *buffer = Memory::GetPointerWrite(bufferPtr);
#ifdef USE_FFMPEG
if (!m_pFrame || !m_pFrameRGB)
@@ -895,7 +895,7 @@ int MediaEngine::writeVideoImageWithRange(u32 bufferPtr, int frameWidth, int vid
return 0;
}
u8 *buffer = Memory::GetPointer(bufferPtr);
u8 *buffer = Memory::GetPointerWrite(bufferPtr);
#ifdef USE_FFMPEG
if (!m_pFrame || !m_pFrameRGB)
@@ -1032,7 +1032,7 @@ int MediaEngine::getAudioSamples(u32 bufferPtr) {
ERROR_LOG_REPORT(ME, "Ignoring bad audio decode address %08x during video playback", bufferPtr);
}
u8 *buffer = Memory::GetPointer(bufferPtr);
u8 *buffer = Memory::GetPointerWrite(bufferPtr);
if (!m_demux) {
return 0;
}
+4 -4
View File
@@ -64,13 +64,13 @@ void VagDecoder::Start(u32 data, u32 vagSize, bool loopEnabled) {
s_2 = 0;
}
void VagDecoder::DecodeBlock(u8 *&read_pointer) {
void VagDecoder::DecodeBlock(const u8 *&read_pointer) {
if (curBlock_ == numBlocks_ - 1) {
end_ = true;
return;
}
u8 *readp = read_pointer;
const u8 *readp = read_pointer;
int predict_nr = *readp++;
int shift_factor = predict_nr & 0xf;
predict_nr >>= 4;
@@ -124,8 +124,8 @@ void VagDecoder::GetSamples(s16 *outSamples, int numSamples) {
WARN_LOG(SASMIX, "Bad VAG samples address?");
return;
}
u8 *readp = Memory::GetPointerUnchecked(read_);
u8 *origp = readp;
const u8 *readp = Memory::GetPointerUnchecked(read_);
const u8 *origp = readp;
for (int i = 0; i < numSamples; i++) {
if (curSample == 28) {
+1 -1
View File
@@ -102,7 +102,7 @@ public:
void GetSamples(s16 *outSamples, int numSamples);
void DecodeBlock(u8 *&readp);
void DecodeBlock(const u8 *&readp);
bool End() const { return end_; }
void DoState(PointerWrap &p);
+3 -3
View File
@@ -177,7 +177,7 @@ bool SimpleAudio::IsOK() const {
#endif
}
bool SimpleAudio::Decode(void *inbuf, int inbytes, uint8_t *outbuf, int *outbytes) {
bool SimpleAudio::Decode(const uint8_t *inbuf, int inbytes, uint8_t *outbuf, int *outbytes) {
#ifdef USE_FFMPEG
if (!codecOpen_) {
OpenCodec(inbytes);
@@ -185,7 +185,7 @@ bool SimpleAudio::Decode(void *inbuf, int inbytes, uint8_t *outbuf, int *outbyte
AVPacket packet;
av_init_packet(&packet);
packet.data = static_cast<uint8_t *>(inbuf);
packet.data = (uint8_t *)(inbuf);
packet.size = inbytes;
int got_frame = 0;
@@ -338,7 +338,7 @@ size_t AuCtx::FindNextMp3Sync() {
// return output pcm size, <0 error
u32 AuCtx::AuDecode(u32 pcmAddr) {
u32 outptr = PCMBuf + nextOutputHalf * PCMBufSize / 2;
auto outbuf = Memory::GetPointer(outptr);
auto outbuf = Memory::GetPointerWrite(outptr);
int outpcmbufsize = 0;
if (pcmAddr)
+1 -1
View File
@@ -45,7 +45,7 @@ public:
SimpleAudio(int audioType, int sample_rate = 44100, int channels = 2);
~SimpleAudio();
bool Decode(void* inbuf, int inbytes, uint8_t *outbuf, int *outbytes);
bool Decode(const uint8_t* inbuf, int inbytes, uint8_t *outbuf, int *outbytes);
bool IsOK() const;
int GetOutSamples();