예제 #1
0
// midi write
jboolean
Java_org_billthefarmer_accordion_MidiDriver_write(JNIEnv *env,
						  jobject obj,
						  jbyteArray byteArray)
{
    jboolean isCopy;
    EAS_RESULT result;
    jint length;
    EAS_U8 *buf;

    if (pEASData == NULL || midiHandle == NULL)
	return JNI_FALSE;

    buf = (EAS_U8 *)env->GetByteArrayElements(byteArray, &isCopy);
    length = env->GetArrayLength(byteArray);

    // lock
    pthread_mutex_lock(&mutex);

    result = EAS_WriteMIDIStream(pEASData, midiHandle, buf, length);

    // unlock
    pthread_mutex_unlock(&mutex);      

    env->ReleaseByteArrayElements(byteArray, (jbyte *)buf, 0);

    if (result != EAS_SUCCESS)
	return JNI_FALSE;

    return JNI_TRUE;
}
예제 #2
0
// write midi stream
MIDI_RESULT MIDI_WriteStream(MIDI_HANDLE handle, char *data, long size)
{
    EAS_RESULT result;

    // lock
    pthread_mutex_lock(&mutex);

    // write midi stream
    if ((result = EAS_WriteMIDIStream(pEASData, handle, data,
				      size)) != EAS_SUCCESS)
    {
        // unlock
        pthread_mutex_unlock(&mutex);      
	return result;
    }

    // unlock
    pthread_mutex_unlock(&mutex);

    return MIDI_SUCCESS;
}