Beispiel #1
1
bool audio::orchestra::api::Core::open(uint32_t _device,
                                       audio::orchestra::mode _mode,
                                       uint32_t _channels,
                                       uint32_t _firstChannel,
                                       uint32_t _sampleRate,
                                       audio::format _format,
                                       uint32_t *_bufferSize,
                                       const audio::orchestra::StreamOptions& _options) {
	// Get device ID
	uint32_t nDevices = getDeviceCount();
	if (nDevices == 0) {
		// This should not happen because a check is made before this function is called.
		ATA_ERROR("no devices found!");
		return false;
	}
	if (_device >= nDevices) {
		// This should not happen because a check is made before this function is called.
		ATA_ERROR("device ID is invalid!");
		return false;
	}
	AudioDeviceID deviceList[ nDevices/2 ];
	uint32_t dataSize = sizeof(AudioDeviceID) * nDevices/2;
	AudioObjectPropertyAddress property = {
		kAudioHardwarePropertyDevices,
		kAudioObjectPropertyScopeGlobal,
		kAudioObjectPropertyElementMaster
	};
	OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
	                                             &property,
	                                             0,
	                                             nullptr,
	                                             &dataSize,
	                                             (void *) &deviceList);
	if (result != noErr) {
		ATA_ERROR("OS-X system error getting device IDs.");
		return false;
	}
	AudioDeviceID id = deviceList[ _device/2 ];
	// Setup for stream mode.
	bool isInput = false;
	if (_mode == audio::orchestra::mode_input) {
		isInput = true;
		property.mScope = kAudioDevicePropertyScopeInput;
	} else {
		property.mScope = kAudioDevicePropertyScopeOutput;
	}
	// Get the stream "configuration".
	AudioBufferList	*bufferList = nil;
	dataSize = 0;
	property.mSelector = kAudioDevicePropertyStreamConfiguration;
	result = AudioObjectGetPropertyDataSize(id, &property, 0, nullptr, &dataSize);
	if (    result != noErr
	     || dataSize == 0) {
		ATA_ERROR("system error (" << getErrorCode(result) << ") getting stream configuration info for device (" << _device << ").");
		return false;
	}
	// Allocate the AudioBufferList.
	bufferList = (AudioBufferList *) malloc(dataSize);
	if (bufferList == nullptr) {
		ATA_ERROR("memory error allocating AudioBufferList.");
		return false;
	}
	result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, bufferList);
	if (    result != noErr
	     || dataSize == 0) {
		ATA_ERROR("system error (" << getErrorCode(result) << ") getting stream configuration for device (" << _device << ").");
		return false;
	}
	// Search for one or more streams that contain the desired number of
	// channels. CoreAudio devices can have an arbitrary number of
	// streams and each stream can have an arbitrary number of channels.
	// For each stream, a single buffer of interleaved samples is
	// provided. orchestra prefers the use of one stream of interleaved
	// data or multiple consecutive single-channel streams.	However, we
	// now support multiple consecutive multi-channel streams of
	// interleaved data as well.
	uint32_t iStream, offsetCounter = _firstChannel;
	uint32_t nStreams = bufferList->mNumberBuffers;
	bool monoMode = false;
	bool foundStream = false;
	// First check that the device supports the requested number of
	// channels.
	uint32_t deviceChannels = 0;
	for (iStream=0; iStream<nStreams; iStream++) {
		deviceChannels += bufferList->mBuffers[iStream].mNumberChannels;
	}
	if (deviceChannels < (_channels + _firstChannel)) {
		free(bufferList);
		ATA_ERROR("the device (" << _device << ") does not support the requested channel count.");
		return false;
	}
	// Look for a single stream meeting our needs.
	uint32_t firstStream, streamCount = 1, streamChannels = 0, channelOffset = 0;
	for (iStream=0; iStream<nStreams; iStream++) {
		streamChannels = bufferList->mBuffers[iStream].mNumberChannels;
		if (streamChannels >= _channels + offsetCounter) {
			firstStream = iStream;
			channelOffset = offsetCounter;
			foundStream = true;
			break;
		}
		if (streamChannels > offsetCounter) {
			break;
		}
		offsetCounter -= streamChannels;
	}
	// If we didn't find a single stream above, then we should be able
	// to meet the channel specification with multiple streams.
	if (foundStream == false) {
		monoMode = true;
		offsetCounter = _firstChannel;
		for (iStream=0; iStream<nStreams; iStream++) {
			streamChannels = bufferList->mBuffers[iStream].mNumberChannels;
			if (streamChannels > offsetCounter) {
				break;
			}
			offsetCounter -= streamChannels;
		}
		firstStream = iStream;
		channelOffset = offsetCounter;
		int32_t channelCounter = _channels + offsetCounter - streamChannels;
		if (streamChannels > 1) {
			monoMode = false;
		}
		while (channelCounter > 0) {
			streamChannels = bufferList->mBuffers[++iStream].mNumberChannels;
			if (streamChannels > 1) {
				monoMode = false;
			}
			channelCounter -= streamChannels;
			streamCount++;
		}
	}
	free(bufferList);
	// Determine the buffer size.
	AudioValueRange	bufferRange;
	dataSize = sizeof(AudioValueRange);
	property.mSelector = kAudioDevicePropertyBufferFrameSizeRange;
	result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, &bufferRange);
	if (result != noErr) {
		ATA_ERROR("system error (" << getErrorCode(result) << ") getting buffer size range for device (" << _device << ").");
		return false;
	}
	if (bufferRange.mMinimum > *_bufferSize) {
		*_bufferSize = (uint64_t) bufferRange.mMinimum;
	} else if (bufferRange.mMaximum < *_bufferSize) {
		*_bufferSize = (uint64_t) bufferRange.mMaximum;
	}
	if (_options.flags.m_minimizeLatency == true) {
		*_bufferSize = (uint64_t) bufferRange.mMinimum;
	}
	// Set the buffer size.	For multiple streams, I'm assuming we only
	// need to make this setting for the master channel.
	uint32_t theSize = (uint32_t) *_bufferSize;
	dataSize = sizeof(uint32_t);
	property.mSelector = kAudioDevicePropertyBufferFrameSize;
	result = AudioObjectSetPropertyData(id, &property, 0, nullptr, dataSize, &theSize);
	if (result != noErr) {
		ATA_ERROR("system error (" << getErrorCode(result) << ") setting the buffer size for device (" << _device << ").");
		return false;
	}
	// If attempting to setup a duplex stream, the bufferSize parameter
	// MUST be the same in both directions!
	*_bufferSize = theSize;
	if (    m_mode == audio::orchestra::mode_output
	     && _mode == audio::orchestra::mode_input
	     && *_bufferSize != m_bufferSize) {
		ATA_ERROR("system error setting buffer size for duplex stream on device (" << _device << ").");
		return false;
	}
	m_bufferSize = *_bufferSize;
	m_nBuffers = 1;
	// Check and if necessary, change the sample rate for the device.
	double nominalRate;
	dataSize = sizeof(double);
	property.mSelector = kAudioDevicePropertyNominalSampleRate;
	result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, &nominalRate);
	if (result != noErr) {
		ATA_ERROR("system error (" << getErrorCode(result) << ") getting current sample rate.");
		return false;
	}
	// Only change the sample rate if off by more than 1 Hz.
	if (fabs(nominalRate - (double)_sampleRate) > 1.0) {
		// Set a property listener for the sample rate change
		double reportedRate = 0.0;
		AudioObjectPropertyAddress tmp = { kAudioDevicePropertyNominalSampleRate, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
		result = AudioObjectAddPropertyListener(id, &tmp, &rateListener, (void *) &reportedRate);
		if (result != noErr) {
			ATA_ERROR("system error (" << getErrorCode(result) << ") setting sample rate property listener for device (" << _device << ").");
			return false;
		}
		nominalRate = (double) _sampleRate;
		result = AudioObjectSetPropertyData(id, &property, 0, nullptr, dataSize, &nominalRate);
		if (result != noErr) {
			ATA_ERROR("system error (" << getErrorCode(result) << ") setting sample rate for device (" << _device << ").");
			return false;
		}
		// Now wait until the reported nominal rate is what we just set.
		uint32_t microCounter = 0;
		while (reportedRate != nominalRate) {
			microCounter += 5000;
			if (microCounter > 5000000) {
				break;
			}
			std::this_thread::sleep_for(std::chrono::milliseconds(5));
		}
		// Remove the property listener.
		AudioObjectRemovePropertyListener(id, &tmp, &rateListener, (void *) &reportedRate);
		if (microCounter > 5000000) {
			ATA_ERROR("timeout waiting for sample rate update for device (" << _device << ").");
			return false;
		}
	}
	// Now set the stream format for all streams.	Also, check the
	// physical format of the device and change that if necessary.
	AudioStreamBasicDescription	description;
	dataSize = sizeof(AudioStreamBasicDescription);
	property.mSelector = kAudioStreamPropertyVirtualFormat;
	result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, &description);
	if (result != noErr) {
		ATA_ERROR("system error (" << getErrorCode(result) << ") getting stream format for device (" << _device << ").");
		return false;
	}
	// Set the sample rate and data format id.	However, only make the
	// change if the sample rate is not within 1.0 of the desired
	// rate and the format is not linear pcm.
	bool updateFormat = false;
	if (fabs(description.mSampleRate - (double)_sampleRate) > 1.0) {
		description.mSampleRate = (double) _sampleRate;
		updateFormat = true;
	}
	if (description.mFormatID != kAudioFormatLinearPCM) {
		description.mFormatID = kAudioFormatLinearPCM;
		updateFormat = true;
	}
	if (updateFormat) {
		result = AudioObjectSetPropertyData(id, &property, 0, nullptr, dataSize, &description);
		if (result != noErr) {
			ATA_ERROR("system error (" << getErrorCode(result) << ") setting sample rate or data format for device (" << _device << ").");
			return false;
		}
	}
	// Now check the physical format.
	property.mSelector = kAudioStreamPropertyPhysicalFormat;
	result = AudioObjectGetPropertyData(id, &property, 0, nullptr,	&dataSize, &description);
	if (result != noErr) {
		ATA_ERROR("system error (" << getErrorCode(result) << ") getting stream physical format for device (" << _device << ").");
		return false;
	}
	//std::cout << "Current physical stream format:" << std::endl;
	//std::cout << "	 mBitsPerChan = " << description.mBitsPerChannel << std::endl;
	//std::cout << "	 aligned high = " << (description.mFormatFlags & kAudioFormatFlagIsAlignedHigh) << ", isPacked = " << (description.mFormatFlags & kAudioFormatFlagIsPacked) << std::endl;
	//std::cout << "	 bytesPerFrame = " << description.mBytesPerFrame << std::endl;
	//std::cout << "	 sample rate = " << description.mSampleRate << std::endl;
	if (    description.mFormatID != kAudioFormatLinearPCM
	     || description.mBitsPerChannel < 16) {
		description.mFormatID = kAudioFormatLinearPCM;
		//description.mSampleRate = (double) sampleRate;
		AudioStreamBasicDescription	testDescription = description;
		uint32_t formatFlags;
		// We'll try higher bit rates first and then work our way down.
		std::vector< std::pair<uint32_t, uint32_t>	> physicalFormats;
		formatFlags = (description.mFormatFlags | kLinearPCMFormatFlagIsFloat) & ~kLinearPCMFormatFlagIsSignedInteger;
		physicalFormats.push_back(std::pair<float, uint32_t>(32, formatFlags));
		formatFlags = (description.mFormatFlags | kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked) & ~kLinearPCMFormatFlagIsFloat;
		physicalFormats.push_back(std::pair<float, uint32_t>(32, formatFlags));
		physicalFormats.push_back(std::pair<float, uint32_t>(24, formatFlags));	 // 24-bit packed
		formatFlags &= ~(kAudioFormatFlagIsPacked | kAudioFormatFlagIsAlignedHigh);
		physicalFormats.push_back(std::pair<float, uint32_t>(24.2, formatFlags)); // 24-bit in 4 bytes, aligned low
		formatFlags |= kAudioFormatFlagIsAlignedHigh;
		physicalFormats.push_back(std::pair<float, uint32_t>(24.4, formatFlags)); // 24-bit in 4 bytes, aligned high
		formatFlags = (description.mFormatFlags | kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked) & ~kLinearPCMFormatFlagIsFloat;
		physicalFormats.push_back(std::pair<float, uint32_t>(16, formatFlags));
		physicalFormats.push_back(std::pair<float, uint32_t>(8, formatFlags));
		bool setPhysicalFormat = false;
		for(uint32_t i=0; i<physicalFormats.size(); i++) {
			testDescription = description;
			testDescription.mBitsPerChannel = (uint32_t) physicalFormats[i].first;
			testDescription.mFormatFlags = physicalFormats[i].second;
			if (    (24 == (uint32_t)physicalFormats[i].first)
			     && ~(physicalFormats[i].second & kAudioFormatFlagIsPacked)) {
				testDescription.mBytesPerFrame =	4 * testDescription.mChannelsPerFrame;
			} else {
				testDescription.mBytesPerFrame =	testDescription.mBitsPerChannel/8 * testDescription.mChannelsPerFrame;
			}
			testDescription.mBytesPerPacket = testDescription.mBytesPerFrame * testDescription.mFramesPerPacket;
			result = AudioObjectSetPropertyData(id, &property, 0, nullptr, dataSize, &testDescription);
			if (result == noErr) {
				setPhysicalFormat = true;
				//std::cout << "Updated physical stream format:" << std::endl;
				//std::cout << "	 mBitsPerChan = " << testDescription.mBitsPerChannel << std::endl;
				//std::cout << "	 aligned high = " << (testDescription.mFormatFlags & kAudioFormatFlagIsAlignedHigh) << ", isPacked = " << (testDescription.mFormatFlags & kAudioFormatFlagIsPacked) << std::endl;
				//std::cout << "	 bytesPerFrame = " << testDescription.mBytesPerFrame << std::endl;
				//std::cout << "	 sample rate = " << testDescription.mSampleRate << std::endl;
				break;
			}
		}
		if (!setPhysicalFormat) {
			ATA_ERROR("system error (" << getErrorCode(result) << ") setting physical data format for device (" << _device << ").");
			return false;
		}
	} // done setting virtual/physical formats.
	// Get the stream / device latency.
	uint32_t latency;
	dataSize = sizeof(uint32_t);
	property.mSelector = kAudioDevicePropertyLatency;
	if (AudioObjectHasProperty(id, &property) == true) {
		result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, &latency);
		if (result == kAudioHardwareNoError) {
			m_latency[ _mode ] = latency;
		} else {
			ATA_ERROR("system error (" << getErrorCode(result) << ") getting device latency for device (" << _device << ").");
			return false;
		}
	}
	// Byte-swapping: According to AudioHardware.h, the stream data will
	// always be presented in native-endian format, so we should never
	// need to byte swap.
	m_doByteSwap[modeToIdTable(_mode)] = false;
	// From the CoreAudio documentation, PCM data must be supplied as
	// 32-bit floats.
	m_userFormat = _format;
	m_deviceFormat[modeToIdTable(_mode)] = audio::format_float;
	if (streamCount == 1) {
		m_nDeviceChannels[modeToIdTable(_mode)] = description.mChannelsPerFrame;
	} else {
		// multiple streams
		m_nDeviceChannels[modeToIdTable(_mode)] = _channels;
	}
	m_nUserChannels[modeToIdTable(_mode)] = _channels;
	m_channelOffset[modeToIdTable(_mode)] = channelOffset;	// offset within a CoreAudio stream
	m_deviceInterleaved[modeToIdTable(_mode)] = true;
	if (monoMode == true) {
		m_deviceInterleaved[modeToIdTable(_mode)] = false;
	}
	// Set flags for buffer conversion.
	m_doConvertBuffer[modeToIdTable(_mode)] = false;
	if (m_userFormat != m_deviceFormat[modeToIdTable(_mode)]) {
		m_doConvertBuffer[modeToIdTable(_mode)] = true;
	}
	if (m_nUserChannels[modeToIdTable(_mode)] < m_nDeviceChannels[modeToIdTable(_mode)]) {
		m_doConvertBuffer[modeToIdTable(_mode)] = true;
	}
	if (streamCount == 1) {
		if (    m_nUserChannels[modeToIdTable(_mode)] > 1
		     && m_deviceInterleaved[modeToIdTable(_mode)] == false) {
			m_doConvertBuffer[modeToIdTable(_mode)] = true;
		}
	} else if (monoMode) {
		m_doConvertBuffer[modeToIdTable(_mode)] = true;
	}
	m_private->iStream[modeToIdTable(_mode)] = firstStream;
	m_private->nStreams[modeToIdTable(_mode)] = streamCount;
	m_private->id[modeToIdTable(_mode)] = id;
	// Allocate necessary internal buffers.
	uint64_t bufferBytes;
	bufferBytes = m_nUserChannels[modeToIdTable(_mode)] * *_bufferSize * audio::getFormatBytes(m_userFormat);
	//	m_userBuffer[modeToIdTable(_mode)] = (char *) calloc(bufferBytes, 1);
	m_userBuffer[modeToIdTable(_mode)].resize(bufferBytes, 0);
	if (m_userBuffer[modeToIdTable(_mode)].size() == 0) {
		ATA_ERROR("error allocating user buffer memory.");
		goto error;
	}
	// If possible, we will make use of the CoreAudio stream buffers as
	// "device buffers".	However, we can't do this if using multiple
	// streams.
	if (    m_doConvertBuffer[modeToIdTable(_mode)]
	     && m_private->nStreams[modeToIdTable(_mode)] > 1) {
		bool makeBuffer = true;
		bufferBytes = m_nDeviceChannels[modeToIdTable(_mode)] * audio::getFormatBytes(m_deviceFormat[modeToIdTable(_mode)]);
		if (_mode == audio::orchestra::mode_input) {
			if (    m_mode == audio::orchestra::mode_output
			     && m_deviceBuffer) {
				uint64_t bytesOut = m_nDeviceChannels[0] * audio::getFormatBytes(m_deviceFormat[0]);
				if (bufferBytes <= bytesOut) {
					makeBuffer = false;
				}
			}
		}
		if (makeBuffer) {
			bufferBytes *= *_bufferSize;
			if (m_deviceBuffer) {
				free(m_deviceBuffer);
				m_deviceBuffer = nullptr;
			}
			m_deviceBuffer = (char *) calloc(bufferBytes, 1);
			if (m_deviceBuffer == nullptr) {
				ATA_ERROR("error allocating device buffer memory.");
				goto error;
			}
		}
	}
	m_sampleRate = _sampleRate;
	m_device[modeToIdTable(_mode)] = _device;
	m_state = audio::orchestra::state::stopped;
	ATA_VERBOSE("Set state as stopped");
	// Setup the buffer conversion information structure.
	if (m_doConvertBuffer[modeToIdTable(_mode)]) {
		if (streamCount > 1) {
			setConvertInfo(_mode, 0);
		} else {
			setConvertInfo(_mode, channelOffset);
		}
	}
	if (    _mode == audio::orchestra::mode_input
	     && m_mode == audio::orchestra::mode_output
	     && m_device[0] == _device) {
		// Only one callback procedure per device.
		m_mode = audio::orchestra::mode_duplex;
	} else {
#if defined(MAC_OS_X_VERSION_10_5) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
		result = AudioDeviceCreateIOProcID(id, &audio::orchestra::api::Core::callbackEvent, this, &m_private->procId[modeToIdTable(_mode)]);
#else
		// deprecated in favor of AudioDeviceCreateIOProcID()
		result = AudioDeviceAddIOProc(id, &audio::orchestra::api::Core::callbackEvent, this);
#endif
		if (result != noErr) {
			ATA_ERROR("system error setting callback for device (" << _device << ").");
			goto error;
		}
		if (    m_mode == audio::orchestra::mode_output
		     && _mode == audio::orchestra::mode_input) {
			m_mode = audio::orchestra::mode_duplex;
		} else {
			m_mode = _mode;
		}
	}
	// Setup the device property listener for over/underload.
	property.mSelector = kAudioDeviceProcessorOverload;
	result = AudioObjectAddPropertyListener(id, &property, &audio::orchestra::api::Core::xrunListener, this);
	return true;
error:
	m_userBuffer[0].clear();
	m_userBuffer[1].clear();
	if (m_deviceBuffer) {
		free(m_deviceBuffer);
		m_deviceBuffer = 0;
	}
	m_state = audio::orchestra::state::closed;
	ATA_VERBOSE("Set state as closed");
	return false;
}
Beispiel #2
0
void testCalculate() {
	char str[64];
	int len=0, i, k=0;
	DParam dp;
	char strbuff[256] = "f(x)=-x^2";
	Function *f = NULL;
	double val[1];

	dp.values = val;

	f = (Function*)malloc(sizeof(Function));
	f->prefix = NULL;
	f->domain = NULL;
	f->criterias = NULL;
	f->str = NULL;
	f->len = 0;
	f->variableNode = NULL;
	f->numVarNode = 0;
	f->valLen = 0;

	//printf("Input function: ");
	//scanf("%s", &strbuff);
	len = strlen(strbuff);
	parseFunction(strbuff, len, f);
	if(getErrorCode() != NMATH_NO_ERROR) {
		printError(getErrorColumn(), getErrorCode());
		releaseFunct(f);
		free(f);
		return;
	} 

	if( f->valLen==0 ) {
		printf("This expression is not a function due to variables not determined.\n");
	}

		
	dp.error = NMATH_NO_ERROR;
	dp.t = f->prefix->list[0];
	dp.variables[0] = 'x';
	dp.values[0] = 2;
	//reduce_t(&dp);
	calc_t(&dp);
	if(dp.error == NMATH_NO_ERROR) {
		k = 0;
		printNMAST(dp.t, 0);
		printf("\n");
		toString(dp.t, str, &k, 64);
		f->prefix->list[0] = dp.t;
		printf("Calculating result: %lf\n", dp.retv);
	}

	//release token list

	releaseFunct(f);
	clearPool();
	free(f);
}
QString ErrorItem::toString() const
{
   QString str = getCodeLocation().toString();
   if(!str.isEmpty()){
      str += QLatin1Char(' ');
   }
   str += getDescription();
   if(getErrorCode() != -1){
      str += QString(" code : %1").arg(getErrorCode());
   }
   return str;
}
Beispiel #4
0
void testUTF(Function *f) {
	char str[64];
	int len, i, k=0;
	DParam dp;
	TokenList tokens;

	str[0] = 0x31;
	str[1] = 0x2B;
	str[2] = 0xCF;
	str[3] = 0x80;
	len = 4;

	//Lexer
	tokens.loggedSize = len;
	tokens.list = (Token*)malloc(sizeof(Token) * tokens.loggedSize);
	tokens.size = 0;
	/* build the tokens list from the input string */
	lexicalAnalysisUTF8(str, len, &tokens, 0);

	if( getErrorCode() == NMATH_NO_ERROR ) {
		printf("lexical analysis successfully, number of token: %d\n", tokens.size);

		parseExpression(&tokens, &k, f);

		if( getErrorCode() == NMATH_NO_ERROR ) {
			dp.error = NMATH_NO_ERROR;
			dp.t = f->prefix->list[0];
			reduce_t(&dp);
			if(dp.error == NMATH_NO_ERROR) {
				k = 0;
				printNMAST(dp.t, 0);
				printf("\n");
				toString(dp.t, str, &k, 64);
				f->prefix->list[0] = dp.t;
				printf("Calculating result: %s\n", str);
			}
		}

		//release token list
			
		for(i = 0; i<tokens.size; i++){
			printf("%X ", tokens.list[i].type);
		}

		printf("\n");
		free(tokens.list);
	}

	if(getErrorCode() != NMATH_NO_ERROR) {
		printError(getErrorColumn(), getErrorCode());
	}
}
Beispiel #5
0
int testDerivative() {
	DParam d;
	int error;
	double vars[] = {4, 1};
	double ret;
	char dstr[64];
	int l = 0;
	Function *f;

	f = (Function*)malloc(sizeof(Function));
	f->prefix = NULL;
	f->domain = NULL;
	f->criterias = NULL;
	f->str = NULL;
	f->len = 0;
	f->variableNode = NULL;
	f->numVarNode = 0;
	f->valLen = 0;

	printf("Input function: ");
	scanf("%s", &dstr);
	l = strlen(dstr);
	parseFunction(dstr, l, f);
	if(getErrorCode() != NMATH_NO_ERROR) {
		printError(getErrorColumn(), getErrorCode());
		releaseFunct(f);
		free(f);
		return getErrorCode();
	} 

	if( f->valLen==0 ) {
		printf("This expression is not a function due to variables not determined.\n");
	}
	
	d.t = f->prefix->list[0];
	d.error = 0;
	d.returnValue = NULL;
	d.variables[0] = 'x';

	derivative(&d);

	toString(d.returnValue, dstr, &l, 64);
	printf("f' = %s\n", dstr);
	clearTree(&(d.returnValue));

	releaseFunct(f);
	clearPool();
	free(f);

	return 0;
}
Beispiel #6
0
bool NetMgr::loadData()
{
    //加载所有用户数据
    unsigned long long curID = 0;
    do
    {
        auto sql = BaseInfo_LOAD(curID);
        auto result = DBMgr::getRef().infoQuery(sql);
        if (result->getErrorCode() != QEC_SUCCESS)
        {
            LOGE("load contact error. curID:" << curID << ", err=" << result->getLastError());
            return false;
        }
        if (!result->haveRow())
        {
            break;
        }
        auto mapInfo = BaseInfo_FETCH(result);
        for (auto & kv : mapInfo)
        {
            if (kv.first > _genID.getCurObjID())
            {
                _genID.setCurObjID(kv.first);
            }
            createUser(kv.second);
        }
        curID += mapInfo.size();
    } while (true);
    return true;
}
Beispiel #7
0
void testReuseFunction(Function *f) {
	double val;
	int error;
	double var[1] = {10};

	releaseFunct(f);
	parseFunction("f(x)=x + 1/2", 12, f);
	if(getErrorCode() != NMATH_NO_ERROR) {
		printError(getErrorColumn(), getErrorCode());
		releaseFunct(f);
		free(f);
	}

	val = calc(f, var, 1, &error);
	printf("Ret = %lf \n", val );

}
Beispiel #8
0
void Exception::formatEntry(std::ostream &stream, size_t depth) const {
	LocaleUtils::CLocaleScope localeScope(stream);

	if (depth > maxDepth_) {
		return;
	}

	if (hasTypeName(depth)) {
		formatTypeName(stream, depth);
	}
	else {
		stream << "(Unknown exception)";
	}

	if (hasFileName(depth)) {
		stream << " ";
		formatFileName(stream, depth);
	}

	if (hasFunctionName(depth)) {
		stream << " ";
		formatFunctionName(stream, depth);
	}

	if (hasLineNumber(depth)) {
		stream << " line=" << getLineNumber(depth);
	}

	if (hasErrorCode(depth)) {
		stream << " [";

		if (!hasErrorCodeName(depth)) {
			stream << "Code:";
		}

		stream << getErrorCode(depth);

		if (hasErrorCodeName(depth)) {
			stream << ":";
			formatErrorCodeName(stream, depth);
		}

		stream << "]";
	}

	if (hasMessage(depth)) {
		stream << " " ;
		formatMessage(stream, depth);
	}
#ifdef UTIL_STACK_TRACE_ENABLED

	if (hasStackTrace(depth)) {
		stream << " : " ;
		formatStackTrace(stream, depth);
	}
#endif
}
Beispiel #9
0
// copy common fields from xbee response to target response
void XBeeResponse::setCommon(XBeeResponse &target) {
	target.setApiId(getApiId());
	target.setAvailable(isAvailable());
	target.setChecksum(getChecksum());
	target.setErrorCode(getErrorCode());
	target.setFrameLength(getFrameDataLength());
	target.setMsbLength(getMsbLength());
	target.setLsbLength(getLsbLength());
}
Beispiel #10
0
GTEST_TEST(ExpectedTest, failure_error_str_contructor_initialization) {
  const auto msg =
      std::string{"\"#$%&'()*+,-./089:;<[=]>\" is it a valid error message?"};
  auto expected = Expected<std::string, TestError>::failure(msg);
  EXPECT_FALSE(expected);
  EXPECT_TRUE(expected.isError());
  EXPECT_EQ(expected.getErrorCode(), TestError::Some);
  auto fullMsg = expected.getError().getFullMessage();
  EXPECT_PRED2(stringContains, fullMsg, msg);
}
void getWholeSiteStatus(const ComType com, const GetWholeSiteStatus *data) {
	uint32_t status = 0;
	
	//Treadmill
	utilShiftBit(getFirstTreadmill()->isRunning, 	0, &status);
	utilShiftBit(getSecondTreadmill()->isRunning, 	1, &status);
	utilShiftBit(getThirdTreadmill()->isRunning, 	2, &status);
	utilShiftBit(getFourthTreadmill()->isRunning, 	3, &status);
	
	//Tool
	utilShiftBit(getFirstTool()->isRunning,			4, &status);
	utilShiftBit(getSecondTool()->isRunning,		5, &status);
	
	//LightBarriers
	utilShiftBit(getFirstLightBarrier()->isBlocked,	6, &status);
	utilShiftBit(getSecondLightBarrier()->isBlocked,7, &status);
	utilShiftBit(getThirdLightBarrier()->isBlocked,	8, &status);
	utilShiftBit(getFourthLightBarrier()->isBlocked,9, &status);
	utilShiftBit(getFifthLightBarrier()->isBlocked,	10, &status);
	
	//Pusher
	Pusher *pusher = getFirstPusher();
	uint8_t isActive = pusher->runningDirection == BACKWARDS ? 1 : 0;
	utilShiftBit(isActive, 							11, &status);
	
	isActive = pusher->runningDirection == FORWARDS ? 1 : 0;
	utilShiftBit(isActive, 							12, &status);
	
	utilShiftBit(pusher->isFrontTriggerActivated,	13, &status);
	utilShiftBit(pusher->isBackTriggerActivated,	14, &status);
	
	pusher = getSecondPusher();
	isActive = pusher->runningDirection == BACKWARDS ? 1 : 0;
	utilShiftBit(isActive, 							15, &status);
	
	isActive = pusher->runningDirection == FORWARDS ? 1 : 0;
	utilShiftBit(isActive, 							16, &status);
	
	utilShiftBit(pusher->isFrontTriggerActivated,	17, &status);
	utilShiftBit(pusher->isBackTriggerActivated,	18, &status);
	
	utilShiftByte(getErrorCode(), 					19, &status);

	//Now build and send response.
	GetWholeSiteStatusReturn response;
	
	response.header = data->header;
	response.header.length = sizeof(GetWholeSiteStatusReturn);
	response.status = status;

	send_blocking_with_timeout(&response, sizeof(GetWholeSiteStatusReturn), com);
}
Beispiel #12
0
enum audio::orchestra::error audio::orchestra::api::Core::stopStream() {
	if (verifyStream() != audio::orchestra::error_none) {
		return audio::orchestra::error_fail;
	}
	if (m_state == audio::orchestra::state::stopped) {
		ATA_ERROR("the stream is already stopped!");
		return audio::orchestra::error_warning;
	}
	OSStatus result = noErr;
	if (    m_mode == audio::orchestra::mode_output
	     || m_mode == audio::orchestra::mode_duplex) {
		if (m_private->drainCounter == 0) {
			std::unique_lock<std::mutex> lck(m_mutex);
			m_private->drainCounter = 2;
			m_private->condition.wait(lck);
		}
		result = AudioDeviceStop(m_private->id[0], &audio::orchestra::api::Core::callbackEvent);
		if (result != noErr) {
			ATA_ERROR("system error (" << getErrorCode(result) << ") stopping callback procedure on device (" << m_device[0] << ").");
			goto unlock;
		}
	}
	if (    m_mode == audio::orchestra::mode_input
	     || (    m_mode == audio::orchestra::mode_duplex
	          && m_device[0] != m_device[1])) {
		result = AudioDeviceStop(m_private->id[1], &audio::orchestra::api::Core::callbackEvent);
		if (result != noErr) {
			ATA_ERROR("system error (" << getErrorCode(result) << ") stopping input callback procedure on device (" << m_device[1] << ").");
			goto unlock;
		}
	}
	m_state = audio::orchestra::state::stopped;
	ATA_VERBOSE("Set state as stopped");
unlock:
	if (result == noErr) {
		return audio::orchestra::error_none;
	}
	return audio::orchestra::error_systemError;
}
Beispiel #13
0
void TroopInformationView::onRequestCallback(cocos2d::CCObject *obj) {
    auto ret = dynamic_cast<NetResult*>(obj);
    if (!ret || ret->getErrorCode() != Error_OK) {
        // todo : parse error
        return;
    }
    
    auto info = dynamic_cast<CCDictionary*>(ret->getData());
    int totalTroops = 0;
    if (info && info->objectForKey("uuid")) {
        string uuid = info->valueForKey("uuid")->getCString();
        if (!uuid.empty()) {
            auto infoNode = TroopInformation::create(info);
            auto bgSize = m_tileBg->getContentSize();
            auto pos = ccp(bgSize.width / 2, bgSize.height - 40);
            infoNode->setPosition(pos);
            m_subNode->addChild(infoNode);
            
            if(info->objectForKey("totalTroops")){
                totalTroops = info->valueForKey("totalTroops")->intValue();
            }
            if(info->objectForKey("members")){
                CCArray* arr = dynamic_cast<CCArray*>(info->objectForKey("members"));
                if (arr!=NULL) {
                    int num = arr->count();
                    for (int i=0; i<num; i++) {
                        auto tDic = _dict(arr->objectAtIndex(i));
                        if (tDic && tDic->objectForKey("totalTroops")) {
                            totalTroops += tDic->valueForKey("totalTroops")->intValue();
                        }
                    }
                }
            }
            std::string titleStr = _lang("108585");//_lang("108638");
//            titleStr.append(" ");
//            if (totalTroops!=0) {
//                titleStr.append(CCCommonUtils::getResourceStr(totalTroops).c_str());
//            }
            m_title->setString(titleStr);
        }
    }
    if(totalTroops<=0){
        Label* label = Label::create("", "", 22);
        label->setDimensions(550, 200);
        label->setColor({255,190,0});
        label->setString(_lang("140174"));
        label->setPosition(m_subNode->getContentSize().width/2, m_subNode->getContentSize().height/2);
        m_subNode->addChild(label);
    }
}
Beispiel #14
0
GTEST_TEST(ExpectedTest, nested_errors_example) {
  const auto msg = std::string{"Write a good error message"};
  auto firstFailureSource = [&msg]() -> Expected<std::vector<int>, TestError> {
    return createError(TestError::Semantic, msg);
  };
  auto giveMeNestedError = [&]() -> Expected<std::vector<int>, TestError> {
    auto ret = firstFailureSource();
    ret.isError();
    return createError(TestError::Runtime, msg, ret.takeError());
  };
  auto ret = giveMeNestedError();
  EXPECT_FALSE(ret);
  ASSERT_TRUE(ret.isError());
  EXPECT_EQ(ret.getErrorCode(), TestError::Runtime);
  ASSERT_TRUE(ret.getError().hasUnderlyingError());
  EXPECT_PRED2(stringContains, ret.getError().getFullMessage(), msg);
}
Beispiel #15
0
bool UserManager::init()
{
	auto build = UserInfo_BUILD();
	if (DBManager::getRef().infoQuery(build[0])->getErrorCode() != QEC_SUCCESS)
	{
		if (DBManager::getRef().infoQuery(build[1])->getErrorCode() != QEC_SUCCESS)
		{
			LOGE("create table error. sql=" << build[1]);
			return false;
		}
	}

	for (size_t i = 2; i < build.size(); i++)
	{
		DBManager::getRef().infoQuery(build[i]);
	}

	
	
	//加载所有用户数据
	unsigned long long curID = 0;
	do
	{
		auto sql = UserInfo_LOAD(curID);
		auto result = DBManager::getRef().infoQuery(sql);
		if (result->getErrorCode() != QEC_SUCCESS)
		{
			LOGE("load contact error. curID:" << curID << ", err=" << result->getLastError());
			return false;
		}
		if (!result->haveRow())
		{
			break;
		}
		auto mapInfo = UserInfo_FETCH(result);
		for (auto & kv : mapInfo)
		{
			addUser(kv.second);
		}
		curID += mapInfo.size();
	} while (true);


	return true;
}
Beispiel #16
0
GTEST_TEST(ExpectedTest, createError_example) {
  auto giveMeDozen = [](bool valid) -> LocalExpected<int> {
    if (valid) {
      return 50011971;
    }
    return createError(TestError::Logical,
                       "an error message is supposed to be here");
  };
  auto v = giveMeDozen(true);
  EXPECT_TRUE(v);
  ASSERT_FALSE(v.isError());
  EXPECT_EQ(*v, 50011971);

  auto errV = giveMeDozen(false);
  EXPECT_FALSE(errV);
  ASSERT_TRUE(errV.isError());
  EXPECT_EQ(errV.getErrorCode(), TestError::Logical);
}
Beispiel #17
0
GTEST_TEST(ExpectedTest, error_handling_example) {
  auto failureSource = []() -> Expected<std::vector<int>, TestError> {
    return createError(TestError::Runtime, "Test error message ()*+,-.");
  };
  auto ret = failureSource();
  if (ret.isError()) {
    switch (ret.getErrorCode()) {
    case TestError::Some:
    case TestError::Another:
    case TestError::Semantic:
    case TestError::Logical:
      FAIL() << "There is must be a Runtime type of error";
    case TestError::Runtime:
      SUCCEED();
    }
  } else {
    FAIL() << "There is must be an error";
  }
}
Beispiel #18
0
std::ostream& Message::printTo(std::ostream& out) const {

	// start with type ...
	switch(getType()) {
	case insieme::core::checks::Message::Type::WARNING:
		out << "WARNING: "; break;
	case insieme::core::checks::Message::Type::ERROR:
		out << "ERROR:   "; break;
	}

	// add error code
	out << getErrorCode();

	// .. continue with location ..
	out << " @ (" << getLocation();

	// .. and conclude with the message.
	out << ") - MSG: " << getMessage();
	return out;
}
Beispiel #19
0
void Exception::formatField(
		std::ostream &stream, FieldType fieldType, size_t depth) const {

	switch (fieldType) {
	case FIELD_ERROR_CODE:
		{
			LocaleUtils::CLocaleScope localeScope(stream);
			stream << getErrorCode(depth);
		}
		break;
	case FIELD_ERROR_CODE_NAME:
		formatErrorCodeName(stream, depth);
		break;
	case FIELD_MESSAGE:
		formatMessage(stream, depth);
		break;
	case FIELD_FILE_NAME:
		formatFileName(stream, depth);
		break;
	case FIELD_FUNCTION_NAME:
		formatFunctionName(stream, depth);
		break;
	case FIELD_LINE_NUMBER:
		{
			LocaleUtils::CLocaleScope localeScope(stream);
			stream << getLineNumber(depth);
		}
		break;
	case FIELD_STACK_TRACE:
		formatStackTrace(stream, depth);
		break;
	case FIELD_TYPE_NAME:
		formatTypeName(stream, depth);
		break;
	default:
		assert(false);
		break;
	}
}
char* osmsMessageRegisterDigitalItemInstanceResponseError::encode()
{
	XMLDocument* pDoc = new XMLDocument();
	if (pDoc == NULL)
		return NULL;

	if (!pDoc->decode(xmlTemplate(), getName()))
	{
		delete pDoc;
		return NULL;
	}

	pDoc->setInteger("MessageType", getMessageType());
	pDoc->setInteger("ErrorCode", getErrorCode());
	pDoc->setString("ResponseString", getResponseString());

	char *result = pDoc->encode();

	delete pDoc;

	return result;
}
Beispiel #21
0
enum audio::orchestra::error audio::orchestra::api::Core::startStream() {
	// TODO : Check return ...
	audio::orchestra::Api::startStream();
	if (verifyStream() != audio::orchestra::error_none) {
		return audio::orchestra::error_fail;
	}
	if (m_state == audio::orchestra::state::running) {
		ATA_ERROR("the stream is already running!");
		return audio::orchestra::error_warning;
	}
	OSStatus result = noErr;
	if (    m_mode == audio::orchestra::mode_output
	     || m_mode == audio::orchestra::mode_duplex) {
		result = AudioDeviceStart(m_private->id[0], &audio::orchestra::api::Core::callbackEvent);
		if (result != noErr) {
			ATA_ERROR("system error (" << getErrorCode(result) << ") starting callback procedure on device (" << m_device[0] << ").");
			goto unlock;
		}
	}
	if (    m_mode == audio::orchestra::mode_input
	     || (    m_mode == audio::orchestra::mode_duplex
	          && m_device[0] != m_device[1])) {
		result = AudioDeviceStart(m_private->id[1], &audio::orchestra::api::Core::callbackEvent);
		if (result != noErr) {
			ATA_ERROR("system error starting input callback procedure on device (" << m_device[1] << ").");
			goto unlock;
		}
	}
	m_private->drainCounter = 0;
	m_private->internalDrain = false;
	m_state = audio::orchestra::state::running;
	ATA_VERBOSE("Set state as running");
unlock:
	if (result == noErr) {
		return audio::orchestra::error_none;
	}
	return audio::orchestra::error_systemError;
}
Beispiel #22
0
const char* stream_t::getErrorDescription (void) {
  ___CBTPUSH;

  const char* description;
  switch (getErrorCode ()) {
  case IO_ERR__HARDWARE_ERROR:
    description = "Hardware error.";
    break;
  case IO_ERR__IS_DIRECTORY:
    description = "The specified file is a directory.";
    break;
  case IO_ERR__NO_DISK_SPACE_LEFT:
    description = "No disk space left.";
    break;
  case IO_ERR__NO_READ_PERMISSION:
    description = "No permission to read.";
    break;
  case IO_ERR__NO_SUCH_FILE:
    description = "No such file.";
    break;
  case IO_ERR__NO_WRITE_PERMISSION:
    description = "No permission to write.";
    break;
  case IO_ERR__TOO_MANY_STREAMS_OPEN:
    description = "Too many streams open.";
    break;
  case IO_ERR__UNKNOWN_ERROR:
    description = "Unknown error.";
    break;
  default:
    description = NULL;
  }

  ___CBTPOP;
  return description;
}
Beispiel #23
0
PRIVATE void page_fault_exception           (void){
	u_int32 errorCode=getErrorCode();
	sys_exception_panic(errorCode,14);
}
Beispiel #24
0
audio::orchestra::DeviceInfo audio::orchestra::api::Core::getDeviceInfo(uint32_t _device) {
	audio::orchestra::DeviceInfo info;
	// Get device ID
	uint32_t nDevices = getDeviceCount();
	if (nDevices == 0) {
		ATA_ERROR("no devices found!");
		info.clear();
		return info;
	}
	if (_device >= nDevices) {
		ATA_ERROR("device ID is invalid!");
		info.clear();
		return info;
	}
	info.input = false;
	if (_device%2 == 1) {
		info.input = true;
	}
	// The /2 corespond of not mixing input and output ... ==< then the user number of devide is twice the number of real device ...
	AudioDeviceID deviceList[nDevices/2];
	uint32_t dataSize = sizeof(AudioDeviceID) * nDevices/2;
	AudioObjectPropertyAddress property = {
		kAudioHardwarePropertyDevices,
		kAudioObjectPropertyScopeGlobal,
		kAudioObjectPropertyElementMaster
	};
	OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
	                                             &property,
	                                             0,
	                                             nullptr,
	                                             &dataSize,
	                                             (void*)&deviceList);
	if (result != noErr) {
		ATA_ERROR("OS-X system error getting device IDs.");
		info.clear();
		return info;
	}
	AudioDeviceID id = deviceList[ _device/2 ];
	// ------------------------------------------------
	// Get the device name.
	// ------------------------------------------------
	info.name.erase();
	CFStringRef cfname;
	dataSize = sizeof(CFStringRef);
	property.mSelector = kAudioObjectPropertyManufacturer;
	result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, &cfname);
	if (result != noErr) {
		ATA_ERROR("system error (" << getErrorCode(result) << ") getting device manufacturer.");
		info.clear();
		return info;
	}
	//const char *mname = CFStringGetCStringPtr(cfname, CFStringGetSystemEncoding());
	int32_t length = CFStringGetLength(cfname);
	std::vector<char> name;
	name.resize(length * 3 + 1, '\0');
	CFStringGetCString(cfname, &name[0], length * 3 + 1, CFStringGetSystemEncoding());
	info.name.append(&name[0], strlen(&name[0]));
	info.name.append(": ");
	CFRelease(cfname);
	property.mSelector = kAudioObjectPropertyName;
	result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, &cfname);
	if (result != noErr) {
		ATA_ERROR("system error (" << getErrorCode(result) << ") getting device name.");
		info.clear();
		return info;
	}
	//const char *name = CFStringGetCStringPtr(cfname, CFStringGetSystemEncoding());
	length = CFStringGetLength(cfname);
	name.resize(length * 3 + 1, '\0');
	CFStringGetCString(cfname, &name[0], length * 3 + 1, CFStringGetSystemEncoding());
	info.name.append(&name[0], strlen(&name[0]));
	CFRelease(cfname);
	// ------------------------------------------------
	// Get the output stream "configuration".
	// ------------------------------------------------
	property.mSelector = kAudioDevicePropertyStreamConfiguration;
	
	if (info.input == false) {
		property.mScope = kAudioDevicePropertyScopeOutput;
	} else {
		property.mScope = kAudioDevicePropertyScopeInput;
	}
	AudioBufferList	*bufferList = nullptr;
	dataSize = 0;
	result = AudioObjectGetPropertyDataSize(id, &property, 0, nullptr, &dataSize);
	if (result != noErr || dataSize == 0) {
		ATA_ERROR("system error (" << getErrorCode(result) << ") getting stream configuration info for device (" << _device << ").");
		info.clear();
		return info;
	}
	// Allocate the AudioBufferList.
	bufferList = (AudioBufferList *) malloc(dataSize);
	if (bufferList == nullptr) {
		ATA_ERROR("memory error allocating AudioBufferList.");
		info.clear();
		return info;
	}
	result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, bufferList);
	if (    result != noErr
	     || dataSize == 0) {
		free(bufferList);
		ATA_ERROR("system error (" << getErrorCode(result) << ") getting stream configuration for device (" << _device << ").");
		info.clear();
		return info;
	}
	// Get channel information.
	for (size_t iii=0; iii<bufferList->mNumberBuffers; ++iii) {
		for (size_t jjj=0; jjj<bufferList->mBuffers[iii].mNumberChannels; ++jjj) {
			info.channels.push_back(audio::channel_unknow);
		}
	}
	free(bufferList);
	if (info.channels.size() == 0) {
		ATA_DEBUG("system error (" << getErrorCode(result) << ") getting stream configuration for device (" << _device << ") ==> no channels.");
		info.clear();
		return info;
	}
	
	// ------------------------------------------------
	// Determine the supported sample rates.
	// ------------------------------------------------
	property.mSelector = kAudioDevicePropertyAvailableNominalSampleRates;
	result = AudioObjectGetPropertyDataSize(id, &property, 0, nullptr, &dataSize);
	if (    result != kAudioHardwareNoError
	     || dataSize == 0) {
		ATA_ERROR("system error (" << getErrorCode(result) << ") getting sample rate info.");
		info.clear();
		return info;
	}
	uint32_t nRanges = dataSize / sizeof(AudioValueRange);
	AudioValueRange rangeList[ nRanges ];
	result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, &rangeList);
	if (result != kAudioHardwareNoError) {
		ATA_ERROR("system error (" << getErrorCode(result) << ") getting sample rates.");
		info.clear();
		return info;
	}
	double minimumRate = 100000000.0, maximumRate = 0.0;
	for (uint32_t i=0; i<nRanges; i++) {
		if (rangeList[i].mMinimum < minimumRate) {
			minimumRate = rangeList[i].mMinimum;
		}
		if (rangeList[i].mMaximum > maximumRate) {
			maximumRate = rangeList[i].mMaximum;
		}
	}
	info.sampleRates.clear();
	for (auto &it : audio::orchestra::genericSampleRate()) {
		if (    it >= minimumRate
			 && it <= maximumRate) {
			info.sampleRates.push_back(it);
		}
	}
	if (info.sampleRates.size() == 0) {
		ATA_ERROR("No supported sample rates found for device (" << _device << ").");
		info.clear();
		return info;
	}
	// ------------------------------------------------
	// Determine the format.
	// ------------------------------------------------
	// CoreAudio always uses 32-bit floating point data for PCM streams.
	// Thus, any other "physical" formats supported by the device are of
	// no interest to the client.
	info.nativeFormats.push_back(audio::format_float);
	// ------------------------------------------------
	// Determine the default channel.
	// ------------------------------------------------
	
	if (info.input == false) {
		if (getDefaultOutputDevice() == _device) {
			info.isDefault = true;
		}
	} else {
		if (getDefaultInputDevice() == _device) {
			info.isDefault = true;
		}
	}
	info.isCorrect = true;
	return info;
}
Beispiel #25
0
PRIVATE void invalid_TSS_exception          (void){
	u_int32 errorCode=getErrorCode();
	sys_exception_panic(errorCode,10);
}
Beispiel #26
0
DOMException* DOMException::create(const String& message, const String& name)
{
    return new DOMException(getErrorCode(name), name, message, message);
}
Beispiel #27
0
PRIVATE void seg_not_present_exception      (void){
	u_int32 errorCode=getErrorCode();
	sys_exception_panic(errorCode,11);
}
Beispiel #28
0
PRIVATE void stack_seg_exception            (void){
	u_int32 errorCode=getErrorCode();
	sys_exception_panic(errorCode,12);
}
Beispiel #29
0
PRIVATE void parallel_check_exception       (void){
	u_int32 errorCode=getErrorCode();
	sys_exception_panic(errorCode,17);
}
Beispiel #30
0
PRIVATE void general_protection_exception   (void){
	u_int32 errorCode=getErrorCode();
	sys_exception_panic(errorCode,13);
}