mirror of
https://github.com/libretro/RetroArch
synced 2025-04-02 16:20:39 +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"
|
#include "../audio_driver.h"
|
||||||
|
|
||||||
#define AUDIO_BUFFER 64 * 1024
|
#define AUDIO_BUFFER 128 * 1024
|
||||||
#define AUDIO_CHANNELS 2
|
#define AUDIO_CHANNELS 2
|
||||||
#define AUDIO_BITS 16
|
#define AUDIO_BITS 16
|
||||||
|
|
||||||
typedef struct ps2_audio
|
typedef struct ps2_audio
|
||||||
{
|
{
|
||||||
fifo_buffer_t* buffer;
|
|
||||||
bool nonblocking;
|
bool nonblocking;
|
||||||
bool running;
|
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)
|
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;
|
ps2_audio_t* ps2 = (ps2_audio_t*)data;
|
||||||
|
|
||||||
if (!ps2->running)
|
if (!ps2->running)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (ps2->nonblocking)
|
bytes_sent = audsrv_play_audio(buf, size);
|
||||||
{
|
|
||||||
if (fifo_write_avail(ps2->buffer) < size)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
audsrv_wait_audio(size);
|
return bytes_sent;
|
||||||
audsrv_play_audio(buf, size);
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ps2_audio_alive(void *data)
|
static bool ps2_audio_alive(void *data)
|
||||||
|
@ -248,6 +248,7 @@ static void frontend_ps2_deinit(void *data)
|
|||||||
padEnd();
|
padEnd();
|
||||||
audsrv_quit();
|
audsrv_quit();
|
||||||
fileXioExit();
|
fileXioExit();
|
||||||
|
Exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void frontend_ps2_exec(const char *path, bool should_load_game)
|
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, \
|
0x80888888, 0x80999999, 0x80AAAAAA, 0x80BBBBBB, \
|
||||||
0x80CCCCCC, 0x80DDDDDD, 0x80EEEEEE, 0x80FFFFFF };
|
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)
|
static void ps2_prepare_font(GSGLOBAL *gsGlobal, GSFONTM *gsFontM)
|
||||||
{
|
{
|
||||||
if(gsKit_fontm_unpack(gsFontM) == 0) {
|
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)
|
static void ps2_font_free_font(void *data, bool is_threaded)
|
||||||
{
|
{
|
||||||
ps2_font_info_t *ps2 = (ps2_font_info_t *)data;
|
ps2_font_info_t *ps2 = (ps2_font_info_t *)data;
|
||||||
free(ps2->gsFontM);
|
deinit_gsfont(ps2->gsFontM);
|
||||||
free(ps2);
|
ps2->ps2_video = NULL;
|
||||||
|
ps2 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ps2_font_render_msg(
|
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
|
#elif defined(__CELLOS_LV2__) || defined(_MSC_VER) && _MSC_VER <= 1310
|
||||||
return fseek(stream->fp, (long)offset, whence);
|
return fseek(stream->fp, (long)offset, whence);
|
||||||
#elif defined(PS2)
|
#elif defined(PS2)
|
||||||
int64_t ret = fioLseek(fileno(stream->fp), (off_t)offset, whence);
|
int64_t ret = fileXioLseek(fileno(stream->fp), (off_t)offset, whence);
|
||||||
/* fioLseek could return positive numbers */
|
/* fileXioLseek could return positive numbers */
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ bool waitUntilDeviceIsReady(enum BootDeviceIDs device_id)
|
|||||||
|
|
||||||
while(openFile < 0 && retries > 0)
|
while(openFile < 0 && retries > 0)
|
||||||
{
|
{
|
||||||
openFile = fioDopen(rootDevice);
|
openFile = fileXioDopen(rootDevice);
|
||||||
/* Wait untill the device is ready */
|
/* Wait untill the device is ready */
|
||||||
nopdelay();
|
nopdelay();
|
||||||
nopdelay();
|
nopdelay();
|
||||||
@ -172,7 +172,7 @@ bool waitUntilDeviceIsReady(enum BootDeviceIDs device_id)
|
|||||||
retries--;
|
retries--;
|
||||||
};
|
};
|
||||||
|
|
||||||
fioDclose(openFile);
|
fileXioDclose(openFile);
|
||||||
|
|
||||||
return openFile >= 0;
|
return openFile >= 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user