⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 org_tritonus_lowlevel_alsa_alsaseq.c

📁 linux下建立JAVA虚拟机的源码KAFFE
💻 C
📖 第 1 页 / 共 3 页
字号:
Java_org_tritonus_lowlevel_alsa_AlsaSeq_subscribePort(JNIEnv* env, jobject obj, jobject portSubscribeObj){	snd_seq_t*			seq;	snd_seq_port_subscribe_t*	pPortSubscribe;	int				nReturn;	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_subscribePort(): begin\n"); }	seq = getHandle(env, obj);	pPortSubscribe = getPortSubscribeNativeHandle(env, portSubscribeObj);	nReturn = snd_seq_subscribe_port(seq, pPortSubscribe);	if (nReturn < 0)	{		throwRuntimeException(env, "snd_seq_subscribe_port() failed");	}	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_subscribePort(): end\n"); }	return (jint) nReturn;}/* * Class:     org_tritonus_lowlevel_alsa_AlsaSeq * Method:    unsubscribePort * Signature: (Lorg/tritonus/lowlevel/alsa/AlsaSeq$PortSubscribe;)I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_unsubscribePort(JNIEnv* env, jobject obj, jobject portSubscribeObj){	snd_seq_t*			seq;	snd_seq_port_subscribe_t*	pPortSubscribe;	int				nReturn;	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_unsubscribePort(): begin\n"); }	seq = getHandle(env, obj);	pPortSubscribe = getPortSubscribeNativeHandle(env, portSubscribeObj);	nReturn = snd_seq_unsubscribe_port(seq, pPortSubscribe);	if (nReturn < 0)	{		throwRuntimeException(env, "snd_seq_unsubscribe_port() failed");	}	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_unsubscribePort(): end\n"); }	return (jint) nReturn;}/* * Class:     org_tritonus_lowlevel_alsa_AlsaSeq * Method:    setTrace * Signature: (Z)V */JNIEXPORT void JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_setTrace(JNIEnv* env UNUSED, jclass cls UNUSED, jboolean bTrace){	debug_flag = bTrace;	debug_file = stderr;}/* * Class:     org_tritonus_lowlevel_alsa_AlsaSeq * Method:    eventOutput * Signature: (Lorg/tritonus/lowlevel/alsa/AlsaSeq$Event;)I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_eventOutput(JNIEnv* env, jobject obj, jobject eventObj){	snd_seq_t*		seq;	snd_seq_event_t*	event;	int			nReturn;	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_eventOutput(): begin\n"); }	seq = getHandle(env, obj);	event = getEventNativeHandle(env, eventObj);	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_eventOutput(): length of event: %d\n", snd_seq_event_length(event)); }	nReturn = snd_seq_event_output(seq, event);	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_eventOutput(): snd_seq_event_output() returns %d\n", nReturn); }	if (nReturn < 0)	{		throwRuntimeException(env, "snd_seq_event_output() failed");	}	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_eventOutput(): end\n"); }	return (jint) nReturn;}/* * Class:     org_tritonus_lowlevel_alsa_AlsaSeq * Method:    eventOutputBuffer * Signature: (Lorg/tritonus/lowlevel/alsa/AlsaSeq$Event;)I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_eventOutputBuffer(JNIEnv* env, jobject obj, jobject eventObj){	snd_seq_t*		seq;	snd_seq_event_t*	event;	int			nReturn;	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_eventOutputBuffer(): begin\n"); }	seq = getHandle(env, obj);	event = getEventNativeHandle(env, eventObj);	nReturn = snd_seq_event_output_buffer(seq, event);	if (nReturn < 0)	{		throwRuntimeException(env, "snd_seq_event_output_buffer() failed");	}	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_eventOutputBuffer(): end\n"); }	return (jint) nReturn;}/* * Class:     org_tritonus_lowlevel_alsa_AlsaSeq * Method:    eventOutputDirect * Signature: (Lorg/tritonus/lowlevel/alsa/AlsaSeq$Event;)I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_eventOutputDirect(JNIEnv* env, jobject obj, jobject eventObj){	snd_seq_t*		seq;	snd_seq_event_t*	event;	int			nReturn;	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_eventOutputDirect(): begin\n"); }	seq = getHandle(env, obj);	event = getEventNativeHandle(env, eventObj);	nReturn = snd_seq_event_output_direct(seq, event);	if (nReturn < 0)	{		throwRuntimeException(env, "snd_seq_event_output_direct() failed");	}	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_eventOutputDirect(): end\n"); }	return (jint) nReturn;}/* * Class:     org_tritonus_lowlevel_alsa_AlsaSeq * Method:    eventInput * Signature: (Lorg/tritonus/lowlevel/alsa/AlsaSeq$Event;)I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_eventInput(JNIEnv* env, jobject obj, jobject eventObj){	snd_seq_t*		seq;	snd_seq_event_t*	event;	snd_seq_event_t*	handle;	int			nReturn;	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_eventInput(): begin\n"); }	seq = getHandle(env, obj);	/*	 *	snd_seq_event_input() results in a blocking read on a	 *	device file. There are two problems:	 *	1. green threads VMs do no blocking read. Therefore, this	 *	code doesn't work with green threads at all. A solution is	 *	outstanding.	 *	2. In some cases, the read is interrupted by a signal. This	 *	is the reason for the do..while.	 */	do	{		// printf("1\n");		//errno = 0;		event = NULL;		nReturn = snd_seq_event_input(seq, &event);		//printf("return: %d\n", nReturn);		// printf("event: %p\n", pEvent);		// printf("errno: %d\n", errno);		//perror("abc");		// printf("2\n");	}	// TODO: should catch -EAGAIN, too?	while (nReturn == -EINTR);// 	if (nReturn < 0)// 	{// 		throwRuntimeException(env, "snd_seq_event_input() failed");// 	}	if (event != NULL)	{		/*		  - get snd_seq_event_t handle of Event instance		  - if varlength, free associated mem		  - copy event to handle's memory		  - if varlength, allocate new memory for var part		  - copy data to new memory		  - set new var pointer		  TODO: make thread-safe (should acquire a lock)		  or: document behaviour		 */		handle = getEventNativeHandle(env, eventObj);		if (snd_seq_ev_is_variable(handle))		{			free(handle->data.ext.ptr);		}		*handle = *event;		if (snd_seq_ev_is_variable(handle))		{			char*	ptr = (char*) malloc(handle->data.ext.len);			memcpy(ptr, handle->data.ext.ptr, handle->data.ext.len);			handle->data.ext.ptr = ptr;		}	}	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_eventInput(): end\n"); }	return (jint) nReturn;}/* * Class:     org_tritonus_lowlevel_alsa_AlsaSeq * Method:    eventInputPending * Signature: (I)I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_eventInputPending(JNIEnv* env, jobject obj, jint nFetchSequencer){	snd_seq_t*		seq;	int			nReturn;	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_eventInputPending(): begin\n"); }	seq = getHandle(env, obj);	nReturn = snd_seq_event_input_pending(seq, nFetchSequencer);	if (nReturn < 0)	{		throwRuntimeException(env, "snd_seq_event_input_pending() failed");	}	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_eventInputPending(): end\n"); }	return (jint) nReturn;}/* * Class:     org_tritonus_lowlevel_alsa_AlsaSeq * Method:    drainOutput * Signature: ()I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_drainOutput(JNIEnv* env, jobject obj){	snd_seq_t*		seq;	int			nReturn;	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_drainOutput(): begin\n"); }	seq = getHandle(env, obj);	nReturn = snd_seq_drain_output(seq);	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_drainOutput(): snd_seq_drain_output() returned %d\n", nReturn); }	if (nReturn < 0)	{		throwRuntimeException(env, "snd_seq_drain_output() failed");	}	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_drainOutput(): end\n"); }	return (jint) nReturn;}/* * Class:     org_tritonus_lowlevel_alsa_AlsaSeq * Method:    eventOutputPending * Signature: ()I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_eventOutputPending(JNIEnv* env, jobject obj){	snd_seq_t*		seq;	int			nReturn;	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_eventOutputPending(): begin\n"); }	seq = getHandle(env, obj);	nReturn = snd_seq_event_output_pending(seq);	if (nReturn < 0)	{		throwRuntimeException(env, "snd_seq_event_output_direct() failed");	}	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_eventOutputPending(): end\n"); }	return (jint) nReturn;}/* * Class:     org_tritonus_lowlevel_alsa_AlsaSeq * Method:    extractOutput * Signature: (Lorg/tritonus/lowlevel/alsa/AlsaSeq$Event;)I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_extractOutput(JNIEnv* env, jobject obj, jobject eventObj){	snd_seq_t*		seq;	snd_seq_event_t*	event;	snd_seq_event_t*	handle;	int			nReturn;	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_extractOutput(): begin\n"); }	seq = getHandle(env, obj);	nReturn = snd_seq_extract_output(seq, &event);	if (nReturn < 0)	{		throwRuntimeException(env, "snd_seq_extrct_output() failed");	}	handle = getEventNativeHandle(env, eventObj);	if (snd_seq_ev_is_variable(handle))	{		free(handle->data.ext.ptr);	}	*handle = *event;	if (snd_seq_ev_is_variable(handle))	{		char*	ptr = (char*) malloc(handle->data.ext.len);		memcpy(ptr, handle->data.ext.ptr, handle->data.ext.len);		handle->data.ext.ptr = ptr;	}	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_extractOutput(): end\n"); }	return (jint) nReturn;}/* * Class:     org_tritonus_lowlevel_alsa_AlsaSeq * Method:    dropOutput * Signature: ()I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_dropOutput(JNIEnv* env, jobject obj){	snd_seq_t*		seq;	int			nReturn;	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_dropOutput(): begin\n"); }	seq = getHandle(env, obj);	nReturn = snd_seq_drop_output(seq);	if (nReturn < 0)	{		throwRuntimeException(env, "snd_seq_drop_output() failed");	}	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_dropOutput(): end\n"); }	return (jint) nReturn;}/* * Class:     org_tritonus_lowlevel_alsa_AlsaSeq * Method:    dropOutputBuffer * Signature: ()I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_dropOutputBuffer(JNIEnv* env, jobject obj){	snd_seq_t*		seq;	int			nReturn;	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_dropOutputBuffer(): begin\n"); }	seq = getHandle(env, obj);	nReturn = snd_seq_drop_output_buffer(seq);	if (nReturn < 0)	{		throwRuntimeException(env, "snd_seq_drop_output_buffer() failed");	}	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_dropOutputBuffer(): end\n"); }	return (jint) nReturn;}/* * Class:     org_tritonus_lowlevel_alsa_AlsaSeq * Method:    dropInput * Signature: ()I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_dropInput(JNIEnv* env, jobject obj){	snd_seq_t*		seq;	int			nReturn;	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_dropInput(): begin\n"); }	seq = getHandle(env, obj);	nReturn = snd_seq_drop_input(seq);	if (nReturn < 0)	{		throwRuntimeException(env, "snd_seq_drop_input() failed");	}	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_dropInput(): end\n"); }	return (jint) nReturn;}/* * Class:     org_tritonus_lowlevel_alsa_AlsaSeq * Method:    dropInputBuffer * Signature: ()I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_dropInputBuffer(JNIEnv* env, jobject obj){	snd_seq_t*		seq;	int			nReturn;	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_dropInputBuffer(): begin\n"); }	seq = getHandle(env, obj);	nReturn = snd_seq_drop_input_buffer(seq);	if (nReturn < 0)	{		throwRuntimeException(env, "snd_seq_drop_input_buffer() failed");	}	if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_dropInputBuffer(): end\n"); }	return (jint) nReturn;}/*** org_tritonus_lowlevel_alsa_AlsaSeq.c ***/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -