本文整理汇总了C++中SDL_JNI_SetupThreadEnv函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_JNI_SetupThreadEnv函数的具体用法?C++ SDL_JNI_SetupThreadEnv怎么用?C++ SDL_JNI_SetupThreadEnv使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_JNI_SetupThreadEnv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SDL_AMediaCodecJava_delete
static sdl_amedia_status_t SDL_AMediaCodecJava_delete(SDL_AMediaCodec* acodec)
{
ALOGI("%s\n", __func__);
if (!acodec)
return SDL_AMEDIA_OK;
JNIEnv *env = NULL;
if (JNI_OK != SDL_JNI_SetupThreadEnv(&env)) {
ALOGE("SDL_AMediaCodecJava_delete: SetupThreadEnv failed");
return SDL_AMEDIA_ERROR_UNKNOWN;
}
SDL_AMediaCodec_Opaque *opaque = (SDL_AMediaCodec_Opaque *)acodec->opaque;
if (opaque) {
if (opaque->android_media_codec) {
(*env)->CallVoidMethod(env, opaque->android_media_codec, g_clazz.jmid_release);
SDL_JNI_CatchException(env);
}
SDL_JNI_DeleteGlobalRefP(env, &opaque->output_buffer_info);
SDL_JNI_DeleteGlobalRefP(env, &opaque->output_buffer);
SDL_JNI_DeleteGlobalRefP(env, &opaque->output_buffer_array);
SDL_JNI_DeleteGlobalRefP(env, &opaque->input_buffer);
SDL_JNI_DeleteGlobalRefP(env, &opaque->input_buffer_array);
SDL_JNI_DeleteGlobalRefP(env, &opaque->android_media_codec);
}
SDL_AMediaCodec_FreeInternal(acodec);
return SDL_AMEDIA_OK;
}
示例2: SDL_AMediaCodecJava_dequeueInputBuffer
ssize_t SDL_AMediaCodecJava_dequeueInputBuffer(SDL_AMediaCodec* acodec, int64_t timeoutUs)
{
AMCTRACE("%s(%d)", __func__, (int)timeoutUs);
JNIEnv *env = NULL;
if (JNI_OK != SDL_JNI_SetupThreadEnv(&env)) {
ALOGE("%s: SetupThreadEnv failed", __func__);
return -1;
}
SDL_AMediaCodec_Opaque *opaque = (SDL_AMediaCodec_Opaque *)acodec->opaque;
// docs lie, getInputBuffers should be good after
// m_codec->start() but the internal refs are not
// setup until much later on some devices.
//if (-1 == getInputBuffers(env, acodec)) {
// ALOGE("%s: getInputBuffers failed", __func__);
// return -1;
//}
jobject android_media_codec = opaque->android_media_codec;
jint idx = (*env)->CallIntMethod(env, android_media_codec, g_clazz.jmid_dequeueInputBuffer, (jlong)timeoutUs);
if (SDL_JNI_CatchException(env)) {
ALOGE("%s: dequeueInputBuffer failed", __func__);
opaque->is_input_buffer_valid = false;
return -1;
}
return idx;
}
示例3: enqueue_thread_func
static int enqueue_thread_func(void *arg)
{
JNIEnv *env = NULL;
IJKFF_Pipenode *node = arg;
IJKFF_Pipenode_Opaque *opaque = node->opaque;
FFPlayer *ffp = opaque->ffp;
VideoState *is = ffp->is;
Decoder *d = &is->viddec;
PacketQueue *q = d->queue;
int ret = -1;
int dequeue_count = 0;
if (JNI_OK != SDL_JNI_SetupThreadEnv(&env)) {
ALOGE("%s: SetupThreadEnv failed\n", __func__);
goto fail;
}
while (!q->abort_request) {
ret = feed_input_buffer(env, node, AMC_INPUT_TIMEOUT_US, &dequeue_count);
if (ret != 0) {
goto fail;
}
}
ret = 0;
fail:
ffp_packet_queue_abort(&opaque->fake_pictq);
ALOGI("MediaCodec: %s: exit: %d", __func__, ret);
return ret;
}
示例4: func_destroy
static void func_destroy(IJKFF_Pipenode *node)
{
if (!node || !node->opaque)
return;
IJKFF_Pipenode_Opaque *opaque = node->opaque;
SDL_DestroyCondP(&opaque->acodec_cond);
SDL_DestroyMutexP(&opaque->acodec_mutex);
SDL_DestroyCondP(&opaque->acodec_first_dequeue_output_cond);
SDL_DestroyMutexP(&opaque->acodec_first_dequeue_output_mutex);
SDL_AMediaCodec_decreaseReferenceP(&opaque->acodec);
SDL_AMediaFormat_deleteP(&opaque->input_aformat);
SDL_AMediaFormat_deleteP(&opaque->output_aformat);
#if AMC_USE_AVBITSTREAM_FILTER
av_freep(&opaque->orig_extradata);
#endif
ffp_packet_queue_destroy(&opaque->fake_pictq);
if (opaque->bsfc) {
av_bitstream_filter_close(opaque->bsfc);
opaque->bsfc = NULL;
}
JNIEnv *env = NULL;
if (JNI_OK == SDL_JNI_SetupThreadEnv(&env)) {
SDL_JNI_DeleteGlobalRefP(env, &opaque->jsurface);
}
}
示例5: SDL_AMediaFormatJava_setBuffer
static void SDL_AMediaFormatJava_setBuffer(SDL_AMediaFormat* aformat, const char* name, void* data, size_t size)
{
int ret = -1;
JNIEnv *env = NULL;
if (JNI_OK != SDL_JNI_SetupThreadEnv(&env)) {
ALOGE("%s: SDL_JNI_SetupThreadEnv: failed", __func__);
return;
}
SDL_AMediaFormat_Opaque *opaque = (SDL_AMediaFormat_Opaque *)aformat->opaque;
jobject android_media_format = opaque->android_media_format;
if (!opaque->android_byte_buffer) {
opaque->android_byte_buffer = J4AC_ByteBuffer__allocateDirect__asGlobalRef__catchAll(env, size);
if (!opaque->android_byte_buffer) {
J4A_FUNC_FAIL_TRACE();
return;
}
}
ret = J4AC_ByteBuffer__assignData__catchAll(env, opaque->android_byte_buffer, data, size);
if (ret < 0) {
J4A_FUNC_FAIL_TRACE();
return;
}
J4AC_MediaFormat__setByteBuffer__withCString(env, android_media_format, name, opaque->android_byte_buffer);
if (J4A_ExceptionCheck__catchAll(env)) {
ALOGE("%s: call jmid_setByteBuffer: failed", __func__);
return;
}
}
示例6: aout_open_audio
static int aout_open_audio(SDL_Aout *aout, const SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
{
// SDL_Aout_Opaque *opaque = aout->opaque;
JNIEnv *env = NULL;
if (JNI_OK != SDL_JNI_SetupThreadEnv(&env)) {
ALOGE("aout_open_audio: AttachCurrentThread: failed");
return -1;
}
return aout_open_audio_n(env, aout, desired, obtained);
}
示例7: inject_callback
// NOTE: support to be called from read_thread
static int
inject_callback(void *opaque, int what, void *data, size_t data_size)
{
JNIEnv *env = NULL;
jobject jbundle = NULL;
int ret = -1;
int is_handled = 0;
SDL_JNI_SetupThreadEnv(&env);
jobject weak_thiz = (jobject) opaque;
if (weak_thiz == NULL )
goto fail;
switch (what) {
case AIRSTASHAVINJECT_CONCAT_RESOLVE_SEGMENT:
case AIRSTASHAVINJECT_ON_TCP_OPEN:
case AIRSTASHAVINJECT_ON_HTTP_OPEN:
case AIRSTASHAVINJECT_ON_HTTP_RETRY:
case AIRSTASHAVINJECT_ON_LIVE_RETRY: {
AirStashAVInject_OnUrlOpenData *real_data = (AirStashAVInject_OnUrlOpenData *) data;
real_data->is_handled = 0;
jbundle = AirStashC_Bundle__Bundle__catchAll(env);
if (!jbundle) {
ALOGE("%s: ASDK_Bundle__init failed\n", __func__);
goto fail;
}
AirStashC_Bundle__putString__withCString__catchAll(env, jbundle, "url", real_data->url);
AirStashC_Bundle__putInt__withCString__catchAll(env, jbundle, "segment_index", real_data->segment_index);
AirStashC_Bundle__putInt__withCString__catchAll(env, jbundle, "retry_counter", real_data->retry_counter);
is_handled = AirStashC_AirStashMediaPlayer__onNativeInvoke__catchAll(env, weak_thiz, what, jbundle);
if (AirStash_ExceptionCheck__catchAll(env))
goto fail;
AirStashC_Bundle__getString__withCString__asCBuffer(env, jbundle, "url", real_data->url, sizeof(real_data->url));
if (AirStash_ExceptionCheck__catchAll(env))
goto fail;
real_data->is_handled = is_handled;
ret = 0;
break;
}
default: {
goto fail;
}
}
fail:
SDL_JNI_DeleteLocalRefP(env, &jbundle);
return ret;
}
示例8: aout_thread
static int aout_thread(void *arg)
{
SDL_Aout *aout = arg;
// SDL_Aout_Opaque *opaque = aout->opaque;
JNIEnv *env = NULL;
if (JNI_OK != SDL_JNI_SetupThreadEnv(&env)) {
ALOGE("aout_thread: SDL_AndroidJni_SetupEnv: failed");
return -1;
}
return aout_thread_n(env, aout);
}
示例9: inject_callback
// NOTE: support to be called from read_thread
static int
inject_callback(void *opaque, int what, void *data, size_t data_size)
{
JNIEnv *env = NULL;
jobject jbundle = NULL;
int ret = -1;
SDL_JNI_SetupThreadEnv(&env);
jobject weak_thiz = (jobject) opaque;
if (weak_thiz == NULL )
goto fail;
switch (what) {
case IJKAVINJECT_CONCAT_RESOLVE_SEGMENT: {
ret = _onNativeControlResolveSegment(env, weak_thiz, what, data, data_size);
break;
}
case IJKAVINJECT_ON_TCP_OPEN:
case IJKAVINJECT_ON_HTTP_OPEN:
case IJKAVINJECT_ON_HTTP_RETRY:
case IJKAVINJECT_ON_LIVE_RETRY: {
IJKAVInject_OnUrlOpenData *real_data = (IJKAVInject_OnUrlOpenData *) data;
jbundle = ASDK_Bundle__init(env);
if (SDL_JNI_CatchException(env) || !jbundle) {
ALOGE("%s: ASDK_Bundle__init failed\n", __func__);
goto fail;
}
ASDK_Bundle__putString_c(env, jbundle, "url", real_data->url);
ASDK_Bundle__putInt_c(env, jbundle, "segment_index", real_data->segment_index);
ASDK_Bundle__putInt_c(env, jbundle, "retry_counter", real_data->retry_counter);
if (!(*env)->CallStaticBooleanMethod(env, g_clazz.clazz, g_clazz.jmid_onNativeInvoke, weak_thiz, what, jbundle))
goto fail;
ASDK_Bundle__getString_cbuf(env, jbundle, "url", real_data->url, sizeof(real_data->url));
ret = 0;
break;
}
default: {
goto fail;
}
}
fail:
SDL_JNI_CatchException(env);
SDL_JNI_DeleteLocalRefP(env, &jbundle);
return ret;
}
示例10: audiotrack_get_native_output_sample_rate
int audiotrack_get_native_output_sample_rate(JNIEnv *env)
{
if (!env) {
if (JNI_OK != SDL_JNI_SetupThreadEnv(&env)) {
ALOGE("%s: SetupThreadEnv failed", __func__);
return -1;
}
}
jint retval = JJKC_AudioTrack__getNativeOutputSampleRate(env, STREAM_MUSIC);
if (JJK_ExceptionCheck__catchAll(env) || retval <= 0)
return -1;
return retval;
}
示例11: SDL_AMediaCodecJava_dequeueOutputBuffer
ssize_t SDL_AMediaCodecJava_dequeueOutputBuffer(SDL_AMediaCodec* acodec, SDL_AMediaCodecBufferInfo *info, int64_t timeoutUs)
{
AMCTRACE("%s(%d)", __func__, (int)timeoutUs);
JNIEnv *env = NULL;
if (JNI_OK != SDL_JNI_SetupThreadEnv(&env)) {
ALOGE("%s: SetupThreadEnv failed", __func__);
return AMEDIACODEC__UNKNOWN_ERROR;
}
SDL_AMediaCodec_Opaque *opaque = (SDL_AMediaCodec_Opaque *)acodec->opaque;
jobject android_media_codec = opaque->android_media_codec;
if (!opaque->output_buffer_info) {
opaque->output_buffer_info = SDL_JNI_NewObjectAsGlobalRef(env, g_clazz_BufferInfo.clazz, g_clazz_BufferInfo.jmid__ctor);
if (SDL_JNI_CatchException(env) || !opaque->output_buffer_info) {
ALOGE("%s: SDL_JNI_NewObjectAsGlobalRef failed", __func__);
return AMEDIACODEC__UNKNOWN_ERROR;
}
}
jint idx = AMEDIACODEC__UNKNOWN_ERROR;
while (1) {
idx = (*env)->CallIntMethod(env, android_media_codec, g_clazz.jmid_dequeueOutputBuffer, opaque->output_buffer_info, (jlong)timeoutUs);
if (SDL_JNI_CatchException(env)) {
ALOGI("%s: Exception\n", __func__);
return AMEDIACODEC__UNKNOWN_ERROR;
}
if (idx == AMEDIACODEC__INFO_OUTPUT_BUFFERS_CHANGED) {
ALOGI("%s: INFO_OUTPUT_BUFFERS_CHANGED\n", __func__);
SDL_JNI_DeleteGlobalRefP(env, &opaque->input_buffer_array);
SDL_JNI_DeleteGlobalRefP(env, &opaque->output_buffer_array);
continue;
} else if (idx == AMEDIACODEC__INFO_OUTPUT_FORMAT_CHANGED) {
ALOGI("%s: INFO_OUTPUT_FORMAT_CHANGED\n", __func__);
} else if (idx >= 0) {
AMCTRACE("%s: buffer ready (%d) ====================\n", __func__, idx);
if (info) {
info->offset = (*env)->GetIntField(env, opaque->output_buffer_info, g_clazz_BufferInfo.jfid_offset);
info->size = (*env)->GetIntField(env, opaque->output_buffer_info, g_clazz_BufferInfo.jfid_size);
info->presentationTimeUs = (*env)->GetLongField(env, opaque->output_buffer_info, g_clazz_BufferInfo.jfid_presentationTimeUs);
info->flags = (*env)->GetIntField(env, opaque->output_buffer_info, g_clazz_BufferInfo.jfid_flags);
}
}
break;
}
return idx;
}
示例12: func_destroy
static void func_destroy(IJKFF_Pipeline *pipeline)
{
IJKFF_Pipeline_Opaque *opaque = pipeline->opaque;
JNIEnv *env = NULL;
SDL_DestroyMutexP(&opaque->surface_mutex);
if (JNI_OK != SDL_JNI_SetupThreadEnv(&env)) {
ALOGE("amediacodec-pipeline:destroy: SetupThreadEnv failed\n");
goto fail;
}
SDL_JNI_DeleteGlobalRefP(env, &opaque->jsurface);
fail:
return;
}
示例13: SDL_AMediaCodecJava_queueInputBuffer
sdl_amedia_status_t SDL_AMediaCodecJava_queueInputBuffer(SDL_AMediaCodec* acodec, size_t idx, off_t offset, size_t size, uint64_t time, uint32_t flags)
{
AMCTRACE("%s: %d", __func__, (int)idx);
JNIEnv *env = NULL;
if (JNI_OK != SDL_JNI_SetupThreadEnv(&env)) {
ALOGE("SDL_AMediaCodecJava_queueInputBuffer: SetupThreadEnv failed");
return SDL_AMEDIA_ERROR_UNKNOWN;
}
SDL_AMediaCodec_Opaque *opaque = (SDL_AMediaCodec_Opaque *)acodec->opaque;
jobject android_media_codec = opaque->android_media_codec;
(*env)->CallVoidMethod(env, android_media_codec, g_clazz.jmid_queueInputBuffer, (jint)idx, (jint)offset, (jint)size, (jlong)time, (jint)flags);
if (SDL_JNI_CatchException(env)) {
return SDL_AMEDIA_ERROR_UNKNOWN;
}
return SDL_AMEDIA_OK;
}
示例14: SDL_AMediaCodecJava_flush
static sdl_amedia_status_t SDL_AMediaCodecJava_flush(SDL_AMediaCodec* acodec)
{
SDLTRACE("%s", __func__);
JNIEnv *env = NULL;
if (JNI_OK != SDL_JNI_SetupThreadEnv(&env)) {
ALOGE("%s: SetupThreadEnv failed", __func__);
return SDL_AMEDIA_ERROR_UNKNOWN;
}
jobject android_media_codec = SDL_AMediaCodecJava_getObject(env, acodec);
(*env)->CallVoidMethod(env, android_media_codec, g_clazz.jmid_flush, android_media_codec);
if (SDL_JNI_CatchException(env)) {
ALOGE("%s: flush", __func__);
return SDL_AMEDIA_ERROR_UNKNOWN;
}
return SDL_AMEDIA_OK;
}
示例15: mediacodec_select_callback
static bool mediacodec_select_callback(void *opaque, ijkmp_mediacodecinfo_context *mcc)
{
JNIEnv *env = NULL;
jobject jmime = NULL;
jstring jcodec_name = NULL;
jobject weak_this = (jobject) opaque;
const char *codec_name = NULL;
bool found_codec = false;
if (JNI_OK != SDL_JNI_SetupThreadEnv(&env)) {
ALOGE("%s: SetupThreadEnv failed\n", __func__);
return -1;
}
jmime = (*env)->NewStringUTF(env, mcc->mime_type);
if (SDL_JNI_CatchException(env) || !jmime) {
goto fail;
}
jcodec_name = (*env)->CallStaticObjectMethod(env, g_clazz.clazz, g_clazz.jmid_onSelectCodec, weak_this, jmime, mcc->profile, mcc->level);
if (SDL_JNI_CatchException(env) || !jcodec_name) {
goto fail;
}
codec_name = (*env)->GetStringUTFChars(env, jcodec_name, NULL );
if (!codec_name || !*codec_name) {
goto fail;
}
strncpy(mcc->codec_name, codec_name, sizeof(mcc->codec_name) / sizeof(*mcc->codec_name));
mcc->codec_name[sizeof(mcc->codec_name) / sizeof(*mcc->codec_name) - 1] = 0;
found_codec = true;
fail:
if (codec_name) {
(*env)->ReleaseStringUTFChars(env, jcodec_name, codec_name);
codec_name = NULL;
}
SDL_JNI_DeleteLocalRefP(env, &jcodec_name);
SDL_JNI_DeleteLocalRefP(env, &jmime);
return found_codec;
}