本文整理汇总了C++中AudioTrack::latency方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioTrack::latency方法的具体用法?C++ AudioTrack::latency怎么用?C++ AudioTrack::latency使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioTrack
的用法示例。
在下文中一共展示了AudioTrack::latency方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/**
* \brief get output latency in ms
* \param audec pointer to audec
* \return output latency
*/
extern "C" unsigned long android_latency(struct aml_audio_dec* audec)
{
unsigned long latency;
audio_out_operations_t *out_ops = &audec->aout_ops;
AudioTrack *track = (AudioTrack *)out_ops->private_data;
if (track) {
latency = track->latency();
return latency;
}
return 0;
}
示例2: LOGD
status_t MediaPlayerService::AudioOutput::open(uint32_t sampleRate, int channelCount, int format, int bufferCount)
{
// Check argument "bufferCount" against the mininum buffer count
if (bufferCount < mMinBufferCount) {
LOGD("bufferCount (%d) is too small and increased to %d", bufferCount, mMinBufferCount);
bufferCount = mMinBufferCount;
}
LOGV("open(%u, %d, %d, %d)", sampleRate, channelCount, format, bufferCount);
if (mTrack) close();
int afSampleRate;
int afFrameCount;
int frameCount;
if (AudioSystem::getOutputFrameCount(&afFrameCount, mStreamType) != NO_ERROR) {
return NO_INIT;
}
if (AudioSystem::getOutputSamplingRate(&afSampleRate, mStreamType) != NO_ERROR) {
return NO_INIT;
}
frameCount = (sampleRate*afFrameCount*bufferCount)/afSampleRate;
AudioTrack *t = new AudioTrack(mStreamType, sampleRate, format, channelCount, frameCount);
if ((t == 0) || (t->initCheck() != NO_ERROR)) {
LOGE("Unable to create audio track");
delete t;
return NO_INIT;
}
LOGV("setVolume");
t->setVolume(mLeftVolume, mRightVolume);
mMsecsPerFrame = 1.e3 / (float) sampleRate;
mLatency = t->latency() + kAudioVideoDelayMs;
mTrack = t;
return NO_ERROR;
}
示例3: SNDDMA_Init
qboolean SNDDMA_Init(void)
{
if ( ! enableSound() ) {
return false;
}
gDMAByteIndex = 0;
// Initialize the AudioTrack.
status_t result = gAudioTrack.set(
AudioSystem::DEFAULT, // stream type
SAMPLE_RATE, // sample rate
BITS_PER_SAMPLE == 16 ? AudioSystem::PCM_16_BIT : AudioSystem::PCM_8_BIT, // format (8 or 16)
(CHANNEL_COUNT > 1) ? AudioSystem::CHANNEL_OUT_STEREO : AudioSystem::CHANNEL_OUT_MONO, // channel mask
0, // default buffer size
0, // flags
AndroidQuakeSoundCallback, // callback
0, // user
0); // default notification size
LOGI("AudioTrack status = %d (%s)\n", result, result == NO_ERROR ? "success" : "error");
if ( result == NO_ERROR ) {
LOGI("AudioTrack latency = %u ms\n", gAudioTrack.latency());
LOGI("AudioTrack format = %u bits\n", gAudioTrack.format() == AudioSystem::PCM_16_BIT ? 16 : 8);
LOGI("AudioTrack sample rate = %u Hz\n", gAudioTrack.getSampleRate());
LOGI("AudioTrack frame count = %d\n", int(gAudioTrack.frameCount()));
LOGI("AudioTrack channel count = %d\n", gAudioTrack.channelCount());
// Initialize Quake's idea of a DMA buffer.
shm = &sn;
memset((void*)&sn, 0, sizeof(sn));
shm->splitbuffer = false; // Not used.
shm->samplebits = gAudioTrack.format() == AudioSystem::PCM_16_BIT ? 16 : 8;
shm->speed = gAudioTrack.getSampleRate();
shm->channels = gAudioTrack.channelCount();
shm->samples = TOTAL_BUFFER_SIZE / BYTES_PER_SAMPLE;
shm->samplepos = 0; // Not used.
shm->buffer = (unsigned char*) Hunk_AllocName(TOTAL_BUFFER_SIZE, (char*) "shmbuf");
shm->submission_chunk = 1; // Not used.
shm->soundalive = true;
if ( (shm->samples & 0x1ff) != 0 ) {
LOGE("SNDDDMA_Init: samples must be power of two.");
return false;
}
if ( shm->buffer == 0 ) {
LOGE("SNDDDMA_Init: Could not allocate sound buffer.");
return false;
}
gAudioTrack.setVolume(1.0f, 1.0f);
gAudioTrack.start();
}
return result == NO_ERROR;
}