コード例 #1
0
ファイル: SimpleLogger.cpp プロジェクト: fpcMotif/fredcpp
SimpleLogger::SimpleLogger() {
  setupChannel(internal::LogLevel::LOG_INFO);
  setupChannel(internal::LogLevel::LOG_WARN);
  setupChannel(internal::LogLevel::LOG_ERROR);
  setupChannel(internal::LogLevel::LOG_FATAL);
  setupChannel(internal::LogLevel::LOG_DEBUG);


  // Default config
  // - enable WARN, ERROR, FATAL
  // - disable INFO and DEBUG
  // - output to std::cerr, INFO to std::cout

  enableLevel(internal::LogLevel::LOG_WARN);
  enableLevel(internal::LogLevel::LOG_ERROR);
  enableLevel(internal::LogLevel::LOG_FATAL);

  disableLevel(internal::LogLevel::LOG_INFO);
  disableLevel(internal::LogLevel::LOG_DEBUG);

  setOutput(std::cerr);
  setOutput(internal::LogLevel::LOG_INFO, std::cout);

  formatter_ = defaultLogFormat;

}
コード例 #2
0
SETTINGS_READER_RESULT Settings_parseDataChannelSetting(char const * const setting, int lineNo)
{
    char * pSettingString;
    char * pValueString;
    char * pChannelString;
    char * pChannelSettingString;

    uint8_t length = strlen(setting);

    char lowercaseCopy[MAX_LINE_LENGTH];

    strncpy_safe(lowercaseCopy, setting, length+1);
    toLowerStr(lowercaseCopy);

    bool success = true;

    if (*setting == '#') { return noError(); } // Line is a comment
    
    // If line is blank, fail early
    if (stringIsWhitespace(setting)) { return noError(); }

    // Split the string by '=' to get setting and name
    success &= splitAndStripWhiteSpace(lowercaseCopy, '=', &pSettingString, NULL, &pValueString, NULL);
    if (!success) { return noEqualsError(lineNo); }

    // Split the setting to get channel and setting name
    success &= splitAndStripWhiteSpace(pSettingString, '.', &pChannelString, NULL, &pChannelSettingString, NULL);
    if (!success) { return noSettingError(lineNo); }

    int8_t ch = Settings_getChannelFromSetting(pChannelString);
    if (ch == -1) { return noChannelError(lineNo); }

    if (0 == strncmp(pChannelSettingString, "type", 4))
    {
        // Try to interpret setting as a channel type
        s_fieldTypes[ch] = Setting_parseSettingAsType(pValueString);
        if (s_fieldTypes[ch] == INVALID_TYPE) { return unknownTypeError(lineNo, pValueString); }

        setupChannel(ch, s_fieldTypes[ch]);
        return noError();
    }

    /* If processing got this far, the setting needs to be interpreted based on the channel datatype */
    switch (s_fieldTypes[ch])
    {
    case VOLTAGE:
        return tryParseAsVoltageSetting(ch, pChannelSettingString, pValueString, lineNo);
    case CURRENT:
        return tryParseAsCurrentSetting(ch, pChannelSettingString, pValueString, lineNo);
    case TEMPERATURE_C:
    case TEMPERATURE_F:
    case TEMPERATURE_K:
        return tryParseAsThermistorSetting(ch, pChannelSettingString, pValueString, lineNo);

    case INVALID_TYPE:
    default:
        // If the channel type is not set prior to any other settings, this is an error.
        return channelNotSetError(lineNo, ch);
    }
}
コード例 #3
0
ファイル: llaudioengine.cpp プロジェクト: AlchemyDev/Carbon
bool LLAudioSource::play(const LLUUID &audio_uuid)
{
	// Special abuse of play(); don't play a sound, but kill it.
	if (audio_uuid.isNull())
	{
		if (getChannel())
		{
			getChannel()->setSource(NULL);
			setChannel(NULL);
			if (!isMuted())
			{
				mCurrentDatap = NULL;
			}
		}
		return false;
	}

	// Reset our age timeout if someone attempts to play the source.
	mAgeTimer.reset();

	if (!gAudiop)
	{
		LL_WARNS("AudioEngine") << "LLAudioEngine instance doesn't exist!" << LL_ENDL;
		return false;
	}

	LLAudioData *adp = gAudiop->getAudioData(audio_uuid);
	addAudioData(adp);

	if (isMuted())
	{
		return false;
	}

	bool has_buffer = gAudiop->updateBufferForData(adp, audio_uuid);
	if (!has_buffer)
	{
		// Don't bother trying to set up a channel or anything, we don't have an audio buffer.
		return false;
	}

	if (!setupChannel())
	{
		return false;
	}

	if (isSyncSlave())
	{
		// A sync slave, it doesn't start playing until it's synced up with the master.
		// Flag this channel as waiting for sync, and return true.
		getChannel()->setWaiting(true);
		return true;
	}

	getChannel()->play();
	return true;
}
コード例 #4
0
bool LLAudioSource::play(const LLUUID &audio_uuid)
{
	// Special abuse of play(); don't play a sound, but kill it.
	if (audio_uuid.isNull())
	{
		if (getChannel())
		{
			llassert(this == getChannel()->getSource());
			getChannel()->setSource(NULL);
			if (!isMuted())
			{
				mCurrentDatap = NULL;
			}
		}
		return false;
	}

	// <edit>
	if(mType != LLAudioEngine::AUDIO_TYPE_UI) //&& mSourceID.notNull())
		logSoundPlay(this, audio_uuid);
	// </edit>

	// Reset our age timeout if someone attempts to play the source.
	mAgeTimer.reset();

	LLAudioData *adp = gAudiop->getAudioData(audio_uuid);
	addAudioData(adp);

	if (isMuted())
	{
		return false;
	}

	bool has_buffer = gAudiop->updateBufferForData(adp, audio_uuid);
	if (!has_buffer)
	{
		// Don't bother trying to set up a channel or anything, we don't have an audio buffer.
		return false;
	}

	if (!setupChannel())
	{
		return false;
	}

	if (isSyncSlave())
	{
		// A sync slave, it doesn't start playing until it's synced up with the master.
		// Flag this channel as waiting for sync, and return true.
		getChannel()->setWaiting(true);
		return true;
	}

	getChannel()->play();
	return true;
}
コード例 #5
0
ファイル: player_ad.cpp プロジェクト: ilookha/scummvm
void Player_AD::parseSlot(Channel *channel) {
	while (true) {
		const byte *curOffset = channel->currentOffset;

		switch (*curOffset) {
		case 1:
			// INSTRUMENT DEFINITION
			++curOffset;
			channel->instrumentData[0] = *(curOffset + 0);
			channel->instrumentData[1] = *(curOffset + 2);
			channel->instrumentData[2] = *(curOffset + 9);
			channel->instrumentData[3] = *(curOffset + 8);
			channel->instrumentData[4] = *(curOffset + 4);
			channel->instrumentData[5] = *(curOffset + 3);
			channel->instrumentData[6] = 0;

			setupChannel(channel->hardwareChannel, curOffset);

			writeReg(0xA0 + channel->hardwareChannel, *(curOffset + 0));
			writeReg(0xB0 + channel->hardwareChannel, *(curOffset + 1) & 0xDF);

			channel->currentOffset += 15;
			break;

		case 2:
			// NOTE DEFINITION
			++curOffset;
			channel->state = kChannelStatePlay;
			noteOffOn(channel->hardwareChannel);
			parseNote(&channel->notes[0], *channel, curOffset + 0);
			parseNote(&channel->notes[1], *channel, curOffset + 5);
			return;

		case 0x80:
			// LOOP
			channel->currentOffset = channel->startOffset;
			break;

		default:
			// START OF CHANNEL
			// When we encounter a start of another channel while playback
			// it means that the current channel is finished. Thus, we will
			// stop it.
			clearChannel(*channel);
			channel->state = kChannelStateOff;
			return;
		}
	}
}
コード例 #6
0
ファイル: player_ad.cpp プロジェクト: ilookha/scummvm
void Player_AD::setupRhythm(uint rhythmInstr, uint instrOffset) {
	if (rhythmInstr == 1) {
		setupChannel(6, _musicData + instrOffset);
		writeReg(0xA6, _musicData[instrOffset++]);
		writeReg(0xB6, _musicData[instrOffset] & 0xDF);
		_mdvdrState |= 0x10;
		writeReg(0xBD, _mdvdrState);
	} else if (rhythmInstr < 6) {
		const byte *secondOperatorOffset = _musicData + instrOffset + 8;
		setupOperator(_rhythmOperatorTable[rhythmInstr], secondOperatorOffset);
		writeReg(0xA0 + _rhythmChannelTable[rhythmInstr], _musicData[instrOffset++]);
		writeReg(0xB0 + _rhythmChannelTable[rhythmInstr], _musicData[instrOffset++] & 0xDF);
		writeReg(0xC0 + _rhythmChannelTable[rhythmInstr], _musicData[instrOffset]);
		_mdvdrState |= _mdvdrTable[rhythmInstr];
		writeReg(0xBD, _mdvdrState);
	}
}
コード例 #7
0
ファイル: gpdma_18xx_43xx.c プロジェクト: pridolfi/workspace
/* Do a DMA transfer M2M, M2P,P2M or P2P */
Status Chip_GPDMA_Transfer(LPC_GPDMA_T *pGPDMA,
						   uint8_t ChannelNum,
						   uint32_t src,
						   uint32_t dst,
						   GPDMA_FLOW_CONTROL_T TransferType,
						   uint32_t Size)
{
	GPDMA_CH_CFG_T GPDMACfg;
	uint8_t SrcPeripheral = 0, DstPeripheral = 0;
	uint32_t cwrd;
	int ret;

	ret = Chip_GPDMA_InitChannelCfg(pGPDMA, &GPDMACfg, ChannelNum, src, dst, Size, TransferType);
	if (ret < 0) {
		return ERROR;
	}

	/* Adjust src/dst index if they are memory */
	if (ret & 1) {
		src = 0;
	}
	else {
		SrcPeripheral = configDMAMux(src);
	}

	if (ret & 2) {
		dst = 0;
	}
	else {
		DstPeripheral = configDMAMux(dst);
	}

	cwrd = makeCtrlWord(&GPDMACfg,
						(uint32_t) GPDMA_LUTPerBurst[src],
						(uint32_t) GPDMA_LUTPerBurst[dst],
						(uint32_t) GPDMA_LUTPerWid[src],
						(uint32_t) GPDMA_LUTPerWid[dst]);
	if (setupChannel(pGPDMA, &GPDMACfg, cwrd, 0, SrcPeripheral, DstPeripheral) == ERROR) {
		return ERROR;
	}

	/* Start the Channel */
	Chip_GPDMA_ChannelCmd(pGPDMA, ChannelNum, ENABLE);
	return SUCCESS;
}
コード例 #8
0
BOOL LLAudioSource::play(const LLUUID &audio_uuid)
{
	if (audio_uuid.isNull())
	{
		if (getChannel())
		{
			getChannel()->setSource(NULL);
			setChannel(NULL);
			addAudioData(NULL, TRUE);
		}
	}
	// Reset our age timeout if someone attempts to play the source.
	mAgeTimer.reset();

	LLAudioData *adp = gAudiop->getAudioData(audio_uuid);

	BOOL has_buffer = gAudiop->updateBufferForData(adp, audio_uuid);


	addAudioData(adp);

	if (!has_buffer)
	{
		// Don't bother trying to set up a channel or anything, we don't have an audio buffer.
		return FALSE;
	}

	if (!setupChannel())
	{
		return FALSE;
	}

	if (isSyncSlave())
	{
		// A sync slave, it doesn't start playing until it's synced up with the master.
		// Flag this channel as waiting for sync, and return true.
		getChannel()->setWaiting(TRUE);
		return TRUE;
	}

	getChannel()->play();
	return TRUE;
}
コード例 #9
0
ファイル: music.cpp プロジェクト: lordhoto/adplayer
void MusicPlayer::setupRhythm(uint8_t rhythmInstr, uint16_t instrOffset) {
	if (rhythmInstr == 1) {
		setupChannel(6, instrOffset);
		writeReg(0xA6, _file.at(instrOffset++));
		writeReg(0xB6, _file.at(instrOffset) & 0xDF);
		_mdvdrState |= 0x10;
		writeReg(0xBD, _mdvdrState);
	} else if (rhythmInstr < 6) {
		uint16_t secondOperatorOffset = instrOffset + 8;
		setupOperator(_rhythmOperatorTable[rhythmInstr], secondOperatorOffset);
		writeReg(0xA0 + _rhythmChannelTable[rhythmInstr], _file.at(instrOffset++));
		writeReg(0xB0 + _rhythmChannelTable[rhythmInstr], _file.at(instrOffset++) & 0xDF);
		writeReg(0xC0 + _rhythmChannelTable[rhythmInstr], _file.at(instrOffset));
		_mdvdrState |= _mdvdrTable[rhythmInstr];
		writeReg(0xBD, _mdvdrState);
	} else {
		// throw range error
	}
}
コード例 #10
0
ファイル: gpdma_18xx_43xx.c プロジェクト: pridolfi/workspace
/* Do a DMA scatter-gather transfer M2M, M2P,P2M or P2P using DMA descriptors */
Status Chip_GPDMA_SGTransfer(LPC_GPDMA_T *pGPDMA,
							 uint8_t ChannelNum,
							 const DMA_TransferDescriptor_t *DMADescriptor,
							 GPDMA_FLOW_CONTROL_T TransferType)
{
	const DMA_TransferDescriptor_t *dsc = DMADescriptor;
	GPDMA_CH_CFG_T GPDMACfg;
	uint8_t SrcPeripheral = 0, DstPeripheral = 0;
	uint32_t src = DMADescriptor->src, dst = DMADescriptor->dst;
	int ret;

	ret = Chip_GPDMA_InitChannelCfg(pGPDMA, &GPDMACfg, ChannelNum, src, dst, 0, TransferType);
	if (ret < 0) {
		return ERROR;
	}

	/* Adjust src/dst index if they are memory */
	if (ret & 1) {
		src = 0;
	}
	else {
		SrcPeripheral = configDMAMux(src);
	}

	if (ret & 2) {
		dst = 0;
	}
	else {
		DstPeripheral = configDMAMux(dst);
	}

	if (setupChannel(pGPDMA, &GPDMACfg, dsc->ctrl, dsc->lli, SrcPeripheral, DstPeripheral) == ERROR) {
		return ERROR;
	}

	/* Start the Channel */
	Chip_GPDMA_ChannelCmd(pGPDMA, ChannelNum, ENABLE);
	return SUCCESS;
}
コード例 #11
0
ファイル: llaudioengine.cpp プロジェクト: gabeharms/firestorm
bool LLAudioSource::play(const LLUUID &audio_uuid)
{
	// NaCl - Sound Explorer
	if(mType != LLAudioEngine::AUDIO_TYPE_UI) //&& mSourceID.notNull())
	{
		logSoundPlay(mLogID, this, mPositionGlobal, mType, audio_uuid, mOwnerID, mSourceID, mIsTrigger, mLoop);
	}
	// NaCl End
	// Special abuse of play(); don't play a sound, but kill it.
	if (audio_uuid.isNull())
	{
		if (getChannel())
		{
			// NaCl - Sound Explorer
			if(getChannel()->getSource())
			// NaCl End
			getChannel()->setSource(NULL);
			setChannel(NULL);
			if (!isMuted())
			{
				mCurrentDatap = NULL;
			}
		}
		return false;
	}

	// Reset our age timeout if someone attempts to play the source.
	mAgeTimer.reset();

	if (!gAudiop)
	{
		LL_WARNS("AudioEngine") << "LLAudioEngine instance doesn't exist!" << LL_ENDL;
		return false;
	}

	LLAudioData *adp = gAudiop->getAudioData(audio_uuid);
	if( !adp )
		return false;
	addAudioData(adp);

	if (isMuted())
	{
		return false;
	}

	bool has_buffer = gAudiop->updateBufferForData(adp, audio_uuid);
	if (!has_buffer)
	{
		// Don't bother trying to set up a channel or anything, we don't have an audio buffer.
		return false;
	}

	if (!setupChannel())
	{
		return false;
	}

	if (isSyncSlave())
	{
		// A sync slave, it doesn't start playing until it's synced up with the master.
		// Flag this channel as waiting for sync, and return true.
		getChannel()->setWaiting(true);
		return true;
	}

	getChannel()->play();
	return true;
}
コード例 #12
0
ファイル: player_ad.cpp プロジェクト: ilookha/scummvm
bool Player_AD::parseCommand() {
	uint command = _musicData[_curOffset++];
	if (command == 0xFF) {
		// META EVENT
		// Get the command number.
		command = _musicData[_curOffset++];
		if (command == 47) {
			// End of track
			if (_loopFlag) {
				// In case the track is looping jump to the start.
				_curOffset = _musicLoopStart;
				_nextEventTimer = 0;
			} else {
				// Otherwise completely stop playback.
				stopMusic();
			}
			return true;
		} else if (command == 88) {
			// This is proposedly a debug information insertion. The CMS
			// player code handles this differently, but is still using
			// the same resources...
			_curOffset += 5;
		} else if (command == 81) {
			// Change tempo. This is used exclusively in Loom.
			const uint timing = _musicData[_curOffset + 2] | (_musicData[_curOffset + 1] << 8);
			_musicTicks = 0x73000 / timing;
			command = _musicData[_curOffset++];
			_curOffset += command;
		} else {
			// In case an unknown meta event occurs just skip over the
			// data by using the length supplied.
			command = _musicData[_curOffset++];
			_curOffset += command;
		}
	} else {
		if (command >= 0x90) {
			// NOTE ON
			// Extract the channel number and save it in command.
			command -= 0x90;

			const uint instrOffset = _instrumentOffset[command];
			if (instrOffset) {
				if (_musicData[instrOffset + 13] != 0) {
					setupRhythm(_musicData[instrOffset + 13], instrOffset);
				} else {
					// Priority 256 makes sure we always prefer music
					// channels over SFX channels.
					int channel = allocateHWChannel(256);
					if (channel != -1) {
						setupChannel(channel, _musicData + instrOffset);
						_voiceChannels[channel].lastEvent = command + 0x90;
						_voiceChannels[channel].frequency = _musicData[_curOffset];
						setupFrequency(channel, _musicData[_curOffset]);
					}
				}
			}
		} else {
			// NOTE OFF
			const uint note = _musicData[_curOffset];
			command += 0x10;

			// Find the output channel which plays the note.
			uint channel = 0xFF;
			for (int i = 0; i < ARRAYSIZE(_voiceChannels); ++i) {
				if (_voiceChannels[i].frequency == note && _voiceChannels[i].lastEvent == command) {
					channel = i;
					break;
				}
			}

			if (channel != 0xFF) {
				// In case a output channel playing the note was found,
				// stop it.
				noteOff(channel);
			} else {
				// In case there is no such note this will disable the
				// rhythm instrument played on the channel.
				command -= 0x90;
				const uint instrOffset = _instrumentOffset[command];
				if (instrOffset && _musicData[instrOffset + 13] != 0) {
					const uint rhythmInstr = _musicData[instrOffset + 13];
					if (rhythmInstr < 6) {
						_mdvdrState &= _mdvdrTable[rhythmInstr] ^ 0xFF;
						writeReg(0xBD, _mdvdrState);
					}
				}
			}
		}

		_curOffset += 2;
	}

	return false;
}
コード例 #13
0
ファイル: music.cpp プロジェクト: lordhoto/adplayer
void MusicPlayer::callback() {
	if (!_isPlaying)
		return;

	_musicTimer += _musicTicks;
	if (_musicTimer < _timerLimit)
		return;

	_musicTimer -= _timerLimit;

	--_nextEventTimer;
	if (_nextEventTimer)
		return;

	while (true) {
		uint8_t command = _file.at(_curOffset++);
		if (command == 0xFF) {
			command = _file.at(_curOffset++);
			if (command == 47) {
				// End of track
				_isPlaying = false;
				return;
			} else if (command == 88) {
				// This is proposedly a debug information insertion. The CMS
				// player code handles this differently, but is still using
				// the same resources...
				_curOffset += 5;
			} else if (command == 81) {
				uint16_t timing = _file.at(_curOffset + 2) | (_file.at(_curOffset + 1) << 8);
				_musicTicks = 0x73000 / timing;
				command = _file.at(_curOffset++);
				_curOffset += command;
			} else {
				command = _file.at(_curOffset++);
				_curOffset += command;
			}
		} else {
			if (command >= 0x90) {
				command -= 0x90;

				const uint16_t instrOffset = _instrumentOffset[command];
				if (instrOffset) {
					if (_file.at(instrOffset + 13) != 0) {
						setupRhythm(_file[instrOffset + 13], instrOffset);
					} else {
						uint8_t channel = findFreeChannel();
						if (channel != 0xFF) {
							noteOff(channel);
							setupChannel(channel, instrOffset);
							_channelLastEvent[channel] = command + 0x90;
							_channelFrequency[channel] = _file.at(_curOffset);
							setupFrequency(channel, _file[_curOffset]);
						}
					}
				}
			} else {
				const uint8_t note = _file.at(_curOffset);
				command += 0x10;

				uint8_t channel = 0xFF;
				for (uint8_t i = 0; i < _voiceChannels; ++i) {
					if (_channelFrequency[i] == note && _channelLastEvent[i] == command) {
						channel = i;
						break;
					}
				}

				if (channel != 0xFF) {
					noteOff(channel);
				} else {
					command -= 0x90;
					const uint16_t instrOffset = _instrumentOffset[command];
					if (instrOffset && _file.at(instrOffset + 13) != 0) {
						const uint8_t rhythmInstr = _file[instrOffset + 13];
						//if (rhythmInstr >= 6)
						//	throw std::range_error("rhythmInstr >= 6");
						if (rhythmInstr < 6) {
							_mdvdrState &= _mdvdrTable[rhythmInstr] ^ 0xFF;
							writeReg(0xBD, _mdvdrState);
						}
					}
				}
			}

			_curOffset += 2;
		}

		if (_file.at(_curOffset) != 0)
			break;
		++_curOffset;
	}

	_nextEventTimer = _file.at(_curOffset++);
	if (_nextEventTimer & 0x80) {
		_nextEventTimer -= 0x80;
		_nextEventTimer <<= 7;
		_nextEventTimer |= _file.at(_curOffset++);
	}

	_nextEventTimer >>= _isLoom ? 2 : 1;
	if (!_nextEventTimer)
		_nextEventTimer = 1;
}