Skip to content

Commit

Permalink
Some C89 build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Jun 29, 2015
1 parent 018c685 commit fefa500
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 21 deletions.
3 changes: 2 additions & 1 deletion camera/drivers/video4linux2.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,15 @@ 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)
{
RARCH_ERR("video4linux2 returns raw framebuffers.\n");
return NULL;
}

video4linux_t *v4l = (video4linux_t*)calloc(1, sizeof(video4linux_t));
v4l = (video4linux_t*)calloc(1, sizeof(video4linux_t));
if (!v4l)
return NULL;

Expand Down
6 changes: 3 additions & 3 deletions cores/ffmpeg_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
{
Expand Down
6 changes: 4 additions & 2 deletions gfx/drivers_context/drm_egl_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
7 changes: 3 additions & 4 deletions menu/drivers/xmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,14 +565,13 @@ static void xmb_frame_messagebox(const char *message)

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));

Expand Down
27 changes: 17 additions & 10 deletions record/drivers/record_ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand All @@ -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)
{
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion tools/retroarch-joyconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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);

Expand Down

0 comments on commit fefa500

Please sign in to comment.