Commit f25c4b0e authored by sletz's avatar sletz
Browse files

Add EndTime function (especially for Windows).

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4736 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 8f2b2511
......@@ -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.
......
......@@ -127,6 +127,7 @@ struct JackLibGlobals
{
if (--fClientCount == 0 && fGlobals) {
jack_log("JackLibGlobals Destroy %x", fGlobals);
EndTime();
delete fGlobals;
fGlobals = NULL;
}
......
......@@ -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;
......
......@@ -140,6 +140,7 @@ int JackServer::Close()
fEngine->Close();
// TODO: move that in reworked JackServerGlobals::Destroy()
JackMessageBuffer::Destroy();
EndTime();
return 0;
}
......
......@@ -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);
......
......@@ -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));
......
......@@ -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);
......
......@@ -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);
......
......@@ -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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment