mirror of
https://github.com/libretro/RetroArch
synced 2025-04-15 23:42:30 +00:00
Create abstract interface for FFemu.
This commit is contained in:
parent
b7e1628963
commit
804626e20d
2
Makefile
2
Makefile
@ -327,7 +327,7 @@ ifeq ($(HAVE_ZLIB), 1)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HAVE_FFMPEG), 1)
|
ifeq ($(HAVE_FFMPEG), 1)
|
||||||
OBJ += record/ffemu.o
|
OBJ += record/ffemu.o record/ffmpeg.o
|
||||||
LIBS += $(AVCODEC_LIBS) $(AVFORMAT_LIBS) $(AVUTIL_LIBS) $(SWSCALE_LIBS)
|
LIBS += $(AVCODEC_LIBS) $(AVFORMAT_LIBS) $(AVUTIL_LIBS) $(SWSCALE_LIBS)
|
||||||
DEFINES += $(AVCODEC_CFLAGS) $(AVFORMAT_CFLAGS) $(AVUTIL_CFLAGS) $(SWSCALE_CFLAGS) -DHAVE_RECORD
|
DEFINES += $(AVCODEC_CFLAGS) $(AVFORMAT_CFLAGS) $(AVUTIL_CFLAGS) $(SWSCALE_CFLAGS) -DHAVE_RECORD
|
||||||
endif
|
endif
|
||||||
|
@ -589,7 +589,9 @@ struct global
|
|||||||
|
|
||||||
// FFmpeg record.
|
// FFmpeg record.
|
||||||
#ifdef HAVE_RECORD
|
#ifdef HAVE_RECORD
|
||||||
ffemu_t *rec;
|
const ffemu_backend_t *rec_driver;
|
||||||
|
void *rec;
|
||||||
|
|
||||||
char record_path[PATH_MAX];
|
char record_path[PATH_MAX];
|
||||||
char record_config[PATH_MAX];
|
char record_config[PATH_MAX];
|
||||||
bool recording;
|
bool recording;
|
||||||
|
1294
record/ffemu.c
1294
record/ffemu.c
File diff suppressed because it is too large
Load Diff
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include "../boolean.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -78,14 +79,20 @@ struct ffemu_audio_data
|
|||||||
size_t frames;
|
size_t frames;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct ffemu ffemu_t;
|
typedef struct ffemu_backend
|
||||||
|
{
|
||||||
|
void *(*init)(const struct ffemu_params *params);
|
||||||
|
void (*free)(void *data);
|
||||||
|
bool (*push_video)(void *data, const struct ffemu_video_data *video_data);
|
||||||
|
bool (*push_audio)(void *data, const struct ffemu_audio_data *audio_data);
|
||||||
|
bool (*finalize)(void *data);
|
||||||
|
const char *ident;
|
||||||
|
} ffemu_backend_t;
|
||||||
|
|
||||||
void *ffemu_new(const struct ffemu_params *params);
|
extern const ffemu_backend_t ffemu_ffmpeg;
|
||||||
void ffemu_free(void *data);
|
|
||||||
|
|
||||||
bool ffemu_push_video(void *data, const struct ffemu_video_data *video_data);
|
const ffemu_backend_t *ffemu_find_backend(const char *ident);
|
||||||
bool ffemu_push_audio(void *data, const struct ffemu_audio_data *audio_data);
|
bool ffemu_init_first(const ffemu_backend_t **backend, void **data, const struct ffemu_params *params);
|
||||||
bool ffemu_finalize(void *data);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
1323
record/ffmpeg.c
Normal file
1323
record/ffmpeg.c
Normal file
File diff suppressed because it is too large
Load Diff
15
retroarch.c
15
retroarch.c
@ -265,7 +265,7 @@ static void recording_dump_frame(const void *data, unsigned width, unsigned heig
|
|||||||
ffemu_data.is_dupe = !data;
|
ffemu_data.is_dupe = !data;
|
||||||
}
|
}
|
||||||
|
|
||||||
ffemu_push_video(g_extern.rec, &ffemu_data);
|
g_extern.rec_driver->push_video(g_extern.rec, &ffemu_data);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -369,7 +369,7 @@ static bool audio_flush(const int16_t *data, size_t samples)
|
|||||||
ffemu_data.data = data;
|
ffemu_data.data = data;
|
||||||
ffemu_data.frames = samples / 2;
|
ffemu_data.frames = samples / 2;
|
||||||
|
|
||||||
ffemu_push_audio(g_extern.rec, &ffemu_data);
|
g_extern.rec_driver->push_audio(g_extern.rec, &ffemu_data);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1392,8 +1392,7 @@ void rarch_init_recording(void)
|
|||||||
params.fb_width, params.fb_height,
|
params.fb_width, params.fb_height,
|
||||||
(unsigned)params.pix_fmt);
|
(unsigned)params.pix_fmt);
|
||||||
|
|
||||||
g_extern.rec = ffemu_new(¶ms);
|
if (!ffemu_init_first(&g_extern.rec_driver, &g_extern.rec, ¶ms))
|
||||||
if (!g_extern.rec)
|
|
||||||
{
|
{
|
||||||
RARCH_ERR("Failed to start FFmpeg recording.\n");
|
RARCH_ERR("Failed to start FFmpeg recording.\n");
|
||||||
g_extern.recording = false;
|
g_extern.recording = false;
|
||||||
@ -1405,12 +1404,14 @@ void rarch_init_recording(void)
|
|||||||
|
|
||||||
void rarch_deinit_recording(void)
|
void rarch_deinit_recording(void)
|
||||||
{
|
{
|
||||||
if (!g_extern.recording)
|
if (!g_extern.rec || !g_extern.rec_driver)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ffemu_finalize(g_extern.rec);
|
g_extern.rec_driver->finalize(g_extern.rec);
|
||||||
ffemu_free(g_extern.rec);
|
g_extern.rec_driver->free(g_extern.rec);
|
||||||
|
|
||||||
g_extern.rec = NULL;
|
g_extern.rec = NULL;
|
||||||
|
g_extern.rec_driver = NULL;
|
||||||
|
|
||||||
free(g_extern.record_gpu_buffer);
|
free(g_extern.record_gpu_buffer);
|
||||||
g_extern.record_gpu_buffer = NULL;
|
g_extern.record_gpu_buffer = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user