diff --git a/Makefile b/Makefile index 4b1695d..5761895 100644 --- a/Makefile +++ b/Makefile @@ -112,15 +112,13 @@ else endif OBJECTS := mpv-libretro.o -LDFLAGS += -lmpv -CFLAGS += -Wall -pedantic -std=c99 +LDFLAGS += -lmpv -lm +CFLAGS += -Wall -pedantic -std=c99 -I. ifneq (,$(findstring gles,$(platform))) -LDFLAGS += -ldl + LDFLAGS += -ldl endif -LDFLAGS += -lm - all: $(TARGET) $(TARGET): $(OBJECTS) diff --git a/mpv-libretro.c b/mpv-libretro.c index 3f95acc..9ee8838 100644 --- a/mpv-libretro.c +++ b/mpv-libretro.c @@ -14,13 +14,16 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + +/* Required for nanosleep */ +#define _POSIX_C_SOURCE 199309L #include #include #include #include #include -#include +#include #ifdef HAVE_OPENGLES #include @@ -336,7 +339,8 @@ static void context_reset(void) "playback-time", MPV_FORMAT_INT64, &playback_time) < 0) { /* Garbage fix to overflowing log */ - usleep(10); + static struct timespec ts = { 0, 10 * 1000 }; + nanosleep(&ts, NULL); } /* TODO #2: Check for the highest samplerate in audio stream, and use that. @@ -610,7 +614,13 @@ bool retro_load_game(const struct retro_game_info *info) /* Copy the file path to a global variable as we need it in context_reset() * where mpv is initialised. */ - filepath = strdup(info->path); + if((filepath = malloc(strlen(info->path)+1)) == NULL) + { + log_cb(RETRO_LOG_ERROR, "Unable to allocate memory for filepath\n"); + return false; + } + + strcpy(filepath,info->path); environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc);