Unverified Commit bda7032a authored by Libretro-Admin's avatar Libretro-Admin Committed by GitHub
Browse files

Merge pull request #24 from jdgleaver/load-content-fix

Fix content loading
parents c587cfd9 d1cc63ba
Pipeline #56401 passed with stages
in 9 minutes and 46 seconds
...@@ -477,6 +477,10 @@ endif ...@@ -477,6 +477,10 @@ endif
CFLAGS += -Wall $(INCFLAGS) $(INCFLAGS_PLATFORM) CFLAGS += -Wall $(INCFLAGS) $(INCFLAGS_PLATFORM)
CXXFLAGS += -Wall $(INCFLAGS) $(INCFLAGS_PLATFORM) CXXFLAGS += -Wall $(INCFLAGS) $(INCFLAGS_PLATFORM)
ifeq ($(DEBUG),1)
CFLAGS += -O0 -g
endif
ifneq (,$(findstring msvc,$(platform))) ifneq (,$(findstring msvc,$(platform)))
ifeq ($(DEBUG),1) ifeq ($(DEBUG),1)
CFLAGS += -MTd CFLAGS += -MTd
......
...@@ -187,9 +187,11 @@ bool get_file_data(const char *path,file_data ***dest_files, int *dest_numfiles) ...@@ -187,9 +187,11 @@ bool get_file_data(const char *path,file_data ***dest_files, int *dest_numfiles)
else else
{ {
file_data *fd; file_data *fd;
fp = fopen(path,"rb");
if (!fp)
return false;
files = malloc(sizeof(file_data*)); files = malloc(sizeof(file_data*));
fd = malloc(sizeof(file_data)); fd = malloc(sizeof(file_data));
fp = fopen(path,"rb");
//get file length //get file length
fseek (fp,0,SEEK_END); fseek (fp,0,SEEK_END);
fd->length = ftell(fp); fd->length = ftell(fp);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "log.h" #include "log.h"
// Static globals // Static globals
static surface *framebuffer = NULL;; static surface *framebuffer = NULL;
static uint16_t previnput = 0; static uint16_t previnput = 0;
// Callbacks // Callbacks
...@@ -87,7 +87,7 @@ void retro_get_system_info(struct retro_system_info *info) ...@@ -87,7 +87,7 @@ void retro_get_system_info(struct retro_system_info *info)
memset(info, 0, sizeof(*info)); memset(info, 0, sizeof(*info));
info->library_name = "Game Music Emulator"; info->library_name = "Game Music Emulator";
info->library_version = "v0.6.1"; info->library_version = "v0.6.1";
info->need_fullpath = false; info->need_fullpath = true;
info->valid_extensions = "ay|gbs|gym|hes|kss|nsf|nsfe|sap|spc|vgm|vgz|zip"; info->valid_extensions = "ay|gbs|gym|hes|kss|nsf|nsfe|sap|spc|vgm|vgz|zip";
info->block_extract = true; info->block_extract = true;
} }
...@@ -123,7 +123,9 @@ void retro_init(void) ...@@ -123,7 +123,9 @@ void retro_init(void)
// End of retrolib // End of retrolib
void retro_deinit(void) void retro_deinit(void)
{ {
free(framebuffer); if (framebuffer)
free_surface(framebuffer);
framebuffer = NULL;
} }
// Reset gme // Reset gme
...@@ -171,8 +173,7 @@ bool retro_load_game(const struct retro_game_info *info) ...@@ -171,8 +173,7 @@ bool retro_load_game(const struct retro_game_info *info)
{ {
long sample_rate = 44100; long sample_rate = 44100;
// ensure there is ROM data if (!info)
if (!info || !info->data)
return false; return false;
if(open_file(info->path,sample_rate)) if(open_file(info->path,sample_rate))
......
...@@ -37,7 +37,8 @@ bool open_file(const char *path, long sample_rate) ...@@ -37,7 +37,8 @@ bool open_file(const char *path, long sample_rate)
void close_file(void) void close_file(void)
{ {
gme_delete( emu ); gme_delete(emu);
emu = NULL;
if(plist!=NULL) if(plist!=NULL)
cleanup_playlist(plist); cleanup_playlist(plist);
} }
......
...@@ -9,23 +9,19 @@ ...@@ -9,23 +9,19 @@
bool get_playlist(const char *path, playlist **dest_pl) bool get_playlist(const char *path, playlist **dest_pl)
{ {
//local variables //local variables
int i,j,position; int i,j;
Music_Emu *temp_emu; int position = 0;
gme_file_data *gfd; Music_Emu *temp_emu = NULL;
gme_file_data *gfd = NULL;
gme_err_t err_msg; gme_err_t err_msg;
playlist *pl; playlist *pl = NULL;
//init playlist //init playlist
pl = malloc(sizeof(playlist)); pl = (playlist *)calloc(1, sizeof(playlist));
pl->num_files = 0;
pl->files = NULL;
pl->num_tracks = 0;
pl->tracks = NULL;
//load libretro content file //load libretro content file
if(get_playlist_gme_files(path,&(pl->files),&(pl->num_files),&(pl->num_tracks))) if(get_playlist_gme_files(path,&(pl->files),&(pl->num_files),&(pl->num_tracks)))
{ {
pl->tracks = malloc(sizeof(gme_track_data*) * pl->num_tracks); pl->tracks = (gme_track_data **)calloc(pl->num_tracks, sizeof(gme_track_data*));
//read tracks //read tracks
position = 0;
for(i=0;i<pl->num_files;i++) for(i=0;i<pl->num_files;i++)
{ {
gfd = pl->files[i]; gfd = pl->files[i];
...@@ -42,13 +38,26 @@ bool get_playlist(const char *path, playlist **dest_pl) ...@@ -42,13 +38,26 @@ bool get_playlist(const char *path, playlist **dest_pl)
} }
} }
else else
return false; goto error;
gme_delete(temp_emu);
temp_emu = NULL;
} }
} }
else else
return false; goto error;
*dest_pl = pl; *dest_pl = pl;
return true; return true;
error:
if (temp_emu)
gme_delete(temp_emu);
if (pl)
cleanup_playlist(pl);
return false;
} }
bool get_playlist_gme_files(const char *path,gme_file_data ***dest_files,int *dest_num_files, int *dest_num_tracks) bool get_playlist_gme_files(const char *path,gme_file_data ***dest_files,int *dest_num_files, int *dest_num_tracks)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment