/* Don't call this directly. Only uenum_unext should be calling this. */ U_CAPI const UChar* U_EXPORT2 uenum_unextDefault(UEnumeration* en, int32_t* resultLength, UErrorCode* status) { UChar *ustr = NULL; int32_t len = 0; if (en->next != NULL) { const char *cstr = en->next(en, &len, status); if (cstr != NULL) { ustr = (UChar*) _getBuffer(en, (len+1) * sizeof(UChar)); if (ustr == NULL) { *status = U_MEMORY_ALLOCATION_ERROR; } else { u_charsToUChars(cstr, ustr, len+1); } } } else { *status = U_UNSUPPORTED_ERROR; } if (resultLength) { *resultLength = len; } return ustr; }
U32 SFXDSVoice::_tell() const { DWORD position = 0; mDSBuffer->GetCurrentPosition( &position, NULL ); U32 samplePos = _getBuffer()->getSamplePos( position ); return samplePos; }
void SFXDSVoice::setPitch( F32 pitch ) { F32 sampleRate = _getBuffer()->getFormat().getSamplesPerSecond(); F32 frequency = mFloor( mClampF( sampleRate * pitch, DSBFREQUENCY_MIN, DSBFREQUENCY_MAX ) ); DSAssert( mDSBuffer->SetFrequency( ( U32 )frequency ), "SFXDSVoice::setPitch - couldn't set playback frequency."); }
indri::api::ParsedDocument* indri::parse::KrovetzStemmerTransformation::transform( indri::api::ParsedDocument* document ) { indri::utility::greedy_vector<char*>& terms = document->terms; // this is the minimum amount of space we're willing to start with, but we may get more int bufferLength = document->textLength * 2 + KSTEM_MAX_WORD_LENGTH + KSTEM_EXTRA_SPACE; char* stem = _getBuffer( bufferLength ); const char* end = _getBufferEnd() - KSTEM_MAX_WORD_LENGTH; return _processTerms( document, 0, stem, end ); }
SFXDSVoice::~SFXDSVoice() { SAFE_RELEASE( mDSBuffer3D ); SFXDSBuffer* dsBuffer = _getBuffer(); if( dsBuffer ) dsBuffer->releaseVoice( &mDSBuffer ); mBuffer = NULL; }
bool parcJSONParser_RequireString(PARCJSONParser *parser, const char *string) { PARCBuffer *buffer = _getBuffer(parser); for (const char *requiredCharacter = string; *requiredCharacter != 0; requiredCharacter++) { uint8_t actualCharacter = parcBuffer_GetUint8(buffer); if (actualCharacter != *requiredCharacter) { return false; } } return true; }
indri::api::ParsedDocument* indri::parse::KrovetzStemmerTransformation::_restart( indri::api::ParsedDocument* document, size_t lastIndex, char* endOfStemming ) { int stemmedRegion = endOfStemming - _stemBuffer; float proportion = (float(document->terms.size()) / float(lastIndex+1)) * 1.5; int expectedLength = int(proportion * stemmedRegion) + KSTEM_MAX_WORD_LENGTH; char* oldBuffer = _getBuffer(0); char* newStart = _growBuffer( expectedLength, endOfStemming ); char* newBuffer = _getBuffer(0); const char* newEnd = _getBufferEnd(); int fixup = newBuffer - oldBuffer; for( size_t i=0; i<=lastIndex; i++ ) { if( document->terms[i] >= oldBuffer && document->terms[i] <= endOfStemming ) { // this pointer points into the old buffer, so we have to fix it up document->terms[i] += fixup; } } return _processTerms( document, lastIndex+1, newStart, newEnd ); }
void SFXXAudioVoice::_loadNonStreamed() { AssertFatal( !mBuffer->isStreaming(), "SFXXAudioVoice::_loadNonStreamed - must not be called on streaming voices" ); AssertFatal( mXAudioVoice != NULL, "SFXXAudioVoice::_loadNonStreamed - invalid voice" ); AssertWarn( !mNonStreamBufferLoaded, "SFXXAudioVoice::_nonStreamNonstreamed - Data already loaded" ); #ifdef DEBUG_SPEW Platform::outputDebugString( "[SFXXAudioVoice] Loading non-stream buffer at %i", mNonStreamSampleStartPos ); #endif EnterCriticalSection( &mLock ); const XAUDIO2_BUFFER& orgBuffer = _getBuffer()->mBufferQueue.front().mData; mNonStreamBuffer = orgBuffer; if( mNonStreamSampleStartPos ) { mNonStreamBuffer.PlayBegin = mNonStreamSampleStartPos; mNonStreamBuffer.PlayLength = _getBuffer()->getNumSamples() - mNonStreamSampleStartPos; mSamplesPlayedOffset += mNonStreamSampleStartPos; // Add samples that we are skipping. mNonStreamSampleStartPos = 0; } if( mIsLooping ) { mNonStreamBuffer.LoopCount = XAUDIO2_LOOP_INFINITE; mNonStreamBuffer.LoopLength = _getBuffer()->getNumSamples(); } // Submit buffer. mXAudioVoice->SubmitSourceBuffer( &mNonStreamBuffer ); mNonStreamBufferLoaded = true; LeaveCriticalSection( &mLock ); }
PARCBuffer * parcJSONParser_ParseString(PARCJSONParser *parser) { PARCBuffer *result = NULL; PARCBuffer *buffer = _getBuffer(parser); if (parcBuffer_GetUint8(buffer) == '"') { // skip the initial '"' character starting the string. PARCBufferComposer *composer = parcBufferComposer_Create(); while (parcBuffer_Remaining(buffer)) { uint8_t c = parcBuffer_GetUint8(buffer); if (c == '"') { // This is the only successful way to exit this while loop. result = parcBufferComposer_ProduceBuffer(composer); break; } else if (c == '\\') { c = parcBuffer_GetUint8(buffer); if (c == '"') { // this special character passes directly into the composed string. } else if (c == '\\') { // this special character passes directly into the composed string. } else if (c == '/') { // this special character passes directly into the composed string. } else if (c == 'b') { c = '\b'; } else if (c == 'f') { c = '\f'; } else if (c == 'n') { c = '\n'; } else if (c == 'r') { c = '\r'; } else if (c == 't') { c = '\t'; } else if (c == 'u') { // Not supporting unicode at this point. trapNotImplemented("Unicode is not supported."); } } else if (iscntrl(c)) { // !! Syntax Error. break; } parcBufferComposer_PutChar(composer, c); } parcBufferComposer_Release(&composer); } return result; }
/* Don't call this directly. Only uenum_next should be calling this. */ U_CAPI const char* U_EXPORT2 uenum_nextDefault(UEnumeration* en, int32_t* resultLength, UErrorCode* status) { if (en->uNext != NULL) { char *tempCharVal; const UChar *tempUCharVal = en->uNext(en, resultLength, status); if (tempUCharVal == NULL) { return NULL; } tempCharVal = (char*) _getBuffer(en, (*resultLength+1) * sizeof(char)); if (!tempCharVal) { *status = U_MEMORY_ALLOCATION_ERROR; return NULL; } u_UCharsToChars(tempUCharVal, tempCharVal, *resultLength + 1); return tempCharVal; } else { *status = U_UNSUPPORTED_ERROR; return NULL; } }