📄 org_tritonus_lowlevel_alsa_alsaseq.c
字号:
/* * org_tritonus_lowlevel_alsa_AlsaSeq.c *//* * Copyright (c) 1999 - 2001 by Matthias Pfisterer <Matthias.Pfisterer@gmx.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */#include "common.h"#include "org_tritonus_lowlevel_alsa_AlsaSeq.h"#include "constants_check.h"HandleFieldHandler(snd_seq_t*)snd_seq_client_info_t*getClientInfoNativeHandle(JNIEnv* env, jobject obj);snd_seq_event_t*getEventNativeHandle(JNIEnv* env, jobject obj);snd_seq_port_info_t*getPortInfoNativeHandle(JNIEnv* env, jobject obj);snd_seq_port_subscribe_t*getPortSubscribeNativeHandle(JNIEnv* env, jobject obj);snd_seq_queue_info_t*getQueueInfoNativeHandle(JNIEnv* env, jobject obj);snd_seq_queue_status_t*getQueueStatusNativeHandle(JNIEnv* env, jobject obj);snd_seq_queue_tempo_t*getQueueTempoNativeHandle(JNIEnv* env, jobject obj);snd_seq_queue_timer_t*getQueueTimerNativeHandle(JNIEnv* env, jobject obj);snd_seq_remove_events_t*getRemoveEventsNativeHandle(JNIEnv* env, jobject obj);snd_seq_system_info_t*getSystemInfoNativeHandle(JNIEnv *env, jobject obj);/* * Class: org_tritonus_lowlevel_alsa_AlsaSeq * Method: open * Signature: ()I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_open(JNIEnv* env, jobject obj){ snd_seq_t* seq; int nReturn; if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_open(): begin\n"); } check_constants(); nReturn = snd_seq_open(&seq, "hw", SND_SEQ_OPEN_DUPLEX, 0); if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_open(): snd_seq_open() returns: %d\n", nReturn); } if (nReturn < 0) { throwRuntimeException(env, "snd_seq_open() failed"); } setHandle(env, obj, seq); if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_open(): end\n"); } return (jint) nReturn;}/* * Class: org_tritonus_lowlevel_alsa_AlsaSeq * Method: close * Signature: ()V */JNIEXPORT void JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_close(JNIEnv* env, jobject obj){ snd_seq_t* seq; int nReturn; if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_close(): begin\n"); } seq = getHandle(env, obj); if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_close(): now closing ALSA seq (client %d)\n", snd_seq_client_id(seq)); } nReturn = snd_seq_close(seq); if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_close(): closed\n"); } if (nReturn < 0) { throwRuntimeException(env, "snd_seq_close() failed"); } if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_close(): end\n"); }}/* * Class: org_tritonus_lowlevel_alsa_AlsaSeq * Method: getName * Signature: ()Ljava/lang/String; */JNIEXPORT jstring JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_getName(JNIEnv* env, jobject obj){ snd_seq_t* seq; const char* pName; jstring strName; if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getName(): begin\n"); } seq = getHandle(env, obj); pName = snd_seq_name(seq); if (pName == NULL) { throwRuntimeException(env, "snd_seq_name() failed"); } strName = (*env)->NewStringUTF(env, pName); // TODO: check return value if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getName(): end\n"); } return strName;}/* * Class: org_tritonus_lowlevel_alsa_AlsaSeq * Method: getType * Signature: ()I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_getType(JNIEnv* env, jobject obj){ snd_seq_t* seq; int nReturn; if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getType(): begin\n"); } seq = getHandle(env, obj); nReturn = snd_seq_type(seq); if (nReturn < 0) { throwRuntimeException(env, "snd_seq_type() failed"); } if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getType(): end\n"); } return nReturn;}/* * Class: org_tritonus_lowlevel_alsa_AlsaSeq * Method: setNonblock * Signature: (Z)I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_setNonblock(JNIEnv* env, jobject obj, jboolean bNonblock){ snd_seq_t* seq; int nReturn; if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_setNonblock(): begin\n"); } seq = getHandle(env, obj); nReturn = snd_seq_nonblock(seq, bNonblock); if (nReturn < 0) { throwRuntimeException(env, "snd_seq_nonblock() failed"); } if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_setNonblock(): end\n"); } return nReturn;}/* * Class: org_tritonus_lowlevel_alsa_AlsaSeq * Method: getClientId * Signature: ()I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_getClientId(JNIEnv* env, jobject obj){ snd_seq_t* seq; int nReturn; if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getClientId(): begin\n"); } seq = getHandle(env, obj); nReturn = snd_seq_client_id(seq); if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getClientId(): end\n"); } return nReturn;}/* * Class: org_tritonus_lowlevel_alsa_AlsaSeq * Method: getOutputBufferSize * Signature: ()I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_getOutputBufferSize(JNIEnv* env, jobject obj){ snd_seq_t* seq; int nReturn; if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getOutputBufferSize(): begin\n"); } seq = getHandle(env, obj); nReturn = snd_seq_get_output_buffer_size(seq); if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getOutputBufferSize(): end\n"); } return nReturn;}/* * Class: org_tritonus_lowlevel_alsa_AlsaSeq * Method: getInputBufferSize * Signature: ()I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_getInputBufferSize(JNIEnv* env, jobject obj){ snd_seq_t* seq; int nReturn; if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getInputBufferSize(): begin\n"); } seq = getHandle(env, obj); nReturn = snd_seq_get_input_buffer_size(seq); if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getInputBufferSize(): end\n"); } return nReturn;}/* * Class: org_tritonus_lowlevel_alsa_AlsaSeq * Method: setOutputBufferSize * Signature: (I)I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_setOutputBufferSize(JNIEnv* env, jobject obj, jint nBufferSize){ snd_seq_t* seq; int nReturn; if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_setOutputBufferSize(): begin\n"); } seq = getHandle(env, obj); nReturn = snd_seq_set_output_buffer_size(seq, nBufferSize); if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_setOutputBufferSize(): end\n"); } return nReturn;}/* * Class: org_tritonus_lowlevel_alsa_AlsaSeq * Method: setInputBufferSize * Signature: (I)I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_setInputBufferSize(JNIEnv* env, jobject obj, jint nBufferSize){ snd_seq_t* seq; int nReturn; if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_setInputBufferSize(): begin\n"); } seq = getHandle(env, obj); nReturn = snd_seq_set_input_buffer_size(seq, nBufferSize); if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_setInputBufferSize(): end\n"); } return nReturn;}/* * Class: org_tritonus_lowlevel_alsa_AlsaSeq * Method: getSystemInfo * Signature: (Lorg/tritonus/lowlevel/alsa/AlsaSeq$SystemInfo;)I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_getSystemInfo(JNIEnv* env, jobject obj, jobject systemInfoObj){ snd_seq_t* seq; snd_seq_system_info_t* systemInfo; int nReturn; if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getSystemInfo(): begin\n"); } seq = getHandle(env, obj); systemInfo = getSystemInfoNativeHandle(env, systemInfoObj); nReturn = snd_seq_system_info(seq, systemInfo); if (nReturn < 0) { throwRuntimeException(env, "snd_seq_system_info() failed"); } if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getSystemInfo(): end\n"); } return (jint) nReturn;}/* * Class: org_tritonus_lowlevel_alsa_AlsaSeq * Method: getClientInfo * Signature: (ILorg/tritonus/lowlevel/alsa/AlsaSeq$ClientInfo;)I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_getClientInfo(JNIEnv* env, jobject obj, jint nClient, jobject clientInfoObj){ snd_seq_t* seq; snd_seq_client_info_t* clientInfo; int nReturn; if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getClientInfo(): begin\n"); } seq = getHandle(env, obj); clientInfo = getClientInfoNativeHandle(env, clientInfoObj); if (nClient >= 0) { nReturn = snd_seq_get_any_client_info(seq, nClient, clientInfo); } else { nReturn = snd_seq_get_client_info(seq, clientInfo); } if (nReturn < 0) { throwRuntimeException(env, "snd_seq_get_client_info() failed"); } if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getClientInfo(): end\n"); } return (jint) nReturn;}/* * Class: org_tritonus_lowlevel_alsa_AlsaSeq * Method: setClientInfo * Signature: (Lorg/tritonus/lowlevel/alsa/AlsaSeq$ClientInfo;)I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_setClientInfo(JNIEnv* env, jobject obj, jobject clientInfoObj){ snd_seq_t* seq; snd_seq_client_info_t* clientInfo; int nReturn; if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_setClientInfo(): begin\n"); } seq = getHandle(env, obj); clientInfo = getClientInfoNativeHandle(env, clientInfoObj); nReturn = snd_seq_set_client_info(seq, clientInfo); if (nReturn < 0) { throwRuntimeException(env, "snd_seq_set_client_info() failed"); } if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_setClientInfo(): end\n"); } return (jint) nReturn;}/* * Class: org_tritonus_lowlevel_alsa_AlsaSeq * Method: getNextClient * Signature: (I[I)I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_getNextClient(JNIEnv* env, jobject obj, jint nClient, jintArray anValues){ snd_seq_t* seq; snd_seq_client_info_t* clientInfo; int nReturn; if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getNextClient(): begin\n"); } if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getNextClient(): passed client: %d\n", (int) nClient); } seq = getHandle(env, obj); snd_seq_client_info_alloca(&clientInfo); snd_seq_client_info_set_client(clientInfo, nClient); nReturn = snd_seq_query_next_client(seq, clientInfo); if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getNextClient(): return value from snd_seq_query_next_client(): %d\n", nReturn); } if (nReturn < 0) { // -2 (no such file or directory): returned when no more client is available if (nReturn != -2) { throwRuntimeException(env, "snd_seq_query_next_client() failed"); } } else { jint nThisClient; checkArrayLength(env, anValues, 1); nThisClient = snd_seq_client_info_get_client(clientInfo); (*env)->SetIntArrayRegion(env, anValues, 0, 1, &nThisClient); } if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getNextClient(): end\n"); } return (jint) nReturn;}/* * Class: org_tritonus_lowlevel_alsa_AlsaSeq * Method: getPortInfo * Signature: (IILorg/tritonus/lowlevel/alsa/AlsaSeq$PortInfo;)I */JNIEXPORT jint JNICALLJava_org_tritonus_lowlevel_alsa_AlsaSeq_getPortInfo(JNIEnv* env, jobject obj, jint nClient, jint nPort, jobject portInfoObj){ snd_seq_t* seq; snd_seq_port_info_t* portInfo; int nReturn; if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaSeq_getPortInfo(): begin\n"); } seq = getHandle(env, obj); portInfo = getPortInfoNativeHandle(env, portInfoObj); if (nClient >= 0) { nReturn = snd_seq_get_any_port_info(seq, nClient, nPort, portInfo); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -