Browse Source

Michael Voigt JackTime patch.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2929 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.90
sletz 16 years ago
parent
commit
3b8e4f2c23
15 changed files with 176 additions and 254 deletions
  1. +10
    -5
      ChangeLog
  2. +0
    -1
      common/JackDriver.cpp
  3. +2
    -4
      common/JackDriverLoader.cpp
  4. +0
    -1
      common/JackEngine.cpp
  5. +0
    -1
      common/JackServerAPI.cpp
  6. +0
    -122
      common/JackTime.c
  7. +10
    -3
      common/JackTime.h
  8. +5
    -5
      common/JackTools.h
  9. +2
    -1
      common/wscript
  10. +101
    -0
      linux/JackLinuxTime.c
  11. +0
    -61
      linux/JackTime_os.h
  12. +20
    -24
      macosx/JackMachTime.c
  13. +20
    -20
      windows/JackWinTime.c
  14. +3
    -3
      windows/libjack.cbp
  15. +3
    -3
      windows/libjackserver.cbp

+ 10
- 5
ChangeLog View File

@@ -17,28 +17,33 @@ Nedko Arnaudov
Fernando Lopez-Lezcano Fernando Lopez-Lezcano
Romain Moret Romain Moret
Florian Faber Florian Faber
Michael Voigt


--------------------------- ---------------------------
Jackdmp changes log Jackdmp changes log
--------------------------- ---------------------------


2008-08-17 Stephane Letz <letz@grame.fr>
2008-08-19 Stephane Letz <letz@grame.fr>
* Michael Voigt JackTime patch.

2008-09-17 Stephane Letz <letz@grame.fr>
* New JackDriverInfo class to cleanup driver loading code. * New JackDriverInfo class to cleanup driver loading code.


2008-08-08 Stephane Letz <letz@grame.fr>
2008-09-08 Stephane Letz <letz@grame.fr>
* Better symbols export for server and client side libraries. * Better symbols export for server and client side libraries.


2008-08-06 Stephane Letz <letz@grame.fr>
2008-09-06 Stephane Letz <letz@grame.fr>
* Correct driver hierarchy on macosx and windows targets. * Correct driver hierarchy on macosx and windows targets.


2008-08-05 Stephane Letz <letz@grame.fr>
2008-09-05 Stephane Letz <letz@grame.fr>
* Merge Michael Voigt "drops" branch after reorganization step. * Merge Michael Voigt "drops" branch after reorganization step.


2008-08-04 Stephane Letz <letz@grame.fr>
2008-09-04 Stephane Letz <letz@grame.fr>
* Michael Voigt 4th source reorganization patch. * Michael Voigt 4th source reorganization patch.
* Correct JackNetDriver initialization. * Correct JackNetDriver initialization.


+ 0
- 1
common/JackDriver.cpp View File

@@ -23,7 +23,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#endif #endif


#include "JackSystemDeps.h" #include "JackSystemDeps.h"

#include "JackDriver.h" #include "JackDriver.h"
#include "JackTime.h" #include "JackTime.h"
#include "JackError.h" #include "JackError.h"


+ 2
- 4
common/JackDriverLoader.cpp View File

@@ -785,12 +785,10 @@ Jack::JackDriverClientInterface* JackDriverInfo::Open(jack_driver_desc_t* driver
if (fHandle == NULL) { if (fHandle == NULL) {
#ifdef WIN32 #ifdef WIN32
if ((errstr = GetLastError ()) != 0) { if ((errstr = GetLastError ()) != 0) {
jack_error ("can't load \"%s\": %ld", driver_desc->file,
errstr);
jack_error ("can't load \"%s\": %ld", driver_desc->file, errstr);
#else #else
if ((errstr = dlerror ()) != 0) { if ((errstr = dlerror ()) != 0) {
jack_error ("can't load \"%s\": %s", driver_desc->file,
errstr);
jack_error ("can't load \"%s\": %s", driver_desc->file, errstr);
#endif #endif


} else { } else {


+ 0
- 1
common/JackEngine.cpp View File

@@ -26,7 +26,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include <assert.h> #include <assert.h>


#include "JackSystemDeps.h" #include "JackSystemDeps.h"

#include "JackLockedEngine.h" #include "JackLockedEngine.h"
#include "JackExternalClient.h" #include "JackExternalClient.h"
#include "JackInternalClient.h" #include "JackInternalClient.h"


+ 0
- 1
common/JackServerAPI.cpp View File

@@ -23,7 +23,6 @@ This program is free software; you can redistribute it and/or modify
#endif #endif


#include "JackSystemDeps.h" #include "JackSystemDeps.h"

#include "JackGraphManager.h" #include "JackGraphManager.h"
#include "JackInternalClient.h" #include "JackInternalClient.h"
#include "JackServer.h" #include "JackServer.h"


+ 0
- 122
common/JackTime.c View File

@@ -1,122 +0,0 @@
/*
Copyright (C) 2001-2003 Paul Davis
Copyright (C) 2004-2008 Grame

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

*/

#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif

#include "JackTime.h"
#include "JackError.h"

#ifdef __APPLE__

double __jack_time_ratio;

/* This should only be called ONCE per process. */
void InitTime()
{
jack_log("InitTime");
mach_timebase_info_data_t info;
mach_timebase_info(&info);
__jack_time_ratio = ((float)info.numer / info.denom) / 1000;
}

#endif

#ifdef WIN32

SERVER_EXPORT LARGE_INTEGER _jack_freq;

void InitTime()
{
QueryPerformanceFrequency(&_jack_freq);
jack_log("InitTime freq = %ld %ld", _jack_freq.HighPart, _jack_freq.LowPart);
_jack_freq.QuadPart = _jack_freq.QuadPart / 1000000; // by usec
}

jack_time_t GetMicroSeconds(void)
{
LARGE_INTEGER t1;
QueryPerformanceCounter (&t1);
return (jack_time_t)(((double)t1.QuadPart)/((double)_jack_freq.QuadPart));
}

// TODO
#endif

#ifdef linux

#ifdef GETCYCLE_TIME

#include <stdio.h>
jack_time_t GetMhz(void)
{
FILE *f = fopen("/proc/cpuinfo", "r");
if (f == 0) {
perror("can't open /proc/cpuinfo\n");
exit(1);
}

for (;;) {
jack_time_t mhz;
int ret;
char buf[1000];

if (fgets(buf, sizeof(buf), f) == NULL) {
jack_error ("FATAL: cannot locate cpu MHz in "
"/proc/cpuinfo\n");
exit(1);
}

#if defined(__powerpc__)
ret = sscanf(buf, "clock\t: %" SCNu64 "MHz", &mhz);
#elif defined( __i386__ ) || defined (__hppa__) || defined (__ia64__) || \
defined(__x86_64__)
ret = sscanf(buf, "cpu MHz : %" SCNu64, &mhz);
#elif defined( __sparc__ )
ret = sscanf(buf, "Cpu0Bogo : %" SCNu64, &mhz);
#elif defined( __mc68000__ )
ret = sscanf(buf, "Clocking: %" SCNu64, &mhz);
#elif defined( __s390__ )
ret = sscanf(buf, "bogomips per cpu: %" SCNu64, &mhz);
#else /* MIPS, ARM, alpha */
ret = sscanf(buf, "BogoMIPS : %" SCNu64, &mhz);
#endif
if (ret == 1) {
fclose(f);
return (jack_time_t)mhz;
}
}
}

jack_time_t __jack_cpu_mhz;

void InitTime()
{
__jack_cpu_mhz = GetMhz();
}

#else
void InitTime()
{}

#endif

#endif

+ 10
- 3
common/JackTime.h View File

@@ -23,11 +23,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


#include "types.h" #include "types.h"
#include "JackCompilerDeps.h" #include "JackCompilerDeps.h"
#include <stdio.h>

#include "JackTime_os.h"


#ifdef __cplusplus
extern "C"
{
#endif #endif


SERVER_EXPORT void InitTime();
SERVER_EXPORT jack_time_t GetMicroSeconds();
SERVER_EXPORT void JackSleep(long usec);


#ifdef __cplusplus
}
#endif


#endif

+ 5
- 5
common/JackTools.h View File

@@ -32,16 +32,16 @@
#include <sys/syslimits.h> #include <sys/syslimits.h>
#endif #endif


#include "jslist.h"
#include "driver_interface.h"
#include "JackCompilerDeps.h"
#include "JackError.h"

#include <string> #include <string>
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include "jslist.h"
#include "driver_interface.h"

#include "JackCompilerDeps.h"
#include "JackError.h"


namespace Jack namespace Jack
{ {


+ 2
- 1
common/wscript View File

@@ -78,7 +78,6 @@ def build(bld):
'JackEngineControl.cpp', 'JackEngineControl.cpp',
'JackShmMem.cpp', 'JackShmMem.cpp',
'shm.c', 'shm.c',
'JackTime.c',
'JackGlobals.cpp', 'JackGlobals.cpp',
'JackDebugClient.cpp', 'JackDebugClient.cpp',
'JackTransportEngine.cpp', 'JackTransportEngine.cpp',
@@ -97,6 +96,7 @@ def build(bld):
'../posix/JackFifo.cpp', '../posix/JackFifo.cpp',
'../posix/JackProcessSync.cpp', '../posix/JackProcessSync.cpp',
'../posix/JackSocket.cpp', '../posix/JackSocket.cpp',
'../linux/JackLinuxTime.c',
] ]
includes = ['../linux', '../posix'] + includes includes = ['../linux', '../posix'] + includes
uselib.append('RT') uselib.append('RT')
@@ -109,6 +109,7 @@ def build(bld):
'../macosx/JackMachThread.cpp', '../macosx/JackMachThread.cpp',
'../macosx/JackMachSemaphore.cpp', '../macosx/JackMachSemaphore.cpp',
'../macosx/JackMachPort.cpp', '../macosx/JackMachPort.cpp',
'../macosx/JackMachTime.c',
] ]
includes = ['../macosx', '../macosx/RPC', '../posix'] + includes includes = ['../macosx', '../macosx/RPC', '../posix'] + includes




+ 101
- 0
linux/JackLinuxTime.c View File

@@ -0,0 +1,101 @@
/*
Copyright (C) 2001-2003 Paul Davis
Copyright (C) 2004-2008 Grame

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

*/

#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif

#include "JackTime.h"
#include <unistd.h>

SERVER_EXPORT void JackSleep(long usec)
{
usleep(usec);
}

#ifdef GETCYCLE_TIME

#include <stdio.h>
#include "cycles.h"

static jack_time_t __jack_cpu_mhz;

static inline jack_time_t GetMhz(void)
{
FILE *f = fopen("/proc/cpuinfo", "r");
if (f == 0) {
perror("can't open /proc/cpuinfo\n");
exit(1);
}
for (;;) {
jack_time_t mhz;
int ret;
char buf[1000];
if (fgets(buf, sizeof(buf), f) == NULL) {
jack_error("FATAL: cannot locate cpu MHz in /proc/cpuinfo\n");
exit(1);
}
#if defined(__powerpc__)
ret = sscanf(buf, "clock\t: %" SCNu64 "MHz", &mhz);
#elif defined( __i386__ ) || defined (__hppa__) || defined (__ia64__) || \
defined(__x86_64__)
ret = sscanf(buf, "cpu MHz : %" SCNu64, &mhz);
#elif defined( __sparc__ )
ret = sscanf(buf, "Cpu0Bogo : %" SCNu64, &mhz);
#elif defined( __mc68000__ )
ret = sscanf(buf, "Clocking: %" SCNu64, &mhz);
#elif defined( __s390__ )
ret = sscanf(buf, "bogomips per cpu: %" SCNu64, &mhz);
#else /* MIPS, ARM, alpha */
ret = sscanf(buf, "BogoMIPS : %" SCNu64, &mhz);
#endif
if (ret == 1) {
fclose(f);
return (jack_time_t)mhz;
}
}
}

SERVER_EXPORT void InitTime()
{
__jack_cpu_mhz = GetMhz();
}
SERVER_EXPORT jack_time_t GetMicroSeconds(void)
{
return get_cycles() / __jack_cpu_mhz;
}
#else

#include <time.h>
SERVER_EXPORT void InitTime()
{}
SERVER_EXPORT jack_time_t GetMicroSeconds(void)
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (jack_time_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
}
#endif

+ 0
- 61
linux/JackTime_os.h View File

@@ -1,61 +0,0 @@
/*
Copyright (C) 2001-2003 Paul Davis
Copyright (C) 2004-2008 Grame

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

*/

#ifndef __JackTime_linux__
#define __JackTime_linux__

#ifdef __cplusplus
extern "C"
{
#endif

#include <unistd.h>

static inline void JackSleep(long usec)
{
usleep(usec);
}

#ifdef GETCYCLE_TIME
#include "cycles.h"
extern jack_time_t __jack_cpu_mhz;
jack_time_t GetMhz();
void InitTime();
static inline jack_time_t GetMicroSeconds(void)
{
return get_cycles() / __jack_cpu_mhz;
}
#else
#include <time.h>
void InitTime();
static inline jack_time_t GetMicroSeconds(void)
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (jack_time_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
}
#endif

#ifdef __cplusplus
}
#endif

#endif


macosx/JackTime_os.h → macosx/JackMachTime.c View File

@@ -13,40 +13,36 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.


You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


*/ */


#ifndef __JackTime_APPLE__
#define __JackTime_APPLE__

#ifdef __cplusplus
extern "C"
{
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif #endif


#include "JackTime.h"
#include "JackError.h"
#include <mach/mach_time.h> #include <mach/mach_time.h>
#include <unistd.h> #include <unistd.h>


extern EXPORT double __jack_time_ratio;

static inline jack_time_t GetMicroSeconds(void)
{
return (jack_time_t) (mach_absolute_time () * __jack_time_ratio);
}
double __jack_time_ratio;


/* This should only be called ONCE per process. */
void InitTime();

static inline void JackSleep(int usec)
{
usleep(usec);
}

#ifdef __cplusplus
SERVER_EXPORT void JackSleep(long usec)
{
usleep(usec);
} }
#endif


/* This should only be called ONCE per process. */
SERVER_EXPORT void InitTime()
{
mach_timebase_info_data_t info;
mach_timebase_info(&info);
__jack_time_ratio = ((float)info.numer / info.denom) / 1000;
}


#endif
SERVER_EXPORT jack_time_t GetMicroSeconds(void)
{
return (jack_time_t) (mach_absolute_time () * __jack_time_ratio);
}

windows/JackTime_os.h → windows/JackWinTime.c View File

@@ -13,34 +13,34 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.


You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


*/ */


#ifndef __JackTime_WIN32__
#define __JackTime_WIN32__

#ifdef __cplusplus
extern "C"
{
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif #endif


extern SERVER_EXPORT LARGE_INTEGER _jack_freq;

SERVER_EXPORT jack_time_t GetMicroSeconds(void) ;
#include "JackTime.h"
#include "JackError.h"


void InitTime();
static LARGE_INTEGER _jack_freq;


static void JackSleep(int usec)
{
Sleep(usec / 1000);
}

#ifdef __cplusplus
SERVER_EXPORT JackSleep(long usec)
{
Sleep(usec / 1000);
} }
#endif


SERVER_EXPORT void InitTime()
{
QueryPerformanceFrequency(&_jack_freq);
_jack_freq.QuadPart = _jack_freq.QuadPart / 1000000; // by usec
}


#endif

SERVER_EXPORT jack_time_t GetMicroSeconds(void)
{
LARGE_INTEGER t1;
QueryPerformanceCounter(&t1);
return (jack_time_t)(((double)t1.QuadPart) / ((double)_jack_freq.QuadPart));
}

+ 3
- 3
windows/libjack.cbp View File

@@ -160,9 +160,6 @@
<Unit filename="..\common\JackPort.cpp" /> <Unit filename="..\common\JackPort.cpp" />
<Unit filename="..\common\JackPortType.cpp" /> <Unit filename="..\common\JackPortType.cpp" />
<Unit filename="..\common\JackShmMem.cpp" /> <Unit filename="..\common\JackShmMem.cpp" />
<Unit filename="..\common\JackTime.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\common\JackTools.cpp" /> <Unit filename="..\common\JackTools.cpp" />
<Unit filename="..\common\JackTransportEngine.cpp" /> <Unit filename="..\common\JackTransportEngine.cpp" />
<Unit filename="..\common\shm.c"> <Unit filename="..\common\shm.c">
@@ -173,6 +170,9 @@
<Unit filename="JackWinProcessSync.cpp" /> <Unit filename="JackWinProcessSync.cpp" />
<Unit filename="JackWinSemaphore.cpp" /> <Unit filename="JackWinSemaphore.cpp" />
<Unit filename="JackWinThread.cpp" /> <Unit filename="JackWinThread.cpp" />
<Unit filename="JackWinTime.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="libjack.rc"> <Unit filename="libjack.rc">
<Option compilerVar="WINDRES" /> <Option compilerVar="WINDRES" />
</Unit> </Unit>


+ 3
- 3
windows/libjackserver.cbp View File

@@ -140,9 +140,6 @@
<Unit filename="..\common\JackServerGlobals.cpp" /> <Unit filename="..\common\JackServerGlobals.cpp" />
<Unit filename="..\common\JackShmMem.cpp" /> <Unit filename="..\common\JackShmMem.cpp" />
<Unit filename="..\common\JackThreadedDriver.cpp" /> <Unit filename="..\common\JackThreadedDriver.cpp" />
<Unit filename="..\common\JackTime.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\common\JackTools.cpp" /> <Unit filename="..\common\JackTools.cpp" />
<Unit filename="..\common\JackTransportEngine.cpp" /> <Unit filename="..\common\JackTransportEngine.cpp" />
<Unit filename="..\common\JackWaitThreadedDriver.cpp" /> <Unit filename="..\common\JackWaitThreadedDriver.cpp" />
@@ -161,6 +158,9 @@
<Unit filename="JackWinProcessSync.cpp" /> <Unit filename="JackWinProcessSync.cpp" />
<Unit filename="JackWinSemaphore.cpp" /> <Unit filename="JackWinSemaphore.cpp" />
<Unit filename="JackWinThread.cpp" /> <Unit filename="JackWinThread.cpp" />
<Unit filename="JackWinTime.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="getopt.c"> <Unit filename="getopt.c">
<Option compilerVar="CC" /> <Option compilerVar="CC" />
</Unit> </Unit>


Loading…
Cancel
Save