diff --git a/camera/drivers/video4linux2.c b/camera/drivers/video4linux2.c index e6633558f8..40e4b6bbce 100644 --- a/camera/drivers/video4linux2.c +++ b/camera/drivers/video4linux2.c @@ -300,6 +300,7 @@ static void *v4l_init(const char *device, uint64_t caps, unsigned width, unsigned height) { struct stat st; + video4linux_t *v4l = NULL; if ((caps & (1ULL << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER)) == 0) { @@ -307,7 +308,7 @@ static void *v4l_init(const char *device, uint64_t caps, return NULL; } - video4linux_t *v4l = (video4linux_t*)calloc(1, sizeof(video4linux_t)); + v4l = (video4linux_t*)calloc(1, sizeof(video4linux_t)); if (!v4l) return NULL; diff --git a/cores/ffmpeg_core.c b/cores/ffmpeg_core.c index 310c604113..ce83b293b6 100644 --- a/cores/ffmpeg_core.c +++ b/cores/ffmpeg_core.c @@ -312,6 +312,8 @@ void CORE_PREFIX(retro_reset)(void) static void check_variables(void) { + struct retro_variable color_var; + #ifdef HAVE_OPENGL struct retro_variable var = { .key = "ffmpeg_temporal_interp" @@ -352,9 +354,7 @@ static void check_variables(void) fft_multisample = strtoul(fft_ms_var.value, NULL, 0); #endif - struct retro_variable color_var = { - .key = "ffmpeg_color_space", - }; + color_var.key = "ffmpeg_color_space"; if (CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &color_var) && color_var.value) { diff --git a/gfx/drivers_context/drm_egl_ctx.c b/gfx/drivers_context/drm_egl_ctx.c index c7f3309ce6..786042231b 100644 --- a/gfx/drivers_context/drm_egl_ctx.c +++ b/gfx/drivers_context/drm_egl_ctx.c @@ -750,12 +750,14 @@ static bool gfx_ctx_drm_egl_set_video_mode(void *data, /* Find best match. */ for (i = 0; i < drm->g_connector->count_modes; i++) { + float diff; if (width != drm->g_connector->modes[i].hdisplay || height != drm->g_connector->modes[i].vdisplay) continue; - float diff = fabsf(refresh_mod * - drm->g_connector->modes[i].vrefresh - settings->video.refresh_rate); + diff = fabsf(refresh_mod * drm->g_connector->modes[i].vrefresh + - settings->video.refresh_rate); + if (!drm->g_drm_mode || diff < minimum_fps_diff) { drm->g_drm_mode = &drm->g_connector->modes[i]; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index bf75c85049..69ec8c14da 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -565,14 +565,13 @@ end: static void xmb_update_boxart(xmb_handle_t *xmb, unsigned i) { - settings_t *settings = config_get_ptr(); - + menu_entry_t entry; + char path[PATH_MAX_LENGTH] = {0}; + settings_t *settings = config_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); - menu_entry_t entry; menu_entry_get(&entry, i, menu_list->selection_buf, true); - char path[PATH_MAX_LENGTH] = {0}; fill_pathname_join(path, settings->boxarts_directory, entry.path, sizeof(path)); strlcat(path, ".png", sizeof(path)); diff --git a/record/drivers/record_ffmpeg.c b/record/drivers/record_ffmpeg.c index 585d788468..8bad2f4767 100644 --- a/record/drivers/record_ffmpeg.c +++ b/record/drivers/record_ffmpeg.c @@ -357,6 +357,7 @@ static bool ffmpeg_init_audio(ffmpeg_t *handle) static bool ffmpeg_init_video(ffmpeg_t *handle) { + size_t size; struct ff_config_param *params = &handle->config; struct ff_video_info *video = &handle->video; struct ffemu_params *param = &handle->params; @@ -478,7 +479,7 @@ static bool ffmpeg_init_video(ffmpeg_t *handle) video->frame_drop_ratio = params->frame_drop_ratio; - size_t size = avpicture_get_size(video->pix_fmt, param->out_width, + size = avpicture_get_size(video->pix_fmt, param->out_width, param->out_height); video->conv_frame_buf = (uint8_t*)av_malloc(size); video->conv_frame = av_frame_alloc(); @@ -491,6 +492,7 @@ static bool ffmpeg_init_video(ffmpeg_t *handle) static bool ffmpeg_init_config(struct ff_config_param *params, const char *config) { + struct config_file_entry entry; char pix_fmt[64] = {0}; params->out_pix_fmt = PIX_FMT_NONE; @@ -544,7 +546,6 @@ static bool ffmpeg_init_config(struct ff_config_param *params, } } - struct config_file_entry entry; if (!config_get_entry_list_head(params->conf, &entry)) return true; @@ -774,6 +775,7 @@ static bool ffmpeg_push_video(void *data, bool drop_frame; struct ffemu_video_data attr_data; ffmpeg_t *handle = (ffmpeg_t*)data; + int offset = 0; if (!handle || !video_data) return false; @@ -826,7 +828,6 @@ static bool ffmpeg_push_video(void *data, fifo_write(handle->attr_fifo, &attr_data, sizeof(attr_data)); - int offset = 0; for (y = 0; y < attr_data.height; y++, offset += video_data->pitch) fifo_write(handle->video_fifo, (const uint8_t*)video_data->data + offset, attr_data.pitch); @@ -928,13 +929,14 @@ static void ffmpeg_scale_input(ffmpeg_t *handle, if (handle->video.use_sws) { + int linesize = data->pitch; + handle->video.sws = sws_getCachedContext(handle->video.sws, data->width, data->height, handle->video.in_pix_fmt, handle->params.out_width, handle->params.out_height, handle->video.pix_fmt, shrunk ? SWS_BILINEAR : SWS_POINT, NULL, NULL, NULL); - int linesize = data->pitch; sws_scale(handle->video.sws, (const uint8_t* const*)&data->data, &linesize, 0, data->height, handle->video.conv_frame->data, handle->video.conv_frame->linesize); @@ -1039,6 +1041,7 @@ static bool encode_audio(ffmpeg_t *handle, AVPacket *pkt, bool dry) { AVFrame *frame; int samples_size; + int got_packet = 0; av_init_packet(pkt); pkt->data = handle->audio.outbuf; @@ -1066,7 +1069,6 @@ static bool encode_audio(ffmpeg_t *handle, AVPacket *pkt, bool dry) handle->audio.buffer, samples_size, 0); - int got_packet = 0; if (avcodec_encode_audio2(handle->audio.codec, pkt, dry ? NULL : frame, &got_packet) < 0) { @@ -1223,9 +1225,10 @@ static void ffmpeg_flush_audio(ffmpeg_t *handle, void *audio_buf, if (avail) { + struct ffemu_audio_data aud = {0}; + fifo_read(handle->audio_fifo, audio_buf, avail); - struct ffemu_audio_data aud = {0}; aud.frames = avail / (sizeof(int16_t) * handle->params.channels); aud.data = audio_buf; @@ -1277,9 +1280,10 @@ static void ffmpeg_flush_buffers(ffmpeg_t *handle) { if (fifo_read_avail(handle->audio_fifo) >= audio_buf_size) { + struct ffemu_audio_data aud = {0}; + fifo_read(handle->audio_fifo, audio_buf, audio_buf_size); - struct ffemu_audio_data aud = {0}; aud.frames = handle->audio.codec->frame_size; aud.data = audio_buf; @@ -1333,6 +1337,8 @@ static bool ffmpeg_finalize(void *data) static void ffmpeg_thread(void *data) { + size_t audio_buf_size; + void *audio_buf; ffmpeg_t *ff = (ffmpeg_t*)data; /* For some reason, FFmpeg has a tendency to crash @@ -1341,9 +1347,9 @@ static void ffmpeg_thread(void *data) ff->params.fb_height * ff->video.pix_size); assert(video_buf); - size_t audio_buf_size = ff->config.audio_enable ? + audio_buf_size = ff->config.audio_enable ? (ff->audio.codec->frame_size * ff->params.channels * sizeof(int16_t)) : 0; - void *audio_buf = audio_buf_size ? av_malloc(audio_buf_size) : NULL; + audio_buf = audio_buf_size ? av_malloc(audio_buf_size) : NULL; while (ff->alive) { @@ -1391,12 +1397,13 @@ static void ffmpeg_thread(void *data) if (avail_audio) { + struct ffemu_audio_data aud = {0}; + slock_lock(ff->lock); fifo_read(ff->audio_fifo, audio_buf, audio_buf_size); slock_unlock(ff->lock); scond_signal(ff->cond); - struct ffemu_audio_data aud = {0}; aud.frames = ff->audio.codec->frame_size; aud.data = audio_buf; diff --git a/tools/retroarch-joyconfig.c b/tools/retroarch-joyconfig.c index 177334805e..5d311a0db6 100644 --- a/tools/retroarch-joyconfig.c +++ b/tools/retroarch-joyconfig.c @@ -474,6 +474,7 @@ void input_config_autoconfigure_joypad(autoconfig_params_t *params) int main(int argc, char *argv[]) { config_file_t *conf; + config_file_t *auto_conf = NULL; const char *index_list[] = { "input_player1_joypad_index", @@ -497,7 +498,6 @@ int main(int argc, char *argv[]) config_set_int(conf, index_list[g_player - 1], g_joypad); - config_file_t *auto_conf = NULL; if (g_auto_path) auto_conf = config_file_new(NULL);