From 923c19356bd1afce9b64f120b9ea71c009e0bbc5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Dec 2019 20:43:59 +0100 Subject: [PATCH] (ffmpeg) - Fix CXX_BUILD errors - see https://github.com/ZoneMinder/zoneminder/blob/master/src/zm_ffmpeg.h (comment on av_err2str) --- cores/libretro-ffmpeg/ffmpeg_core.c | 44 +++++++++++++++++++++++++++-- record/drivers/record_ffmpeg.c | 28 +++++++++++++++--- retroarch.c | 12 ++++---- 3 files changed, 71 insertions(+), 13 deletions(-) diff --git a/cores/libretro-ffmpeg/ffmpeg_core.c b/cores/libretro-ffmpeg/ffmpeg_core.c index 07b17cd309..330a51dc6d 100644 --- a/cores/libretro-ffmpeg/ffmpeg_core.c +++ b/cores/libretro-ffmpeg/ffmpeg_core.c @@ -895,7 +895,11 @@ exit: if ((ret = av_hwdevice_ctx_create(&hw_device_ctx, type, NULL, NULL, 0)) < 0) { +#ifdef __cplusplus + log_cb(RETRO_LOG_ERROR, "[FFMPEG] Failed to create specified HW device: %d\n", ret); +#else log_cb(RETRO_LOG_ERROR, "[FFMPEG] Failed to create specified HW device: %s\n", av_err2str(ret)); +#endif decoder_pix_fmt = AV_PIX_FMT_NONE; } else @@ -1009,7 +1013,11 @@ static bool open_codec(AVCodecContext **ctx, enum AVMediaType type, unsigned ind if ((ret = avcodec_open2(*ctx, codec, NULL)) < 0) { +#ifdef __cplusplus + log_cb(RETRO_LOG_ERROR, "[FFMPEG] Could not open codec: %d\n", ret); +#else log_cb(RETRO_LOG_ERROR, "[FFMPEG] Could not open codec: %s\n", av_err2str(ret)); +#endif return false; } @@ -1291,7 +1299,7 @@ static void sws_worker_thread(void *arg) tmp_frame = ctx->source; ctx->sws = sws_getCachedContext(ctx->sws, - media.width, media.height, tmp_frame->format, + media.width, media.height, (enum AVPixelFormat)tmp_frame->format, media.width, media.height, PIX_FMT_RGB32, SWS_POINT, NULL, NULL, NULL); @@ -1303,7 +1311,11 @@ static void sws_worker_thread(void *arg) tmp_frame->linesize, 0, media.height, (uint8_t * const*)ctx->target->data, ctx->target->linesize)) < 0) { +#ifdef __cplusplus + log_cb(RETRO_LOG_ERROR, "[FFMPEG] Error while scaling image: %d\n", ret); +#else log_cb(RETRO_LOG_ERROR, "[FFMPEG] Error while scaling image: %s\n", av_err2str(ret)); +#endif } swsbuffer_finish_slot(swsbuffer, ctx); @@ -1388,7 +1400,11 @@ static void decode_video(AVCodecContext *ctx, AVPacket *pkt, size_t frame_size) if ((ret = avcodec_send_packet(ctx, pkt)) < 0) { +#ifdef __cplusplus + log_cb(RETRO_LOG_ERROR, "[FFMPEG] Can't decode video packet: %d\n", ret); +#else log_cb(RETRO_LOG_ERROR, "[FFMPEG] Can't decode video packet: %s\n", av_err2str(ret)); +#endif return; } @@ -1417,7 +1433,11 @@ static void decode_video(AVCodecContext *ctx, AVPacket *pkt, size_t frame_size) } else if (ret < 0) { +#ifdef __cplusplus + log_cb(RETRO_LOG_ERROR, "[FFMPEG] Error while reading video frame: %d\n", ret); +#else log_cb(RETRO_LOG_ERROR, "[FFMPEG] Error while reading video frame: %s\n", av_err2str(ret)); +#endif goto end; } @@ -1426,7 +1446,11 @@ static void decode_video(AVCodecContext *ctx, AVPacket *pkt, size_t frame_size) /* Copy data from VRAM to RAM */ if ((ret = av_hwframe_transfer_data(sws_ctx->hw_source, sws_ctx->source, 0)) < 0) { +#ifdef __cplusplus + log_cb(RETRO_LOG_ERROR, "[FFMPEG] Error transferring the data to system memory: %d\n", ret); +#else log_cb(RETRO_LOG_ERROR, "[FFMPEG] Error transferring the data to system memory: %s\n", av_err2str(ret)); +#endif goto end; } #endif @@ -1463,7 +1487,11 @@ static int16_t *decode_audio(AVCodecContext *ctx, AVPacket *pkt, if ((ret = avcodec_send_packet(ctx, pkt)) < 0) { +#ifdef __cplusplus + log_cb(RETRO_LOG_ERROR, "[FFMPEG] Can't decode audio packet: %d\n", ret); +#else log_cb(RETRO_LOG_ERROR, "[FFMPEG] Can't decode audio packet: %s\n", av_err2str(ret)); +#endif return buffer; } @@ -1471,12 +1499,14 @@ static int16_t *decode_audio(AVCodecContext *ctx, AVPacket *pkt, { ret = avcodec_receive_frame(ctx, frame); if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) - { break; - } else if (ret < 0) { +#ifdef __cplusplus + log_cb(RETRO_LOG_ERROR, "[FFMPEG] Error while reading audio frame: %d\n", ret); +#else log_cb(RETRO_LOG_ERROR, "[FFMPEG] Error while reading audio frame: %s\n", av_err2str(ret)); +#endif break; } @@ -1923,7 +1953,11 @@ bool CORE_PREFIX(retro_load_game)(const struct retro_game_info *info) if ((ret = avformat_open_input(&fctx, info->path, NULL, NULL)) < 0) { +#ifdef __cplusplus + log_cb(RETRO_LOG_ERROR, "[FFMPEG] Failed to open input: %d\n", ret); +#else log_cb(RETRO_LOG_ERROR, "[FFMPEG] Failed to open input: %s\n", av_err2str(ret)); +#endif goto error; } @@ -1931,7 +1965,11 @@ bool CORE_PREFIX(retro_load_game)(const struct retro_game_info *info) if ((ret = avformat_find_stream_info(fctx, NULL)) < 0) { +#ifdef __cplusplus + log_cb(RETRO_LOG_ERROR, "[FFMPEG] Failed to find stream info: %d\n", ret); +#else log_cb(RETRO_LOG_ERROR, "[FFMPEG] Failed to find stream info: %s\n", av_err2str(ret)); +#endif goto error; } diff --git a/record/drivers/record_ffmpeg.c b/record/drivers/record_ffmpeg.c index 5755a7e141..009efe9638 100644 --- a/record/drivers/record_ffmpeg.c +++ b/record/drivers/record_ffmpeg.c @@ -1202,7 +1202,11 @@ static bool encode_video(ffmpeg_t *handle, AVFrame *frame) ret = avcodec_send_frame(handle->video.codec, frame); if (ret < 0) { +#ifdef __cplusplus + RARCH_ERR("[FFmpeg]: Cannot send video frame. Error code: %d.\n", ret); +#else RARCH_ERR("[FFmpeg]: Cannot send video frame. Error code: %s.\n", av_err2str(ret)); +#endif return false; } @@ -1210,12 +1214,14 @@ static bool encode_video(ffmpeg_t *handle, AVFrame *frame) { ret = avcodec_receive_packet(handle->video.codec, &pkt); if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) - { break; - } else if (ret < 0) { +#ifdef __cplusplus + RARCH_ERR("[FFmpeg]: Cannot receive video packet. Error code: %d.\n", ret); +#else RARCH_ERR("[FFmpeg]: Cannot receive video packet. Error code: %s.\n", av_err2str(ret)); +#endif return false; } @@ -1231,7 +1237,11 @@ static bool encode_video(ffmpeg_t *handle, AVFrame *frame) ret = av_interleaved_write_frame(handle->muxer.ctx, &pkt); if (ret < 0) { +#ifdef __cplusplus + RARCH_ERR("[FFmpeg]: Cannot write video packet to output file. Error code: %d.\n", ret); +#else RARCH_ERR("[FFmpeg]: Cannot write video packet to output file. Error code: %s.\n", av_err2str(ret)); +#endif return false; } } @@ -1375,7 +1385,11 @@ static bool encode_audio(ffmpeg_t *handle, bool dry) if (ret < 0) { av_frame_free(&frame); +#ifdef __cplusplus + RARCH_ERR("[FFmpeg]: Cannot send audio frame. Return code: %d.\n", ret); +#else RARCH_ERR("[FFmpeg]: Cannot send audio frame. Return code: %s.\n", av_err2str(ret)); +#endif return false; } @@ -1383,13 +1397,15 @@ static bool encode_audio(ffmpeg_t *handle, bool dry) { ret = avcodec_receive_packet(handle->audio.codec, &pkt); if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) - { break; - } else if (ret < 0) { av_frame_free(&frame); +#ifdef __cplusplus + RARCH_ERR("[FFmpeg]: Cannot receive audio packet. Return code: %d.\n", ret); +#else RARCH_ERR("[FFmpeg]: Cannot receive audio packet. Return code: %s.\n", av_err2str(ret)); +#endif return false; } @@ -1407,7 +1423,11 @@ static bool encode_audio(ffmpeg_t *handle, bool dry) if (ret < 0) { av_frame_free(&frame); +#ifdef __cplusplus + RARCH_ERR("[FFmpeg]: Cannot write video packet to output file. Error code: %d.\n", ret); +#else RARCH_ERR("[FFmpeg]: Cannot write video packet to output file. Error code: %s.\n", av_err2str(ret)); +#endif return false; } } diff --git a/retroarch.c b/retroarch.c index a445dea26e..ac3f4ba1aa 100644 --- a/retroarch.c +++ b/retroarch.c @@ -29160,7 +29160,7 @@ static bool accessibility_speak_macos( #if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__) && !defined(EMSCRIPTEN) -static char *accessibility_win_language_code(const char* language) +static const char *accessibility_win_language_code(const char* language) { if (string_is_equal(language,"en")) return "Microsoft David Desktop"; @@ -29270,12 +29270,12 @@ static bool accessibility_speak_windows( const char* speak_text, const char* voice, int priority) { char cmd[1200]; - char* language = accessibility_win_language_code(voice); - bool res; + const char *language = accessibility_win_language_code(voice); + bool res = false; - settings_t *settings = configuration_settings; - char* speeds[10] = {"-10", "-7.5", "-5", "-2.5", "0", "2", "4", "6", "8", "10"}; - int speed = settings->uints.accessibility_narrator_speech_speed; + settings_t *settings = configuration_settings; + const char* speeds[10] = {"-10", "-7.5", "-5", "-2.5", "0", "2", "4", "6", "8", "10"}; + int speed = settings->uints.accessibility_narrator_speech_speed; if (speed < 1) speed = 1;