[Mplayer-cvslog] CVS: 0_90/linux timer-macosx.c,NONE,1.1 Makefile,1.8,1.9

Arpi of Ize arpi at mplayerhq.hu
Mon Mar 10 16:51:43 CET 2003


Update of /cvsroot/mplayer/0_90/linux
In directory mail:/var/tmp.root/cvs-serv3762

Modified Files:
	Makefile 
Added Files:
	timer-macosx.c 
Log Message:
backport: timer-macosx.c added


--- NEW FILE ---
/*
 * Semi-precise timer routines using CoreFoundation
 *
 * (C) 2003 Dan Christiansen
 *
 * Released into the public domain.
 */

#include <unistd.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include "../config.h"

#ifdef MACOSX
# include <CoreFoundation/CFRunLoop.h>
#endif

/* Rather than using CF timers, we simply store the absolute time 
 * CFAbsoluteTime == double */
static CFAbsoluteTime relative_time;

int usec_sleep(int usec_delay)
{
  CFRunLoopRunInMode(kCFRunLoopDefaultMode,  usec_delay / 1000000.0, false);
}


// Returns current time in microseconds
unsigned int GetTimer(){
  return (unsigned int)(CFAbsoluteTimeGetCurrent() * 1000000);
}  

// Returns current time in milliseconds
unsigned int GetTimerMS(){
  return (unsigned int)(CFAbsoluteTimeGetCurrent() * 1000);
}

// Returns time spent between now and last call in seconds
float GetRelativeTime(){
  CFAbsoluteTime last_time = relative_time;
  relative_time = CFAbsoluteTimeGetCurrent();
  return (float)(relative_time - last_time);
}

// Initialize timer, must be called at least once at start
void InitTimer(){
  GetRelativeTime();
}

#if 0
int main() {
  int i;

  for (i = 0; i < 20; i++) {
    printf("CF relative time:\t%f\n", GetRelativeTime());
    usec_sleep(1000000);
    printf("usleep relative time:\t%f\n", GetRelativeTime());
    usleep(1000000);
  }
}
#endif



Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/0_90/linux/Makefile,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Makefile	7 Feb 2003 22:47:20 -0000	1.8
+++ Makefile	10 Mar 2003 15:51:41 -0000	1.9
@@ -3,14 +3,21 @@
 
 LIBNAME = libosdep.a
 
-SRCS=getch2.c timer-lx.c shmem.c strsep.c vsscanf.c scandir.c # timer.c
-OBJS=$(SRCS:.c=.o)
+SRCS=getch2.c shmem.c strsep.c vsscanf.c scandir.c # timer.c
 
 ifeq ($(TARGET_ARCH_X86),yes)
 ifeq ($(TARGET_OS),Linux)
 SRCS += lrmi.c vbelib.c
 endif
 endif
+
+ifeq ($(MACOSX),yes)
+SRCS += timer-macosx.c
+else
+SRCS += timer-lx.c
+endif
+
+OBJS=$(SRCS:.c=.o)
 
 CFLAGS  = $(OPTFLAGS) -I. -I.. $(EXTRA_INC)
 # -I/usr/X11R6/include/



More information about the MPlayer-cvslog mailing list