< prev index next >

modules/javafx.media/src/main/native/jfxmedia/jni/JavaBandsHolder.cpp

Print this page
rev 10028 : 8156563: JavaFX Ensemble8 media sample hang and crash
Reviewed-by: almatvee, kcr

*** 1,7 **** /* ! * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 39,53 **** { CJavaEnvironment jenv(m_jvm); JNIEnv *pEnv = jenv.getEnvironment(); if (pEnv) { ! if (m_Magnitudes) pEnv->DeleteGlobalRef(m_Magnitudes); ! if (m_Phases) pEnv->DeleteGlobalRef(m_Phases); } } void CJavaBandsHolder::UpdateBands(int size, const float* magnitudes, const float* phases) { --- 39,57 ---- { CJavaEnvironment jenv(m_jvm); JNIEnv *pEnv = jenv.getEnvironment(); if (pEnv) { ! if (m_Magnitudes) { pEnv->DeleteGlobalRef(m_Magnitudes); + m_Magnitudes = NULL; + } ! if (m_Phases) { pEnv->DeleteGlobalRef(m_Phases); + m_Phases = NULL; + } } } void CJavaBandsHolder::UpdateBands(int size, const float* magnitudes, const float* phases) {
*** 55,63 **** return; CJavaEnvironment jenv(m_jvm); JNIEnv *pEnv = jenv.getEnvironment(); if (pEnv) { ! pEnv->SetFloatArrayRegion(m_Magnitudes, 0, size, magnitudes); ! pEnv->SetFloatArrayRegion(m_Phases, 0, size, phases); } } --- 59,76 ---- return; CJavaEnvironment jenv(m_jvm); JNIEnv *pEnv = jenv.getEnvironment(); if (pEnv) { ! // use local references due to threading issues ! jfloatArray localMagnitudes = (jfloatArray)pEnv->NewLocalRef(m_Magnitudes); ! jfloatArray localPhases = (jfloatArray)pEnv->NewLocalRef(m_Phases); ! ! if (localMagnitudes && localPhases) { ! pEnv->SetFloatArrayRegion(localMagnitudes, 0, size, magnitudes); ! pEnv->SetFloatArrayRegion(localPhases, 0, size, phases); ! } ! ! pEnv->DeleteLocalRef(localMagnitudes); ! pEnv->DeleteLocalRef(localPhases); } }
< prev index next >