mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 04:20:27 +00:00
Merge pull request #8424 from fjtrujy/master
[PS2] Fixed some memory leaks
This commit is contained in:
commit
58eed3322b
@ -23,13 +23,12 @@
|
||||
|
||||
#include "../audio_driver.h"
|
||||
|
||||
#define AUDIO_BUFFER 64 * 1024
|
||||
#define AUDIO_BUFFER 128 * 1024
|
||||
#define AUDIO_CHANNELS 2
|
||||
#define AUDIO_BITS 16
|
||||
|
||||
typedef struct ps2_audio
|
||||
{
|
||||
fifo_buffer_t* buffer;
|
||||
bool nonblocking;
|
||||
bool running;
|
||||
|
||||
@ -82,21 +81,15 @@ static void ps2_audio_free(void *data)
|
||||
|
||||
static ssize_t ps2_audio_write(void *data, const void *buf, size_t size)
|
||||
{
|
||||
int bytes_sent;
|
||||
ps2_audio_t* ps2 = (ps2_audio_t*)data;
|
||||
|
||||
if (!ps2->running)
|
||||
return -1;
|
||||
|
||||
if (ps2->nonblocking)
|
||||
{
|
||||
if (fifo_write_avail(ps2->buffer) < size)
|
||||
return 0;
|
||||
}
|
||||
bytes_sent = audsrv_play_audio(buf, size);
|
||||
|
||||
audsrv_wait_audio(size);
|
||||
audsrv_play_audio(buf, size);
|
||||
|
||||
return size;
|
||||
return bytes_sent;
|
||||
}
|
||||
|
||||
static bool ps2_audio_alive(void *data)
|
||||
|
@ -248,6 +248,7 @@ static void frontend_ps2_deinit(void *data)
|
||||
padEnd();
|
||||
audsrv_quit();
|
||||
fileXioExit();
|
||||
Exit(0);
|
||||
}
|
||||
|
||||
static void frontend_ps2_exec(const char *path, bool should_load_game)
|
||||
|
@ -43,6 +43,22 @@ static u32 gsKit_fontm_clut[16] = { 0x00000000, 0x11111111, 0x22222222, 0x333333
|
||||
0x80888888, 0x80999999, 0x80AAAAAA, 0x80BBBBBB, \
|
||||
0x80CCCCCC, 0x80DDDDDD, 0x80EEEEEE, 0x80FFFFFF };
|
||||
|
||||
static void deinit_texture(GSTEXTURE *texture)
|
||||
{
|
||||
free(texture->Mem);
|
||||
free(texture->Clut);
|
||||
texture->Mem = NULL;
|
||||
texture->Clut = NULL;
|
||||
}
|
||||
|
||||
static void deinit_gsfont(GSFONTM *gsFontM)
|
||||
{
|
||||
deinit_texture(gsFontM->Texture);
|
||||
free(gsFontM->TexBase);
|
||||
gsFontM->TexBase = NULL;
|
||||
free(gsFontM);
|
||||
}
|
||||
|
||||
static void ps2_prepare_font(GSGLOBAL *gsGlobal, GSFONTM *gsFontM)
|
||||
{
|
||||
if(gsKit_fontm_unpack(gsFontM) == 0) {
|
||||
@ -94,8 +110,9 @@ static void *ps2_font_init_font(void *gl_data, const char *font_path,
|
||||
static void ps2_font_free_font(void *data, bool is_threaded)
|
||||
{
|
||||
ps2_font_info_t *ps2 = (ps2_font_info_t *)data;
|
||||
free(ps2->gsFontM);
|
||||
free(ps2);
|
||||
deinit_gsfont(ps2->gsFontM);
|
||||
ps2->ps2_video = NULL;
|
||||
ps2 = NULL;
|
||||
}
|
||||
|
||||
static void ps2_font_render_msg(
|
||||
|
@ -222,8 +222,8 @@ int64_t retro_vfs_file_seek_internal(libretro_vfs_implementation_file *stream, i
|
||||
#elif defined(__CELLOS_LV2__) || defined(_MSC_VER) && _MSC_VER <= 1310
|
||||
return fseek(stream->fp, (long)offset, whence);
|
||||
#elif defined(PS2)
|
||||
int64_t ret = fioLseek(fileno(stream->fp), (off_t)offset, whence);
|
||||
/* fioLseek could return positive numbers */
|
||||
int64_t ret = fileXioLseek(fileno(stream->fp), (off_t)offset, whence);
|
||||
/* fileXioLseek could return positive numbers */
|
||||
if (ret > 0) {
|
||||
ret = 0;
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ bool waitUntilDeviceIsReady(enum BootDeviceIDs device_id)
|
||||
|
||||
while(openFile < 0 && retries > 0)
|
||||
{
|
||||
openFile = fioDopen(rootDevice);
|
||||
openFile = fileXioDopen(rootDevice);
|
||||
/* Wait untill the device is ready */
|
||||
nopdelay();
|
||||
nopdelay();
|
||||
@ -172,7 +172,7 @@ bool waitUntilDeviceIsReady(enum BootDeviceIDs device_id)
|
||||
retries--;
|
||||
};
|
||||
|
||||
fioDclose(openFile);
|
||||
fileXioDclose(openFile);
|
||||
|
||||
return openFile >= 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user