| 594 | } |
| 595 | |
| 596 | void cOpenslesSource::android_AudioIn2(opensl_stream2 *p, const sWaveParameters * pcmParam) { |
| 597 | if (p->hasNewInternalData_ > 0) { |
| 598 | //SMILE_IWRN(1, "hasNewInternalData_ %d, p->internalBufferCurR %d, p->internalBufferCurW %d", |
| 599 | //p->hasNewInternalData_, p->internalBufferCurR, p->internalBufferCurW); |
| 600 | int16_t * currentBuffer = p->internalInputBuffers[p->internalBufferCurR]; |
| 601 | threadMatrix_->nT = smilePcm_convertSamples((uint8_t *)currentBuffer, |
| 602 | pcmParam, threadMatrix_->data, nChannels_, |
| 603 | p->inBufSamples / nChannels_, monoMixdown_); |
| 604 | // indicate to the callback in an atomic operation that another |
| 605 | // internal buffer is free |
| 606 | __sync_fetch_and_sub(&(p->hasNewInternalData_), 1); |
| 607 | // our read counter is only used in our thread, |
| 608 | // so no synchronization needed |
| 609 | p->internalBufferCurR = (p->internalBufferCurR + 1) |
| 610 | % NUM_RECORDING_DBL_BUFFERS; |
| 611 | if (agcEnabled_) |
| 612 | performAgc(threadMatrix_); |
| 613 | if (!writer_->checkWrite(threadMatrix_->nT)) { |
| 614 | SMILE_IWRN(1, "Audio data was lost, processing might be too slow (lost %ld samples)", |
| 615 | threadMatrix_->nT - writer_->getNFree()) |
| 616 | if (writer_->getNFree() > 0) { |
| 617 | threadMatrix_->nT = writer_->getNFree(); |
| 618 | } |
| 619 | } |
| 620 | if (writer_->checkWrite(threadMatrix_->nT)) { |
| 621 | writer_->setNextMatrix(threadMatrix_); |
| 622 | smileMutexLock(dataFlagMutex_); |
| 623 | dataFlag_ = true; |
| 624 | smileMutexUnlock(dataFlagMutex_); |
| 625 | // signal the threadCondition_ to show that there is new data. |
| 626 | smileCondSignal(threadCondition_); |
| 627 | } |
| 628 | p->time += (double)p->inBufSamples / (double)(p->sr * p->inchannels); |
| 629 | } else { |
| 630 | smileCondTimedWait(p->recorderCondition_, (p->inBufMSeconds * 3.0));// / 2.0); |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | // puts a buffer of size samples to the device |
| 635 | int cOpenslesSource::android_AudioOut(opensl_stream2 *p, float *buffer,int size){ |
nothing calls this directly
no test coverage detected