File: WaitSecsMex.c

package info (click to toggle)
psychtoolbox-3 3.0.14.20170103%2Bgit6-g605ff5c.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 103,044 kB
  • ctags: 69,483
  • sloc: ansic: 167,371; cpp: 11,232; objc: 4,708; sh: 1,875; python: 383; php: 344; makefile: 207; java: 113
file content (80 lines) | stat: -rwxr-xr-x 2,067 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
	PsychToolbox3/Source/Common/WaitSecsMex/WaitSecsMex.c
	
	PLATFORMS:	Matlab only
			
	
	AUTHORS:
	Allen Ingling		awi		Allen.Ingling@nyu.edu

	HISTORY:
	8/06/02			awi		wrote it. 
        
        DESCRIPTION 

        WaitSecsMex is a variant of WaitSecs which strips out the Psychtoolbox mex/mx abstraction layer.
        The purposes are to provide a simplified example to Mathworks and to verify that the psychtoolbox mex/mx abstraction layer
        is not the source of trouble.  
	
	

*/


#include "WaitSecsMex.h"

void PsychGetPrecisionTimerSeconds(double *secs)
{
    UInt64	ticks;
    
    ticks=AudioGetCurrentHostTime();
    *secs=(double)(AudioConvertHostTimeToNanos(ticks) / (double)1000000000.0);
}


void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    double startTime, endTime, currentTime;
    

    PsychGetPrecisionTimerSeconds(&startTime);
    
    if(nlhs > 0)
        mexErrMsgTxt("WaitSecsMex uses no output arguments.");
    if(nrhs > 1)
        mexErrMsgTxt("WaitSecsMex requires only one input argument.");
    if(nrhs < 1)
        mexErrMsgTxt("WaitSecsMex requires one input argument.");
    if(mxGetM(prhs[0]) * mxGetN(prhs[0]) != 1)
        mexErrMsgTxt("WaitSecs requires 1x1 double as input argument");
    endTime=mxGetPr(prhs[0])[0] + startTime;
    for(PsychGetPrecisionTimerSeconds(&currentTime);currentTime<endTime;PsychGetPrecisionTimerSeconds(&currentTime))
        ;
        
}


/*
PsychError WAITSECSWaitSecs(void) 
{
    double 	*waitPeriod, readTime, endTime;
    
    //grab the time right away
    PsychGetPrecisionTimerSeconds(&readTime);
    

    //check to see if the user supplied superfluous arguments
    PsychErrorExit(PsychCapNumOutputArgs(0));
    PsychErrorExit(PsychCapNumInputArgs(1));
    
    //Allocate a return matrix and load it with the depth values.
    PsychAllocInDoubleArg(1,TRUE,&waitPeriod);
    endTime = *waitPeriod + readTime; 
    
    while(readTime < endTime)
        PsychGetPrecisionTimerSeconds(&readTime);
        
    return(PsychError_none);	
}
*/