bool LLAudioSource::setupChannel() { LLAudioData *adp = getCurrentData(); if (!adp->getBuffer()) { // We're not ready to play back the sound yet, so don't try and allocate a channel for it. //llwarns << "Aborting, no buffer" << llendl; return false; } if (!mChannelp) { // Update the priority, in case we need to push out another channel. updatePriority(); setChannel(gAudiop->getFreeChannel(getPriority())); } if (!mChannelp) { // Ugh, we don't have any free channels. // Now we have to reprioritize. // For now, just don't play the sound. //llwarns << "Aborting, no free channels" << llendl; return false; } mChannelp->setSource(this); llassert(this == mChannelp->getSource()); llassert(mChannelp->mCurrentBufferp == getCurrentBuffer()); return true; }
void LLAudioSource::update() { if(mCorrupted) { return ; //no need to update } if (!getCurrentBuffer()) { LLAudioData *adp = getCurrentData(); if (adp) { // Hack - try and load the sound. Will do this as a callback // on decode later. if (adp->load() && adp->getBuffer()) { play(adp->getID()); } else if (adp->hasCompletedDecode()) // Only mark corrupted after decode is done { llwarns << "Marking LLAudioSource corrupted for " << adp->getID() << llendl; mCorrupted = true ; } } } }
bool newFrame(unsigned char *ptr) { if(!isEmpty(writer)) { // printf("No empty buffer!\n"); return false; } unsigned char *dest = getCurrentBuffer(writer); // printf("Writing buffer %d @ %p\n", writer, dest); unsigned char thr; #ifdef OPENCV if(facetrack) { thr = (unsigned char)0; } else { #endif thr = (unsigned char)ltr_int_getThreshold(mmm); #ifdef OPENCV } #endif //Processing of kCVPixelFormatType_422YpCbCr8 data size_t i; ptr += 1; for(i = 0; i < (size_t) width * height; ++i) { dest[i] = (*ptr >= thr) ? *ptr : 0; ptr += 2; } /* //BGRA buffer to BW - much more time consuming I guess, will stick with UYVY for now float y; unsigned int cntr, cntr1; for(cntr = cntr1 = 0; cntr1 < (size_t) width * height; cntr += 4, ++cntr1){ //Y = (0.257 * R) + (0.504 * G) + (0.098 * B) + 16 y = 0.257 * ((float)ptr[cntr + 2]) + 0.504 * ((float)ptr[cntr + 1]) + 0.098 * ((float)ptr[cntr + 0]) + 16; if(y > 255) y = 255.0; if(y > thr){ dest[cntr1] = y; }else{ dest[cntr1] = 0; } } */ bufferWritten(&writer); // printf("Signaling new frame!\n"); pthread_mutex_lock(&state_mx); new_frame_flag = true; pthread_cond_broadcast(&state_cv); pthread_mutex_unlock(&state_mx); return true; }
//----------------------------------------------------------- ofSoundBuffer& ofSoundPlayerExtended::getCurrentSoundBufferMono(int _size){ if(channelSoundBuffer.getSampleRate()!= samplerate){ ofLogError()<<"ofSoundPlayerExtended: channelSoundBuffer incorrect Sample Rate"; return; } channelSoundBuffer.copyFrom( getCurrentBuffer(_size), 1, samplerate); return channelSoundBuffer; }
void LLAudioSource::update() { if (!getCurrentBuffer()) { if (getCurrentData()) { // Hack - try and load the sound. Will do this as a callback // on decode later. if (getCurrentData()->load()) { play(getCurrentData()->getID()); } } } }
void BufferManager::addBuffers(std::vector<Buffer*> buffers) { if (_log->isDebug()) _log->debug(2, "BufferManager::addBuffers()"); if (_log->isDebug()) _log->debug(3, "_lockActiveBuffers->lock() %d", (long)_lockActiveBuffers); _lockActiveBuffers->lock(); for (std::vector<Buffer*>::iterator it = buffers.begin(); it != buffers.end(); it++) { Buffer* buffer = *it; if (_log->isDebug()) _log->debug(2, "Adding buffer. fileName: %s", buffer->fileName().c_str()); _buffersCount++; registerBufferControlFile(buffer, true, 0x01); _activeBuffers->push(buffer); _vactiveBuffers->push_back(buffer); } if (_log->isDebug()) _log->debug(3, "_lockActiveBuffers->unlock() %d", (long)_lockActiveBuffers); _lockActiveBuffers->notify(); _lockActiveBuffers->unlock(); // this will force a new buffer to be put getCurrentBuffer(0, true); if (_log->isDebug()) _log->debug("buffersCount: %d", buffersCount()); }
void LLAudioSource::update() { if(mCorrupted) { return ; //no need to update } if (!getCurrentBuffer()) { if (getCurrentData()) { // Hack - try and load the sound. Will do this as a callback // on decode later. if (getCurrentData()->load() && getCurrentData()->getBuffer()) { play(getCurrentData()->getID()); } else { mCorrupted = true ; } } } }
Buffer* BufferManager::getCurrentBuffer(__int32 minimumSize) { return getCurrentBuffer(minimumSize, false); }
AREXPORT void ArRangeDevice::filterCallback(void) { std::list<ArPoseWithTime *>::iterator it; lockDevice(); // first filter the current readings based on time if (myMaxSecondsToKeepCurrent > 0 && myCurrentBuffer.getSize() > 0) { // just walk through and make sure nothings too far away myCurrentBuffer.beginInvalidationSweep(); for (it = getCurrentBuffer()->begin(); it != getCurrentBuffer()->end(); ++it) { if ((*it)->getTime().secSince() >= myMaxSecondsToKeepCurrent) myCurrentBuffer.invalidateReading(it); } myCurrentBuffer.endInvalidationSweep(); } // okay done with current, now do the cumulative bool doingDist = true; bool doingAge = true; if (myCumulativeBuffer.getSize() == 0) { unlockDevice(); return; } double squaredFarDist = (myMaxDistToKeepCumulative * myMaxDistToKeepCumulative); if (squaredFarDist < 1) doingDist = false; if (myMaxSecondsToKeepCumulative <= 0) doingAge = false; if (!doingDist && !doingAge) { unlockDevice(); return; } // just walk through and make sure nothings too far away myCumulativeBuffer.beginInvalidationSweep(); for (it = getCumulativeBuffer()->begin(); it != getCumulativeBuffer()->end(); ++it) { // if its closer to a reading than the filter near dist, just return if (doingDist && myRobot->getPose().squaredFindDistanceTo(*(*it)) > squaredFarDist) myCumulativeBuffer.invalidateReading(it); else if (doingAge && (*it)->getTime().secSince() >= myMaxSecondsToKeepCumulative) myCumulativeBuffer.invalidateReading(it); } myCumulativeBuffer.endInvalidationSweep(); unlockDevice(); }
T* getNextBuffer() { nextBlock.set((nextBlock.get() + 1) % owner.numBuffers); return getCurrentBuffer(); }
void enqueueBuffer () { (*queue)->Enqueue (queue, getCurrentBuffer(), static_cast<SLuint32> (getBufferSizeInSamples() * sizeof (T))); ++numBlocksOut; }
pixel_t *PixelBone_Pixel::getPixel(uint32_t n) const { return &getCurrentBuffer()[n]; }