diff options
author | arved <arved@FreeBSD.org> | 2004-03-10 19:43:58 +0800 |
---|---|---|
committer | arved <arved@FreeBSD.org> | 2004-03-10 19:43:58 +0800 |
commit | e4c38e45f796af52f3a35460473bb36bc8e7029e (patch) | |
tree | a6109c541c1d376623696adc10ac79f3775c3129 /audio/jack | |
parent | 5972679384a448c68f8ee76006631d73a6fd12a9 (diff) | |
download | freebsd-ports-gnome-e4c38e45f796af52f3a35460473bb36bc8e7029e.tar.gz freebsd-ports-gnome-e4c38e45f796af52f3a35460473bb36bc8e7029e.tar.zst freebsd-ports-gnome-e4c38e45f796af52f3a35460473bb36bc8e7029e.zip |
Fix Mhz detection. Thanks to Simon Barner for pointing to example code.
Obtained from: mplayer
Diffstat (limited to 'audio/jack')
-rw-r--r-- | audio/jack/files/patch-client.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/audio/jack/files/patch-client.c b/audio/jack/files/patch-client.c index 18b68558a6f1..bd2fe8768ddf 100644 --- a/audio/jack/files/patch-client.c +++ b/audio/jack/files/patch-client.c @@ -1,5 +1,5 @@ --- libjack/client.c.orig Sun Jan 11 20:07:14 2004 -+++ libjack/client.c Tue Mar 9 20:19:15 2004 ++++ libjack/client.c Wed Mar 10 12:32:47 2004 @@ -26,20 +26,23 @@ #else #include <sys/poll.h> @@ -55,3 +55,52 @@ /* a bigger stack makes the application crash... */ #define BIG_ENOUGH_STACK 10000 #else +@@ -1748,6 +1758,15 @@ + return client->thread_id; + } + ++static int64_t ++rdtsc(void) ++{ ++ unsigned int i, j; ++#define RDTSC ".byte 0x0f, 0x31; " ++ asm(RDTSC : "=a"(i), "=d"(j) : ); ++ return ((int64_t)j<<32) + (int64_t)i; ++} ++ + #if defined(__APPLE__) && defined(__POWERPC__) + + double __jack_time_ratio; +@@ -1763,6 +1782,7 @@ + jack_time_t + jack_get_mhz (void) + { ++#ifndef __FreeBSD__ + FILE *f = fopen("/proc/cpuinfo", "r"); + if (f == 0) + { +@@ -1803,6 +1823,24 @@ + return (jack_time_t)mhz; + } + } ++ ++#else ++ int64_t tsc_start, tsc_end; ++ struct timeval tv_start, tv_end; ++ int usec_delay; ++ ++ tsc_start = rdtsc(); ++ gettimeofday(&tv_start, NULL); ++ usleep(100000); ++ tsc_end = rdtsc(); ++ gettimeofday(&tv_end, NULL); ++ ++ usec_delay = 1000000 * (tv_end.tv_sec - tv_start.tv_sec) ++ + (tv_end.tv_usec - tv_start.tv_usec); ++ ++ printf("cpu MHz\t\t: %.3f\n", ++ (double)(tsc_end-tsc_start) / usec_delay); ++#endif + } + + jack_time_t __jack_cpu_mhz; |