jint Java_edu_vu_isis_ammo_core_ethertracker_EthTrackSvc_initEthernetNative(JNIEnv *env,
		jobject clazz)
{
	int ret = -1;

	//LOGI("==>%s",__FUNCTION__);
	//	__android_log_print(ANDROID_LOG_INFO, LOG_TAG,
	//            "==>%s",__FUNCTION__);
	memset(&addr_msg, 0, sizeof(struct sockaddr_nl));
	addr_msg.nl_family = AF_NETLINK;
	memset(&addr_poll, 0, sizeof(struct sockaddr_nl));
	addr_poll.nl_family = AF_NETLINK;
	addr_poll.nl_pid = 0;//getpid();
	addr_poll.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR;

	/*
	 *Create connection to netlink socket
	 */
	nl_socket_msg = socket(AF_NETLINK,SOCK_RAW,NETLINK_ROUTE);
	if (nl_socket_msg <= 0) {
		//LOGE("Can not create netlink msg socket");

     	__android_log_print(
     						ANDROID_LOG_INFO, 
     						LOG_TAG,
							"Can not create netlink msg socket"
							); 
		goto error;
	}

	//	__android_log_print(ANDROID_LOG_INFO, LOG_TAG,
	//            "Got socket for msg"); 

	if (bind(nl_socket_msg, (struct sockaddr *)(&addr_msg),
				sizeof(struct sockaddr_nl))) {
     	__android_log_print(
     						ANDROID_LOG_INFO, 
     						LOG_TAG,
							"Can not bind to netlink msg socket"
							); 
		goto error;
	}
	__android_log_print(ANDROID_LOG_INFO, LOG_TAG,
			"Bound msg socket .... Getting poll socket"); 

	nl_socket_poll = socket(AF_NETLINK,SOCK_RAW,NETLINK_ROUTE);
	if (nl_socket_poll <= 0) {
     	__android_log_print(
     						ANDROID_LOG_INFO, 
     						LOG_TAG,
							"Can not create netlink poll socket"
							); 
		goto error;
	}

	//	__android_log_print(ANDROID_LOG_INFO, LOG_TAG,
	//            "Got Poll socket ... Trying to bind poll socket"); 

	errno = 0;
	if(bind(nl_socket_poll, (struct sockaddr *)(&addr_poll),
				sizeof(struct sockaddr_nl))) {
     	__android_log_print(
     						ANDROID_LOG_INFO, 
     						LOG_TAG,
							"Can not bind to netlink poll socket,%s",strerror(errno)
							); 

		goto error;
	}

	netlink_send_dump_request(nl_socket_poll, RTM_GETLINK | RTM_GETADDR, AF_PACKET);


	//LOGE("%s exited with success",__FUNCTION__);
	__android_log_print(ANDROID_LOG_INFO, LOG_TAG,
			"%s exited with success",__FUNCTION__);


	doQuery = 1;

	return 0;
error:
	//LOGE("%s exited with error",__FUNCTION__);
	__android_log_print(ANDROID_LOG_INFO, LOG_TAG,
			"%s exited with error",__FUNCTION__);
	if (nl_socket_msg >0)
		close(nl_socket_msg);
	if (nl_socket_poll >0)
		close(nl_socket_poll);
	return ret;

}
	void Receipt::ParseJSON(const org_json_JSONObject::JSONObject& jsonObject)
	{
		Init();

#if ENABLE_VERBOSE_LOGGING
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "jsonData=%s", jsonObject.toString().c_str());
#endif

		std::string field;

#if ENABLE_VERBOSE_LOGGING
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Parse currency");
#endif
		field = "currency";
		if (jsonObject.has(field))
		{
			Currency = jsonObject.getString(field);
		}
		
#if ENABLE_VERBOSE_LOGGING
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Parse gamerUuid");
#endif
		field = "gamerUuid";
		if (jsonObject.has(field))
		{
			GamerUuid = jsonObject.getString(field);
		}
		
#if ENABLE_VERBOSE_LOGGING
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Parse generatedDate");
#endif
		field = "generatedDate";
		if (jsonObject.has(field))
		{
			GeneratedDate = jsonObject.getString(field);
		}
		
#if ENABLE_VERBOSE_LOGGING
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Parse identifier");
#endif
		field = "identifier";
		if (jsonObject.has(field))
		{
			Identifier = jsonObject.getString(field);
		}

#if ENABLE_VERBOSE_LOGGING
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Parse localPrice");
#endif
		field = "localPrice";
		if (jsonObject.has(field))
		{
			LocalPrice = (float)jsonObject.getDouble(field);
		}

#if ENABLE_VERBOSE_LOGGING
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Parse priceInCents");
#endif
		field = "priceInCents";
		if (jsonObject.has(field))
		{
			PriceInCents = jsonObject.getInt(field);
		}
		
#if ENABLE_VERBOSE_LOGGING
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Parse purchaseDate");
#endif
		field = "purchaseDate";
		if (jsonObject.has(field))
		{
			PurchaseDate = jsonObject.getString(field);
		}

#if ENABLE_VERBOSE_LOGGING
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Parse uuid");
#endif
		field = "uuid";
		if (jsonObject.has(field))
		{
			Uuid = jsonObject.getString(field);
		}

#if ENABLE_VERBOSE_LOGGING
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Currency: %s", Currency.c_str());
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "GamerUuid: %s", GamerUuid.c_str());
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "GeneratedDate: %s", GeneratedDate.c_str());
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Identifier: %s", Identifier.c_str());
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "LocalPrice: %f", LocalPrice);
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "PriceInCents: %d", PriceInCents);
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "PurchaseDate: %s", PurchaseDate.c_str());
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Uuid: %s", Uuid.c_str());
#endif
	}
Ejemplo n.º 3
0
extern "C" void Android_JNI_EMU_STATE_Callback( int newState )
{
    __android_log_print( ANDROID_LOG_VERBOSE, "SDL-android", "Emulator state changed to %i", newState );
    mEnv->CallStaticVoidMethod( mActivityClass, midEmuStateCallback, newState );
}
Ejemplo n.º 4
0
bool HQEngineApp::EventHandle()
{
	HQEvent *nextEvent;
#if LOG_TIME_SPEND_IN_LOCK
	HQTime dt;
	HQTimeCheckPoint t1, t2;
	HQTimer::GetCheckPoint(t1);
#endif
	
	hq_engine_eventQueue_internal->Lock();

#if LOG_TIME_SPEND_IN_LOCK
	HQTimer::GetCheckPoint(t2);
	dt = HQTimer::GetElapsedTime(t1 , t2);
#endif	

	bool hasEvent = false;

	while ((nextEvent = hq_engine_eventQueue_internal->GetFirstEvent()) != NULL)
	{

#if LOG_TIME_SPEND_IN_LOCK
		__android_log_print(ANDROID_LOG_DEBUG, "HQEngineApp", "time spend waiting for event queue : %f", dt);
#endif

		HQEvent curEvent = *nextEvent;//copy event
		hq_engine_eventQueue_internal->RemoveFirstEvent();//remove from event queue		
		hq_engine_eventQueue_internal->Unlock();

		switch (curEvent.type) {
			case HQ_TOUCH_BEGAN:
				m_motionListener->TouchBegan(curEvent);
				break;
			case HQ_TOUCH_MOVED:
				m_motionListener->TouchMoved(curEvent);
				break;
			case HQ_TOUCH_ENDED:
				m_motionListener->TouchEnded(curEvent);
				break;
			case HQ_TOUCH_CANCELLED:
				m_motionListener->TouchCancelled(curEvent);
				break;
			case HQ_ORIENTATION_PORTRAIT:
				m_orientListener->ChangedToPortrait();
				break;
			case HQ_ORIENTATION_PORTRAIT_UPSIDE_DOWN:
				m_orientListener->ChangedToPortraitUpsideDown();
				break;
			case HQ_ORIENTATION_LANDSCAPE_LEFT:
				m_orientListener->ChangedToLandscapeLeft();
				break;
			case HQ_ORIENTATION_LANDSCAPE_RIGHT:
				m_orientListener->ChangedToLandscapeRight();
				break;
			default:
				break;
		}
		
		
		hasEvent = true;
	}
	
	hq_engine_eventQueue_internal->Unlock();	

	
	return hasEvent;
}
	int JSONObject::FindJNI()
	{
		JNIEnv* env = cocos2d::JniHelper::getEnv();

		{
			const char* strMethod = "<init>";
			_mConstruct = env->GetMethodID(_jcJsonObject, strMethod, "()V");
			if (_mConstruct)
			{
	#if ENABLE_VERBOSE_LOGGING
				__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Found %s", strMethod);
	#endif
			}
			else
			{
				__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to find %s", strMethod);
			}
		}

		{
			const char* strMethod = "<init>";
			_mConstruct2 = env->GetMethodID(_jcJsonObject, strMethod, "(Ljava/lang/String;)V");
			if (_mConstruct2)
			{
	#if ENABLE_VERBOSE_LOGGING
				__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Found %s", strMethod);
	#endif
			}
			else
			{
				__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to find %s", strMethod);
			}
		}

		{
			const char* strMethod = "getDouble";
			_mGetDouble = env->GetMethodID(_jcJsonObject, strMethod, "(Ljava/lang/String;)D");
			if (_mGetDouble)
			{
#if ENABLE_VERBOSE_LOGGING
				__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Found %s", strMethod);
#endif
			}
			else
			{
				__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to find %s", strMethod);
			}
		}

		{
			const char* strMethod = "getInt";
			_mGetInt = env->GetMethodID(_jcJsonObject, strMethod, "(Ljava/lang/String;)I");
			if (_mGetInt)
			{
#if ENABLE_VERBOSE_LOGGING
				__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Found %s", strMethod);
#endif
			}
			else
			{
				__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to find %s", strMethod);
			}
		}

		{
			const char* strMethod = "getJSONArray";
			_mGetJsonArray = env->GetMethodID(_jcJsonObject, strMethod, "(Ljava/lang/String;)Lorg/json/JSONArray;");
			if (_mGetJsonArray)
			{
#if ENABLE_VERBOSE_LOGGING
				__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Found %s", strMethod);
#endif
			}
			else
			{
				__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to find %s", strMethod);
			}
		}

		{
			const char* strMethod = "getJSONObject";
			_mGetJsonObject = env->GetMethodID(_jcJsonObject, strMethod, "(Ljava/lang/String;)Lorg/json/JSONObject;");
			if (_mGetJsonObject)
			{
#if ENABLE_VERBOSE_LOGGING
				__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Found %s", strMethod);
#endif
			}
			else
			{
				__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to find %s", strMethod);
			}
		}

		{
			const char* strMethod = "getString";
			_mGetString = env->GetMethodID(_jcJsonObject, strMethod, "(Ljava/lang/String;)Ljava/lang/String;");
			if (_mGetString)
			{
#if ENABLE_VERBOSE_LOGGING
				__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Found %s", strMethod);
#endif
			}
			else
			{
				__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to find %s", strMethod);
			}
		}

		{
			const char* strMethod = "has";
			_mHas = env->GetMethodID(_jcJsonObject, strMethod, "(Ljava/lang/String;)Z");
			if (_mHas)
			{
#if ENABLE_VERBOSE_LOGGING
				__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Found %s", strMethod);
#endif
			}
			else
			{
				__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to find %s", strMethod);
			}
		}

		{
			const char* strMethod = "put";
			_mPut = env->GetMethodID(_jcJsonObject, strMethod, "(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;");
			if (_mPut)
			{
#if ENABLE_VERBOSE_LOGGING
				__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Found %s", strMethod);
#endif
			}
			else
			{
				__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to find %s", strMethod);
			}
		}

		{
			const char* strMethod = "toString";
			_mToString = env->GetMethodID(_jcJsonObject, strMethod, "()Ljava/lang/String;");
			if (_mToString)
			{
#if ENABLE_VERBOSE_LOGGING
				__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Found %s", strMethod);
#endif
			}
			else
			{
				__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to find %s", strMethod);
			}
		}

		return JNI_OK;
	}
Ejemplo n.º 6
0
JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *jvm, void *reserved)
{
    __android_log_print(ANDROID_LOG_DEBUG, "EBookDroid", "Unloading EBookDroid JNI library based on MuPDF and DjVuLibre");
    closeHandler();
}
	bool InputView::dispatchGenericMotionEvent(AInputEvent* motionEvent)
	{
		int64_t downTime = AMotionEvent_getDownTime(motionEvent);
		int64_t eventTime = AMotionEvent_getEventTime(motionEvent);
		int32_t action = AMotionEvent_getAction(motionEvent);
		int32_t metaState = AMotionEvent_getMetaState(motionEvent);
		int32_t pointerCount = AMotionEvent_getPointerCount(motionEvent);
		int32_t buttonState = AMotionEvent_getButtonState(motionEvent);
		float xPrecision = AMotionEvent_getXPrecision(motionEvent);
		float yPrecision = AMotionEvent_getYPrecision(motionEvent);
		int32_t deviceId = AInputEvent_getDeviceId(motionEvent);
		int32_t edgeFlags = AMotionEvent_getEdgeFlags(motionEvent);
		int32_t flags = AMotionEvent_getFlags(motionEvent);
		int32_t source = AInputEvent_getSource(motionEvent);

		int* pointerPropertiesId = new int[pointerCount];
		int* pointerPropertiesToolType = new int[pointerCount];
		float* pointerCoordsOrientation = new float[pointerCount];
		float* pointerCoordsPressure = new float[pointerCount];
		float* pointerCoordsSize = new float[pointerCount];
		float* pointerCoordsToolMajor = new float[pointerCount];
		float* pointerCoordsToolMinor = new float[pointerCount];
		float* pointerCoordsTouchMajor = new float[pointerCount];
		float* pointerCoordsTouchMinor = new float[pointerCount];
		float* pointerCoordsX = new float[pointerCount];
		float* pointerCoordsY = new float[pointerCount];

		std::vector<int> listAxisIndices;
		std::vector<float> listAxisValues;

		if (pointerCount > 0)
		{
#if ENABLE_VERBOSE_LOGGING
			__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "pointerCount=%d deviceId=%d source=%d",
				pointerCount, deviceId, source);
#endif

			// MotionEvent.PointerProperties
			long long pointerId = AMotionEvent_getPointerId(motionEvent, 0);
			int32_t toolType = AMotionEvent_getToolType(motionEvent, 0);

#if ENABLE_VERBOSE_LOGGING
			__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "PointerProperties pointerId=%lld toolType-%d",
				pointerId, toolType);
#endif

			pointerPropertiesId[0] = pointerId;
			pointerPropertiesToolType[0] = toolType;

			// MotionEvent.PointerCoords
			float orientation = AMotionEvent_getOrientation(motionEvent, pointerId);
			float pressure = AMotionEvent_getPressure(motionEvent, pointerId);
			float size = AMotionEvent_getSize(motionEvent, pointerId);
			float toolMajor = AMotionEvent_getTouchMajor(motionEvent, pointerId);
			float toolMinor = AMotionEvent_getToolMinor(motionEvent, pointerId);
			float touchMajor = AMotionEvent_getTouchMajor(motionEvent, pointerId);
			float touchMinor = AMotionEvent_getTouchMinor(motionEvent, pointerId);
			float x = AMotionEvent_getX(motionEvent, pointerId);
			float y = AMotionEvent_getY(motionEvent, pointerId);

#if ENABLE_VERBOSE_LOGGING
			__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "PointerCoords orientation=%f pressure=%f size=%f toolMajor=%f toolMinor=%f touchMajor=%f touchMinor=%f x=%f y=%f",
				orientation, pressure, size,
				toolMajor, toolMinor, touchMajor, touchMinor,
				x, y);
#endif

			pointerCoordsOrientation[0] = orientation;
			pointerCoordsPressure[0] = pressure;
			pointerCoordsSize[0] = size;
			pointerCoordsToolMajor[0] = toolMajor;
			pointerCoordsToolMinor[0] = toolMinor;
			pointerCoordsTouchMajor[0] = touchMajor;
			pointerCoordsTouchMinor[0] = touchMinor;
			pointerCoordsX[0] = x;
			pointerCoordsY[0] = y;

			for (int32_t axis = 0; axis < 50; ++axis) // 50 is based on the AXIS_value range I saw in the documentation
			{
				float val = AMotionEvent_getAxisValue(motionEvent, axis, pointerId);
				if (val != 0.0f)
				{
#if ENABLE_VERBOSE_LOGGING
					__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "axis=%d val=%f", axis, val);
#endif
					listAxisIndices.push_back(axis);
					listAxisValues.push_back(val);
				}
			}
		}

		int axisCount = listAxisIndices.size();
		int* axisIndexes = new int[axisCount];
		float* axisValues = new float[axisCount];
		for (int index = 0; index < axisCount; ++index)
		{
			axisIndexes[index] = listAxisIndices[index];
			axisValues[index] = listAxisValues[index];
		}
		listAxisIndices.clear();
		listAxisValues.clear();

		bool handled = javaDispatchGenericMotionEvent(
			downTime,
			eventTime,
			action,
			pointerCount,
			metaState,
			buttonState,
			xPrecision,
			yPrecision,
			deviceId,
			edgeFlags,
			source,
			flags,
			pointerPropertiesId,
			pointerPropertiesToolType,
			pointerCoordsOrientation,
			pointerCoordsPressure,
			pointerCoordsSize,
			pointerCoordsToolMajor,
			pointerCoordsToolMinor,
			pointerCoordsTouchMajor,
			pointerCoordsTouchMinor,
			pointerCoordsX,
			pointerCoordsY,
			axisCount,
			axisIndexes,
			axisValues);

		delete pointerPropertiesId;
		delete pointerPropertiesToolType;
		delete pointerCoordsOrientation;
		delete pointerCoordsPressure;
		delete pointerCoordsSize;
		delete pointerCoordsToolMajor;
		delete pointerCoordsToolMinor;
		delete pointerCoordsTouchMajor;
		delete pointerCoordsTouchMinor;
		delete pointerCoordsX;
		delete pointerCoordsY;
		delete axisIndexes;
		delete axisValues;
		return handled;
	}
Ejemplo n.º 8
0
bool PROGRAM::link(bool debug)
{
    GLenum  type;

    char *log,
    name[MAX_CHAR];

    int status,
    len,
    total,
    size;

    if (this->pid) return false;

    this->pid = glCreateProgram();

    glAttachShader(this->pid, this->vertex_shader->sid);

    glAttachShader(this->pid, this->fragment_shader->sid);

    if (this->programbindattribcallback) this->programbindattribcallback(this);

    glLinkProgram(this->pid);


    if (debug) {
        glGetProgramiv(this->pid, GL_INFO_LOG_LENGTH, &len);

        if (len) {
            log = (char *) malloc(len);

            glGetProgramInfoLog(this->pid, len, &len, log);

#ifdef __IPHONE_4_0

            printf("[ %s ]\n%s", this->name, log);
#else
            __android_log_print(ANDROID_LOG_ERROR, "", "[ %s ]\n%s", program->name, log);
#endif
            
            free(log);
        }
    }
    
    glGetProgramiv(this->pid, GL_LINK_STATUS, &status);

    if (!status) goto delete_program;


    if (debug) {
        glValidateProgram(this->pid);

        glGetProgramiv(this->pid, GL_INFO_LOG_LENGTH, &len);

        if (len) {
            log = (char *) malloc(len);

            glGetProgramInfoLog(this->pid, len, &len, log);

#ifdef __IPHONE_4_0

            printf("[ %s ]\n%s", this->name, log);
#else
            __android_log_print(ANDROID_LOG_ERROR, "", "[ %s ]\n%s", program->name, log);
#endif

            free(log);
        }


        glGetProgramiv(this->pid, GL_VALIDATE_STATUS, &status);

        if (!status) goto delete_program;
    }


    glGetProgramiv(this->pid, GL_ACTIVE_ATTRIBUTES, &total);

    for (int i=0; i != total; ++i) {
        glGetActiveAttrib(this->pid,
                          i,
                          MAX_CHAR,
                          &len,
                          &size,
                          &type,
                          name);

        this->add_vertex_attrib(name, type);
    }

    glGetProgramiv(this->pid, GL_ACTIVE_UNIFORMS, &total);

    for (int i=0; i != total; ++i) {
        glGetActiveUniform(this->pid,
                           i,
                           MAX_CHAR,
                           &len,
                           &size,
                           &type,
                           name);
        
        this->add_uniform(name, type);
    }
    
    return true;
    
    
delete_program:
    
    this->delete_id();
    
    return false;
}
Ejemplo n.º 9
0
extern "C" JNIEXPORT jint JNICALL Java_com_almalence_plugins_processing_night_AlmaShotNight_Process
(
	JNIEnv* env,
	jobject thiz,
	jint sx,
	jint sy,
	jint sxo,
	jint syo,
	jint iso,
	jint noisePref,
	jint DeGhostPref,
	jint lumaEnh,
	jint chromaEnh,
	jfloat fgamma,
	jint nImages,
	jintArray jcrop,
	jint orientation,
	jboolean mirror,
	jfloat zoom,
	jint cameraIndex,
	jboolean isCamera2
)
{
	Uint8 *OutPic, *OutNV21;
	int *crop;
	int nTable[3] = {256/2, 256, 3*256/2};
	int deghostTable[3] = {3*256/4, 256, 3*256/2};

	crop = (int*)env->GetIntArrayElements(jcrop, NULL);

	if (isCamera2)
	{
		//__android_log_print(ANDROID_LOG_ERROR, "Almalence", "sx:%d sy:%d sxo:%d syo:%d", sx, sy, sxo, syo);

		// find zoomed region in the frame
		int sx_zoom = (int)(sx/zoom) + 2*SIZE_GUARANTEE_BORDER;
		int sy_zoom = (int)(sy/zoom) + 2*SIZE_GUARANTEE_BORDER;
		sx_zoom -= sx_zoom&3;
		sy_zoom -= sy_zoom&3;
		if (sx_zoom > sx) sx_zoom = sx;
		if (sy_zoom > sy) sy_zoom = sy;

		// in-place crop of input frames according to the zoom value
		if ((sx_zoom < sx) || (sy_zoom < sy))
		{
			int x0 = (sx-sx_zoom)/2;
			int y0 = (sy-sy_zoom)/2;
			x0 -= x0&1;
			y0 -= y0&1;

			for (int i=0; i<nImages; ++i)
			{
				// Y part
				for (int y=0; y<sy_zoom; ++y)
					memmove(&yuv[i][y*sx_zoom], &yuv[i][x0+(y+y0)*sx], sx_zoom);

				// UV part
				for (int y=0; y<sy_zoom/2; ++y)
					memmove(&yuv[i][sx_zoom*sy_zoom+y*sx_zoom], &yuv[i][sx*sy+x0+(y+y0/2)*sx], sx_zoom);
			}
		}

		if (fgamma && (iso>0))
		{
			// iso 100 = +0.1
			// iso 800 = -0.05
			fgamma += 0.1f - ( logf(iso) * 3.321928095f-6.644f)*0.15f/3.f;
			if (fgamma < 0.45f) fgamma = 0.45f;
			if (fgamma > 0.6f) fgamma = 0.6f;
		}

		// for SR-only fgamma = 0, gamma will evaluate to 0 also
		int gamma = (int)(fgamma * 256 + 0.5f);

		// threshold at which profiles are switched (about 1.5x zoom)
		int zoomAbove15x = sxo >= 3*(sx_zoom-2*SIZE_GUARANTEE_BORDER)/2;
		int zoomAbove30x = sxo >= 3*sx_zoom;


		int sensorGain, deGhostGain, filter, sharpen;

		switch (cameraIndex)
		{
		case 100:		// Nexus 5
			deGhostGain = 256*80/100;
			sensorGain = (int)( 256*powf((float)iso/100, 0.5f) );

			// slightly more sharpening and less filtering at low zooms
			sharpen = 2;
			filter = 384; // 320; // 256;
			if (zoomAbove30x) sharpen = 0x80;	// fine edge enhancement instead of primitive sharpen at high zoom levels
			else if (zoomAbove15x) sharpen = 1;
			else filter = 192;
			break;
		case 103:		// Nexus 6
			deGhostGain = 256*50/100;
			sensorGain = (int)( 107*256/100*powf((float)iso/100, 0.7f) );

			sharpen = 1;
			if (!zoomAbove15x) sharpen = 0x80;	// slightly more filtering at low zooms (noise interpolation artefacts are evident otherwise)
			filter = 256;
			break;
		case 507:		// LG G Flex2
			deGhostGain = 256*60/100;
			sensorGain = (int)( 2*256*powf((float)iso/100, 0.45f) );

			sharpen = 1;
			if (zoomAbove30x) sharpen = 0x80;// fine edge enhancement instead of primitive sharpen at high zoom levels
				filter = 300;
			if (!zoomAbove15x) filter = 192;// slightly less filtering at low zooms (somehow sr processing is creating less sharp images here)
			break;
		default:
			__android_log_print(ANDROID_LOG_INFO, "CameraTest", "Error: Unknown camera");
			break;
		}
		if (zoomAbove30x) sharpen = 0x80;	// fine edge enhancement instead of primitive sharpen at high zoom levels

		//__android_log_print(ANDROID_LOG_ERROR, "Almalence", "Before Super_Process, sensorGain: %d, deghostGain: %d, filter: %d, sharpen: %d, nImages: %d cameraIndex: %d",
		//		sensorGain, deGhostGain, filter, sharpen, nImages, cameraIndex);

		Super_Process(
				yuv, NULL, &OutPic,
				sx_zoom, sy_zoom, sx_zoom, sxo, syo, nImages,
				sensorGain,
				deGhostGain*deghostTable[DeGhostPref]/256,
				1,							// deghostFrames
				filter,
				sharpen,
				gamma,
				cameraIndex,
				0);							// externalBuffers

		//__android_log_print(ANDROID_LOG_ERROR, "Almalence", "Super_Process finished, iso: %d, noise: %d %d", iso, noisePref, nTable[noisePref]);

		crop[0]=crop[1]=0;
		crop[2]=sxo;
		crop[3]=syo;
	}
	else
	{
		BlurLess_Preview(&instance, yuv, NULL, NULL, NULL,
			0, // 256*3,
			deghostTable[DeGhostPref], 1,
			2, nImages, sx, sy, 0, nTable[noisePref], 1, 0, lumaEnh, chromaEnh, 0);

		crop[0]=crop[1]=crop[2]=crop[3]=-1;
		BlurLess_Process(instance, &OutPic, &crop[0], &crop[1], &crop[2], &crop[3]);
	}

	//__android_log_print(ANDROID_LOG_ERROR, "Almalence", "Before rotation");

	int flipLeftRight, flipUpDown;
	int rotate90 = orientation == 90 || orientation == 270;
	if (mirror)
		flipUpDown = flipLeftRight = orientation == 180 || orientation == 90;
	else
		flipUpDown = flipLeftRight = orientation == 180 || orientation == 270;

	// 90/270-degree rotations are out-ot-place
	OutNV21 = OutPic;
	if (rotate90)
		OutNV21 = (Uint8 *)malloc(sxo*syo+2*((sxo+1)/2)*((syo+1)/2));

	TransformNV21(OutPic, OutNV21, sxo, syo, crop, flipLeftRight, flipUpDown, rotate90);

	//__android_log_print(ANDROID_LOG_ERROR, "Almalence", "After rotation");

	if (rotate90)
	{
		free(OutPic);
		OutPic = OutNV21;
	}

	env->ReleaseIntArrayElements(jcrop, (jint*)crop, JNI_ABORT);

	return (jint)OutPic;
}
Ejemplo n.º 10
0
JNIEXPORT jstring JNICALL Java_com_ssb_droidsound_utils_ID3Tag_getStringInfo(JNIEnv *env, jobject obj, jint what)
{
	struct id3_file *id3file = (struct id3_file*)env->GetLongField(obj, refField);
	struct id3_tag *tag = (struct id3_tag*)env->GetLongField(obj, tagRefField);

	__android_log_print(ANDROID_LOG_VERBOSE, "ID3Tag", "Get String Info %p %p", id3file, tag);


	if(!tag && id3file)
		tag = id3_file_tag(id3file);

	if(!tag) return 0;

	const id3_ucs4_t *title = NULL;
	struct id3_frame *frame = NULL;

	__android_log_print(ANDROID_LOG_VERBOSE, "ID3Tag", "id3tag %p", tag);

	switch(what) {
	case INFO_TITLE:
		frame = id3_tag_findframe(tag, ID3_FRAME_TITLE, 0);
		break;
	case INFO_AUTHOR:
		frame = id3_tag_findframe(tag, ID3_FRAME_ARTIST, 0);
		break;
	case INFO_COPYRIGHT:
		frame = id3_tag_findframe(tag, ID3_FRAME_YEAR, 0);
		break;
	case ID3INFO_GENRE:
		frame = id3_tag_findframe(tag, ID3_FRAME_GENRE, 0);
		if(frame) {
			title = id3_field_getstrings(&frame->fields[1], 0);
			title = id3_genre_name(title);
		}
		break;
	case ID3INFO_ALBUM:
		frame = id3_tag_findframe(tag, ID3_FRAME_ALBUM, 0);
		break;
	case ID3INFO_TRACK:
		frame = id3_tag_findframe(tag, ID3_FRAME_TRACK, 0);
		break;
	case ID3INFO_COMMENT:
		frame = id3_tag_findframe(tag, ID3_FRAME_COMMENT, 0);
		if(frame) {
			__android_log_print(ANDROID_LOG_VERBOSE, "ID3Tag", "COMMENT %d fields", frame->nfields);
			if(frame->nfields >= 4)
				title = id3_field_getfullstring(&frame->fields[3]);
		}
		break;
	}

	if(frame) {

		__android_log_print(ANDROID_LOG_VERBOSE, "ID3Tag", "frame %p %d", frame, what);

		if(title == NULL)
			title = id3_field_getstrings(&frame->fields[1], 0);
		if(title) {
			__android_log_print(ANDROID_LOG_VERBOSE, "ID3Tag", "title %p", title);
			id3_utf8_t *titleu8 = id3_ucs4_utf8duplicate(title);
			jstring j = env->NewStringUTF((const char *)titleu8);
			return j;
		}
	}

	return NULL;

}
Ejemplo n.º 11
0
static std::string exampleCommand(std::vector<Token> const& args) {
	__android_log_print(ANDROID_LOG_INFO, "BlockLauncher", "Args count: %d", args.size());
	return "This is an example command " + args[1].getText("");
}
Ejemplo n.º 12
0
void test_function()
{
	__android_log_print(ANDROID_LOG_ERROR, DEBUG_TAG, "Yay, I was called");
}
JNIEXPORT jstring JNICALL Java_io_github_maluta_libusbproject_NativeLib_listDevices(
		JNIEnv *env, jobject object) {

	libusb_device *dev;
	struct libusb_device_descriptor desc;
	int i = 0;
	int j = 0;
	libusb_device **devs;
	int r;
	ssize_t cnt;
	int ret;

	char usb_list[2000];

	if (context == NULL) {
		if (libusb_init(&context) == 0) {
			__android_log_print(ANDROID_LOG_DEBUG, "LOG_TAG", "libusb_init");
			libusb_set_debug(context, 6);
		}
	}

	cnt = libusb_get_device_list(context, &devs);

	while ((dev = devs[i++]) != NULL) {
		int r = libusb_get_device_descriptor(dev, &desc);
		if (r < 0) {
			fprintf(stderr, "failed to get device descriptor");
		}

		j += sprintf(usb_list+j,"%04x:%04x\n", desc.idVendor, desc.idProduct);

		__android_log_print(ANDROID_LOG_DEBUG, "LOG_TAG", "%x:%x",
				desc.idVendor, desc.idProduct);

	}

	return (*env)->NewStringUTF(env, usb_list);

	/* Some other functions that you can use */

	//	ret = libusb_open(dev, &device_handle);

	// if (device_handle == NULL) { }

	/*
	switch (libusb_kernel_driver_active(device_handle, interface)) {
	case 0: {
		break;
	}
	case 1: {

		if (!libusb_detach_kernel_driver(device_handle, interface)) {
			// unable to detach interface
			libusb_close(device_handle);
			device_handle = NULL;
			//goto out3;
		}
		break;
	}
	default: {
		// error quering the device
		libusb_close(device_handle);
		device_handle = NULL;
		//goto out2;
	}
	}*/

	// get interface
	// if (libusb_claim_interface(device_handle, interface) != 0) { }

	// bulk transfer
	// libusb_bulk_transfer(device_handle, (0x02 | LIBUSB_ENDPOINT_OUT), &byte, 1, &actual, 1000);
    // libusb_release_interface(device_handle, interface);
}
/*

	Function : parse_msg_detail

	This function prints the details of a 
	RTM* message.

	@input mlmsghdr : The RTM message
*/
int parse_msg_detail (struct nlmsghdr* nl_msg)
{
  int ret = 0;
	int rtl;
	struct ifinfomsg *linfo;
	struct rtattr *rtap;

	linfo = (struct ifinfomsg *)NLMSG_DATA(nl_msg);

	__android_log_print(
			ANDROID_LOG_INFO, 
			LOG_TAG,  
			"got a new link creation message: family (%d), type (%d), flags(%x) index(%d)\n", 
			linfo->ifi_family, 
			linfo->ifi_type, 
			linfo->ifi_flags, 
			linfo->ifi_index);

	/* determine the type and name of the link */
	rtap = IFLA_RTA(linfo);

	/* get length of attributes */
	rtl = IFLA_PAYLOAD(nl_msg);

	/* process attributes of the link info message */
	for(;RTA_OK(rtap, rtl); rtap=RTA_NEXT(rtap, rtl)) {

		if (rtap->rta_type == IFLA_IFNAME) { /* get interface name */
			strncpy(iface, RTA_DATA(rtap), RTA_PAYLOAD(rtap));

			__android_log_print(
					ANDROID_LOG_INFO, 
					LOG_TAG,  
					"interface %s \n", iface);

		}

		else if (rtap->rta_type == IFLA_LINK) { /* link type */

			int x = *(int *)RTA_DATA(rtap);

			__android_log_print(
					ANDROID_LOG_INFO,
					LOG_TAG,  
					"interface linktype %x \n", x);

		}
		else if (rtap->rta_type == IFLA_LINKMODE) { /* link mode */

			int x = *(int *)RTA_DATA(rtap);

			__android_log_print(
					ANDROID_LOG_INFO, 
					LOG_TAG,  
					"interface linkmode %x \n", x);

		}
		else if (rtap->rta_type == IFLA_OPERSTATE) { /* link type */
			int x = *(int *)RTA_DATA(rtap);
			switch (x)
			{
				case (IF_OPER_DOWN):
					__android_log_print(
							ANDROID_LOG_INFO, 
							LOG_TAG,  
							"IF_OPER_DOWN");
					break;
				case (IF_OPER_UP):
					__android_log_print(
							ANDROID_LOG_INFO, 
							LOG_TAG,  
							"IF_OPER_UP");
					ret = 1;
					break;
				case (IF_OPER_LOWERLAYERDOWN):
					__android_log_print(
							ANDROID_LOG_INFO, 
							LOG_TAG,  
							"IF_OPER_LOWERLAYERDOWN");
					break;
				case (IF_OPER_TESTING):
					__android_log_print(
							ANDROID_LOG_INFO, 
							LOG_TAG,  
							"IF_OPER_TESTING");
					break;
				case (IF_OPER_DORMANT):
					__android_log_print(
							ANDROID_LOG_INFO, 
							LOG_TAG,  
							"IF_OPER_DORMANT");
					break;
				case (IF_OPER_UNKNOWN):
					__android_log_print(
							ANDROID_LOG_INFO, 
							LOG_TAG,  
							"IF_OPER_UNKNOWN");
					break;
				case (IF_OPER_NOTPRESENT):
					__android_log_print(
							ANDROID_LOG_INFO, 
							LOG_TAG,  
							"IF_OPER_NOTPRESENT");
					break;
			}
			__android_log_print(
					ANDROID_LOG_INFO, 
					LOG_TAG,  
					"interface new operstate %x \n", x);
		}
	}
	return ret;
}
void _makeNativeCrashReport(const char *reason, struct siginfo *siginfo, void *sigcontext) {
	JNIEnv *env = 0;

	int result = javaVM->GetEnv((void **) &env, JNI_VERSION_1_6);

	if (result == JNI_EDETACHED) {
		__android_log_print(ANDROID_LOG_WARN, "NativeCrashHandler", "Native crash occured in a non jvm-attached thread");
		result = javaVM->AttachCurrentThread(&env, NULL);
	}

	if (result != JNI_OK)
		__android_log_print(ANDROID_LOG_ERROR, "NativeCrashHandler",
				"Could not attach thread to Java VM for crash reporting.\n"
				"Crash was: %s",
				reason
		);
	else if (env && applicationObject) {
		jobjectArray elements = NULL;

		if (unwind_backtrace_signal_arch != NULL && siginfo != NULL)  {
			map_info_t *map_info = acquire_my_map_info_list();
			backtrace_frame_t frames[256] = {0,};
			backtrace_symbol_t symbols[256] = {0,};
			const ssize_t size = unwind_backtrace_signal_arch(siginfo, sigcontext, map_info, frames, 1, 255);
			get_backtrace_symbols(frames,  size, symbols);

			elements = env->NewObjectArray(size, stackTraceElementClass, NULL);
			Verify(elements, "Could not create StackElement java array");
			int pos = 0;
			jstring jni = env->NewStringUTF("<JNI>");
			for (int i = 0; i < size; ++i) {
				const char *method = symbols[i].demangled_name;
				if (!method)
					method = symbols[i].symbol_name;
				if (!method)
					method = "?";
				//__android_log_print(ANDROID_LOG_ERROR, "DUMP", "%s", method);
				const char *file = symbols[i].map_name;
				if (!file)
					file = "-";
				jobject element = env->NewObject(stackTraceElementClass, stackTraceElementMethod,
						jni,
						env->NewStringUTF(method),
						env->NewStringUTF(file),
						-2
				);
				Verify(element, "Could not create StackElement java object");
				env->SetObjectArrayElement(elements, pos++, element);
				Verify(env->ExceptionCheck() == JNI_FALSE, "Java threw an exception");
			}

			free_backtrace_symbols(symbols, size);
			release_my_map_info_list(map_info);
		}

		env->CallVoidMethod(applicationObject, makeCrashReportMethod, env->NewStringUTF(reason), elements, (jint)gettid());
		Verify(env->ExceptionCheck() == JNI_FALSE, "Java threw an exception");
	}
	else
		__android_log_print(ANDROID_LOG_ERROR, "NativeCrashHandler",
				"Could not create native crash report as registerForNativeCrash was not called in JAVA context.\n"
				"Crash was: %s",
				reason
		);
}
Ejemplo n.º 16
0
Console::kunkuaLog(const char * pszFormat)
{
    __android_log_print(ANDROID_LOG_DEBUG, "flakor debug info", "%s", pszFormat);
}
Ejemplo n.º 17
0
JNIEXPORT void JNICALL 
JAVA_EXPORT_NAME(DemoRenderer_nativeGlContextLostAsyncEvent) ( JNIEnv*  env, jobject thiz )
{
	__android_log_print(ANDROID_LOG_INFO, "libSDL", "OpenGL context lost - sending SDL_ACTIVEEVENT");
	SDL_ANDROID_MainThreadPushAppActive(0);
}
Ejemplo n.º 18
0
JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env, jobject obj, jobject activity,jboolean p_need_reload_hook, jobjectArray p_cmdline) {

	__android_log_print(ANDROID_LOG_INFO,"godot","**INIT EVENT! - %p\n",env);


	initialized=true;

	JavaVM *jvm;
	env->GetJavaVM(&jvm);

	_godot_instance=env->NewGlobalRef(activity);
//	_godot_instance=activity;

	__android_log_print(ANDROID_LOG_INFO,"godot","***************** HELLO FROM JNI!!!!!!!!");

	{
		//setup IO Object

		jclass cls = env->FindClass("com/android/godot/Godot");
		if (cls) {

			cls=(jclass)env->NewGlobalRef(cls);
			__android_log_print(ANDROID_LOG_INFO,"godot","*******CLASS FOUND!!!");
		}

		__android_log_print(ANDROID_LOG_INFO,"godot","STEP2, %p",cls);
		jfieldID fid = env->GetStaticFieldID(cls, "io", "Lcom/android/godot/GodotIO;");
		__android_log_print(ANDROID_LOG_INFO,"godot","STEP3 %i",fid);
		jobject ob = env->GetStaticObjectField(cls,fid);
		__android_log_print(ANDROID_LOG_INFO,"godot","STEP4, %p",ob);
		jobject gob = env->NewGlobalRef(ob);

		__android_log_print(ANDROID_LOG_INFO,"godot","STEP4.5, %p",gob);
		godot_io=gob;

		_on_video_init = env->GetMethodID(cls, "onVideoInit", "(Z)V");

		jclass clsio = env->FindClass("com/android/godot/Godot");
		if (cls) {
			jclass c = env->GetObjectClass(gob);
			_openURI = env->GetMethodID(c,"openURI","(Ljava/lang/String;)I");
			_getDataDir = env->GetMethodID(c,"getDataDir","()Ljava/lang/String;");
			_getLocale = env->GetMethodID(c,"getLocale","()Ljava/lang/String;");
			_getModel = env->GetMethodID(c,"getModel","()Ljava/lang/String;");
			_getUniqueID = env->GetMethodID(c,"getUniqueID","()Ljava/lang/String;");
			_showKeyboard = env->GetMethodID(c,"showKeyboard","(Ljava/lang/String;)V");
			_hideKeyboard = env->GetMethodID(c,"hideKeyboard","()V");
			_setScreenOrientation = env->GetMethodID(c,"setScreenOrientation","(I)V");
			_getSystemDir = env->GetMethodID(c,"getSystemDir","(I)Ljava/lang/String;");
			_playVideo = env->GetMethodID(c,"playVideo","(Ljava/lang/String;)V");
			_isVideoPlaying = env->GetMethodID(c,"isVideoPlaying","()Z");
			_pauseVideo = env->GetMethodID(c,"pauseVideo","()V");
			_stopVideo = env->GetMethodID(c,"stopVideo","()V");
		}

		ThreadAndroid::make_default(jvm);
		FileAccessJAndroid::setup(gob);
		DirAccessJAndroid::setup(gob);
		AudioDriverAndroid::setup(gob);
	}


	const char ** cmdline=NULL;
	int cmdlen=0;
	bool use_apk_expansion=false;
	if (p_cmdline) {
		cmdlen = env->GetArrayLength(p_cmdline);
		if (cmdlen) {
			cmdline = (const char**)malloc((env->GetArrayLength(p_cmdline)+1)*sizeof(const char*));
			cmdline[cmdlen]=NULL;

			for (int i=0; i<cmdlen; i++) {

				jstring string = (jstring) env->GetObjectArrayElement(p_cmdline, i);
				const char *rawString = env->GetStringUTFChars(string, 0);
				if (!rawString) {
					__android_log_print(ANDROID_LOG_INFO,"godot","cmdline arg %i is null\n",i);
				} else {
		//			__android_log_print(ANDROID_LOG_INFO,"godot","cmdline arg %i is: %s\n",i,rawString);

					if (strcmp(rawString,"-main_pack")==0)
						use_apk_expansion=true;
				}

				cmdline[i]=rawString;
			}
		}
	}

	__android_log_print(ANDROID_LOG_INFO,"godot","CMDLINE LEN %i - APK EXPANSION %I\n",cmdlen,int(use_apk_expansion));

	os_android = new OS_Android(_gfx_init_func,env,_open_uri,_get_data_dir,_get_locale, _get_model,_show_vk, _hide_vk,_set_screen_orient,_get_unique_id, _get_system_dir, _play_video,_is_video_playing, _pause_video, _stop_video,use_apk_expansion);
	os_android->set_need_reload_hooks(p_need_reload_hook);

	char wd[500];
	getcwd(wd,500);

	__android_log_print(ANDROID_LOG_INFO,"godot","test construction %i\n",tst.a);
	__android_log_print(ANDROID_LOG_INFO,"godot","running from dir %s\n",wd);

	__android_log_print(ANDROID_LOG_INFO,"godot","**SETUP");


#if 0
	char *args[]={"-test","render",NULL};
	__android_log_print(ANDROID_LOG_INFO,"godot","pre asdasd setup...");
	Error err  = Main::setup("apk",2,args,false);
#else
	Error err  = Main::setup("apk",cmdlen,(char**)cmdline,false);
#endif

	if (err!=OK) {
		__android_log_print(ANDROID_LOG_INFO,"godot","*****UNABLE TO SETUP");

		return; //should exit instead and print the error
	}

	__android_log_print(ANDROID_LOG_INFO,"godot","*****SETUP OK");

	//video driver is determined here, because once initialized, it cant be changed
	String vd = Globals::get_singleton()->get("display/driver");


	env->CallVoidMethod(_godot_instance, _on_video_init, (jboolean)true);

	__android_log_print(ANDROID_LOG_INFO,"godot","**START");

	input_mutex=Mutex::create();
	suspend_mutex=Mutex::create();


}
	void InputView::JNIFind()
	{
		JNIEnv* env = cocos2d::JniHelper::getEnv();

		if (!_jcInputView)
		{
			return;
		}

		{
			const char* strMethod = "getInstance";
			#if ENABLE_VERBOSE_LOGGING
				__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Searching for method %s", strMethod);
			#endif
			_jmGetInstance = env->GetStaticMethodID(_jcInputView, strMethod, "()Lcom/razerzone/store/sdk/engine/cocos2d/InputView;");
			if (_jmGetInstance)
			{
				#if ENABLE_VERBOSE_LOGGING
					__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Found %s", strMethod);
				#endif
			}
			else
			{
				__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to find %s", strMethod);
			}
		}

		{
			const char* strMethod = "javaDispatchKeyEvent";
			#if ENABLE_VERBOSE_LOGGING
				__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Searching for method %s", strMethod);
			#endif
			_jmJavaDispatchKeyEvent = env->GetMethodID(_jcInputView, strMethod, "(JJIIIIIIII)Z");
			if (_jmJavaDispatchKeyEvent)
			{
				#if ENABLE_VERBOSE_LOGGING
					__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Found %s", strMethod);
				#endif
			}
			else
			{
				__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to find %s", strMethod);
			}
		}

		{
			const char* strMethod = "javaDispatchGenericMotionEvent";
			#if ENABLE_VERBOSE_LOGGING
				__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Searching for method %s", strMethod);
			#endif
			_jmJavaDispatchMotionEvent = env->GetMethodID(_jcInputView, strMethod, "(JJIIIIFFIIII[I[I[F[F[F[F[F[F[F[F[FI[I[F)Z");
			if (_jmJavaDispatchMotionEvent)
			{
				#if ENABLE_VERBOSE_LOGGING
					__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Found %s", strMethod);
				#endif
			}
			else
			{
				__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to find %s", strMethod);
			}
		}
	}
Ejemplo n.º 20
0
JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_step(JNIEnv * env, jobject obj)
{


	ThreadAndroid::setup_thread();

	//__android_log_print(ANDROID_LOG_INFO,"godot","**STEP EVENT! - %p-%i\n",env,Thread::get_caller_ID());


	suspend_mutex->lock();
	input_mutex->lock();
	//first time step happens, initialize
	if (step == 0) {
		// ugly hack to initialize the rest of the engine
		// because of the way android forces you to do everything with threads

		java_class_wrapper = memnew( JavaClassWrapper(_godot_instance ));
		Globals::get_singleton()->add_singleton(Globals::Singleton("JavaClassWrapper",java_class_wrapper));
		_initialize_java_modules();

		Main::setup2();
		++step;
		suspend_mutex->unlock();
		input_mutex->unlock();
		return;
	};
	if (step == 1) {
		if (!Main::start()) {

			input_mutex->unlock();
			suspend_mutex->lock();
			return; //should exit instead and print the error
		}

		os_android->main_loop_begin();
		++step;
	}

	while(pointer_events.size()) {

		JAndroidPointerEvent jpe=pointer_events.front()->get();
		os_android->process_touch(jpe.what,jpe.pointer,jpe.points);

		pointer_events.pop_front();
	}

	while (key_events.size()) {

		InputEvent event = key_events.front()->get();
		os_android->process_event(event);

		key_events.pop_front();
	};

	if (quit_request) {

		os_android->main_loop_request_quit();
		quit_request=false;
	}


	input_mutex->unlock();

	os_android->process_accelerometer(accelerometer);

	if (os_android->main_loop_iterate()==true) {

		jclass cls = env->FindClass("com/android/godot/Godot");
		jmethodID _finish = env->GetMethodID(cls, "forceQuit", "()V");
		env->CallVoidMethod(_godot_instance, _finish);
		__android_log_print(ANDROID_LOG_INFO,"godot","**FINISH REQUEST!!! - %p-%i\n",env,Thread::get_caller_ID());

	}

	suspend_mutex->unlock();

}
	bool InputView::javaDispatchGenericMotionEvent(
		long long downTime,
		long long eventTime,
		int action,
		int pointerCount,
		int metaState,
		int buttonState,
		float xPrecision,
		float yPrecision,
		int deviceId,
		int edgeFlags,
		int source,
		int flags,
		int* pointerPropertiesId,
		int* pointerPropertiesToolType,
		float* pointerCoordsOrientation,
		float* pointerCoordsPressure,
		float* pointerCoordsSize,
		float* pointerCoordsToolMajor,
		float* pointerCoordsToolMinor,
		float* pointerCoordsTouchMajor,
		float* pointerCoordsTouchMinor,
		float* pointerCoordsX,
		float* pointerCoordsY,
		int axisCount,
		int* axisIndexes,
		float* axisValues)
	{
		JNIEnv* env = cocos2d::JniHelper::getEnv();

		if (!_instance)
		{
			__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "_instance is not valid!");
			return false;
		}

		if (!_jmJavaDispatchMotionEvent)
		{
			__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "_jmJavaDispatchMotionEvent is not valid!");
			return false;
		}

		jintArray argPointerPropertiesId = env->NewIntArray(pointerCount);
		jintArray argpointerPropertiesToolType = env->NewIntArray(pointerCount);
		jfloatArray argpointerCoordsOrientation = env->NewFloatArray(pointerCount);
		jfloatArray argpointerCoordsPressure = env->NewFloatArray(pointerCount);
		jfloatArray argpointerCoordsSize = env->NewFloatArray(pointerCount);
		jfloatArray argpointerCoordsToolMajor = env->NewFloatArray(pointerCount);
		jfloatArray argpointerCoordsToolMinor = env->NewFloatArray(pointerCount);
		jfloatArray argpointerCoordsTouchMajor = env->NewFloatArray(pointerCount);
		jfloatArray argpointerCoordsTouchMinor = env->NewFloatArray(pointerCount);
		jfloatArray argpointerCoordsX = env->NewFloatArray(pointerCount);
		jfloatArray argpointerCoordsY = env->NewFloatArray(pointerCount);
		jintArray argAxisIndexes = env->NewIntArray(axisCount);
		jfloatArray argAxisValues = env->NewFloatArray(axisCount);

		env->SetIntArrayRegion(argPointerPropertiesId, 0, pointerCount, pointerPropertiesId);
		env->SetIntArrayRegion(argpointerPropertiesToolType, 0, pointerCount, pointerPropertiesToolType);
		env->SetFloatArrayRegion(argpointerCoordsOrientation, 0, pointerCount, pointerCoordsOrientation);
		env->SetFloatArrayRegion(argpointerCoordsPressure, 0, pointerCount, pointerCoordsPressure);
		env->SetFloatArrayRegion(argpointerCoordsSize, 0, pointerCount, pointerCoordsSize);
		env->SetFloatArrayRegion(argpointerCoordsToolMajor, 0, pointerCount, pointerCoordsToolMajor);
		env->SetFloatArrayRegion(argpointerCoordsToolMinor, 0, pointerCount, pointerCoordsToolMinor);
		env->SetFloatArrayRegion(argpointerCoordsTouchMajor, 0, pointerCount, pointerCoordsTouchMajor);
		env->SetFloatArrayRegion(argpointerCoordsTouchMinor, 0, pointerCount, pointerCoordsTouchMinor);
		env->SetFloatArrayRegion(argpointerCoordsX, 0, pointerCount, pointerCoordsX);
		env->SetFloatArrayRegion(argpointerCoordsY, 0, pointerCount, pointerCoordsY);
		env->SetIntArrayRegion(argAxisIndexes, 0, axisCount, axisIndexes);
		env->SetFloatArrayRegion(argAxisValues, 0, axisCount, axisValues);

		bool handled = env->CallBooleanMethod(_instance, _jmJavaDispatchMotionEvent,
				downTime,
				eventTime,
				action,
				pointerCount,
				metaState,
				buttonState,
				xPrecision,
				yPrecision,
				deviceId,
				edgeFlags,
				source,
				flags,
				argPointerPropertiesId,
				argpointerPropertiesToolType,
				argpointerCoordsOrientation,
				argpointerCoordsPressure,
				argpointerCoordsSize,
				argpointerCoordsToolMajor,
				argpointerCoordsToolMinor,
				argpointerCoordsTouchMajor,
				argpointerCoordsTouchMinor,
				argpointerCoordsX,
				argpointerCoordsY,
				axisCount,
				argAxisIndexes,
				argAxisValues);

		env->DeleteLocalRef(argPointerPropertiesId);
		env->DeleteLocalRef(argpointerPropertiesToolType);
		env->DeleteLocalRef(argpointerCoordsOrientation);
		env->DeleteLocalRef(argpointerCoordsPressure);
		env->DeleteLocalRef(argpointerCoordsSize);
		env->DeleteLocalRef(argpointerCoordsToolMajor);
		env->DeleteLocalRef(argpointerCoordsToolMinor);
		env->DeleteLocalRef(argpointerCoordsTouchMajor);
		env->DeleteLocalRef(argpointerCoordsTouchMinor);
		env->DeleteLocalRef(argpointerCoordsX);
		env->DeleteLocalRef(argpointerCoordsY);
		env->DeleteLocalRef(argAxisIndexes);
		env->DeleteLocalRef(argAxisValues);

		return handled;
	}
Ejemplo n.º 22
0
JNIEXPORT jstring JNICALL Java_org_kidfolk_androidRDP_AndroidRDPActivity_getenv(
		JNIEnv *env, jclass thiz) {
	__android_log_print(ANDROID_LOG_INFO, "JNIMsg", "getenv");
	return (*env)->NewStringUTF(env, getenv("EXTERNAL_STORAGE"));
}
Ejemplo n.º 23
0
//SET UP ENCODER
jstring Java_edu_sdsu_server_util_EncoderActivationInterface_encoderStart
  	(JNIEnv *env, jclass cls, /*jstring outfile,*/ jint width,
  			jint height, jint frame_rate, jint bps, jint variableRate) {

	//Open a socket
	g_sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
	if(g_sockfd <= 0)
	{
		__android_log_print(ANDROID_LOG_ERROR, "DWRIGHT--UDPSEND", "Failed to create socket");
		return env->NewStringUTF("Failed to open socket");
	}

	//Bind to port on host side
	sockaddr_in address;

	address.sin_family = AF_INET;
	address.sin_addr.s_addr = INADDR_ANY;
	address.sin_port = htons((unsigned short) PORT);

	int bound = bind(g_sockfd, (sockaddr*) &address, sizeof(address));
	if(bound < 0)
	{
		__android_log_print(ANDROID_LOG_ERROR, "DWRIGHT--UDPSEND", "Failed to bind to socket: %s", strerror(errno));
		close(g_sockfd);
		return env->NewStringUTF("Failed to open socket");
	}
	else
	{
		__android_log_print(ANDROID_LOG_ERROR, "DWRIGHT--UDPSEND", "Bound to socket!: %s", inet_ntoa(address.sin_addr));
	}

	//Set non-blocking
	int nonBlocking = 1;
	if(fcntl(g_sockfd, F_SETFL, O_NONBLOCK, nonBlocking) == -1)
	{
		__android_log_print(ANDROID_LOG_ERROR, "DWRIGHT--UDPSEND", "Failed to set nonblocking");
		close(g_sockfd);
		return env->NewStringUTF("Failed to open socket");
	}

	//Set up encoder params
	g_encoder = NULL;
	g_timeStamp = 0;

	g_params.frameWidth = width;
	g_params.frameHeight = height;
	g_params.frameRate = frame_rate;//30; //Specify frame rate at 30fps
	g_params.rateControl = 3;//2;
	//Need better bitrate calculation
	g_params.bitRate = bps == 0 ? width * height * 3 : bps;
	g_params.codecString = NULL;

	//Flag to vary bitrate
	variable_rate = variableRate;

	//const char *outputFileName = env->GetStringUTFChars(outfile,0);
	//__android_log_print(ANDROID_LOG_ERROR,"QCOMOMXINTERFACE", "FRAME WxH = %dx%d TO %s", width, height, outputFileName);

	//f = fopen(outputFileName, "wb");

	int status = 0;
	g_encoder = encoder_create(&status, &g_params);
	if (g_encoder == NULL) {
		return env->NewStringUTF(resultDescription(status));
	}

	// The input semaphore is important; by using it, the procedure for
	// feeding the component will wait for an available input buffer when
	// the component is busy.
	//
	omx_setup_input_semaphore(g_encoder);

//#if USE_BITRATE_ENCODING_TEST
//	// Uses the variable bitrate encoding as given in BitrateTest.cpp.  The
//	// bitrate setting in g_params is ignored in this version.
//	omx_interface_register_output_callback(g_encoder, handleOutputEncodedToFile, f);
//
//#else
//	// Default implementation uses arbitrary bitrate of width * height * 3 kbps
//	omx_interface_register_output_callback(g_encoder, handleOutputEncoded, f);
//
//#endif

	omx_interface_register_output_callback(g_encoder, pipeEncodedtoPacket, NULL);

	// Initialize the component and set to the execution state, waiting
	// for frames from the camera.
	status = omx_interface_init(g_encoder);

//	status = omx_interface_set_region_of_interest(g_encoder, 0);
//	if(status != 0)
//	{
//		__android_log_print(ANDROID_LOG_ERROR, "DWRIGHT--UDPSEND", "Failed to set region of interest (input)");
//
//	}
//	else
//	{
//		status = omx_interface_set_region_of_interest(g_encoder, 1);
//		if(status != 0)
//		{
//			__android_log_print(ANDROID_LOG_ERROR, "DWRIGHT--UDPSEND", "Failed to set region of interest (output)");
//
//		}
//	}

	// Return the state
	const char *result = resultDescription(status);
	return env->NewStringUTF(result);
}
Ejemplo n.º 24
0
/**
 * @title the temp function
 */
JNIEXPORT jobjectArray JNICALL Java_org_kidfolk_androidRDP_AndroidRDPActivity_getBitmapBytesFormNative(
		JNIEnv * env, jclass clazz, jint x, jint y, jint width, jint height, jobjectArray array) {
	__android_log_print(ANDROID_LOG_INFO, "JNIMsg", "Java_org_kidfolk_androidRDP_AndroidRDPActivity_getBitmapBytesFormNative");
}
Ejemplo n.º 25
0
int main(int argc, char **argv)
{
	__android_log_print(ANDROID_LOG_DEBUG, TAG, "The start of framebuffer\n");

	int fp=0;
    struct fb_var_screeninfo vinfo;
    struct fb_fix_screeninfo finfo;
    int screensize=0;
    char *fbp = 0;
    unsigned int x = 0;
	unsigned int y = 0;
    int location = 0;
    int bytes_per_pixel;

    int a = 3;
    int b = 4;
    int r = 0;

    fp = open("/dev/graphics/fb0", O_RDWR);

    if(fp < 0)
	{
        printf("Error : Can not open framebuffer device\n");
        exit(1);
    }

    if(ioctl(fp, FBIOGET_FSCREENINFO, &finfo))
	{
        printf("Error reading fixed information\n");
        exit(2);
    }

    if(ioctl(fp, FBIOGET_VSCREENINFO, &vinfo))
	{
        printf("Error reading variable information\n");
        exit(3);
    }

    bytes_per_pixel = vinfo.bits_per_pixel / 8;
    screensize = vinfo.xres * vinfo.yres * bytes_per_pixel;
    printf("x=%d  y=%d  bytes_per_pixel=%d\n", vinfo.xres, vinfo.yres, bytes_per_pixel);
    printf("screensize=%d\n", screensize);

    fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fp, 0);
    if((int)fbp == -1)
    {
         printf("Error: failed to map framebuffer device to memory.\n");
         exit(4);
    }
    
	while(1) 
	{
        x = 0;
        y = 0;
        
		for(x = 0; x < vinfo.xres; x++) 
		{
            y = a * x + b;
            if(y > vinfo.yres)
				break;

			location = x * bytes_per_pixel + y  *  finfo.line_length;

            *(fbp + location)     = 255;  
            *(fbp + location + 1) = 255; 
            *(fbp + location + 2) = 255; 
            *(fbp + location + 3) = 0;  
        }
       
        usleep(40);
    }

    munmap(fbp, screensize);
    close(fp);

    return 0;
}
Ejemplo n.º 26
0
/**
 * send data to java level
 */
void send_data_vm(int left, int top, int cx, int cy, int width, int height,
		uint8 * bmpdata) {
	__android_log_print(ANDROID_LOG_INFO, "JNIMsg", "send_data_vm");
}
Ejemplo n.º 27
0
// Load instance based Vulkan function pointers
void loadVulkanFunctions(VkInstance instance)
{
    __android_log_print(ANDROID_LOG_INFO, "vulkanandroid", "Loading instance based function pointers...\n");

    vkEnumeratePhysicalDevices = reinterpret_cast<PFN_vkEnumeratePhysicalDevices>(vkGetInstanceProcAddr(instance, "vkEnumeratePhysicalDevices"));
    vkGetPhysicalDeviceProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceProperties>(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceProperties"));
    vkEnumerateDeviceLayerProperties = reinterpret_cast<PFN_vkEnumerateDeviceLayerProperties>(vkGetInstanceProcAddr(instance, "vkEnumerateDeviceLayerProperties"));
    vkEnumerateDeviceExtensionProperties = reinterpret_cast<PFN_vkEnumerateDeviceExtensionProperties>(vkGetInstanceProcAddr(instance, "vkEnumerateDeviceExtensionProperties"));
    vkGetPhysicalDeviceQueueFamilyProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceQueueFamilyProperties>(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceQueueFamilyProperties"));
    vkGetPhysicalDeviceFeatures = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures>(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceFeatures"));
    vkCreateDevice = reinterpret_cast<PFN_vkCreateDevice>(vkGetInstanceProcAddr(instance, "vkCreateDevice"));
    vkGetPhysicalDeviceFormatProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceFormatProperties>(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceFormatProperties"));
    vkGetPhysicalDeviceMemoryProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceMemoryProperties>(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceMemoryProperties"));

	vkCmdPipelineBarrier = reinterpret_cast<PFN_vkCmdPipelineBarrier>(vkGetInstanceProcAddr(instance, "vkCmdPipelineBarrier"));
	vkCreateShaderModule = reinterpret_cast<PFN_vkCreateShaderModule>(vkGetInstanceProcAddr(instance, "vkCreateShaderModule"));

	vkCreateBuffer = reinterpret_cast<PFN_vkCreateBuffer>(vkGetInstanceProcAddr(instance, "vkCreateBuffer"));
	vkGetBufferMemoryRequirements = reinterpret_cast<PFN_vkGetBufferMemoryRequirements>(vkGetInstanceProcAddr(instance, "vkGetBufferMemoryRequirements"));
	vkMapMemory = reinterpret_cast<PFN_vkMapMemory>(vkGetInstanceProcAddr(instance, "vkMapMemory"));
	vkUnmapMemory = reinterpret_cast<PFN_vkUnmapMemory>(vkGetInstanceProcAddr(instance, "vkUnmapMemory"));
	vkBindBufferMemory = reinterpret_cast<PFN_vkBindBufferMemory>(vkGetInstanceProcAddr(instance, "vkBindBufferMemory"));
	vkDestroyBuffer = reinterpret_cast<PFN_vkDestroyBuffer>(vkGetInstanceProcAddr(instance, "vkDestroyBuffer"));

	vkAllocateMemory = reinterpret_cast<PFN_vkAllocateMemory>(vkGetInstanceProcAddr(instance, "vkAllocateMemory"));
	vkFreeMemory = reinterpret_cast<PFN_vkFreeMemory>(vkGetInstanceProcAddr(instance, "vkFreeMemory"));
	vkCreateRenderPass = reinterpret_cast<PFN_vkCreateRenderPass>(vkGetInstanceProcAddr(instance, "vkCreateRenderPass"));
	vkCmdBeginRenderPass = reinterpret_cast<PFN_vkCmdBeginRenderPass>(vkGetInstanceProcAddr(instance, "vkCmdBeginRenderPass"));
	vkCmdEndRenderPass = reinterpret_cast<PFN_vkCmdEndRenderPass>(vkGetInstanceProcAddr(instance, "vkCmdEndRenderPass"));
	vkCmdExecuteCommands = reinterpret_cast<PFN_vkCmdExecuteCommands>(vkGetInstanceProcAddr(instance, "vkCmdExecuteCommands"));

	vkCreateImage = reinterpret_cast<PFN_vkCreateImage>(vkGetInstanceProcAddr(instance, "vkCreateImage"));
	vkGetImageMemoryRequirements = reinterpret_cast<PFN_vkGetImageMemoryRequirements>(vkGetInstanceProcAddr(instance, "vkGetImageMemoryRequirements"));
	vkCreateImageView = reinterpret_cast<PFN_vkCreateImageView>(vkGetInstanceProcAddr(instance, "vkCreateImageView"));
	vkDestroyImageView = reinterpret_cast<PFN_vkDestroyImageView>(vkGetInstanceProcAddr(instance, "vkDestroyImageView"));
	vkBindImageMemory = reinterpret_cast<PFN_vkBindImageMemory>(vkGetInstanceProcAddr(instance, "vkBindImageMemory"));
	vkGetImageSubresourceLayout = reinterpret_cast<PFN_vkGetImageSubresourceLayout>(vkGetInstanceProcAddr(instance, "vkGetImageSubresourceLayout"));
	vkCmdCopyImage = reinterpret_cast<PFN_vkCmdCopyImage>(vkGetInstanceProcAddr(instance, "vkCmdCopyImage"));
	vkCmdBlitImage = reinterpret_cast<PFN_vkCmdBlitImage>(vkGetInstanceProcAddr(instance, "vkCmdBlitImage"));
	vkDestroyImage = reinterpret_cast<PFN_vkDestroyImage>(vkGetInstanceProcAddr(instance, "vkDestroyImage"));
	
	vkCmdClearAttachments = reinterpret_cast<PFN_vkCmdClearAttachments>(vkGetInstanceProcAddr(instance, "vkCmdClearAttachments"));

	vkCmdCopyBuffer = reinterpret_cast<PFN_vkCmdCopyBuffer>(vkGetInstanceProcAddr(instance, "vkCmdCopyBuffer"));
	vkCmdCopyBufferToImage = reinterpret_cast<PFN_vkCmdCopyBufferToImage>(vkGetInstanceProcAddr(instance, "vkCmdCopyBufferToImage"));

	vkCreateSampler = reinterpret_cast<PFN_vkCreateSampler>(vkGetInstanceProcAddr(instance, "vkCreateSampler"));
	vkDestroySampler = reinterpret_cast<PFN_vkDestroySampler>(vkGetInstanceProcAddr(instance, "vkDestroySampler"));;

	vkCreateSemaphore = reinterpret_cast<PFN_vkCreateSemaphore>(vkGetInstanceProcAddr(instance, "vkCreateSemaphore"));
	vkDestroySemaphore = reinterpret_cast<PFN_vkDestroySemaphore>(vkGetInstanceProcAddr(instance, "vkDestroySemaphore"));

	vkCreateFence = reinterpret_cast<PFN_vkCreateFence>(vkGetInstanceProcAddr(instance, "vkCreateFence"));
	vkDestroyFence = reinterpret_cast<PFN_vkDestroyFence>(vkGetInstanceProcAddr(instance, "vkDestroyFence"));
	vkWaitForFences = reinterpret_cast<PFN_vkWaitForFences>(vkGetInstanceProcAddr(instance, "vkWaitForFences"));

	vkCreateCommandPool = reinterpret_cast<PFN_vkCreateCommandPool>(vkGetInstanceProcAddr(instance, "vkCreateCommandPool"));
	vkDestroyCommandPool = reinterpret_cast<PFN_vkDestroyCommandPool>(vkGetInstanceProcAddr(instance, "vkDestroyCommandPool"));;

	vkAllocateCommandBuffers = reinterpret_cast<PFN_vkAllocateCommandBuffers>(vkGetInstanceProcAddr(instance, "vkAllocateCommandBuffers"));
	vkBeginCommandBuffer = reinterpret_cast<PFN_vkBeginCommandBuffer>(vkGetInstanceProcAddr(instance, "vkBeginCommandBuffer"));
	vkEndCommandBuffer = reinterpret_cast<PFN_vkEndCommandBuffer>(vkGetInstanceProcAddr(instance, "vkEndCommandBuffer"));

	vkGetDeviceQueue = reinterpret_cast<PFN_vkGetDeviceQueue>(vkGetInstanceProcAddr(instance, "vkGetDeviceQueue"));
	vkQueueSubmit = reinterpret_cast<PFN_vkQueueSubmit>(vkGetInstanceProcAddr(instance, "vkQueueSubmit"));
	vkQueueWaitIdle = reinterpret_cast<PFN_vkQueueWaitIdle>(vkGetInstanceProcAddr(instance, "vkQueueWaitIdle"));
	
	vkDeviceWaitIdle = reinterpret_cast<PFN_vkDeviceWaitIdle>(vkGetInstanceProcAddr(instance, "vkDeviceWaitIdle"));

	vkCreateFramebuffer = reinterpret_cast<PFN_vkCreateFramebuffer>(vkGetInstanceProcAddr(instance, "vkCreateFramebuffer"));

	vkCreatePipelineCache = reinterpret_cast<PFN_vkCreatePipelineCache>(vkGetInstanceProcAddr(instance, "vkCreatePipelineCache"));
	vkCreatePipelineLayout = reinterpret_cast<PFN_vkCreatePipelineLayout>(vkGetInstanceProcAddr(instance, "vkCreatePipelineLayout"));
	vkCreateGraphicsPipelines = reinterpret_cast<PFN_vkCreateGraphicsPipelines>(vkGetInstanceProcAddr(instance, "vkCreateGraphicsPipelines"));
	vkCreateComputePipelines = reinterpret_cast<PFN_vkCreateComputePipelines>(vkGetInstanceProcAddr(instance, "vkCreateComputePipelines"));

	vkCreateDescriptorPool = reinterpret_cast<PFN_vkCreateDescriptorPool>(vkGetInstanceProcAddr(instance, "vkCreateDescriptorPool"));
	vkCreateDescriptorSetLayout = reinterpret_cast<PFN_vkCreateDescriptorSetLayout>(vkGetInstanceProcAddr(instance, "vkCreateDescriptorSetLayout"));

	vkAllocateDescriptorSets = reinterpret_cast<PFN_vkAllocateDescriptorSets>(vkGetInstanceProcAddr(instance, "vkAllocateDescriptorSets"));
	vkUpdateDescriptorSets = reinterpret_cast<PFN_vkUpdateDescriptorSets>(vkGetInstanceProcAddr(instance, "vkUpdateDescriptorSets"));

	vkCmdBindDescriptorSets = reinterpret_cast<PFN_vkCmdBindDescriptorSets>(vkGetInstanceProcAddr(instance, "vkCmdBindDescriptorSets"));
	vkCmdBindPipeline = reinterpret_cast<PFN_vkCmdBindPipeline>(vkGetInstanceProcAddr(instance, "vkCmdBindPipeline"));
	vkCmdBindVertexBuffers = reinterpret_cast<PFN_vkCmdBindVertexBuffers>(vkGetInstanceProcAddr(instance, "vkCmdBindVertexBuffers"));
	vkCmdBindIndexBuffer = reinterpret_cast<PFN_vkCmdBindIndexBuffer>(vkGetInstanceProcAddr(instance, "vkCmdBindIndexBuffer"));

	vkCmdSetViewport = reinterpret_cast<PFN_vkCmdSetViewport>(vkGetInstanceProcAddr(instance, "vkCmdSetViewport"));
	vkCmdSetScissor = reinterpret_cast<PFN_vkCmdSetScissor>(vkGetInstanceProcAddr(instance, "vkCmdSetScissor"));
	vkCmdSetLineWidth = reinterpret_cast<PFN_vkCmdSetLineWidth>(vkGetInstanceProcAddr(instance, "vkCmdSetLineWidth"));
	vkCmdSetDepthBias = reinterpret_cast<PFN_vkCmdSetDepthBias>(vkGetInstanceProcAddr(instance, "vkCmdSetDepthBias"));
	vkCmdPushConstants = reinterpret_cast<PFN_vkCmdPushConstants>(vkGetInstanceProcAddr(instance, "vkCmdPushConstants"));;

	vkCmdDrawIndexed = reinterpret_cast<PFN_vkCmdDrawIndexed>(vkGetInstanceProcAddr(instance, "vkCmdDrawIndexed"));
	vkCmdDraw = reinterpret_cast<PFN_vkCmdDraw>(vkGetInstanceProcAddr(instance, "vkCmdDraw"));
	vkCmdDispatch = reinterpret_cast<PFN_vkCmdDispatch>(vkGetInstanceProcAddr(instance, "vkCmdDispatch"));

	vkDestroyPipeline = reinterpret_cast<PFN_vkDestroyPipeline>(vkGetInstanceProcAddr(instance, "vkDestroyPipeline"));
	vkDestroyPipelineLayout = reinterpret_cast<PFN_vkDestroyPipelineLayout>(vkGetInstanceProcAddr(instance, "vkDestroyPipelineLayout"));;
	vkDestroyDescriptorSetLayout = reinterpret_cast<PFN_vkDestroyDescriptorSetLayout>(vkGetInstanceProcAddr(instance, "vkDestroyDescriptorSetLayout"));
	vkDestroyDevice = reinterpret_cast<PFN_vkDestroyDevice>(vkGetInstanceProcAddr(instance, "vkDestroyDevice"));
	vkDestroyInstance = reinterpret_cast<PFN_vkDestroyInstance>(vkGetInstanceProcAddr(instance, "vkDestroyInstance"));
	vkDestroyDescriptorPool = reinterpret_cast<PFN_vkDestroyDescriptorPool>(vkGetInstanceProcAddr(instance, "vkDestroyDescriptorPool"));
	vkFreeCommandBuffers = reinterpret_cast<PFN_vkFreeCommandBuffers>(vkGetInstanceProcAddr(instance, "vkFreeCommandBuffers"));
	vkDestroyRenderPass = reinterpret_cast<PFN_vkDestroyRenderPass>(vkGetInstanceProcAddr(instance, "vkDestroyRenderPass"));
	vkDestroyFramebuffer = reinterpret_cast<PFN_vkDestroyFramebuffer>(vkGetInstanceProcAddr(instance, "vkDestroyFramebuffer"));
	vkDestroyShaderModule = reinterpret_cast<PFN_vkDestroyShaderModule>(vkGetInstanceProcAddr(instance, "vkDestroyShaderModule"));
	vkDestroyPipelineCache = reinterpret_cast<PFN_vkDestroyPipelineCache>(vkGetInstanceProcAddr(instance, "vkDestroyPipelineCache"));

	vkCreateQueryPool = reinterpret_cast<PFN_vkCreateQueryPool>(vkGetInstanceProcAddr(instance, "vkCreateQueryPool"));
	vkDestroyQueryPool = reinterpret_cast<PFN_vkDestroyQueryPool>(vkGetInstanceProcAddr(instance, "vkDestroyQueryPool"));
	vkGetQueryPoolResults = reinterpret_cast<PFN_vkGetQueryPoolResults>(vkGetInstanceProcAddr(instance, "vkGetQueryPoolResults"));

	vkCmdBeginQuery = reinterpret_cast<PFN_vkCmdBeginQuery>(vkGetInstanceProcAddr(instance, "vkCmdBeginQuery"));
	vkCmdEndQuery = reinterpret_cast<PFN_vkCmdEndQuery>(vkGetInstanceProcAddr(instance, "vkCmdEndQuery"));
	vkCmdResetQueryPool = reinterpret_cast<PFN_vkCmdResetQueryPool>(vkGetInstanceProcAddr(instance, "vkCmdResetQueryPool"));
	vkCmdCopyQueryPoolResults = reinterpret_cast<PFN_vkCmdCopyQueryPoolResults>(vkGetInstanceProcAddr(instance, "vkCmdCopyQueryPoolResults"));
	
	vkCreateAndroidSurfaceKHR = reinterpret_cast<PFN_vkCreateAndroidSurfaceKHR>(vkGetInstanceProcAddr(instance, "vkCreateAndroidSurfaceKHR"));
	vkDestroySurfaceKHR = reinterpret_cast<PFN_vkDestroySurfaceKHR>(vkGetInstanceProcAddr(instance, "vkDestroySurfaceKHR"));
}
Ejemplo n.º 28
0
// Add a log entry given a variable argument list
OsStatus OsSysLog::vadd(const char*            taskName,
                        const OsTaskId_t       taskId,                        
                        const OsSysLogFacility facility,
                        const OsSysLogPriority priority,
                        const char*            format,
                        va_list                ap)
{
   // If the log has not been initialized, print everything to the console
   if (!isTaskPtrNull())
   {
      if (willLog(facility, priority))
      {
         UtlString logData;
         UtlString logEntry;
         myvsprintf(logData, format, ap) ;
         logData = escape(logData) ;

#ifdef ANDROID
         __android_log_print(androidPri(priority), "sipXsyslog", "[%s] %s",
                             OsSysLog::sFacilityNames[facility], logData.data());
#endif

         OsTime timeNow;
         OsDateTime::getCurTime(timeNow); 
         OsDateTime logTime(timeNow);
         
         UtlString   strTime ;
         logTime.getIsoTimeStringZus(strTime) ;
         UtlString   taskHex;
         // TODO: Should get abstracted into a OsTaskBase method
#ifdef __pingtel_on_posix__
         OsTaskLinux::getIdString_X(taskHex, taskId);
#endif

         mysprintf(logEntry, "\"%s\":%d:%s:%s:%s:%s:%s:%s:\"%s\"",
               strTime.data(),
               ++sEventCount,
               OsSysLog::sFacilityNames[facility], 
               OsSysLog::sPriorityNames[priority],
               sHostname.data(),
               (taskName == NULL) ? "" : taskName,
               taskHex.data(),
               sProcessId.data(),
               logData.data()) ;         

         // If the logger for some reason trys to log a message
         // there is a recursive problem.  Drop the message on the
         // floor for now.  This can occur if one of the os utilities
         // logs a message.
         if(strcmp("syslog", taskName) == 0)
         {
             // Just discard the log entry
             //
             // (rschaaf):
             // NOTE: Don't try to use osPrintf() to emit the log entry since this
             // can cause consternation for applications (e.g. CGIs) that expect to
             // use stdout for further processing.
         }
         else
         {
             char* szPtr = strdup(logEntry.data()) ;
             OsSysLogMsg msg(OsSysLogMsg::LOG, szPtr) ;
             OsTime timeout(1000) ;
             OsSysLogTask *pOsSysLogTask = spOsSysLogTask;
             if ( pOsSysLogTask != NULL &&
                  pOsSysLogTask->postMessage(msg, timeout) != OS_SUCCESS)
             {
                 printf("OsSysLog jammed: %s\n", szPtr) ;
                 free(szPtr) ;
                 OsTask::yield() ;
              }
          }
       }
   }

   return OS_SUCCESS ;
}
Ejemplo n.º 29
0
jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
	// use __android_log_print for logcat debugging...
	__android_log_print(ANDROID_LOG_INFO, "JavaBridge", "[%s] Creating java link vm = %08x\n", __FUNCTION__, vm);
	java_vm = vm;

	// attach our thread to the java vm; obviously it's already attached but this way we get the JNIEnv..
	JNIEnv* jni_env = 0;
	java_vm->AttachCurrentThread(&jni_env, 0);
	__android_log_print(ANDROID_LOG_INFO, "JavaBridge", "[%s] JNI Environment is = %08x\n", __FUNCTION__, jni_env);

	// first we try to find our main activity..
	jclass cls_Activity		= jni_env->FindClass("com/unity3d/player/UnityPlayer");
	jfieldID fid_Activity	= jni_env->GetStaticFieldID(cls_Activity, "currentActivity", "Landroid/app/Activity;");
	jobject obj_Activity	= jni_env->GetStaticObjectField(cls_Activity, fid_Activity);
	__android_log_print(ANDROID_LOG_INFO, "JavaBridge", "[%s] Current activity = %08x\n", __FUNCTION__, obj_Activity);

	// create a JavaClass object...
	jclass cls_JavaClass	= jni_env->FindClass("com/dolby/ddpexample/JavaClass");
	jmethodID mid_JavaClass	= jni_env->GetMethodID(cls_JavaClass, "<init>", "(Landroid/app/Activity;)V");
	jobject obj_JavaClass	= jni_env->NewObject(cls_JavaClass, mid_JavaClass, obj_Activity);
	__android_log_print(ANDROID_LOG_INFO, "JavaBridge", "[%s] JavaClass object = %08x\n", __FUNCTION__, obj_JavaClass);

	// create a global reference to the JavaClass object and fetch method id(s)..
	JavaClass					= jni_env->NewGlobalRef(obj_JavaClass);
	toggleDdpMethod				= jni_env->GetMethodID(cls_JavaClass, "toggleDolbyDigitalPlus", "()Z");

	getDialogEnhancerOnMethod	= jni_env->GetMethodID(cls_JavaClass, "getDialogEnhancerOn", "()Z");
	getVolumeLevellerOnMethod	= jni_env->GetMethodID(cls_JavaClass, "getVolumeLevellerOn", "()Z");
	getVirtualizerOnMethod		= jni_env->GetMethodID(cls_JavaClass, "getVirtualizerOn", "()Z");
	toggleDialogEnhancerMethod	= jni_env->GetMethodID(cls_JavaClass, "toggleDialogEnhancer", "()Z");
	toggleVolumeLevellerMethod	= jni_env->GetMethodID(cls_JavaClass, "toggleVolumeLeveller", "()Z");
	toggleVirtualizerMethod		= jni_env->GetMethodID(cls_JavaClass, "toggleVirtualizer", "()Z");

	cycleDdpProfileMethod		= jni_env->GetMethodID(cls_JavaClass, "cycleDdpProfile", "()Ljava/lang/String;");
	getCurrentProfileNameMethod	= jni_env->GetMethodID(cls_JavaClass, "getCurrentProfileName", "()Ljava/lang/String;");
	
	__android_log_print(ANDROID_LOG_INFO, "JavaBridge", "Method: %s", __FUNCTION__);
	__android_log_print(ANDROID_LOG_INFO, "JavaBridge", "JavaClass global ref = %08x\n", JavaClass);
	__android_log_print(ANDROID_LOG_INFO, "JavaBridge", "toggleDdpMethod method id = %08x\n", toggleDdpMethod);
	
	__android_log_print(ANDROID_LOG_INFO, "JavaBridge", "getDialogEnhancerOnMethod method id = %08x\n", getDialogEnhancerOnMethod);
	__android_log_print(ANDROID_LOG_INFO, "JavaBridge", "getVolumeLevellerOnMethod method id = %08x\n", getVolumeLevellerOnMethod);
	__android_log_print(ANDROID_LOG_INFO, "JavaBridge", "getVirtualizerOnMethod method id = %08x\n", getVirtualizerOnMethod);
	__android_log_print(ANDROID_LOG_INFO, "JavaBridge", "toggleDialogEnhancerMethod method id = %08x\n", toggleDialogEnhancerMethod);
	__android_log_print(ANDROID_LOG_INFO, "JavaBridge", "toggleVolumeLevellerMethod method id = %08x\n", toggleVolumeLevellerMethod);
	__android_log_print(ANDROID_LOG_INFO, "JavaBridge", "toggleVirtualizerMethod method id = %08x\n", toggleVirtualizerMethod);

	__android_log_print(ANDROID_LOG_INFO, "JavaBridge", "cycleDdpProfileMethod method id = %08x\n", cycleDdpProfileMethod);
	__android_log_print(ANDROID_LOG_INFO, "JavaBridge", "getCurrentProfileNameMethod method id = %08x\n", getCurrentProfileNameMethod);

	return JNI_VERSION_1_6;		// minimum JNI version
}
	jstring 
Java_edu_vu_isis_ammo_core_ethertracker_EthTrackSvc_waitForEvent(JNIEnv *env,
		jobject clazz)
{
	char *buff;
	struct nlmsghdr *nh;
	struct ifinfomsg *einfo;
	struct iovec iov;
	struct msghdr msg;
	char *result = NULL;
	char rbuf[4096];
	unsigned int left;
	interface_info_t *info;
	int len;

	__android_log_print(
			ANDROID_LOG_INFO, 
			LOG_TAG,
			"Poll events from ethernet devices");

	/*
	 *wait on uevent netlink socket for the ethernet device
	 */

	buff = (char *)malloc(NL_POLL_MSG_SZ);
	memset (buff, 0, NL_POLL_MSG_SZ);

	if (!buff) {
		__android_log_print(
				ANDROID_LOG_INFO, 
				LOG_TAG,
				"Allocate poll buffer failed");
		goto error;
	}

	iov.iov_base = buff;
	iov.iov_len = NL_POLL_MSG_SZ;
	memset(&msg,   0, sizeof(msg));
	msg.msg_name = (void *)&addr_msg;
	msg.msg_namelen =  sizeof(addr_msg);
	msg.msg_iov =  &iov;
	msg.msg_iovlen =  1;
	msg.msg_control =  NULL;
	msg.msg_controllen =  0;
	msg.msg_flags =  0;
	char * ethstatmsg; 

	/*
	   __android_log_print(
	   ANDROID_LOG_INFO, 
	   LOG_TAG,
	   "Making a call on recvmsg");
	 */
	if((len = recvmsg(nl_socket_poll, &msg, 0))>= 0) {
		__android_log_print(ANDROID_LOG_INFO, LOG_TAG,
				"recvmsg get data");
		result = rbuf;
		left = 4096;
		rbuf[0] = '\0';
		for (nh = (struct nlmsghdr *) buff; NLMSG_OK (nh, len);
				nh = NLMSG_NEXT (nh, len))
		{

			if (nh->nlmsg_type == NLMSG_DONE){
				//LOGE("Did not find useful eth interface information");
				goto error;
			}

			if (nh->nlmsg_type == NLMSG_ERROR){

				/* Do some error handling. */
				//LOGE("Read device name failed");
				goto error;
			}

			if (nh->nlmsg_type == RTM_DELLINK
			    ||nh->nlmsg_type == RTM_NEWLINK
			    ||nh->nlmsg_type == RTM_NEWADDR )
				ethstatmsg = process_msg (nh);
			else
				ethstatmsg = result;

		}
		//LOGI("Done parsing");
		rbuf[4096 - left] = '\0';
		//LOGI("poll state :%s, left:%d",rbuf, left);
	}
	else
	{
		__android_log_print(
							ANDROID_LOG_INFO, 
							LOG_TAG,
							"Error in recvmsg .. exiting"
							);
							goto error;
	}
	if (ethstatmsg != 0)
		return (*env)->NewStringUTF(env, ethstatmsg);
	else
		return (*env)->NewStringUTF(env, rbuf);

error:
	if(buff)
		free(buff);
	return (*env)->NewStringUTF(env, "Error");
}