static ssize_t read_fd(int fd, void *ptr, size_t nbytes, int *recvfd) { struct msghdr msg; struct iovec iov[1]; ssize_t n; union { struct cmsghdr cm; char control[CMSG_SPACE(sizeof (int))]; } control_un; struct cmsghdr *cmptr; msg.msg_control = control_un.control; msg.msg_controllen = sizeof(control_un.control); msg.msg_name = NULL; msg.msg_namelen = 0; iov[0].iov_base = ptr; iov[0].iov_len = nbytes; msg.msg_iov = iov; msg.msg_iovlen = 1; msg.msg_flags = 0; if ( (n = recvmsg(fd, &msg, 0)) <= 0) return (n); if ( (cmptr = CMSG_FIRSTHDR(&msg)) != NULL && cmptr->cmsg_len == CMSG_LEN(sizeof(int))) { if (cmptr->cmsg_level != SOL_SOCKET) __android_log_write(ANDROID_LOG_ERROR, "OpenVpn_JNI", "control level != SOL_SOCKET"); if (cmptr->cmsg_type != SCM_RIGHTS) __android_log_write(ANDROID_LOG_ERROR, "OpenVpn_JNI", "control type != SCM_RIGHTS"); *recvfd = *((int *) CMSG_DATA(cmptr)); } else *recvfd = -1; /* descriptor was not passed */ return (n); }
void Sys_Error( const char *format, ... ) { va_list argptr; char string[1024]; va_start( argptr, format ); Q_vsnprintfz( string, sizeof( string ), format, argptr ); va_end( argptr ); __android_log_write( ANDROID_LOG_ERROR, "Qfusion", string ); _exit( 1 ); }
static void *thread_logger(void*) { ssize_t rdsz; char buf[128]; while((rdsz = read(pfd[0], buf, sizeof buf - 1)) > 0) { if(buf[rdsz - 1] == '\n') --rdsz; buf[rdsz] = 0; /* add null-terminator */ __android_log_write(ANDROID_LOG_DEBUG, tag, buf); } return 0; }
JNIEXPORT jint JNICALL Java_com_baidu_video_download_JNIP2P_netQueryTaskStat( JNIEnv* env, jobject obj, jlong hTaskHandle, jobject stat) { __android_log_write(ANDROID_LOG_DEBUG,"P2P","QueryTaskStat"); task_stat_t ts; int ret = p2pservice_task_stat( (task_handle_t)hTaskHandle, &ts ); char temp_log[1024]={0}; if(ret!=0) { sprintf(temp_log, "p2pservice_task_stat error, h=%u, ret=%u", (task_handle_t)hTaskHandle, ret); __android_log_write(ANDROID_LOG_DEBUG,"P2P",temp_log); return (jint)ret; } sprintf(temp_log, "h=%u, DownDup=%llu", (task_handle_t)hTaskHandle, ts.down_dup); __android_log_write(ANDROID_LOG_DEBUG,"P2P",temp_log); jclass statClass = env->GetObjectClass(stat); jfieldID id_nTotalDup = env->GetFieldID(statClass,"nTotalDup","J"); env->SetLongField(stat,id_nTotalDup,(jlong)ts.down_dup); return (jint)ret; }
// Copes a file that's been uploaded to the activity's directory into the activity's cache, preserving the directory structure void CacheFile(const Aws::String &fileName, const Aws::String& directory) { Aws::String destDirectory = Aws::Platform::GetCacheDirectory() + directory; Aws::FileSystem::CreateDirectoryIfNotExists(destDirectory.c_str()); Aws::String sourceFileName = "/data/data/aws.androidsdktesting/" + directory + Aws::String( "/" ) + fileName; Aws::String destFileName = destDirectory + Aws::String( "/" ) + fileName; Aws::String logLine = sourceFileName + " -> " + destFileName; __android_log_write(ANDROID_LOG_DEBUG, "Caching ", logLine.c_str()); CopyFile(sourceFileName.c_str(), destFileName.c_str()); }
static inline int readBuffer(MP3File* mp3) { size_t done = 0; int err = mpg123_read(mp3->handle, mp3->buffer, mp3->buffer_size, &done); mp3->leftSamples = done / 2; mp3->offset = 0; if (err != MPG123_OK) __android_log_write(ANDROID_LOG_ERROR, "podax-jni", mpg123_strerror(mp3->handle)); return err != MPG123_OK ? 0 : done; }
void PCLWrapper::benchmark_png(){ int count = 0; //generate a set of random points int width = 640; int height = 480; unsigned short *test1 = (unsigned short *)malloc(width*height*sizeof(unsigned short)); //depth unsigned char *test2 = (unsigned char *)malloc(width*height*sizeof(unsigned char)*3); //rgb //load the input points with some random numbers //worst case for the image compression for (size_t i = 0; i < width*height*3; ++i) { *(test2+i)=rand(); } for (size_t i = 0; i < width*height; ++i) { *(test1+i)=rand(); } int counter=0; int iterations = 50; int average = 25; while (iterations > 0){ struct timeval start, end; double t1, t2; static double elapsed_sec = 0; const int MAX_COUNT = average; //average 10 results before printing gettimeofday(&start, NULL); //do some work here. char my_path[512]; sprintf(my_path, "/data/ni/out_rgb_%06d.png", counter); writeImageRGB(my_path, width, height, test2, my_path); sprintf(my_path, "/data/ni/out_depth_%06d.png", counter); writeImageDepth(my_path, width, height, test1, my_path); gettimeofday(&end, NULL); t1 = start.tv_sec + (start.tv_usec / 1000000.0); t2 = end.tv_sec + (end.tv_usec / 1000000.0); elapsed_sec += (t2 - t1); count++; counter++; if (count >= MAX_COUNT) { char buf[512]; sprintf(buf, "Number of Points: %d, Runtime: %f (s)\n", width*height, (elapsed_sec) / MAX_COUNT); elapsed_sec = 0; count = 0; __android_log_write(ANDROID_LOG_INFO, "PCL Benchmark:", buf); } iterations--; } free(test1); free(test2); }
void RomoDebug::printDebug(const char *tag, const char *message) { if (ROMO_DEBUG) { #ifdef __ANDROID__ __android_log_write(ANDROID_LOG_DEBUG, tag, message); #else // Console: printf("%s: %s\n", tag, message); #endif } }
void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...) { static char buffer [BTE_LOG_BUF_SIZE]; va_list ap; UINT32 trace_type = trace_set_mask & 0x07; //lower 3 bits contain trace type int android_log_type = ANDROID_LOG_INFO; va_start (ap, fmt_str); vsnprintf (buffer, BTE_LOG_MAX_SIZE, fmt_str, ap); va_end (ap); if (trace_type == TRACE_TYPE_ERROR) android_log_type = ANDROID_LOG_ERROR; __android_log_write (android_log_type, "NfcNciHal", buffer); }
JNIEXPORT jint JNICALL Java_com_baidu_video_download_JNIP2P_netTest( JNIEnv* env, jobject obj, jclass pBuffer) { __android_log_write(ANDROID_LOG_DEBUG,"P2P","Test"); const char *pNewBuffer = "JNI array test"; jclass bufferClass = env->GetObjectClass(pBuffer); jfieldID id_arrays = env->GetFieldID(bufferClass,"szBuffer","[B"); jbyteArray jbyte_arr = (jbyteArray)env->GetObjectField(pBuffer, id_arrays); env->SetByteArrayRegion(jbyte_arr, 0, 14, (jbyte*)pNewBuffer); return (jint)0; }
static void write_buffer_to_log() { ssize_t rdsz; char buf[4096]; while((rdsz = read(pfd[0], buf, sizeof buf - 1)) > 0) { if(buf[rdsz - 1] == '\n') --rdsz; buf[rdsz] = 0; /* add null-terminator */ __android_log_write(ANDROID_LOG_DEBUG, tag, buf); if (logFile != NULL) { fprintf(logFile, "%s\n", buf); } fflush(logFile); usleep(500000); } }
JNIEXPORT void JNICALL Java_com_marakana_android_lognative_LogLib_logN (JNIEnv *env, jclass clazz, jint priority, jstring tag, jstring msg) { // Convert jstring to char* const char *c_tag = (*env)->GetStringUTFChars(env, tag, NULL); const char *c_msg = (*env)->GetStringUTFChars(env, msg, NULL); __android_log_write(priority, c_tag, c_msg); // Release char* (*env)->ReleaseStringUTFChars(env, tag, c_tag); (*env)->ReleaseStringUTFChars(env, msg, c_msg); }
//-------------------------------------------------------------------------------------- // Name: FrmLogMessage() // Desc: Platform-dependent debug spew functions //-------------------------------------------------------------------------------------- VOID FrmLogMessage( const CHAR* strPrefix, const CHAR* strMessage, const CHAR* strPostFix ) { //typedef enum android_LogPriority { // ANDROID_LOG_UNKNOWN = 0, // ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */ // ANDROID_LOG_VERBOSE, // ANDROID_LOG_DEBUG, // ANDROID_LOG_INFO, // ANDROID_LOG_WARN, // ANDROID_LOG_ERROR, // ANDROID_LOG_FATAL, // ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */ // } android_LogPriority; if( strPrefix ) __android_log_write(ANDROID_LOG_INFO, "OGLES 2.0 Shaders", strPrefix); if( strMessage ) __android_log_write(ANDROID_LOG_INFO, "OGLES 2.0 Shaders", strMessage); if( strPostFix ) __android_log_write(ANDROID_LOG_INFO, "OGLES 2.0 Shaders", strPostFix); }
void TCPServer::sendData(signed char* data, int len) { unsigned int initialSize = len; unsigned int resultingSize = len*0.25; char compressedData[resultingSize]; bzero(compressedData, resultingSize); BZ2_bzBuffToBuffCompress(compressedData, &resultingSize, (char *)data, initialSize, 5, 0, 0); __android_log_print(ANDROID_LOG_ERROR, "JNIDummy", "COMPRESSED SIZE: %d", resultingSize); //int n = write(newsockfd,data,len); char lenStr[10]; sprintf(lenStr, "%d", resultingSize); int n = write(newsockfd,lenStr,10); n = write(newsockfd,compressedData,resultingSize); if (n < 0){ __android_log_write(ANDROID_LOG_DEBUG, "JNIDummy", "ERROR writing to socket"); //CommonFuncs::error("ERROR writing to socket"); } else { __android_log_write(ANDROID_LOG_DEBUG, "JNIDummy", "SERVER WROTE TO SOCKET"); } }
void JNICALL Java_com_intel_lognative_LogLib_log (JNIEnv *env, jclass clazz, jint priority, jstring tag, jstring message) { // Convert jstring to char* const char *c_tag = (*env)->GetStringUTFChars(env, tag, 0); const char *c_message = (*env)->GetStringUTFChars(env, message, 0); // Call the log write function __android_log_write(priority, c_tag, c_message); // Release char* (*env)->ReleaseStringUTFChars(env, tag, c_tag); (*env)->ReleaseStringUTFChars(env, message, c_message); }
void tempMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { if (!message.isEmpty()) { const char * local=message.toStdString().c_str(); switch (type) { case QtDebugMsg: __android_log_write(ANDROID_LOG_DEBUG,"Interface",local); break; case QtInfoMsg: __android_log_write(ANDROID_LOG_INFO,"Interface",local); break; case QtWarningMsg: __android_log_write(ANDROID_LOG_WARN,"Interface",local); break; case QtCriticalMsg: __android_log_write(ANDROID_LOG_ERROR,"Interface",local); break; case QtFatalMsg: default: __android_log_write(ANDROID_LOG_FATAL,"Interface",local); abort(); } } }
/** * Utility function for displaying and catching pending * exceptions. */ static void handlePendingExceptions(JNIEnv* env) { jthrowable exc; exc = env->ExceptionOccurred(); if (exc) { __android_log_write( ANDROID_LOG_INFO, "@@@ MoSync", "Found pending exception"); env->ExceptionDescribe(); env->ExceptionClear(); } }
JNIEXPORT jint JNICALL Java_org_yoooo_GifUtil_AddFrame(JNIEnv *ioEnv, jobject ioThis, jintArray inArray) { ioEnv->GetIntArrayRegion(inArray, (jint)0, (jint)(inDIB.width * inDIB.height), (jint*)(inDIB.bits)); s[0] = '!'; s[1] = 0xF9; s[2] = 4; s[3] = 0; s[4] = optDelay & 0xFF; s[5] = optDelay / 0x100; s[6] = s[7] = 0; s[8] = ','; s[9] = s[10] = s[11] = s[12] = 0; s[13] = imgw & 0xFF; s[14] = imgw / 0x100; s[15] = imgh & 0xFF; s[16] = imgh / 0x100; s[17] = 0x80 + max_bits(optCol) - 1; fwrite(s, 1, 18, pGif); __android_log_write(ANDROID_LOG_VERBOSE, "gifflen","Quantising"); neuQuant->quantise(outDIB, &inDIB, optCol, optQuality, 0); fwrite(outDIB->palette, 1, optCol * 3, pGif); __android_log_write(ANDROID_LOG_VERBOSE, "gifflen","Doing GIF encoding"); GIF_LZW_compressor(outDIB, optCol, pGif, 0); return 0; }
void __android_log_assert(const char *cond, const char *tag, const char *fmt, ...) { va_list ap; char buf[LOG_BUF_SIZE]; va_start(ap, fmt); vsnprintf(buf, LOG_BUF_SIZE, fmt, ap); va_end(ap); __android_log_write(ANDROID_LOG_FATAL, tag, buf); __builtin_trap(); /* trap so we have a chance to debug the situation */ }
string JniHelpers::jniCommonStringCall(const char* methodName, const char* classPath, const char* arg0) throw (cocos2dx_VirtualItemNotFoundException&) { cocos2d::JniMethodInfo minfo; bool isHave = cocos2d::JniHelper::getStaticMethodInfo(minfo,classPath,methodName, "(Ljava/lang/String;)Ljava/lang/String;"); if (!isHave) { //do nothing } else { jstring stringArg0 = minfo.env->NewStringUTF(arg0); jstring retString = (jstring) minfo.env->CallStaticObjectMethod(minfo.classID, minfo.methodID, stringArg0); minfo.env->DeleteLocalRef(stringArg0); const char *nativeString = minfo.env->GetStringUTFChars(retString, 0); string ret(nativeString); minfo.env->ReleaseStringUTFChars(retString, nativeString); if(minfo.env->ExceptionCheck() == JNI_TRUE ) { __android_log_write(ANDROID_LOG_DEBUG, "SOOMLA JNI", "HAS EXCEPTION"); jthrowable exceptionObj = minfo.env->ExceptionOccurred(); minfo.env->ExceptionClear(); jclass vinfEx = cocos2d::JniHelper::getClassID("com/soomla/store/exceptions/VirtualItemNotFoundException", minfo.env); if (minfo.env->IsInstanceOf(exceptionObj, vinfEx)) { __android_log_write(ANDROID_LOG_DEBUG, "SOOMLA JNI", "Cought VirtualItemNotFoundException!"); throw cocos2dx_VirtualItemNotFoundException(); } } return ret; } return NULL; }
void Java_org_fmod_realtimestitching_Example_cUpdate(JNIEnv *env, jobject thiz) { FMOD_RESULT result = FMOD_OK; /* Replace the subsound that just finished with a new subsound, to create endless seamless stitching! Note that this polls the currently playing subsound using the FMOD_TIMEUNIT_BUFFERED flag. Remember streams are decoded / buffered ahead in advance! Don't use the 'audible time' which is FMOD_TIMEUNIT_SENTENCE_SUBSOUND by itself. When streaming, sound is processed ahead of time, and things like stream buffer / sentence manipulation (as done below) is required to be in 'buffered time', or else there will be synchronization problems and you might end up releasing a sub-sound that is still playing! */ result = FMOD_Channel_GetPosition(gChannel, &gCurrentSubSoundID, (FMOD_TIMEUNIT)(FMOD_TIMEUNIT_SENTENCE_SUBSOUND | FMOD_TIMEUNIT_BUFFERED)); CHECK_RESULT(result); if (gCurrentSubSoundID != gSubSoundID) { /* Release the sound that isn't playing any more. */ result = FMOD_Sound_Release(gSubSound[gSubSoundID]); CHECK_RESULT(result); /* Replace it with a new sound in our list. */ result = FMOD_System_CreateStream(gSystem, gSoundName[gSentenceID], FMOD_DEFAULT, 0, &gSubSound[gSubSoundID]); CHECK_RESULT(result); result = FMOD_Sound_SetSubSound(gSound, gSubSoundID, gSubSound[gSubSoundID]); CHECK_RESULT(result); sprintf(s, "Replacing subsound %d / 2 with sound %d / %d\n", gSubSoundID, gSentenceID, NUMSOUNDS); __android_log_write(ANDROID_LOG_INFO, "fmod_realtimestitching", s); gSentenceID++; if (gSentenceID >= NUMSOUNDS) { gSentenceID = 0; } gSubSoundID = gCurrentSubSoundID; } result = FMOD_System_Update(gSystem); CHECK_RESULT(result); }
/* * Class: com_jni_udt_JniUDT * Method: accept * Signature: (I)Lcom/jni/udt/AcceptResult; */ JNIEXPORT jobject JNICALL Java_com_jni_udt_JniUDT_accept (JNIEnv *env, jobject thiz, jint handle) { sockaddr_storage clientaddr; int addrlen = sizeof(clientaddr); int socket = UDT::accept(handle, (sockaddr*)&clientaddr, &addrlen); char clienthost[NI_MAXHOST]; char clientservice[NI_MAXSERV]; getnameinfo((sockaddr *)&clientaddr, addrlen, clienthost, sizeof(clienthost), clientservice, sizeof(clientservice), NI_NUMERICHOST|NI_NUMERICSERV); jstring addr = env->NewStringUTF(clienthost); jstring port = env->NewStringUTF(clientservice); //----Generate AcceptResult jclass jcAR = env->FindClass("com/jni/udt/AcceptResult"); jmethodID constrocMID = env->GetMethodID(jcAR, "<init>", "(ILjava/lang/String;Ljava/lang/String;)V"); jobject m_obj = env->NewObject(jcAR, constrocMID, socket, addr, port); __android_log_write(ANDROID_LOG_ERROR, TAG, clienthost); __android_log_write(ANDROID_LOG_ERROR, TAG, clientservice); return m_obj; }
static void invalidate(SpiceChannel *channel, gint x, gint y, gint w, gint h, gpointer data) { SpiceDisplay *display = data; if (!do_color_convert(display, x, y, w, h)) return; SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display); if (x + w > d->width || y + h > d->height) { __android_log_write(6, "android-spice", "Not drawing."); } else { uiCallbackInvalidate (d, x, y, w, h); } }
SYSCALL(void, maLoadProgram(MAHandle data, int reload)) { SYSLOG("maLoadProgram"); __android_log_write(ANDROID_LOG_INFO, "MoSync Syscall", "@@@@ MA LOAD PROGRAM"); mReloadHandle = data; if(0 == reload) mIsReloading = false; else mIsReloading = true; gSyscall->resetSyscallState(); }
/* * Class: com_jni_udt_JniUDT * Method: send * Signature: (I[BIII)I */ JNIEXPORT jint JNICALL Java_com_jni_udt_JniUDT_send(JNIEnv *env, jobject thiz, jint handle, jbyteArray buffer, jint offset, jint max_send, jint flag) { jbyte *local_buffer = new jbyte[max_send]; env->GetByteArrayRegion(buffer, offset, max_send, local_buffer); int sent_size = UDT::send(handle, (const char*) local_buffer, max_send, flag); if (sent_size == UDT::ERROR) { __android_log_write(ANDROID_LOG_ERROR, TAG, UDT::getlasterror().getErrorMessage()); } delete local_buffer; return sent_size; }
static void primary_create(SpiceChannel *channel, gint format, gint width, gint height, gint stride, gint shmid, gpointer imgdata, gpointer data) { __android_log_write(6, "android-spice", "primary_create"); SpiceDisplay *display = data; SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display); d->format = format; d->stride = stride; d->shmid = shmid; d->width = width; d->height = height; d->data_origin = d->data = imgdata; uiCallbackSettingsChanged (0, width, height, 4); }
jint Java_jp_ks_livewallpaper_opengl_snowfull_LiveWallpaperRenderer_NDKonSurfaceCreated( JNIEnv *env, jobject obj ) { __android_log_write(ANDROID_LOG_DEBUG, NDK_INTERFACE_TAG_RENDERER,"NDKonSurfaceCreated"); glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); glEnable( GL_DEPTH_TEST ); // glShadeModel( GL_FLAT ); glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_COLOR_ARRAY ); // glEnableClientState( GL_TEXTURE_COORD_ARRAY); glShadeModel(GL_SMOOTH); return 0; }
JNIEXPORT void JNICALL Java_com_omochimetaru_ironcaketest_MainActivity_doTest (JNIEnv * env, jobject thiz){ int argc = 0; char * argv[0] = {}; testing::InitGoogleTest(&argc, argv); testing::internal::CaptureStdout(); (void)testing::UnitTest::GetInstance()->Run(); __android_log_write(ANDROID_LOG_INFO, "IronCake", testing::internal::GetCapturedStdout().c_str()); }
static char *camera_get_parameters(struct camera_device *device) { ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); if (!device) return NULL; char *params = VENDOR_CALL(device, get_parameters); #ifdef LOG_NDEBUG __android_log_write(ANDROID_LOG_VERBOSE, LOG_TAG, params); #endif char *tmp = camera_fixup_getparams(CAMERA_ID(device), params); VENDOR_CALL(device, put_parameters, params); params = tmp; #ifdef LOG_NDEBUG __android_log_write(ANDROID_LOG_VERBOSE, LOG_TAG, params); #endif return params; }
void Log::v(const char *tag, const char *fmt, ...) { char tag_buffer[LOG_BUF_SIZE]; sprintf(tag_buffer, "%s%s", LOG_TAG_PREFIX, tag); va_list ap; char buf[LOG_BUF_SIZE]; va_start(ap, fmt); vsnprintf(buf, LOG_BUF_SIZE, fmt, ap); va_end(ap); __android_log_write(ANDROID_LOG_VERBOSE, tag_buffer, buf); }