Commit 614ec961 authored by Michel Lespinasse's avatar Michel Lespinasse
Browse files

small fixes so we can compile without sys/time.h and strings.h

parent e1cfd486
......@@ -68,6 +68,7 @@ dnl Checks for libraries.
dnl Checks for header files.
INCLUDES='-I$(top_srcdir)/include -I$(top_builddir)/include'
AC_SUBST(INCLUDES)
AC_CHECK_HEADERS([string.h sys/time.h])
AC_CHECK_GENERATE_INTTYPES(include)
dnl Checks for typedefs, structures, and compiler characteristics.
......
......@@ -33,7 +33,7 @@ static uint8_t buffer[BUFFER_SIZE];
static FILE * in_file;
static int demux_track = 0xe0;
static void print_usage (char * argv[])
static void print_usage (char ** argv)
{
fprintf (stderr, "usage: %s [-s<track>] <file>\n"
"\t-s\tset track number (0-15 or 0xe0-0xef)\n", argv[0]);
......@@ -41,7 +41,7 @@ static void print_usage (char * argv[])
exit (1);
}
static void handle_args (int argc, char * argv[])
static void handle_args (int argc, char ** argv)
{
int c;
char * s;
......@@ -177,7 +177,7 @@ static void ps_loop (void)
} while (end == buffer + BUFFER_SIZE);
}
int main (int argc,char *argv[])
int main (int argc, char ** argv)
{
handle_args (argc, argv);
......
......@@ -23,12 +23,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <signal.h>
#include <string.h>
#include <errno.h>
#include <inttypes.h>
#include <getopt.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#include <signal.h>
#endif
#include "video_out.h"
#include "mpeg2.h"
......@@ -37,24 +39,39 @@
#define BUFFER_SIZE 262144
static uint8_t buffer[BUFFER_SIZE];
static FILE * in_file;
static uint32_t frame_counter = 0;
static struct timeval tv_beg, tv_end, tv_start;
static int elapsed;
static int total_elapsed;
static int last_count = 0;
static int demux_track = 0;
static int disable_accel = 0;
static mpeg2dec_t mpeg2dec;
static vo_open_t * output_open = NULL;
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#include <signal.h>
static void print_fps (int final);
static RETSIGTYPE signal_handler (int sig)
{
print_fps (1);
signal (sig, SIG_DFL);
raise (sig);
}
static void print_fps (int final)
{
int fps, tfps, frames;
static uint32_t frame_counter = 0;
static struct timeval tv_beg, tv_start;
static int total_elapsed;
static int last_count = 0;
struct timeval tv_end;
int fps, tfps, frames, elapsed;
gettimeofday (&tv_end, NULL);
if (frame_counter++ == 0) {
if (!frame_counter) {
tv_start = tv_beg = tv_end;
signal (SIGINT, signal_handler);
}
elapsed = (tv_end.tv_sec - tv_beg.tv_sec) * 100 +
......@@ -76,6 +93,8 @@ static void print_fps (int final)
return;
}
frame_counter++;
if (elapsed < 50) /* only display every 0.50 seconds */
return;
......@@ -94,14 +113,15 @@ static void print_fps (int final)
last_count = frame_counter;
}
static RETSIGTYPE signal_handler (int sig)
#else /* !HAVE_SYS_TIME_H */
static void print_fps (int final)
{
print_fps (1);
signal (sig, SIG_DFL);
raise (sig);
}
static void print_usage (char * argv[])
#endif
static void print_usage (char ** argv)
{
int i;
vo_driver_t * drivers;
......@@ -119,7 +139,7 @@ static void print_usage (char * argv[])
exit (1);
}
static void handle_args (int argc, char * argv[])
static void handle_args (int argc, char ** argv)
{
int c;
vo_driver_t * drivers;
......@@ -301,7 +321,7 @@ static void es_loop (void)
} while (end == buffer + BUFFER_SIZE);
}
int main (int argc,char *argv[])
int main (int argc, char ** argv)
{
vo_instance_t * output;
uint32_t accel;
......@@ -321,10 +341,6 @@ int main (int argc,char *argv[])
}
mpeg2_init (&mpeg2dec, accel, output);
signal (SIGINT, signal_handler);
gettimeofday (&tv_beg, NULL);
if (demux_track)
ps_loop ();
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment