本文整理汇总了C++中AudioPlayer::stop方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioPlayer::stop方法的具体用法?C++ AudioPlayer::stop怎么用?C++ AudioPlayer::stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioPlayer
的用法示例。
在下文中一共展示了AudioPlayer::stop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
android::ProcessState::self()->startThreadPool();
OMXClient client;
CHECK_EQ(client.connect(), OK);
const int32_t kSampleRate = 22050;
const int32_t kNumChannels = 2;
sp<MediaSource> audioSource = new SineSource(kSampleRate, kNumChannels);
#if 0
sp<MediaPlayerBase::AudioSink> audioSink;
AudioPlayer *player = new AudioPlayer(audioSink);
player->setSource(audioSource);
player->start();
sleep(10);
player->stop();
#endif
sp<MetaData> encMeta = new MetaData;
encMeta->setCString(kKeyMIMEType,
1 ? MEDIA_MIMETYPE_AUDIO_AMR_WB : MEDIA_MIMETYPE_AUDIO_AAC);
encMeta->setInt32(kKeySampleRate, kSampleRate);
encMeta->setInt32(kKeyChannelCount, kNumChannels);
encMeta->setInt32(kKeyMaxInputSize, 8192);
sp<MediaSource> encoder =
OMXCodec::Create(client.interface(), encMeta, true, audioSource);
encoder->start();
int32_t n = 0;
status_t err;
MediaBuffer *buffer;
while ((err = encoder->read(&buffer)) == OK) {
printf(".");
fflush(stdout);
buffer->release();
buffer = NULL;
if (++n == 100) {
break;
}
}
printf("$\n");
encoder->stop();
client.disconnect();
return 0;
}
示例2: main
int main() {
// We only have an AMR-WB encoder on sholes...
static bool outputWBAMR = false;
static const int32_t kSampleRate = outputWBAMR ? 16000 : 8000;
static const int32_t kNumChannels = 1;
android::ProcessState::self()->startThreadPool();
OMXClient client;
CHECK_EQ(client.connect(), (status_t)OK);
#if 0
sp<MediaSource> source = new SineSource(kSampleRate, kNumChannels);
#else
sp<MediaSource> source = new AudioSource(
AUDIO_SOURCE_DEFAULT,
kSampleRate,
audio_channel_in_mask_from_count(kNumChannels));
#endif
sp<MetaData> meta = new MetaData;
meta->setCString(
kKeyMIMEType,
outputWBAMR ? MEDIA_MIMETYPE_AUDIO_AMR_WB
: MEDIA_MIMETYPE_AUDIO_AMR_NB);
meta->setInt32(kKeyChannelCount, kNumChannels);
meta->setInt32(kKeySampleRate, kSampleRate);
int32_t maxInputSize;
if (source->getFormat()->findInt32(kKeyMaxInputSize, &maxInputSize)) {
meta->setInt32(kKeyMaxInputSize, maxInputSize);
}
sp<MediaSource> encoder = OMXCodec::Create(
client.interface(),
meta, true /* createEncoder */,
source);
#if 1
sp<AMRWriter> writer = new AMRWriter("/sdcard/out.amr");
writer->addSource(encoder);
writer->start();
sleep(10);
writer->stop();
#else
sp<MediaSource> decoder = OMXCodec::Create(
client.interface(),
meta, false /* createEncoder */,
encoder);
#if 0
AudioPlayer *player = new AudioPlayer(NULL);
player->setSource(decoder);
player->start();
sleep(10);
player->stop();
delete player;
player = NULL;
#elif 0
CHECK_EQ(decoder->start(), (status_t)OK);
MediaBuffer *buffer;
while (decoder->read(&buffer) == OK) {
// do something with buffer
putchar('.');
fflush(stdout);
buffer->release();
buffer = NULL;
}
CHECK_EQ(decoder->stop(), (status_t)OK);
#endif
#endif
return 0;
}