boost::filesystem::path LinuxPath::getUserDataPath() const { return getEnv("XDG_DATA_HOME", getUserHome() / ".local/share") / mName; }
void IrreversibleUnimolecularReaction::calcFluxFirstNonZeroIdx(void) { double thresh = get_ThresholdEnergy(); if(thresh<0.0){m_GrnFluxFirstNonZeroIdx = int(-thresh/getEnv().GrainSize);} else{m_GrnFluxFirstNonZeroIdx = 0;} }
int drumsynth::load_patch(char *dsfile) { // init(); // if(wavemode==0) //semi-real-time adjustments if working in memory!! // { // mem_t = 1.0f; // mem_o = 1.0f; // mem_n = 1.0f; // mem_b = 1.0f; // mem_tune = 0.0f; // mem_time = 1.0f; // mem_time = 2.0f; // } //try to read version from input file //lstrcpy(sec, "General"); strcpy(sec, "General"); GetPrivateProfileString(sec,"Version","",ver,sizeof(ver),dsfile); ver[9]=0; //if(lstrcmp(ver, "DrumSynth") != 0) {busy=0; return 2;} //input fail printf("%s\n",ver); if(strcmp(ver, "DrumSynth") != 0) {busy=0; return 2;} //input fail if(ver[11] != '1' && ver[11] != '2') {busy=0; return 1;} //version fail //read master parameters GetPrivateProfileString(sec,"Comment","",comment,sizeof(comment),dsfile); while((comment[commentLen]!=0) && (commentLen<254)) commentLen++; if(commentLen==0) { comment[0]=32; comment[1]=0; commentLen=1;} comment[commentLen+1]=0; commentLen++; if((commentLen % 2)==1) commentLen++; timestretch = .01f * mem_time * GetPrivateProfileFloat(sec,"Stretch",100.0,dsfile); if(timestretch<0.2f) timestretch=0.2f; if(timestretch>10.f) timestretch=10.f; DGain = 1.0f; //leave this here! DGain = (float)pow(10.0, 0.05 * GetPrivateProfileFloat(sec,"Level",0,dsfile)); MasterTune = GetPrivateProfileFloat(sec,"Tuning",0.0,dsfile); MasterTune = (float)pow(1.0594631f, MasterTune + mem_tune); MainFilter = 2 * GetPrivateProfileInt(sec,"Filter",0,dsfile); MFres = 0.0101f * GetPrivateProfileFloat(sec,"Resonance",0.0,dsfile); MFres = (float)pow(MFres, 0.5f); HighPass = GetPrivateProfileInt(sec,"HighPass",0,dsfile); getEnv(7, sec, "FilterEnv", dsfile); //read noise parameters //lstrcpy(sec, "Noise"); strcpy(sec, "Noise"); chkOn[1] = GetPrivateProfileInt(sec,"On",0,dsfile); sliLev[1] = GetPrivateProfileInt(sec,"Level",0,dsfile); NT = GetPrivateProfileInt(sec,"Slope",0,dsfile); getEnv(2, sec, "Envelope", dsfile); NON = chkOn[1]; NL = (float)(sliLev[1] * sliLev[1]) * mem_n; if(NT<0) { a = 1.f + (NT / 105.f); d = -NT / 105.f; g = (1.f + 0.0005f * NT * NT) * NL; } else { a = 1.f; b = -NT / 50.f; c = (float)fabs((float)NT) / 100.f; g = NL; } //if(GetPrivateProfileInt(sec,"FixedSeq",0,dsfile)!=0) srand(1); //fixed random sequence //read tone parameters //lstrcpy(sec, "Tone"); strcpy(sec, "Tone"); chkOn[0] = GetPrivateProfileInt(sec,"On",0,dsfile); TON = chkOn[0]; sliLev[0] = GetPrivateProfileInt(sec,"Level",128,dsfile); TL = (float)(sliLev[0] * sliLev[0]) * mem_t; getEnv(1, sec, "Envelope", dsfile); F1 = MasterTune * TwoPi * GetPrivateProfileFloat(sec,"F1",200.0,dsfile) / Fs; if(fabs(F1)<0.001f) F1=0.001f; //to prevent overtone ratio div0 F2 = MasterTune * TwoPi * GetPrivateProfileFloat(sec,"F2",120.0,dsfile) / Fs; Fsync = F2; TDroopRate = GetPrivateProfileFloat(sec,"Droop",0.f,dsfile); if(TDroopRate>0.f) { TDroopRate = (float)pow(10.0f, (TDroopRate - 20.0f) / 30.0f); TDroopRate = TDroopRate * -4.f / envData[1][MDA_MAX]; TDroop = 1; F2 = F1+((F2-F1)/(1.f-(float)exp(TDroopRate * envData[1][MDA_MAX]))); ddF = F1 - F2; } else ddF = F2-F1; Tphi = GetPrivateProfileFloat(sec,"Phase",90.f,dsfile) / 57.29578f; //degrees>radians //read overtone parameters //lstrcpy(sec, "Overtones"); strcpy(sec, "Overtones"); chkOn[2] = GetPrivateProfileInt(sec,"On",0,dsfile); OON = chkOn[2]; sliLev[2] = GetPrivateProfileInt(sec,"Level",128,dsfile); OL = (float)(sliLev[2] * sliLev[2]) * mem_o; getEnv(3, sec, "Envelope1", dsfile); getEnv(4, sec, "Envelope2", dsfile); OMode = GetPrivateProfileInt(sec,"Method",2,dsfile); OF1 = MasterTune * TwoPi * GetPrivateProfileFloat(sec,"F1",200.0,dsfile) / Fs; OF2 = MasterTune * TwoPi * GetPrivateProfileFloat(sec,"F2",120.0,dsfile) / Fs; OW1 = GetPrivateProfileInt(sec,"Wave1",0,dsfile); OW2 = GetPrivateProfileInt(sec,"Wave2",0,dsfile); OBal2 = (float)GetPrivateProfileInt(sec,"Param",50,dsfile); ODrive = (float)pow(OBal2, 3.0f) / (float)pow(50.0f, 3.0f); OBal2 *= 0.01f; OBal1 = 1.f - OBal2; Ophi1 = Tphi; Ophi2 = Tphi; if(MainFilter==0) MainFilter = GetPrivateProfileInt(sec,"Filter",0,dsfile); if((GetPrivateProfileInt(sec,"Track1",0,dsfile)==1) && (TON==1)) { OF1Sync = 1; OF1 = OF1 / F1; } if((GetPrivateProfileInt(sec,"Track2",0,dsfile)==1) && (TON==1)) { OF2Sync = 1; OF2 = OF2 / F1; } OcA = 0.28f + OBal1 * OBal1; //overtone cymbal mode OcQ = OcA * OcA; OcF = (1.8f - 0.7f * OcQ) * 0.92f; //multiply by env 2 OcA *= 1.0f + 4.0f * OBal1; //level is a compromise! Ocf1 = TwoPi / OF1; Ocf2 = TwoPi / OF2; for(i=0; i<6; i++) Oc[i][0] = Oc[i][1] = Ocf1 + (Ocf2 - Ocf1) * 0.2f * (float)i; //read noise band parameters //lstrcpy(sec, "NoiseBand"); strcpy(sec, "NoiseBand"); chkOn[3] = GetPrivateProfileInt(sec,"On",0,dsfile); BON = chkOn[3]; sliLev[3] = GetPrivateProfileInt(sec,"Level",128,dsfile); BL = (float)(sliLev[3] * sliLev[3]) * mem_b; BF = MasterTune * TwoPi * GetPrivateProfileFloat(sec,"F",1000.0,dsfile) / Fs; BPhi = TwoPi / 8.f; getEnv(5, sec, "Envelope", dsfile); BFStep = GetPrivateProfileInt(sec,"dF",50,dsfile); BQ = (float)BFStep; BQ = BQ * BQ / (10000.f-6600.f*((float)sqrt(BF)-0.19f)); BFStep = 1 + (int)((40.f - (BFStep / 2.5f)) / (BQ + 1.f + (1.f * BF))); //lstrcpy(sec, "NoiseBand2"); strcpy(sec, "NoiseBand2"); chkOn[4] = GetPrivateProfileInt(sec,"On",0,dsfile); BON2 = chkOn[4]; sliLev[4] = GetPrivateProfileInt(sec,"Level",128,dsfile); BL2 = (float)(sliLev[4] * sliLev[4]) * mem_b; BF2 = MasterTune * TwoPi * GetPrivateProfileFloat(sec,"F",1000.0,dsfile) / Fs; BPhi2 = TwoPi / 8.f; getEnv(6, sec, "Envelope", dsfile); BFStep2 = GetPrivateProfileInt(sec,"dF",50,dsfile); BQ2 = (float)BFStep2; BQ2 = BQ2 * BQ2 / (10000.f-6600.f*((float)sqrt(BF2)-0.19f)); BFStep2 = 1 + (int)((40 - (BFStep2 / 2.5)) / (BQ2 + 1 + (1 * BF2))); //read distortion parameters //lstrcpy(sec, "Distortion"); strcpy(sec, "Distortion"); chkOn[5] = GetPrivateProfileInt(sec,"On",0,dsfile); DiON = chkOn[5]; DStep = 1 + GetPrivateProfileInt(sec,"Rate",0,dsfile); if(DStep==7) DStep=20; if(DStep==6) DStep=10; if(DStep==5) DStep=8; clippoint = 32700; DAtten = 1.0f; if(DiON==1) { DAtten = DGain * (short)LoudestEnv(); if(DAtten>32700) clippoint=32700; else clippoint=(short)DAtten; DAtten = (float)pow(2.0, 2.0 * GetPrivateProfileInt(sec,"Bits",0,dsfile)); DGain = DAtten * DGain * (float)pow(10.0, 0.05 * GetPrivateProfileInt(sec,"Clipping",0,dsfile)); } //prepare envelopes randmax = 1.f / RAND_MAX; randmax2 = 2.f * randmax; for (i=1;i<8;i++) { envData[i][NEXTT]=0; envData[i][PNT]=0; } Length = LongestEnv(); /* if(wave!=NULL) free(wave); */ /* wave = (short *)malloc(2 * Length + 1280); //wave memory buffer */ if(wave==NULL) {busy=0; return 1;} wavewords = 0; prepare=1; return 0; }
String getLocaleValue (bool isRegion) { return juceString (LocalRef<jstring> ((jstring) getEnv()->CallStaticObjectMethod (JuceAppActivity, JuceAppActivity.getLocaleValue, isRegion))); }
jdwpError transport_startTransport(jboolean isServer, char *name, char *address, long timeout) { jvmtiStartFunction func; jdwpTransportEnv *trans; char threadName[MAXPATHLEN + 100]; jint err; jdwpError serror; /* * If the transport is already loaded then use it * Note: We're assuming here that we don't support multiple * transports - when we do then we need to handle the case * where the transport library only supports a single environment. * That probably means we have a bag a transport environments * to correspond to the transports bag. */ if (transport != NULL) { trans = transport; } else { serror = loadTransport(name, &trans); if (serror != JDWP_ERROR(NONE)) { return serror; } } if (isServer) { char *retAddress; char *launchCommand; TransportInfo *info; jvmtiError error; int len; char* prop_value; info = jvmtiAllocate(sizeof(*info)); if (info == NULL) { return JDWP_ERROR(OUT_OF_MEMORY); } info->name = jvmtiAllocate((int)strlen(name)+1); (void)strcpy(info->name, name); info->address = NULL; info->timeout = timeout; if (info->name == NULL) { serror = JDWP_ERROR(OUT_OF_MEMORY); goto handleError; } if (address != NULL) { info->address = jvmtiAllocate((int)strlen(address)+1); (void)strcpy(info->address, address); if (info->address == NULL) { serror = JDWP_ERROR(OUT_OF_MEMORY); goto handleError; } } info->transport = trans; err = (*trans)->StartListening(trans, address, &retAddress); if (err != JDWPTRANSPORT_ERROR_NONE) { printLastError(trans, err); serror = JDWP_ERROR(TRANSPORT_INIT); goto handleError; } /* * Record listener address in a system property */ len = strlen(name) + strlen(retAddress) + 2; /* ':' and '\0' */ prop_value = (char*)jvmtiAllocate(len); strcpy(prop_value, name); strcat(prop_value, ":"); strcat(prop_value, retAddress); setTransportProperty(getEnv(), prop_value); jvmtiDeallocate(prop_value); (void)strcpy(threadName, "JDWP Transport Listener: "); (void)strcat(threadName, name); func = &acceptThread; error = spawnNewThread(func, (void*)info, threadName); if (error != JVMTI_ERROR_NONE) { serror = map2jdwpError(error); goto handleError; } launchCommand = debugInit_launchOnInit(); if (launchCommand != NULL) { serror = launch(launchCommand, name, retAddress); if (serror != JDWP_ERROR(NONE)) { goto handleError; } } else { if ( ! gdata->quiet ) { TTY_MESSAGE(("Listening for transport %s at address: %s", name, retAddress)); } } return JDWP_ERROR(NONE); handleError: jvmtiDeallocate(info->name); jvmtiDeallocate(info->address); jvmtiDeallocate(info); } else { /* * Note that we don't attempt to do a launch here. Launching * is currently supported only in server mode. */ /* * If we're connecting to another process, there shouldn't be * any concurrent listens, so its ok if we block here in this * thread, waiting for the attach to finish. */ err = (*trans)->Attach(trans, address, timeout, 0); if (err != JDWPTRANSPORT_ERROR_NONE) { printLastError(trans, err); serror = JDWP_ERROR(TRANSPORT_INIT); return serror; } /* * Start the transport loop in a separate thread */ (void)strcpy(threadName, "JDWP Transport Listener: "); (void)strcat(threadName, name); func = &attachThread; err = spawnNewThread(func, (void*)trans, threadName); serror = map2jdwpError(err); } return serror; }
void set(int const &index, jobject item) { getEnv()->SetObjectArrayElement(array_, index, item); }
static jstring getNewEmptyString() { return getEnv()->NewStringUTF(""); }
~safe_local_ref() { //LOGE("LOCAL UNREF"); getEnv()->DeleteLocalRef(ref_); }
safe_string(JNIEnv *env, jstring const &string) : env_(env), ref_(string), string_(NULL) { string_ = getEnv()->GetStringUTFChars(ref_, NULL); }
String open (const BigInteger& inputChannels, const BigInteger& outputChannels, double requestedSampleRate, int bufferSize) { close(); if (sampleRate != (int) requestedSampleRate) return "Sample rate not allowed"; lastError = String::empty; int preferredBufferSize = (bufferSize <= 0) ? getDefaultBufferSize() : bufferSize; numDeviceInputChannels = 0; numDeviceOutputChannels = 0; activeOutputChans = outputChannels; activeOutputChans.setRange (2, activeOutputChans.getHighestBit(), false); numClientOutputChannels = activeOutputChans.countNumberOfSetBits(); activeInputChans = inputChannels; activeInputChans.setRange (2, activeInputChans.getHighestBit(), false); numClientInputChannels = activeInputChans.countNumberOfSetBits(); actualBufferSize = preferredBufferSize; inputChannelBuffer.setSize (2, actualBufferSize); inputChannelBuffer.clear(); outputChannelBuffer.setSize (2, actualBufferSize); outputChannelBuffer.clear(); JNIEnv* env = getEnv(); if (numClientOutputChannels > 0) { numDeviceOutputChannels = 2; outputDevice = GlobalRef (env->NewObject (AudioTrack, AudioTrack.constructor, STREAM_MUSIC, sampleRate, CHANNEL_OUT_STEREO, ENCODING_PCM_16BIT, (jint) (minBufferSizeOut * numDeviceOutputChannels * sizeof (int16)), MODE_STREAM)); if (env->CallIntMethod (outputDevice, AudioTrack.getState) != STATE_UNINITIALIZED) isRunning = true; else outputDevice.clear(); // failed to open the device } if (numClientInputChannels > 0 && numDeviceInputChannelsAvailable > 0) { numDeviceInputChannels = jmin (numClientInputChannels, numDeviceInputChannelsAvailable); inputDevice = GlobalRef (env->NewObject (AudioRecord, AudioRecord.constructor, 0 /* (default audio source) */, sampleRate, numDeviceInputChannelsAvailable > 1 ? CHANNEL_IN_STEREO : CHANNEL_IN_MONO, ENCODING_PCM_16BIT, (jint) (minBufferSizeIn * numDeviceInputChannels * sizeof (int16)))); if (env->CallIntMethod (inputDevice, AudioRecord.getState) != STATE_UNINITIALIZED) isRunning = true; else inputDevice.clear(); // failed to open the device } if (isRunning) { if (outputDevice != nullptr) env->CallVoidMethod (outputDevice, AudioTrack.play); if (inputDevice != nullptr) env->CallVoidMethod (inputDevice, AudioRecord.startRecording); startThread (8); } else { closeDevices(); } return lastError; }
void run() { JNIEnv* env = getEnv(); jshortArray audioBuffer = env->NewShortArray (actualBufferSize * jmax (numDeviceOutputChannels, numDeviceInputChannels)); while (! threadShouldExit()) { if (inputDevice != nullptr) { jint numRead = env->CallIntMethod (inputDevice, AudioRecord.read, audioBuffer, 0, actualBufferSize * numDeviceInputChannels); if (numRead < actualBufferSize * numDeviceInputChannels) { DBG ("Audio read under-run! " << numRead); } jshort* const src = env->GetShortArrayElements (audioBuffer, 0); for (int chan = 0; chan < inputChannelBuffer.getNumChannels(); ++chan) { AudioData::Pointer <AudioData::Float32, AudioData::NativeEndian, AudioData::NonInterleaved, AudioData::NonConst> d (inputChannelBuffer.getSampleData (chan)); if (chan < numDeviceInputChannels) { AudioData::Pointer <AudioData::Int16, AudioData::NativeEndian, AudioData::Interleaved, AudioData::Const> s (src + chan, numDeviceInputChannels); d.convertSamples (s, actualBufferSize); } else { d.clearSamples (actualBufferSize); } } env->ReleaseShortArrayElements (audioBuffer, src, 0); } if (threadShouldExit()) break; { const ScopedLock sl (callbackLock); if (callback != nullptr) { callback->audioDeviceIOCallback ((const float**) inputChannelBuffer.getArrayOfChannels(), numClientInputChannels, outputChannelBuffer.getArrayOfChannels(), numClientOutputChannels, actualBufferSize); } else { outputChannelBuffer.clear(); } } if (outputDevice != nullptr) { if (threadShouldExit()) break; jshort* const dest = env->GetShortArrayElements (audioBuffer, 0); for (int chan = 0; chan < numDeviceOutputChannels; ++chan) { AudioData::Pointer <AudioData::Int16, AudioData::NativeEndian, AudioData::Interleaved, AudioData::NonConst> d (dest + chan, numDeviceOutputChannels); const float* const sourceChanData = outputChannelBuffer.getSampleData (jmin (chan, outputChannelBuffer.getNumChannels() - 1)); AudioData::Pointer <AudioData::Float32, AudioData::NativeEndian, AudioData::NonInterleaved, AudioData::Const> s (sourceChanData); d.convertSamples (s, actualBufferSize); } env->ReleaseShortArrayElements (audioBuffer, dest, 0); jint numWritten = env->CallIntMethod (outputDevice, AudioTrack.write, audioBuffer, 0, actualBufferSize * numDeviceOutputChannels); if (numWritten < actualBufferSize * numDeviceOutputChannels) { DBG ("Audio write underrun! " << numWritten); } } } }
/* Methods */ int VbitmapResize(Vbitmap *vbitmap, int width, int height) { if (vbitmap == NULL) { return YMAGINE_ERROR; } if (width <= 0 || height <= 0) { return YMAGINE_ERROR; } if (width == vbitmap->width && height == vbitmap->height) { /* Size not changed, ignore */ return YMAGINE_OK; } if (vbitmap->bitmaptype == VBITMAP_NONE) { vbitmap->width = width; vbitmap->height = height; return YMAGINE_OK; } if (vbitmap->bitmaptype == VBITMAP_ANDROID) { AndroidBitmapInfo bitmapinfo; jobject jbitmap; jobject jbitmapref; int ret; JNIEnv *jenv = getEnv(vbitmap); if (jenv == NULL) { return YMAGINE_ERROR; } jbitmap = createAndroidBitmap(jenv, width, height); if (jbitmap == NULL) { return YMAGINE_ERROR; } ret = AndroidBitmap_getInfo(jenv, jbitmap, &bitmapinfo); if (ret < 0 || bitmapinfo.format != ANDROID_BITMAP_FORMAT_RGBA_8888 || bitmapinfo.width != width || bitmapinfo.height != height) { return YMAGINE_ERROR; } jbitmapref = (*jenv)->NewGlobalRef(jenv, jbitmap); if (jbitmapref == NULL) { return YMAGINE_ERROR; } /* Replace Bitmap */ if (vbitmap->jbitmap != NULL) { if (vbitmap->jkeepref) { (*jenv)->DeleteGlobalRef(jenv, vbitmap->jbitmap); vbitmap->jkeepref = 0; } vbitmap->jbitmap = NULL; } #if VBITMAP_ENABLE_GLOBAL_REF vbitmap->jbitmap = jbitmapref; vbitmap->jkeepref = 1; #else vbitmap->jbitmap = jbitmap; vbitmap->jkeepref = 0; (*jenv)->DeleteGlobalRef(jenv, jbitmapref); #endif vbitmap->width = bitmapinfo.width; vbitmap->height = bitmapinfo.height; vbitmap->pitch = bitmapinfo.stride; return YMAGINE_OK; } if (vbitmap->bitmaptype == VBITMAP_MEMORY) { int bpp = colorBpp(VbitmapColormode(vbitmap)); int pitch = width * bpp; unsigned char *pixels = NULL; if (pitch > 0) { pixels = Ymem_malloc(pitch * height); } if (pixels == NULL) { return YMAGINE_ERROR; } if (vbitmap->pixels != NULL) { Ymem_free(vbitmap->pixels); } vbitmap->pixels = pixels; vbitmap->width = width; vbitmap->height = height; vbitmap->pitch = pitch; return YMAGINE_OK; } if (vbitmap->bitmaptype == VBITMAP_STATIC) { /* Can't resize a static bitmap */ return YMAGINE_ERROR; } return YMAGINE_ERROR; }
std::string getEnv(const std::string& env, const std::string& defaultValue) { return ws2s(getEnv(s2ws(env), s2ws(defaultValue))); }
boost::filesystem::path LinuxPath::getCachePath() const { return getEnv("XDG_CACHE_HOME", getUserHome() / ".cache") / mName; }
safe_object_array(JNIEnv *env, jobjectArray array) : env_(env), array_(array) { size_ = getEnv()->GetArrayLength(array); }
~safe_string() { if (string_) { getEnv()->ReleaseStringUTFChars(ref_, string_); string_ = NULL; } }
jobject get(int const &index) const { if ((index < 0) || (static_cast<size_t>(index) > size_)) { throw safe_jni::index_out_of_bounds_exception("Index out of bounds."); } return getEnv()->GetObjectArrayElement(array_, index); }
size_t length() const { return getEnv()->GetStringUTFLength(ref_); }
jamruby_context::~jamruby_context() { std::for_each(classes.begin(), classes.end(), destruct_class(getEnv())); classes.clear(); }
~clear_exception() { if (do_clear_) { getEnv()->ExceptionClear(); } }
String getSystemProperty (const String& name) { return juceString (LocalRef<jstring> ((jstring) getEnv()->CallStaticObjectMethod (SystemClass, SystemClass.getProperty, javaString (name).get()))); }
void operator () (jobject obj, ...) const { va_list args; va_start(args, obj); getEnv()->CallVoidMethodV(obj, mid_, args); va_end(args); }
/* * loadTransport() is adapted from loadJVMHelperLib() in * JDK 1.2 javai.c v1.61 */ static jdwpError loadTransport(char *name, jdwpTransportEnv **transportPtr) { JNIEnv *env; jdwpTransport_OnLoad_t onLoad; void *handle; char *libdir; /* Make sure library name is not empty */ if (name == NULL) { ERROR_MESSAGE(("library name is empty")); return JDWP_ERROR(TRANSPORT_LOAD); } /* First, look in sun.boot.library.path. This should find the standard * dt_socket and dt_shmem transport libraries, or any library * that was delivered with the J2SE. * Note: Java property sun.boot.library.path contains a single directory. */ libdir = gdata->property_sun_boot_library_path; if (libdir == NULL) { ERROR_MESSAGE(("Java property sun.boot.library.path is not set")); return JDWP_ERROR(TRANSPORT_LOAD); } handle = loadTransportLibrary(libdir, name); if (handle == NULL) { /* Second, look along the path used by the native dlopen/LoadLibrary * functions. This should effectively try and load the simple * library name, which will cause the default system library * search technique to happen. * We should only reach here if the transport library wasn't found * in the J2SE directory, e.g. it's a custom transport library * not installed in the J2SE like dt_socket and dt_shmem is. * * Note: Why not use java.library.path? Several reasons: * a) This matches existing agentlib search * b) These are technically not JNI libraries */ handle = loadTransportLibrary("", name); } /* See if a library was found with this name */ if (handle == NULL) { ERROR_MESSAGE(("transport library not found: %s", name)); return JDWP_ERROR(TRANSPORT_LOAD); } /* Find the onLoad address */ onLoad = findTransportOnLoad(handle); if (onLoad == NULL) { ERROR_MESSAGE(("transport library missing onLoad entry: %s", name)); return JDWP_ERROR(TRANSPORT_LOAD); } /* Get transport interface */ env = getEnv(); if ( env != NULL ) { jdwpTransportEnv *t; JavaVM *jvm; jint ver; JNI_FUNC_PTR(env,GetJavaVM)(env, &jvm); ver = (*onLoad)(jvm, &callback, JDWPTRANSPORT_VERSION_1_0, &t); if (ver != JNI_OK) { switch (ver) { case JNI_ENOMEM : ERROR_MESSAGE(("insufficient memory to complete initialization")); break; case JNI_EVERSION : ERROR_MESSAGE(("transport doesn't recognize version %x", JDWPTRANSPORT_VERSION_1_0)); break; case JNI_EEXIST : ERROR_MESSAGE(("transport doesn't support multiple environments")); break; default: ERROR_MESSAGE(("unrecognized error %d from transport", ver)); break; } return JDWP_ERROR(TRANSPORT_INIT); } *transportPtr = t; } else { return JDWP_ERROR(TRANSPORT_LOAD); } return JDWP_ERROR(NONE); }
void operator () (jclass cls, ...) const { va_list args; va_start(args, cls); getEnv()->CallStaticVoidMethodV(cls, mid_, args); va_end(args); }
util::String getEnv (char const * name) { util::String value; getEnv (name, value); return value; }
method(JNIEnv *env, jobject obj, char const * const name, char const * const sig) : env_(env), mid_(NULL) { safe_local_ref<jclass> cls(getEnv(), getEnv()->GetObjectClass(obj)); mid_ = getEnv()->GetMethodID(cls.get(), name, sig); }
// get_player_information() int ModApiServer::l_get_player_information(lua_State *L) { NO_MAP_LOCK_REQUIRED; const char * name = luaL_checkstring(L, 1); Player *player = getEnv(L)->getPlayer(name); if(player == NULL) { lua_pushnil(L); // no such player return 1; } Address addr; try { addr = getServer(L)->getPeerAddress(player->peer_id); } catch(con::PeerNotFoundException) // unlikely { dstream << __FUNCTION_NAME << ": peer was not found" << std::endl; lua_pushnil(L); // error return 1; } float min_rtt,max_rtt,avg_rtt,min_jitter,max_jitter,avg_jitter; ClientState state; u32 uptime; u16 prot_vers; u8 ser_vers,major,minor,patch; std::string vers_string; #define ERET(code) \ if (!(code)) { \ dstream << __FUNCTION_NAME << ": peer was not found" << std::endl; \ lua_pushnil(L); /* error */ \ return 1; \ } ERET(getServer(L)->getClientConInfo(player->peer_id,con::MIN_RTT,&min_rtt)) ERET(getServer(L)->getClientConInfo(player->peer_id,con::MAX_RTT,&max_rtt)) ERET(getServer(L)->getClientConInfo(player->peer_id,con::AVG_RTT,&avg_rtt)) ERET(getServer(L)->getClientConInfo(player->peer_id,con::MIN_JITTER,&min_jitter)) ERET(getServer(L)->getClientConInfo(player->peer_id,con::MAX_JITTER,&max_jitter)) ERET(getServer(L)->getClientConInfo(player->peer_id,con::AVG_JITTER,&avg_jitter)) ERET(getServer(L)->getClientInfo(player->peer_id, &state, &uptime, &ser_vers, &prot_vers, &major, &minor, &patch, &vers_string)) lua_newtable(L); int table = lua_gettop(L); lua_pushstring(L,"address"); lua_pushstring(L, addr.serializeString().c_str()); lua_settable(L, table); lua_pushstring(L,"ip_version"); if (addr.getFamily() == AF_INET) { lua_pushnumber(L, 4); } else if (addr.getFamily() == AF_INET6) { lua_pushnumber(L, 6); } else { lua_pushnumber(L, 0); } lua_settable(L, table); lua_pushstring(L,"min_rtt"); lua_pushnumber(L, min_rtt); lua_settable(L, table); lua_pushstring(L,"max_rtt"); lua_pushnumber(L, max_rtt); lua_settable(L, table); lua_pushstring(L,"avg_rtt"); lua_pushnumber(L, avg_rtt); lua_settable(L, table); lua_pushstring(L,"min_jitter"); lua_pushnumber(L, min_jitter); lua_settable(L, table); lua_pushstring(L,"max_jitter"); lua_pushnumber(L, max_jitter); lua_settable(L, table); lua_pushstring(L,"avg_jitter"); lua_pushnumber(L, avg_jitter); lua_settable(L, table); lua_pushstring(L,"connection_uptime"); lua_pushnumber(L, uptime); lua_settable(L, table); #ifndef NDEBUG lua_pushstring(L,"serialization_version"); lua_pushnumber(L, ser_vers); lua_settable(L, table); lua_pushstring(L,"protocol_version"); lua_pushnumber(L, prot_vers); lua_settable(L, table); lua_pushstring(L,"major"); lua_pushnumber(L, major); lua_settable(L, table); lua_pushstring(L,"minor"); lua_pushnumber(L, minor); lua_settable(L, table); lua_pushstring(L,"patch"); lua_pushnumber(L, patch); lua_settable(L, table); lua_pushstring(L,"version_string"); lua_pushstring(L, vers_string.c_str()); lua_settable(L, table); lua_pushstring(L,"state"); lua_pushstring(L,ClientInterface::state2Name(state).c_str()); lua_settable(L, table); #endif #undef ERET return 1; }
method(JNIEnv *env, jclass cls, char const * const name, char const * const sig) : env_(env), mid_(NULL) { mid_ = getEnv()->GetStaticMethodID(cls, name, sig); }
void AndroidUtil::throwRuntimeException(const std::string &message) { getEnv()->ThrowNew(Class_java_lang_RuntimeException.j(), message.c_str()); }
boost::filesystem::path LinuxPath::getUserConfigPath() const { return getEnv("XDG_CONFIG_HOME", getUserHome() / ".config") / mName; }