本文整理汇总了C++中PsychErrorExitMsg函数的典型用法代码示例。如果您正苦于以下问题:C++ PsychErrorExitMsg函数的具体用法?C++ PsychErrorExitMsg怎么用?C++ PsychErrorExitMsg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PsychErrorExitMsg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SCREENAddAudioBufferToMovie
PsychError SCREENAddAudioBufferToMovie(void)
{
static char useString[] = "Screen('AddAudioBufferToMovie', moviePtr, audioBuffer);";
static char synopsisString[] =
"Add a buffer filled with audio data samples to movie 'moviePtr'.\n"
"The movie must have been created in 'CreateMovie' with an options string that "
"enables writing of an audio track into the movie, otherwise this function will fail.\n"
"You enable writing of audio tracks by adding the keyword 'AddAudioTrack' to the options string.\n"
"Alternatively, if your options string is a gst-launch style pipeline description, it must contain "
"one pipeline element with a name option of 'name=ptbaudioappsrc'.\n"
"'audioBuffer' must be 'numChannels' rows by 'numSamples' columns double matrix of audio data. "
"Each row encodes one audio channel, each column element in a row encodes a sample. "
"E.g., a 2-by-48000 matrix would encode 48000 samples for a two channel stereo sound track.\n"
"Sample values must lie in the range between -1.0 and +1.0.\n"
"The audio buffer is converted into a movie specific sound format and then appended to "
"the audio samples already stored in the audio track.\n"
"\n";
static char seeAlsoString[] = "FinalizeMovie AddFrameToMovie CloseMovie PlayMovie GetMovieImage GetMovieTimeIndex SetMovieTimeIndex";
int moviehandle = -1;
int m, n, p;
double* buffer;
// All sub functions should have these two lines
PsychPushHelp(useString, synopsisString, seeAlsoString);
if(PsychIsGiveHelp()) {PsychGiveHelp(); return(PsychError_none);};
PsychErrorExit(PsychCapNumInputArgs(2)); // Max. 2 input args.
PsychErrorExit(PsychRequireNumInputArgs(2)); // Min. 2 input args required.
PsychErrorExit(PsychCapNumOutputArgs(0)); // Max. 0 output args.
// Get movie handle:
PsychCopyInIntegerArg(1, kPsychArgRequired, &moviehandle);
// And audio date buffer:
PsychAllocInDoubleMatArg(2, kPsychArgRequired, &m, &n, &p, &buffer);
if (p!=1 || m < 1 || n < 1) PsychErrorExitMsg(PsychError_user, "Invalid audioBuffer provided. Must be a 2D matrix with at least one row and at least one column!");
// Pass audio data to movie writing engine:
PsychAddAudioBufferToMovie(moviehandle, m, n, buffer);
return(PsychError_none);
}
示例2: SCREENPlayMovie
PsychError SCREENPlayMovie(void)
{
int moviehandle = -1;
double rate = 0;
int loop = 0;
double sndvolume = 1;
double dropped = 0;
// All sub functions should have these two lines
PsychPushHelp(useString, synopsisString, seeAlsoString);
if(PsychIsGiveHelp()) {PsychGiveHelp(); return(PsychError_none);};
PsychErrorExit(PsychCapNumInputArgs(4)); // Max. 4 input args.
PsychErrorExit(PsychRequireNumInputArgs(2)); // Min. 2 input args required.
PsychErrorExit(PsychCapNumOutputArgs(1)); // Max. 1 output args.
// Get the movie handle:
PsychCopyInIntegerArg(1, TRUE, &moviehandle);
if (moviehandle==-1) {
PsychErrorExitMsg(PsychError_user, "PlayMovie called without valid handle to a movie object.");
}
// Get the requested playback rate.
PsychCopyInDoubleArg(2, TRUE, &rate);
// Get the 'loop' flag: If zero, we don't loop, otherwise we loop.
PsychCopyInIntegerArg(3, FALSE, &loop);
// Get the requested sound volume. Defaults to 1 == Full blast!
PsychCopyInDoubleArg(4, FALSE, &sndvolume);
if (sndvolume<0) sndvolume = 0;
if (sndvolume>1) sndvolume = 1;
// Start playback via low-level routines:
dropped = (double) PsychPlaybackRate(moviehandle, rate, loop, sndvolume);
// Return optional count of dropped frames:
PsychCopyOutDoubleArg(1, FALSE, dropped);
// Ready!
return(PsychError_none);
}
示例3: PsychHIDGetIndexFromRecord
/*
PsychHIDGetIndexFromRecord()
The inverse of PsychHIDGetDeviceRecordPtrFromIndex.
This O(n) where n is the number of device elements. We could make it O(1) if we modified
the element structure in the HID Utilities library to include a field specifying the index of the element or
collection.
Note that if PsychHIDGetIndexFromRecord() is O(n) then its caller, PsychHIDGetCollections, is O(n^2) for each
device, whereas if PsychHIDGetIndexFromRecord() is O(1) then psychHIDGetCollections becomes O(n) for each
device.
*/
int PsychHIDGetIndexFromRecord(pRecDevice deviceRecord, pRecElement elementRecord, HIDElementTypeMask typeMask)
{
int elementIndex;
pRecElement currentElement;
if (elementRecord == NULL)
return(0);
elementIndex = 1;
for (currentElement = HIDGetFirstDeviceElement(deviceRecord, typeMask);
currentElement != elementRecord && currentElement != NULL;
currentElement = HIDGetNextDeviceElement(currentElement, typeMask))
++elementIndex;
if (currentElement == elementRecord)
return elementIndex;
else {
PsychErrorExitMsg(PsychError_internal, "Element record not found within device record");
return 0; //make the compiler happy
}
}
示例4: PsychCopyInWindowIndexArg
psych_bool PsychCopyInWindowIndexArg(int position, psych_bool required, PsychWindowIndexType *windowIndex)
{
double *arg;
psych_bool isThere;
if(position==kPsychUseDefaultArgPosition)
position = kPsychDefaultNumdexArgPosition;
isThere=PsychAllocInDoubleArg(position,required,&arg);
if(!isThere)
return(FALSE);
*windowIndex = (PsychWindowIndexType)*arg;
if(IsWindowIndex(*windowIndex))
return(TRUE);
else{
PsychErrorExitMsg(PsychError_invalidWindex,NULL);
return(FALSE); //only to satisfy the compiler with a return statement.
}
}
示例5: PsychHIDGetCollectionRecordFromDeviceRecordAndCollectionIndex
pRecElement PsychHIDGetCollectionRecordFromDeviceRecordAndCollectionIndex(pRecDevice deviceRecord, int elementIndex)
{
int i;
pRecElement currentElement;
PsychHIDVerifyInit();
i=1;
for(currentElement=HIDGetFirstDeviceElement(deviceRecord, kHIDElementTypeCollection);
currentElement != NULL;
currentElement=HIDGetNextDeviceElement (currentElement, kHIDElementTypeCollection))
{
if(i==elementIndex)
return(currentElement);
++i;
}
PsychErrorExitMsg(PsychError_internal, "Invalid collection index specified. Has a device has been unplugged? Try rebuilding the device list");
return(NULL); //make the compiler happy.
}
示例6: PsychSetOutputDithering
/* PsychSetOutputDithering() - Control bit depth control and dithering on digital display output encoder:
*
* This function enables or disables bit depths truncation or dithering of digital display output ports of supported
* graphics hardware. Currently the ATI Radeon X1000/HD2000/HD3000/HD4000/HD5000 and later cards should allow this.
*
* This needs support from the Psychtoolbox kernel level support driver for low-level register reads
* and writes to the GPU registers.
*
*
* 'windowRecord' Is used to find the Id of the screen for which mode should be changed. If set to NULL then...
* 'screenId' ... is used to determine the screenId for the screen. Otherwise 'screenId' is ignored.
* 'ditherEnable' Zero = Disable any dithering. Non-Zero Reenable dithering after it has been disabled by us,
* or if it wasn't disabled beforehand, enable it with a control mode as specified by the numeric
* value of 'ditherEnable'. The value is GPU specific.
*
*/
psych_bool PsychSetOutputDithering(PsychWindowRecordType* windowRecord, int screenId, unsigned int ditherEnable)
{
#if PSYCH_SYSTEM == PSYCH_OSX || PSYCH_SYSTEM == PSYCH_LINUX
// Child protection:
if (windowRecord && !PsychIsOnscreenWindow(windowRecord)) PsychErrorExitMsg(PsychError_internal, "Invalid non-onscreen windowRecord provided!!!");
// Either screenid from windowRecord or as passed in:
if (windowRecord) screenId = windowRecord->screenNumber;
// Do the call:
PsychOSKDSetDitherMode(screenId, ditherEnable);
return(TRUE);
#else
// This cool stuff not supported on the uncool Windows OS:
if(PsychPrefStateGet_Verbosity() > 1) printf("PTB-WARNING: GPU dithering control requested, but this is not supported on MS-Windows.\n");
return(FALSE);
#endif
}
示例7: PsychSetATSUStyleAttributesFromPsychWindowRecord
void PsychSetATSUStyleAttributesFromPsychWindowRecord(ATSUStyle atsuStyle, PsychWindowRecordType *winRec)
{
PsychFontStructType *psychFontRecord;
int psychColorSize;
//for ATSU attributes
ATSUFontID atsuFontID;
Fixed atsuFontSize;
ATSURGBAlphaColor atsuFontColor;
ATSStyleRenderingOptions atsuRenderOptions;
GLdouble colorVector[4];
OSStatus callError;
ATSUAttributeTag aaTags[] = {kATSUFontTag, kATSUSizeTag, kATSURGBAlphaColorTag, kATSUStyleRenderingOptionsTag };
ByteCount aaSizes[] = {sizeof(ATSUFontID), sizeof(Fixed), sizeof(ATSURGBAlphaColor), sizeof(ATSStyleRenderingOptions) };
ATSUAttributeValuePtr aaValue[] = {&atsuFontID, &atsuFontSize, &atsuFontColor, &atsuRenderOptions};
//set the font index
PsychGetFontRecordFromFontNumber(winRec->textAttributes.textFontNumber, &psychFontRecord);
if(psychFontRecord==NULL)
PsychErrorExitMsg(PsychError_internal, "Failed to lookup the font from the font number");
atsuFontID=psychFontRecord->fontFMRef;
//set the font size
atsuFontSize=Long2Fix((long)(winRec->textAttributes.textSize));
//set the color
PsychCoerceColorMode(&(winRec->textAttributes.textColor));
PsychConvertColorToDoubleVector(&(winRec->textAttributes.textColor), winRec, colorVector);
atsuFontColor.red=(float)colorVector[0];
atsuFontColor.green=(float)colorVector[1];
atsuFontColor.blue=(float)colorVector[2];
atsuFontColor.alpha=(float)colorVector[3];
// Set anti-aliasing mode (on/off): Default is to leave it up to the system to decide when
// to anti-alias and when not. But this flag allows to always force anti-aliasin on or off:
atsuRenderOptions = kATSStyleNoOptions;
if(PsychPrefStateGet_TextAntiAliasing()==0) atsuRenderOptions = kATSStyleNoAntiAliasing;
if(PsychPrefStateGet_TextAntiAliasing()> 0) atsuRenderOptions = kATSStyleApplyAntiAliasing;
//assign attributes to the style object
callError=ATSUSetAttributes(atsuStyle, 4, aaTags, aaSizes, aaValue);
}
示例8: FindCollectionElements
/*
FindCollectionElements()
Non-recursively return of a list of a collection's memember elements.
HID element records hold three pointers to other element records: pPrevious, pChild and pSibling. FindCollectionElements()
operates on the theory that the members of a collection are its child and all of that child's siblings.
*/
int PsychHIDFindCollectionElements(pRecElement collectionRecord, HIDElementTypeMask elementTypeMask, pRecElement *collectionMembers, int maxListElements)
{
pRecElement currentElement;
int numElements = 0;
CFIndex i, nmax;
HIDElementTypeMask currentElementMaskValue;
CFArrayRef children = IOHIDElementGetChildren(collectionRecord);
nmax = CFArrayGetCount(children);
for (i = 0; i < nmax; i++) {
currentElement = (pRecElement)CFArrayGetValueAtIndex(children, i);
currentElementMaskValue = HIDConvertElementTypeToMask(IOHIDElementGetType(currentElement));
if (currentElementMaskValue & elementTypeMask) {
if (numElements == maxListElements) PsychErrorExitMsg(PsychError_internal, "Number of collection elements exceeds allocated storage space.");
collectionMembers[numElements] = currentElement;
++numElements;
}
}
return numElements;
}
示例9: PsychHIDOSKbQueueFlush
void PsychHIDOSKbQueueFlush(int deviceIndex)
{
if(!hidDataRef || !psychHIDKbQueueFirstPress || !psychHIDKbQueueFirstRelease || !psychHIDKbQueueLastPress || !psychHIDKbQueueLastRelease){
PsychErrorExitMsg(PsychError_user, "Queue has not been created.");
}
// Drain the queue of any unprocessed events
{
IOHIDEventStruct event;
AbsoluteTime zeroTime= {0,0};
while( (*hidDataRef->hidQueueInterface)->getNextEvent(hidDataRef->hidQueueInterface, &event, zeroTime, 0) == kIOReturnSuccess){
if ((event.longValueSize != 0) && (event.longValue != NULL)) free(event.longValue);
}
}
pthread_mutex_lock(&psychHIDKbQueueMutex);
// Zero out the scored values
{
int i;
for(i=0; i<256; i++){
psychHIDKbQueueFirstPress[i].hi=0;
psychHIDKbQueueFirstPress[i].lo=0;
psychHIDKbQueueFirstRelease[i].hi=0;
psychHIDKbQueueFirstRelease[i].lo=0;
psychHIDKbQueueLastPress[i].hi=0;
psychHIDKbQueueLastPress[i].lo=0;
psychHIDKbQueueLastRelease[i].hi=0;
psychHIDKbQueueLastRelease[i].lo=0;
}
modifierKeyState = 0;
}
pthread_mutex_unlock(&psychHIDKbQueueMutex);
}
示例10: PsychHIDOSKbQueueRelease
void PsychHIDOSKbQueueRelease(int deviceIndex)
{
if (deviceIndex < 0) {
deviceIndex = PsychHIDGetDefaultKbQueueDevice();
// Ok, deviceIndex now contains our default keyboard to use - The first suitable keyboard.
}
if ((deviceIndex < 0) || (deviceIndex >= ndevices)) {
// Out of range index:
PsychErrorExitMsg(PsychError_user, "Invalid 'deviceIndex' specified. No such device!");
}
// Keyboard queue for this deviceIndex already exists?
if (NULL == psychHIDKbQueueFirstPress[deviceIndex]) {
// No. Nothing to do then.
return;
}
// Ok, we have a keyboard queue. Stop any operation on it first:
PsychHIDOSKbQueueStop(deviceIndex);
// Release its data structures:
free(psychHIDKbQueueFirstPress[deviceIndex]);
psychHIDKbQueueFirstPress[deviceIndex] = NULL;
free(psychHIDKbQueueFirstRelease[deviceIndex]);
psychHIDKbQueueFirstRelease[deviceIndex] = NULL;
free(psychHIDKbQueueLastPress[deviceIndex]);
psychHIDKbQueueLastPress[deviceIndex] = NULL;
free(psychHIDKbQueueLastRelease[deviceIndex]);
psychHIDKbQueueLastRelease[deviceIndex] = NULL;
free(psychHIDKbQueueScanKeys[deviceIndex]);
psychHIDKbQueueScanKeys[deviceIndex] = NULL;
// Release kbqueue event buffer:
PsychHIDDeleteEventBuffer(deviceIndex);
// Done.
return;
}
示例11: PsychGetScreenDepths
void PsychGetScreenDepths(int screenNumber, PsychDepthType *depths)
{
int* x11_depths;
int i, count;
if(screenNumber>=numDisplays) PsychErrorExitMsg(PsychError_internal, "screenNumber is out of range"); //also checked within SCREENPixelSizes
x11_depths = XListDepths(displayCGIDs[screenNumber], PsychGetXScreenIdForScreen(screenNumber), &count);
if (depths && count>0) {
// Query successful: Add all values to depth struct:
for(i=0; i<count; i++) PsychAddValueToDepthStruct(x11_depths[i], depths);
XFree(x11_depths);
}
else {
// Query failed: Assume at least 32 bits is available.
printf("PTB-WARNING: Couldn't query available display depths values! Returning a made up list...\n");
fflush(NULL);
PsychAddValueToDepthStruct(32, depths);
PsychAddValueToDepthStruct(24, depths);
PsychAddValueToDepthStruct(16, depths);
}
}
示例12: ReportSysctlError
static void ReportSysctlError(int errorValue)
{
psych_bool foundError;
int sysctlErrors[]={EFAULT, EINVAL, ENOMEM, ENOTDIR, EISDIR, EOPNOTSUPP, EPERM};
int i, errorIndex, numSysctlErrors=7;
char *sysctlErrorStrings[]={"EFAULT", "EINVAL", "ENOMEM", "ENOTDIR", "EISDIR", "EOPNOTSUPP", "EPERM", "UNRECOGNIZED"};
if(errorValue == 0) return;
foundError=0;
errorIndex=7;
for(i=0; i<numSysctlErrors; i++){
if(errno==sysctlErrors[i]){
foundError=1;
errorIndex=i;
break;
}
}
PsychErrorExitMsg(PsychError_internal, sysctlErrorStrings[errorIndex]);
}
示例13: Screen
/* PsychSetupVertexColorArrays()
Helper routine, called from the different batch drawing functions of Screen():
*/
void PsychSetupVertexColorArrays(PsychWindowRecordType *windowRecord, psych_bool enable, int mc, double* colors, unsigned char *bytecolors)
{
if (enable) {
// Enable and setup whatever's used:
if (windowRecord->defaultDrawShader) {
// Shader based unclamped path:
if (colors) glTexCoordPointer(mc, GL_DOUBLE, 0, colors);
// Can't support uint8 datatype for this vertex attribute :-(
if (bytecolors) PsychErrorExitMsg(PsychError_user, "Sorry, this function can't accept matrices of uint8 type for colors\nif color clamping is disabled or high precision mode active.\n Use the double() operator to convert to double matrix.");
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glColorPointer(4, GL_DOUBLE, 0, NULL);
}
else {
// Standard path:
if (colors) glColorPointer(mc, GL_DOUBLE, 0, colors);
if (bytecolors) glColorPointer(mc, GL_UNSIGNED_BYTE, 0, bytecolors);
glEnableClientState(GL_COLOR_ARRAY);
glTexCoordPointer(4, GL_DOUBLE, 0, NULL);
}
}
else {
// Disable whatever's used:
if (windowRecord->defaultDrawShader) {
// Shader based unclamped path:
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
else {
// Standard path:
glDisableClientState(GL_COLOR_ARRAY);
}
glColorPointer(4, GL_DOUBLE, 0, NULL);
glTexCoordPointer(4, GL_DOUBLE, 0, NULL);
}
}
示例14: SCREENTextMode
PsychError SCREENTextMode(void)
{
PsychTextDrawingModeType newCopyMode;
Str255 oldCopyModeName;
char *newCopyModeName;
psych_bool doSetMode;
PsychWindowRecordType *windowRecord;
psych_bool nameError;
//all subfunctions should have these two lines.
PsychPushHelp(useString, synopsisString, seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check for valid number of arguments
PsychErrorExit(PsychRequireNumInputArgs(1));
PsychErrorExit(PsychCapNumInputArgs(2));
PsychErrorExit(PsychCapNumOutputArgs(1));
//Get the window record
PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
//Get the old copy mode & its name
PsychGetTextDrawingModeNameFromTextDrawingModeConstant(oldCopyModeName, 255, windowRecord->textAttributes.textMode);
PsychCopyOutCharArg(1, FALSE, oldCopyModeName);
//Get the copy new mode string
doSetMode= PsychAllocInCharArg(2, FALSE, &newCopyModeName);
if(doSetMode){
nameError=PsychGetTextDrawingModeConstantFromTextDrawingModeName(&newCopyMode, newCopyModeName);
if(nameError)
PsychErrorExitMsg(PsychError_user, "Invalid text copy mode. See Screen('TextModes') for a list of allowable modes");
windowRecord->textAttributes.needsRebuild|=(windowRecord->textAttributes.textMode != newCopyMode) ? TRUE : FALSE;
windowRecord->textAttributes.textMode=newCopyMode;
}
return(PsychError_none);
}
示例15: PsychHIDOSKbQueueFlush
void PsychHIDOSKbQueueFlush(int deviceIndex)
{
// Get true keyboardqueue index assigned to deviceIndex from original user provided deviceIndex:
deviceIndex = PsychHIDOSGetKbQueueDevice(deviceIndex, NULL);
// Does Keyboard queue for this deviceIndex already exist?
if (NULL == psychHIDKbQueueFirstPress[deviceIndex]) {
// No. Bad bad...
printf("PsychHID-ERROR: Tried to flush non-existent keyboard queue for deviceIndex %i! Call KbQueueCreate first!\n", deviceIndex);
PsychErrorExitMsg(PsychError_user, "Invalid keyboard 'deviceIndex' specified. No queue for that device yet!");
}
// Clear out current state for this queue:
PsychLockMutex(&KbQueueMutex);
memset(psychHIDKbQueueFirstPress[deviceIndex] , 0, (256 * sizeof(double)));
memset(psychHIDKbQueueFirstRelease[deviceIndex] , 0, (256 * sizeof(double)));
memset(psychHIDKbQueueLastPress[deviceIndex] , 0, (256 * sizeof(double)));
memset(psychHIDKbQueueLastRelease[deviceIndex] , 0, (256 * sizeof(double)));
modifierKeyState[deviceIndex] = 0;
PsychUnlockMutex(&KbQueueMutex);
return;
}