2362N/A * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A/* include Java Sound specific headers as C code */ 0N/A * Callback from the MIDI device for all messages. 0N/A//$$fb dwParam1 holds a pointer for long messages. How can that be a DWORD then ??? 0N/A TRACE3(
" MIDI_IN_PutMessage: MIM_MOREDATA or MIM_DATA. status=%x data1=%x data2=%x\n",
0N/A // queue stores packedMsg in big endian 0N/A //(dwParam1 << 24) | ((dwParam1 << 8) & 0xFF0000) | ((dwParam1 >> 8) & 0xFF00), 0N/A // queue uses microseconds 0N/A // overwrite if queue is full 0N/A // sysex buffer index 0N/A // queue uses microseconds 0N/A // overwrite if queue is full 0N/A ERROR0(
"< MIDI_IN_PutMessage: MIM_ERROR!\n");
0N/A TRACE2(
" MIDI_IN_PutMessage: MIM_LONGERROR! recorded: %d bytes with status 0x%2x\n",
0N/A // re-add hdr to device query 0N/A ERROR0(
"< MIDI_IN_PutMessage: MIM_LONGERROR!\n");
0N/A ERROR1(
"< MIDI_IN_PutMessage: ERROR unknown message %d!\n",
wMsg);
0N/A** (joint into MidiIn_OpenHelper class) 0N/A** see 6415669 - MidiIn device stops work and crushes JVM after exiting 0N/A** from thread that has open the device (it looks like WinMM bug). 0N/A /* opens MidiIn device */ 0N/A /* checks for initialization success */ 0N/A // public data to access from parent class 0N/A // data to process; (handle == null) is command to thread terminating 0N/A /* StartThread function */ 0N/A/* MidiIn_OpenHelper class implementation 0N/A // - Windows will do during process shutdown 0N/A // wait for something to do 0N/A // (data.handle == NULL) is a signal to terminate thread 0N/A// PLATFORM_MIDI_IN method implementations 0N/A/* not thread safe */ 0N/A ERROR0(
"MIDI_IN_prepareBuffers: handle, or longBuffers, or deviceHandle==NULL\n");
0N/A ERROR0(
"MIDI_IN_unprepareBuffers: handle, or longBuffers, or deviceHandle==NULL\n");
0N/A ERROR0(
"< ERROR: MIDI_IN_OpenDevice: out of memory\n");
0N/A ERROR0(
"< ERROR: MIDI_IN_OpenDevice: could not create queue\n");
0N/A // create long buffer queue 0N/A ERROR0(
"< ERROR: MIDI_IN_OpenDevice: could not create long Buffers\n");
0N/A // finally open the device 0N/A TRACE0(
"< MIDI_IN_OpenDevice: midiInOpen succeeded\n");
0N/A TRACE0(
"> MIDI_IN_CloseDevice: midiInClose\n");
0N/A ERROR0(
"ERROR: MIDI_IN_CloseDevice: handle is NULL\n");
0N/A TRACE0(
"< MIDI_IN_CloseDevice: midiInClose succeeded\n");
0N/A ERROR0(
"ERROR: MIDI_IN_StartDevice: handle or queue is NULL\n");
0N/A // clear all the events from the queue 0N/A ERROR0(
"ERROR: MIDI_IN_StartDevice: could not create event\n");
0N/A /* $$mp 200308-11: This method is already called in ...open(). It is 0N/A unclear why is is called again. The specification says that 0N/A MidiDevice.getMicrosecondPosition() returns the time since the 0N/A So I guess this call is obsolete. */ 0N/A TRACE0(
"MIDI_IN_StartDevice: midiInStart finished\n");
0N/A TRACE0(
"> MIDI_IN_StopDevice: midiInStop \n");
0N/A ERROR0(
"ERROR: MIDI_IN_StopDevice: handle or event is NULL\n");
0N/A // encourage MIDI_IN_GetMessage to return soon 0N/A // wait until the Java thread has exited 0N/A TRACE0(
"< MIDI_IN_StopDevice: midiInStop finished\n");
0N/A/* return time stamp in microseconds */ 0N/A// read the next message from the queue 0N/A //fprintf(stdout, "GetMessage returns index %d\n", msg->data.l.index); fflush(stdout); 0N/A TRACE0(
"MIDI_IN_GetMessage: before waiting\n");
0N/A // break out back to Java from time to time - just to be sure 0N/A TRACE0(
"MIDI_IN_GetMessage: waiting finished with timeout\n");
0N/A TRACE0(
"MIDI_IN_GetMessage: waiting finished\n");
0N/A //fprintf(stdout, "ReleaseMessage index %d\n", msg->data.l.index); fflush(stdout); 0N/A#
endif // USE_PLATFORM_MIDI_IN