Add EndTime function (especially for Windows).

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4736 0c269be4-1314-0410-8aa9-9f06e86f4224
This commit is contained in:
sletz 2012-01-26 09:51:44 +00:00
parent 8f2b2511a6
commit f25c4b0e49
9 changed files with 38 additions and 1 deletions

View File

@ -36,6 +36,10 @@ John Emmas
Jackdmp changes log
---------------------------
2012-01-26 Stephane Letz <letz@grame.fr>
* Add EndTime function (especially for Windows).
2012-01-25 Stephane Letz <letz@grame.fr>
* Fix NetJack2 initialisation bug.

View File

@ -127,6 +127,7 @@ struct JackLibGlobals
{
if (--fClientCount == 0 && fGlobals) {
jack_log("JackLibGlobals Destroy %x", fGlobals);
EndTime();
delete fGlobals;
fGlobals = NULL;
}

View File

@ -413,7 +413,7 @@ extern "C"
value.i = 2;
jack_driver_descriptor_add_parameter(desc, &filler, "input-ports", 'C', JackDriverParamInt, &value, NULL, "Number of audio input ports", NULL);
jack_driver_descriptor_add_parameter(desc, &filler, "output-ports", 'C', JackDriverParamInt, &value, NULL, "Number of audio output ports", NULL);
jack_driver_descriptor_add_parameter(desc, &filler, "output-ports", 'P', JackDriverParamInt, &value, NULL, "Number of audio output ports", NULL);
#if HAVE_CELT
value.i = -1;

View File

@ -140,6 +140,7 @@ int JackServer::Close()
fEngine->Close();
// TODO: move that in reworked JackServerGlobals::Destroy()
JackMessageBuffer::Destroy();
EndTime();
return 0;
}

View File

@ -30,6 +30,7 @@ extern "C"
#endif
SERVER_EXPORT void InitTime();
SERVER_EXPORT void EndTime();
SERVER_EXPORT jack_time_t GetMicroSeconds(void);
SERVER_EXPORT void JackSleep(long usec);

View File

@ -220,6 +220,9 @@ SERVER_EXPORT void InitTime()
__jack_cpu_mhz = jack_get_mhz ();
}
SERVER_EXPORT void EndTime()
{}
void SetClockSource(jack_timer_type_t source)
{
jack_log("Clock source : %s", ClockSourceName(source));

View File

@ -39,6 +39,9 @@ SERVER_EXPORT void InitTime()
__jack_time_ratio = ((float)info.numer / info.denom) / 1000;
}
SERVER_EXPORT void EndTime()
{}
SERVER_EXPORT jack_time_t GetMicroSeconds(void)
{
return (jack_time_t) (mach_absolute_time () * __jack_time_ratio);

View File

@ -31,6 +31,9 @@ SERVER_EXPORT void JackSleep(long usec)
SERVER_EXPORT void InitTime()
{}
SERVER_EXPORT void EndTime()
{}
SERVER_EXPORT jack_time_t GetMicroSeconds(void)
{
return (jack_time_t)(gethrtime() / 1000);

View File

@ -19,8 +19,10 @@
#include "JackTime.h"
#include "JackError.h"
static LARGE_INTEGER _jack_freq;
static UINT gPeriod = 0;
SERVER_EXPORT void JackSleep(long usec)
{
@ -30,6 +32,25 @@ SERVER_EXPORT void JackSleep(long usec)
SERVER_EXPORT void InitTime()
{
QueryPerformanceFrequency(&_jack_freq);
TIMECAPS caps;
if (timeGetDevCaps(&caps, sizeof(TIMECAPS)) != TIMERR_NOERROR) {
jack_error("InitTime : could not get timer device");
} else {
gPeriod = caps.wPeriodMin;
if (timeBeginPeriod(gPeriod) != TIMERR_NOERROR) {
jack_error("InitTime : could not set minimum timer");
gPeriod = 0;
} else {
jack_info("InitTime : multimedia timer resolution set to %d milliseconds", gPeriod);
}
}
}
SERVER_EXPORT void EndTime()
{
if (gPeriod > 0) {
timeEndPeriod(gPeriod);
}
}
SERVER_EXPORT jack_time_t GetMicroSeconds(void)