blob: ed5dfc5f6cfb78bb6d823ec0d11be3edd0e6516e [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2003-2007 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26#include <alsa/asoundlib.h>
27#include "Utilities.h"
28
29#ifndef PLATFORM_API_LINUXOS_ALSA_COMMONUTILS_H_INCLUDED
30#define PLATFORM_API_LINUXOS_ALSA_COMMONUTILS_H_INCLUDED
31
32#define ALSA_VERSION_PROC_FILE "/proc/asound/version"
33#define ALSA_HARDWARE "hw"
34#define ALSA_HARDWARE_CARD ALSA_HARDWARE":%d"
35#define ALSA_HARDWARE_DEVICE ALSA_HARDWARE_CARD",%d"
36#define ALSA_HARDWARE_SUBDEVICE ALSA_HARDWARE_DEVICE",%d"
37
38#define ALSA_PLUGHARDWARE "plughw"
39#define ALSA_DEFAULT_DEVICE_NAME "default"
40
41#define ALSA_DEFAULT_DEVICE_ID (0)
42
43#define ALSA_PCM (0)
44#define ALSA_RAWMIDI (1)
45
46// for use in info objects
47#define ALSA_VENDOR "ALSA (http://www.alsa-project.org)"
48
49// Environment variable for inclusion of subdevices in device listing.
50// If this variable is unset or "no", then subdevices are ignored, and
51// it's ALSA's choice which one to use (enables hardware mixing)
52#define ENV_ENUMERATE_PCM_SUBDEVICES "ALSA_ENUMERATE_PCM_SUBDEVICES"
53
54// if defined, subdevices are listed.
55//#undef ALSA_MIDI_ENUMERATE_SUBDEVICES
56#define ALSA_MIDI_ENUMERATE_SUBDEVICES
57
58// must be called before any ALSA calls
59void initAlsaSupport();
60
61/* if true (non-zero), ALSA sub devices should be listed as separate devices
62 */
63int needEnumerateSubdevices(int isMidi);
64
65
66/*
67 * deviceID contains packed card, device and subdevice numbers
68 * each number takes 10 bits
69 * "default" device has id == ALSA_DEFAULT_DEVICE_ID
70 */
71UINT32 encodeDeviceID(int card, int device, int subdevice);
72
73void decodeDeviceID(UINT32 deviceID, int* card, int* device, int* subdevice,
74 int isMidi);
75
76void getDeviceStringFromDeviceID(char* buffer, UINT32 deviceID,
77 int usePlugHw, int isMidi);
78
79void getALSAVersion(char* buffer, int len);
80
81
82#endif // PLATFORM_API_LINUXOS_ALSA_COMMONUTILS_H_INCLUDED