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