1/* 2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26#include <alsa/asoundlib.h> 27#include "Utilities.h" 28#include "PlatformMidi.h" 29 30 31#ifndef PLATFORM_API_BSDOS_ALSA_MIDIUTILS_H_INCLUDED 32#define PLATFORM_API_BSDOS_ALSA_MIDIUTILS_H_INCLUDED 33 34#define EVENT_PARSER_BUFSIZE (2048) 35 36// if this is defined, use plughw: devices 37//#define ALSA_MIDI_USE_PLUGHW 38#undef ALSA_MIDI_USE_PLUGHW 39 40typedef struct tag_ALSA_MIDIDeviceDescription { 41 int index; // in 42 int strLen; // in 43 INT32 deviceID; // out 44 char* name; // out 45 char* description; // out 46} ALSA_MIDIDeviceDescription; 47 48 49const char* getErrorStr(INT32 err); 50 51/* Returns the number of devices. */ 52/* direction is either SND_RAWMIDI_STREAM_OUTPUT or 53 SND_RAWMIDI_STREAM_INPUT. */ 54int getMidiDeviceCount(snd_rawmidi_stream_t direction); 55 56/* Returns MIDI_SUCCESS or MIDI_INVALID_DEVICEID */ 57/* direction is either SND_RAWMIDI_STREAM_OUTPUT or 58 SND_RAWMIDI_STREAM_INPUT. */ 59int getMidiDeviceName(snd_rawmidi_stream_t direction, int index, 60 char *name, UINT32 nameLength); 61 62/* Returns MIDI_SUCCESS or MIDI_INVALID_DEVICEID */ 63int getMidiDeviceVendor(int index, char *name, UINT32 nameLength); 64 65/* Returns MIDI_SUCCESS or MIDI_INVALID_DEVICEID */ 66/* direction is either SND_RAWMIDI_STREAM_OUTPUT or 67 SND_RAWMIDI_STREAM_INPUT. */ 68int getMidiDeviceDescription(snd_rawmidi_stream_t direction, int index, 69 char *name, UINT32 nameLength); 70 71/* Returns MIDI_SUCCESS or MIDI_INVALID_DEVICEID */ 72int getMidiDeviceVersion(int index, char *name, UINT32 nameLength); 73 74// returns 0 on success, otherwise MIDI_OUT_OF_MEMORY or ALSA error code 75/* direction is either SND_RAWMIDI_STREAM_OUTPUT or 76 SND_RAWMIDI_STREAM_INPUT. */ 77INT32 openMidiDevice(snd_rawmidi_stream_t direction, INT32 deviceIndex, 78 MidiDeviceHandle** handle); 79 80// returns 0 on success, otherwise a (negative) ALSA error code 81INT32 closeMidiDevice(MidiDeviceHandle* handle); 82 83INT64 getMidiTimestamp(MidiDeviceHandle* handle); 84 85#endif // PLATFORM_API_BSDOS_ALSA_MIDIUTILS_H_INCLUDED 86