本文整理汇总了C++中SoundPool类的典型用法代码示例。如果您正苦于以下问题:C++ SoundPool类的具体用法?C++ SoundPool怎么用?C++ SoundPool使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SoundPool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: android_media_SoundPool_SoundPoolImpl_unload
static jboolean
android_media_SoundPool_SoundPoolImpl_unload(JNIEnv *env, jobject thiz, jint sampleID) {
ALOGV("android_media_SoundPool_SoundPoolImpl_unload\n");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return JNI_FALSE;
return ap->unload(sampleID) ? JNI_TRUE : JNI_FALSE;
}
示例2: android_media_SoundPool_unload
static bool
android_media_SoundPool_unload(JNIEnv *env, jobject thiz, jint sampleID) {
ALOGV("android_media_SoundPool_unload\n");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return 0;
return ap->unload(sampleID);
}
示例3: android_media_SoundPool_resume
static void
android_media_SoundPool_resume(JNIEnv *env, jobject thiz, jint channelID)
{
ALOGV("android_media_SoundPool_resume");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return;
ap->resume(channelID);
}
示例4: android_media_SoundPool_autoResume
static void
android_media_SoundPool_autoResume(JNIEnv *env, jobject thiz)
{
ALOGV("android_media_SoundPool_autoResume");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return;
ap->autoResume();
}
示例5: android_media_SoundPool_setRate
static void
android_media_SoundPool_setRate(JNIEnv *env, jobject thiz, jint channelID,
float rate)
{
ALOGV("android_media_SoundPool_setRate");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return;
ap->setRate(channelID, rate);
}
示例6: android_media_SoundPool_setLoop
static void
android_media_SoundPool_setLoop(JNIEnv *env, jobject thiz, jint channelID,
int loop)
{
ALOGV("android_media_SoundPool_setLoop");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return;
ap->setLoop(channelID, loop);
}
示例7: android_media_SoundPool_setPriority
static void
android_media_SoundPool_setPriority(JNIEnv *env, jobject thiz, jint channelID,
int priority)
{
ALOGV("android_media_SoundPool_setPriority");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return;
ap->setPriority(channelID, priority);
}
示例8: android_media_SoundPool_setVolume
static void
android_media_SoundPool_setVolume(JNIEnv *env, jobject thiz, jint channelID,
float leftVolume, float rightVolume)
{
ALOGV("android_media_SoundPool_setVolume");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return;
ap->setVolume(channelID, leftVolume, rightVolume);
}
示例9: android_media_SoundPool_play
static int
android_media_SoundPool_play(JNIEnv *env, jobject thiz, jint sampleID,
jfloat leftVolume, jfloat rightVolume, jint priority, jint loop,
jfloat rate)
{
ALOGV("android_media_SoundPool_play\n");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return 0;
return ap->play(sampleID, leftVolume, rightVolume, priority, loop, rate);
}
示例10: android_media_SoundPool_load_FD
static int
android_media_SoundPool_load_FD(JNIEnv *env, jobject thiz, jobject fileDescriptor,
jlong offset, jlong length, jint priority)
{
ALOGV("android_media_SoundPool_load_FD");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return 0;
return ap->load(jniGetFDFromFileDescriptor(env, fileDescriptor),
int64_t(offset), int64_t(length), int(priority));
}
示例11: android_media_SoundPool_load_URL
// ----------------------------------------------------------------------------
static int
android_media_SoundPool_load_URL(JNIEnv *env, jobject thiz, jstring path, jint priority)
{
ALOGV("android_media_SoundPool_load_URL");
SoundPool *ap = MusterSoundPool(env, thiz);
if (path == NULL) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
return 0;
}
const char* s = env->GetStringUTFChars(path, NULL);
int id = ap->load(s, priority);
env->ReleaseStringUTFChars(path, s);
return id;
}
示例12: android_media_SoundPool_native_setup
static jint
android_media_SoundPool_native_setup(JNIEnv *env, jobject thiz, jobject weakRef, jint maxChannels, jint streamType, jint srcQuality)
{
ALOGV("android_media_SoundPool_native_setup");
SoundPool *ap = new SoundPool(maxChannels, (audio_stream_type_t) streamType, srcQuality);
if (ap == NULL) {
return -1;
}
// save pointer to SoundPool C++ object in opaque field in Java object
env->SetIntField(thiz, fields.mNativeContext, (int)ap);
// set callback with weak reference
jobject globalWeakRef = env->NewGlobalRef(weakRef);
ap->setCallback(android_media_callback, globalWeakRef);
return 0;
}
示例13: android_media_SoundPool_release
static void
android_media_SoundPool_release(JNIEnv *env, jobject thiz)
{
ALOGV("android_media_SoundPool_release");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap != NULL) {
// release weak reference
jobject weakRef = (jobject) ap->getUserData();
if (weakRef != NULL) {
env->DeleteGlobalRef(weakRef);
}
// clear callback and native context
ap->setCallback(NULL, NULL);
env->SetIntField(thiz, fields.mNativeContext, 0);
delete ap;
}
}
示例14: android_media_SoundPool_SoundPoolImpl_native_setup
static jint
android_media_SoundPool_SoundPoolImpl_native_setup(JNIEnv *env, jobject thiz, jobject weakRef,
jint maxChannels, jobject jaa)
{
if (jaa == 0) {
ALOGE("Error creating SoundPool: invalid audio attributes");
return -1;
}
audio_attributes_t *paa = NULL;
// read the AudioAttributes values
paa = (audio_attributes_t *) calloc(1, sizeof(audio_attributes_t));
const jstring jtags =
(jstring) env->GetObjectField(jaa, javaAudioAttrFields.fieldFormattedTags);
const char* tags = env->GetStringUTFChars(jtags, NULL);
// copying array size -1, char array for tags was calloc'd, no need to NULL-terminate it
strncpy(paa->tags, tags, AUDIO_ATTRIBUTES_TAGS_MAX_SIZE - 1);
env->ReleaseStringUTFChars(jtags, tags);
paa->usage = (audio_usage_t) env->GetIntField(jaa, javaAudioAttrFields.fieldUsage);
paa->content_type =
(audio_content_type_t) env->GetIntField(jaa, javaAudioAttrFields.fieldContentType);
paa->flags = env->GetIntField(jaa, javaAudioAttrFields.fieldFlags);
ALOGV("android_media_SoundPool_SoundPoolImpl_native_setup");
SoundPool *ap = new SoundPool(maxChannels, paa);
if (ap == NULL) {
return -1;
}
// save pointer to SoundPool C++ object in opaque field in Java object
env->SetLongField(thiz, fields.mNativeContext, (jlong) ap);
// set callback with weak reference
jobject globalWeakRef = env->NewGlobalRef(weakRef);
ap->setCallback(android_media_callback, globalWeakRef);
// audio attributes were copied in SoundPool creation
free(paa);
return 0;
}
示例15: beginThread
int SoundPool::beginThread(void* arg)
{
SoundPool* p = (SoundPool*)arg;
return p->run();
}