summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
Diffstat (limited to 'osdep')
-rw-r--r--osdep/getch2-os2.c5
-rw-r--r--osdep/getch2-win.c6
-rw-r--r--osdep/getch2.c7
-rw-r--r--osdep/getch2.h3
-rw-r--r--osdep/mmap_anon.c2
-rw-r--r--osdep/shmem.c2
-rw-r--r--osdep/timer-darwin.c18
-rw-r--r--osdep/timer-linux.c31
-rw-r--r--osdep/timer-win2.c13
-rw-r--r--osdep/timer.h9
10 files changed, 22 insertions, 74 deletions
diff --git a/osdep/getch2-os2.c b/osdep/getch2-os2.c
index ef2dcf22a6..0b6e84683e 100644
--- a/osdep/getch2-os2.c
+++ b/osdep/getch2-os2.c
@@ -31,6 +31,7 @@
#include "keycodes.h"
#include "input/input.h"
#include "mp_fifo.h"
+#include "getch2.h"
#if defined(HAVE_LANGINFO) && defined(CONFIG_ICONV)
#include <locale.h>
@@ -163,13 +164,13 @@ static int getch2_internal( void )
return -1;
}
-void getch2( void )
+void getch2(struct mp_fifo *fifo)
{
int key;
key = getch2_internal();
if( key != -1 )
- mplayer_put_key( key );
+ mplayer_put_key(fifo, key);
}
void getch2_enable( void )
diff --git a/osdep/getch2-win.c b/osdep/getch2-win.c
index 83d502f7c7..49ec9c46b3 100644
--- a/osdep/getch2-win.c
+++ b/osdep/getch2-win.c
@@ -10,6 +10,8 @@
#include "keycodes.h"
#include "input/input.h"
#include "mp_fifo.h"
+#include "getch2.h"
+
// HACK, stdin is used as something else below
#undef stdin
@@ -119,11 +121,11 @@ static int getch2_internal(void)
return -1;
}
-void getch2(void)
+void getch2(struct mp_fifo *fifo)
{
int r = getch2_internal();
if (r >= 0)
- mplayer_put_key(r);
+ mplayer_put_key(fifo, r);
}
void getch2_enable(){
diff --git a/osdep/getch2.c b/osdep/getch2.c
index 65033965bf..403519913a 100644
--- a/osdep/getch2.c
+++ b/osdep/getch2.c
@@ -37,6 +37,7 @@
#include "mp_fifo.h"
#include "keycodes.h"
+#include "getch2.h"
#ifdef HAVE_TERMIOS
static struct termios tio_orig;
@@ -95,7 +96,7 @@ int load_termcap(char *termtype){
screen_height=tgetnum("li");
if(screen_width<1 || screen_width>255) screen_width=80;
if(screen_height<1 || screen_height>255) screen_height=24;
- erase_to_end_of_line= tgetstr("cd",&term_p);
+ erase_to_end_of_line= tgetstr("ce",&term_p);
termcap_add("kP",KEY_PGUP);
termcap_add("kN",KEY_PGDWN);
@@ -134,7 +135,7 @@ void get_screen_size(void){
#endif
}
-void getch2(void)
+void getch2(struct mp_fifo *fifo)
{
int retval = read(0, &getch2_buf[getch2_len], BUF_LEN-getch2_len);
if (retval < 1)
@@ -243,7 +244,7 @@ void getch2(void)
getch2_len -= len;
for (i = 0; i < getch2_len; i++)
getch2_buf[i] = getch2_buf[len+i];
- mplayer_put_key(code);
+ mplayer_put_key(fifo, code);
}
}
diff --git a/osdep/getch2.h b/osdep/getch2.h
index a2206e605d..a85969207c 100644
--- a/osdep/getch2.h
+++ b/osdep/getch2.h
@@ -22,7 +22,8 @@ void getch2_enable(void);
void getch2_disable(void);
/* Read a character or a special key code (see keycodes.h) */
-void getch2(void);
+struct mp_fifo;
+void getch2(struct mp_fifo *fifo);
/* slave cmd function for Windows and OS/2 */
int mp_input_slave_cmd_func(int fd,char* dest,int size);
diff --git a/osdep/mmap_anon.c b/osdep/mmap_anon.c
index f692e2b341..cd42c92b2f 100644
--- a/osdep/mmap_anon.c
+++ b/osdep/mmap_anon.c
@@ -9,6 +9,8 @@
#include <fcntl.h>
#include <sys/mman.h>
+#include "mmap_anon.h"
+
#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
#define MAP_ANONYMOUS MAP_ANON
#endif
diff --git a/osdep/shmem.c b/osdep/shmem.c
index 378512b38b..1adacfaef5 100644
--- a/osdep/shmem.c
+++ b/osdep/shmem.c
@@ -35,6 +35,8 @@
#include <sys/shm.h>
#endif
+#include "shmem.h"
+
#if defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
#define MAP_ANON MAP_ANONYMOUS
#endif
diff --git a/osdep/timer-darwin.c b/osdep/timer-darwin.c
index 4eb973a0c7..64edfe7ef6 100644
--- a/osdep/timer-darwin.c
+++ b/osdep/timer-darwin.c
@@ -27,10 +27,9 @@
#include "timer.h"
/* global variables */
-static double relative_time;
static double timebase_ratio;
-const char *timer_name = "Darwin accurate";
+const char timer_name[] = "Darwin accurate";
@@ -63,19 +62,6 @@ unsigned int GetTimerMS()
return (unsigned int)(uint64_t)(mach_absolute_time() * timebase_ratio * 1e3);
}
-/* time spent between now and last call in seconds */
-float GetRelativeTime()
-{
- double last_time = relative_time;
-
- if (!relative_time)
- InitTimer();
-
- relative_time = mach_absolute_time() * timebase_ratio;
-
- return (float)(relative_time-last_time);
-}
-
/* initialize timer, must be called at least once at start */
void InitTimer()
{
@@ -84,8 +70,6 @@ void InitTimer()
mach_timebase_info(&timebase);
timebase_ratio = (double)timebase.numer / (double)timebase.denom
* (double)1e-9;
-
- relative_time = (double)(mach_absolute_time() * timebase_ratio);
}
#if 0
diff --git a/osdep/timer-linux.c b/osdep/timer-linux.c
index cab110927a..6e066711d5 100644
--- a/osdep/timer-linux.c
+++ b/osdep/timer-linux.c
@@ -8,8 +8,9 @@
#include <time.h>
#include <sys/time.h>
#include "config.h"
+#include "timer.h"
-const char *timer_name =
+const char timer_name[] =
#ifdef HAVE_NANOSLEEP
"nanosleep()";
#else
@@ -31,45 +32,17 @@ int usec_sleep(int usec_delay)
// Returns current time in microseconds
unsigned int GetTimer(void){
struct timeval tv;
-// float s;
gettimeofday(&tv,NULL);
-// s=tv.tv_usec;s*=0.000001;s+=tv.tv_sec;
return tv.tv_sec * 1000000 + tv.tv_usec;
}
// Returns current time in milliseconds
unsigned int GetTimerMS(void){
struct timeval tv;
-// float s;
gettimeofday(&tv,NULL);
-// s=tv.tv_usec;s*=0.000001;s+=tv.tv_sec;
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
-static unsigned int RelativeTime=0;
-
-// Returns time spent between now and last call in seconds
-float GetRelativeTime(void){
-unsigned int t,r;
- t=GetTimer();
-// t*=16;printf("time=%ud\n",t);
- r=t-RelativeTime;
- RelativeTime=t;
- return (float)r * 0.000001F;
-}
-
// Initialize timer, must be called at least once at start
void InitTimer(void){
- GetRelativeTime();
-}
-
-
-#if 0
-#include <stdio.h>
-int main(void){
- float t=0;
- InitTimer();
- while(1){ t+=GetRelativeTime();printf("time= %10.6f\r",t);fflush(stdout); }
}
-#endif
-
diff --git a/osdep/timer-win2.c b/osdep/timer-win2.c
index 2f0b5c3075..43c4b07fa9 100644
--- a/osdep/timer-win2.c
+++ b/osdep/timer-win2.c
@@ -4,7 +4,7 @@
#include <mmsystem.h>
#include "timer.h"
-const char *timer_name = "Windows native";
+const char timer_name[] = "Windows native";
// Returns current time in microseconds
unsigned int GetTimer(){
@@ -25,16 +25,5 @@ int usec_sleep(int usec_delay){
return 0;
}
-static DWORD RelativeTime = 0;
-
-float GetRelativeTime(){
- DWORD t, r;
- t = GetTimer();
- r = t - RelativeTime;
- RelativeTime = t;
- return (float) r *0.000001F;
-}
-
void InitTimer(){
- GetRelativeTime();
}
diff --git a/osdep/timer.h b/osdep/timer.h
index 8320665c73..4ddac524ef 100644
--- a/osdep/timer.h
+++ b/osdep/timer.h
@@ -1,19 +1,12 @@
#ifndef MPLAYER_TIMER_H
#define MPLAYER_TIMER_H
-extern const char *timer_name;
+extern const char timer_name[];
void InitTimer(void);
unsigned int GetTimer(void);
unsigned int GetTimerMS(void);
-//int uGetTimer();
-float GetRelativeTime(void);
int usec_sleep(int usec_delay);
-/* timer's callback handling */
-typedef void timer_callback( void );
-unsigned set_timer_callback(unsigned ms,timer_callback func);
-void restore_timer(void);
-
#endif /* MPLAYER_TIMER_H */