AudioSystem.java revision 8a21f5dd79e93aa4e4b08ab4f33b9255d7c06961
1/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.media;
18
19import java.util.ArrayList;
20
21/* IF YOU CHANGE ANY OF THE CONSTANTS IN THIS FILE, DO NOT FORGET
22 * TO UPDATE THE CORRESPONDING NATIVE GLUE AND AudioManager.java.
23 * THANK YOU FOR YOUR COOPERATION.
24 */
25
26/**
27 * @hide
28 */
29public class AudioSystem
30{
31    /* These values must be kept in sync with AudioSystem.h */
32    /*
33     * If these are modified, please also update Settings.System.VOLUME_SETTINGS
34     * and attrs.xml and AudioManager.java.
35     */
36    /* The audio stream for phone calls */
37    public static final int STREAM_VOICE_CALL = 0;
38    /* The audio stream for system sounds */
39    public static final int STREAM_SYSTEM = 1;
40    /* The audio stream for the phone ring and message alerts */
41    public static final int STREAM_RING = 2;
42    /* The audio stream for music playback */
43    public static final int STREAM_MUSIC = 3;
44    /* The audio stream for alarms */
45    public static final int STREAM_ALARM = 4;
46    /* The audio stream for notifications */
47    public static final int STREAM_NOTIFICATION = 5;
48    /* @hide The audio stream for phone calls when connected on bluetooth */
49    public static final int STREAM_BLUETOOTH_SCO = 6;
50    /* @hide The audio stream for enforced system sounds in certain countries (e.g camera in Japan) */
51    public static final int STREAM_SYSTEM_ENFORCED = 7;
52    /* @hide The audio stream for DTMF tones */
53    public static final int STREAM_DTMF = 8;
54    /* @hide The audio stream for text to speech (TTS) */
55    public static final int STREAM_TTS = 9;
56    /**
57     * @deprecated Use {@link #numStreamTypes() instead}
58     */
59    public static final int NUM_STREAMS = 5;
60
61    // Expose only the getter method publicly so we can change it in the future
62    private static final int NUM_STREAM_TYPES = 10;
63    public static final int getNumStreamTypes() { return NUM_STREAM_TYPES; }
64
65    /*
66     * Sets the microphone mute on or off.
67     *
68     * @param on set <var>true</var> to mute the microphone;
69     *           <var>false</var> to turn mute off
70     * @return command completion status see AUDIO_STATUS_OK, see AUDIO_STATUS_ERROR
71     */
72    public static native int muteMicrophone(boolean on);
73
74    /*
75     * Checks whether the microphone mute is on or off.
76     *
77     * @return true if microphone is muted, false if it's not
78     */
79    public static native boolean isMicrophoneMuted();
80
81    /* modes for setPhoneState, must match AudioSystem.h audio_mode */
82    public static final int MODE_INVALID            = -2;
83    public static final int MODE_CURRENT            = -1;
84    public static final int MODE_NORMAL             = 0;
85    public static final int MODE_RINGTONE           = 1;
86    public static final int MODE_IN_CALL            = 2;
87    public static final int MODE_IN_COMMUNICATION   = 3;
88    public static final int NUM_MODES               = 4;
89
90
91    /* Routing bits for the former setRouting/getRouting API */
92    /** @deprecated */
93    @Deprecated public static final int ROUTE_EARPIECE          = (1 << 0);
94    /** @deprecated */
95    @Deprecated public static final int ROUTE_SPEAKER           = (1 << 1);
96    /** @deprecated use {@link #ROUTE_BLUETOOTH_SCO} */
97    @Deprecated public static final int ROUTE_BLUETOOTH = (1 << 2);
98    /** @deprecated */
99    @Deprecated public static final int ROUTE_BLUETOOTH_SCO     = (1 << 2);
100    /** @deprecated */
101    @Deprecated public static final int ROUTE_HEADSET           = (1 << 3);
102    /** @deprecated */
103    @Deprecated public static final int ROUTE_BLUETOOTH_A2DP    = (1 << 4);
104    /** @deprecated */
105    @Deprecated public static final int ROUTE_ALL               = 0xFFFFFFFF;
106
107    // Keep in sync with system/core/include/system/audio.h
108    public static final int AUDIO_SESSION_ALLOCATE = 0;
109
110    /*
111     * Checks whether the specified stream type is active.
112     *
113     * return true if any track playing on this stream is active.
114     */
115    public static native boolean isStreamActive(int stream, int inPastMs);
116
117    /*
118     * Checks whether the specified stream type is active on a remotely connected device. The notion
119     * of what constitutes a remote device is enforced by the audio policy manager of the platform.
120     *
121     * return true if any track playing on this stream is active on a remote device.
122     */
123    public static native boolean isStreamActiveRemotely(int stream, int inPastMs);
124
125    /*
126     * Checks whether the specified audio source is active.
127     *
128     * return true if any recorder using this source is currently recording
129     */
130    public static native boolean isSourceActive(int source);
131
132    /*
133     * Returns a new unused audio session ID
134     */
135    public static native int newAudioSessionId();
136
137    /*
138     * Sets a group generic audio configuration parameters. The use of these parameters
139     * are platform dependent, see libaudio
140     *
141     * param keyValuePairs  list of parameters key value pairs in the form:
142     *    key1=value1;key2=value2;...
143     */
144    public static native int setParameters(String keyValuePairs);
145
146    /*
147     * Gets a group generic audio configuration parameters. The use of these parameters
148     * are platform dependent, see libaudio
149     *
150     * param keys  list of parameters
151     * return value: list of parameters key value pairs in the form:
152     *    key1=value1;key2=value2;...
153     */
154    public static native String getParameters(String keys);
155
156    // These match the enum AudioError in frameworks/base/core/jni/android_media_AudioSystem.cpp
157    /* Command sucessful or Media server restarted. see ErrorCallback */
158    public static final int AUDIO_STATUS_OK = 0;
159    /* Command failed or unspecified audio error.  see ErrorCallback */
160    public static final int AUDIO_STATUS_ERROR = 1;
161    /* Media server died. see ErrorCallback */
162    public static final int AUDIO_STATUS_SERVER_DIED = 100;
163
164    private static ErrorCallback mErrorCallback;
165
166    /*
167     * Handles the audio error callback.
168     */
169    public interface ErrorCallback
170    {
171        /*
172         * Callback for audio server errors.
173         * param error   error code:
174         * - AUDIO_STATUS_OK
175         * - AUDIO_STATUS_SERVER_DIED
176         * - AUDIO_STATUS_ERROR
177         */
178        void onError(int error);
179    };
180
181    /*
182     * Registers a callback to be invoked when an error occurs.
183     * @param cb the callback to run
184     */
185    public static void setErrorCallback(ErrorCallback cb)
186    {
187        synchronized (AudioSystem.class) {
188            mErrorCallback = cb;
189            if (cb != null) {
190                cb.onError(checkAudioFlinger());
191            }
192        }
193    }
194
195    private static void errorCallbackFromNative(int error)
196    {
197        ErrorCallback errorCallback = null;
198        synchronized (AudioSystem.class) {
199            if (mErrorCallback != null) {
200                errorCallback = mErrorCallback;
201            }
202        }
203        if (errorCallback != null) {
204            errorCallback.onError(error);
205        }
206    }
207
208    /*
209     * Error codes used by public APIs (AudioTrack, AudioRecord, AudioManager ...)
210     * Must be kept in sync with frameworks/base/core/jni/android_media_AudioErrors.h
211     */
212    public static final int SUCCESS            = 0;
213    public static final int ERROR              = -1;
214    public static final int BAD_VALUE          = -2;
215    public static final int INVALID_OPERATION  = -3;
216    public static final int PERMISSION_DENIED  = -4;
217    public static final int NO_INIT            = -5;
218    public static final int DEAD_OBJECT        = -6;
219
220    /*
221     * AudioPolicyService methods
222     */
223
224    //
225    // audio device definitions: must be kept in sync with values in system/core/audio.h
226    //
227
228    // reserved bits
229    public static final int DEVICE_BIT_IN = 0x80000000;
230    public static final int DEVICE_BIT_DEFAULT = 0x40000000;
231    // output devices, be sure to update AudioManager.java also
232    public static final int DEVICE_OUT_EARPIECE = 0x1;
233    public static final int DEVICE_OUT_SPEAKER = 0x2;
234    public static final int DEVICE_OUT_WIRED_HEADSET = 0x4;
235    public static final int DEVICE_OUT_WIRED_HEADPHONE = 0x8;
236    public static final int DEVICE_OUT_BLUETOOTH_SCO = 0x10;
237    public static final int DEVICE_OUT_BLUETOOTH_SCO_HEADSET = 0x20;
238    public static final int DEVICE_OUT_BLUETOOTH_SCO_CARKIT = 0x40;
239    public static final int DEVICE_OUT_BLUETOOTH_A2DP = 0x80;
240    public static final int DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100;
241    public static final int DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER = 0x200;
242    public static final int DEVICE_OUT_AUX_DIGITAL = 0x400;
243    public static final int DEVICE_OUT_HDMI = DEVICE_OUT_AUX_DIGITAL;
244    public static final int DEVICE_OUT_ANLG_DOCK_HEADSET = 0x800;
245    public static final int DEVICE_OUT_DGTL_DOCK_HEADSET = 0x1000;
246    public static final int DEVICE_OUT_USB_ACCESSORY = 0x2000;
247    public static final int DEVICE_OUT_USB_DEVICE = 0x4000;
248    public static final int DEVICE_OUT_REMOTE_SUBMIX = 0x8000;
249    public static final int DEVICE_OUT_TELEPHONY_TX = 0x10000;
250    public static final int DEVICE_OUT_LINE = 0x20000;
251    public static final int DEVICE_OUT_HDMI_ARC = 0x40000;
252    public static final int DEVICE_OUT_SPDIF = 0x80000;
253    public static final int DEVICE_OUT_FM = 0x100000;
254
255    public static final int DEVICE_OUT_DEFAULT = DEVICE_BIT_DEFAULT;
256
257    public static final int DEVICE_OUT_ALL = (DEVICE_OUT_EARPIECE |
258                                              DEVICE_OUT_SPEAKER |
259                                              DEVICE_OUT_WIRED_HEADSET |
260                                              DEVICE_OUT_WIRED_HEADPHONE |
261                                              DEVICE_OUT_BLUETOOTH_SCO |
262                                              DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
263                                              DEVICE_OUT_BLUETOOTH_SCO_CARKIT |
264                                              DEVICE_OUT_BLUETOOTH_A2DP |
265                                              DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
266                                              DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER |
267                                              DEVICE_OUT_HDMI |
268                                              DEVICE_OUT_ANLG_DOCK_HEADSET |
269                                              DEVICE_OUT_DGTL_DOCK_HEADSET |
270                                              DEVICE_OUT_USB_ACCESSORY |
271                                              DEVICE_OUT_USB_DEVICE |
272                                              DEVICE_OUT_REMOTE_SUBMIX |
273                                              DEVICE_OUT_TELEPHONY_TX |
274                                              DEVICE_OUT_LINE |
275                                              DEVICE_OUT_HDMI_ARC |
276                                              DEVICE_OUT_SPDIF |
277                                              DEVICE_OUT_FM |
278                                              DEVICE_OUT_DEFAULT);
279    public static final int DEVICE_OUT_ALL_A2DP = (DEVICE_OUT_BLUETOOTH_A2DP |
280                                                   DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
281                                                   DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER);
282    public static final int DEVICE_OUT_ALL_SCO = (DEVICE_OUT_BLUETOOTH_SCO |
283                                                  DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
284                                                  DEVICE_OUT_BLUETOOTH_SCO_CARKIT);
285    public static final int DEVICE_OUT_ALL_USB = (DEVICE_OUT_USB_ACCESSORY |
286                                                  DEVICE_OUT_USB_DEVICE);
287
288    // input devices
289    public static final int DEVICE_IN_COMMUNICATION = DEVICE_BIT_IN | 0x1;
290    public static final int DEVICE_IN_AMBIENT = DEVICE_BIT_IN | 0x2;
291    public static final int DEVICE_IN_BUILTIN_MIC = DEVICE_BIT_IN | 0x4;
292    public static final int DEVICE_IN_BLUETOOTH_SCO_HEADSET = DEVICE_BIT_IN | 0x8;
293    public static final int DEVICE_IN_WIRED_HEADSET = DEVICE_BIT_IN | 0x10;
294    public static final int DEVICE_IN_AUX_DIGITAL = DEVICE_BIT_IN | 0x20;
295    public static final int DEVICE_IN_HDMI = DEVICE_IN_AUX_DIGITAL;
296    public static final int DEVICE_IN_VOICE_CALL = DEVICE_BIT_IN | 0x40;
297    public static final int DEVICE_IN_TELEPHONY_RX = DEVICE_IN_VOICE_CALL;
298    public static final int DEVICE_IN_BACK_MIC = DEVICE_BIT_IN | 0x80;
299    public static final int DEVICE_IN_REMOTE_SUBMIX = DEVICE_BIT_IN | 0x100;
300    public static final int DEVICE_IN_ANLG_DOCK_HEADSET = DEVICE_BIT_IN | 0x200;
301    public static final int DEVICE_IN_DGTL_DOCK_HEADSET = DEVICE_BIT_IN | 0x400;
302    public static final int DEVICE_IN_USB_ACCESSORY = DEVICE_BIT_IN | 0x800;
303    public static final int DEVICE_IN_USB_DEVICE = DEVICE_BIT_IN | 0x1000;
304    public static final int DEVICE_IN_FM_TUNER = DEVICE_BIT_IN | 0x2000;
305    public static final int DEVICE_IN_TV_TUNER = DEVICE_BIT_IN | 0x4000;
306    public static final int DEVICE_IN_LINE = DEVICE_BIT_IN | 0x8000;
307    public static final int DEVICE_IN_SPDIF = DEVICE_BIT_IN | 0x10000;
308    public static final int DEVICE_IN_BLUETOOTH_A2DP = DEVICE_BIT_IN | 0x20000;
309    public static final int DEVICE_IN_DEFAULT = DEVICE_BIT_IN | DEVICE_BIT_DEFAULT;
310
311    public static final int DEVICE_IN_ALL = (DEVICE_IN_COMMUNICATION |
312                                             DEVICE_IN_AMBIENT |
313                                             DEVICE_IN_BUILTIN_MIC |
314                                             DEVICE_IN_BLUETOOTH_SCO_HEADSET |
315                                             DEVICE_IN_WIRED_HEADSET |
316                                             DEVICE_IN_HDMI |
317                                             DEVICE_IN_TELEPHONY_RX |
318                                             DEVICE_IN_BACK_MIC |
319                                             DEVICE_IN_REMOTE_SUBMIX |
320                                             DEVICE_IN_ANLG_DOCK_HEADSET |
321                                             DEVICE_IN_DGTL_DOCK_HEADSET |
322                                             DEVICE_IN_USB_ACCESSORY |
323                                             DEVICE_IN_USB_DEVICE |
324                                             DEVICE_IN_FM_TUNER |
325                                             DEVICE_IN_TV_TUNER |
326                                             DEVICE_IN_LINE |
327                                             DEVICE_IN_SPDIF |
328                                             DEVICE_IN_BLUETOOTH_A2DP |
329                                             DEVICE_IN_DEFAULT);
330    public static final int DEVICE_IN_ALL_SCO = DEVICE_IN_BLUETOOTH_SCO_HEADSET;
331    public static final int DEVICE_IN_ALL_USB = (DEVICE_IN_USB_ACCESSORY |
332                                                 DEVICE_IN_USB_DEVICE);
333
334    // device states, must match AudioSystem::device_connection_state
335    public static final int DEVICE_STATE_UNAVAILABLE = 0;
336    public static final int DEVICE_STATE_AVAILABLE = 1;
337    private static final int NUM_DEVICE_STATES = 1;
338
339    public static final String DEVICE_OUT_EARPIECE_NAME = "earpiece";
340    public static final String DEVICE_OUT_SPEAKER_NAME = "speaker";
341    public static final String DEVICE_OUT_WIRED_HEADSET_NAME = "headset";
342    public static final String DEVICE_OUT_WIRED_HEADPHONE_NAME = "headphone";
343    public static final String DEVICE_OUT_BLUETOOTH_SCO_NAME = "bt_sco";
344    public static final String DEVICE_OUT_BLUETOOTH_SCO_HEADSET_NAME = "bt_sco_hs";
345    public static final String DEVICE_OUT_BLUETOOTH_SCO_CARKIT_NAME = "bt_sco_carkit";
346    public static final String DEVICE_OUT_BLUETOOTH_A2DP_NAME = "bt_a2dp";
347    public static final String DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES_NAME = "bt_a2dp_hp";
348    public static final String DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER_NAME = "bt_a2dp_spk";
349    public static final String DEVICE_OUT_AUX_DIGITAL_NAME = "aux_digital";
350    public static final String DEVICE_OUT_HDMI_NAME = "hdmi";
351    public static final String DEVICE_OUT_ANLG_DOCK_HEADSET_NAME = "analog_dock";
352    public static final String DEVICE_OUT_DGTL_DOCK_HEADSET_NAME = "digital_dock";
353    public static final String DEVICE_OUT_USB_ACCESSORY_NAME = "usb_accessory";
354    public static final String DEVICE_OUT_USB_DEVICE_NAME = "usb_device";
355    public static final String DEVICE_OUT_REMOTE_SUBMIX_NAME = "remote_submix";
356    public static final String DEVICE_OUT_TELEPHONY_TX_NAME = "telephony_tx";
357    public static final String DEVICE_OUT_LINE_NAME = "line";
358    public static final String DEVICE_OUT_HDMI_ARC_NAME = "hmdi_arc";
359    public static final String DEVICE_OUT_SPDIF_NAME = "spdif";
360    public static final String DEVICE_OUT_FM_NAME = "fm_transmitter";
361
362    public static String getOutputDeviceName(int device)
363    {
364        switch(device) {
365        case DEVICE_OUT_EARPIECE:
366            return DEVICE_OUT_EARPIECE_NAME;
367        case DEVICE_OUT_SPEAKER:
368            return DEVICE_OUT_SPEAKER_NAME;
369        case DEVICE_OUT_WIRED_HEADSET:
370            return DEVICE_OUT_WIRED_HEADSET_NAME;
371        case DEVICE_OUT_WIRED_HEADPHONE:
372            return DEVICE_OUT_WIRED_HEADPHONE_NAME;
373        case DEVICE_OUT_BLUETOOTH_SCO:
374            return DEVICE_OUT_BLUETOOTH_SCO_NAME;
375        case DEVICE_OUT_BLUETOOTH_SCO_HEADSET:
376            return DEVICE_OUT_BLUETOOTH_SCO_HEADSET_NAME;
377        case DEVICE_OUT_BLUETOOTH_SCO_CARKIT:
378            return DEVICE_OUT_BLUETOOTH_SCO_CARKIT_NAME;
379        case DEVICE_OUT_BLUETOOTH_A2DP:
380            return DEVICE_OUT_BLUETOOTH_A2DP_NAME;
381        case DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES:
382            return DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES_NAME;
383        case DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER:
384            return DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER_NAME;
385        case DEVICE_OUT_HDMI:
386            return DEVICE_OUT_HDMI_NAME;
387        case DEVICE_OUT_ANLG_DOCK_HEADSET:
388            return DEVICE_OUT_ANLG_DOCK_HEADSET_NAME;
389        case DEVICE_OUT_DGTL_DOCK_HEADSET:
390            return DEVICE_OUT_DGTL_DOCK_HEADSET_NAME;
391        case DEVICE_OUT_USB_ACCESSORY:
392            return DEVICE_OUT_USB_ACCESSORY_NAME;
393        case DEVICE_OUT_USB_DEVICE:
394            return DEVICE_OUT_USB_DEVICE_NAME;
395        case DEVICE_OUT_REMOTE_SUBMIX:
396            return DEVICE_OUT_REMOTE_SUBMIX_NAME;
397        case DEVICE_OUT_TELEPHONY_TX:
398            return DEVICE_OUT_TELEPHONY_TX_NAME;
399        case DEVICE_OUT_LINE:
400            return DEVICE_OUT_LINE_NAME;
401        case DEVICE_OUT_HDMI_ARC:
402            return DEVICE_OUT_HDMI_ARC_NAME;
403        case DEVICE_OUT_SPDIF:
404            return DEVICE_OUT_SPDIF_NAME;
405        case DEVICE_OUT_FM:
406            return DEVICE_OUT_FM_NAME;
407        case DEVICE_OUT_DEFAULT:
408        default:
409            return "";
410        }
411    }
412
413
414    // phone state, match audio_mode???
415    public static final int PHONE_STATE_OFFCALL = 0;
416    public static final int PHONE_STATE_RINGING = 1;
417    public static final int PHONE_STATE_INCALL = 2;
418
419    // device categories config for setForceUse, must match AudioSystem::forced_config
420    public static final int FORCE_NONE = 0;
421    public static final int FORCE_SPEAKER = 1;
422    public static final int FORCE_HEADPHONES = 2;
423    public static final int FORCE_BT_SCO = 3;
424    public static final int FORCE_BT_A2DP = 4;
425    public static final int FORCE_WIRED_ACCESSORY = 5;
426    public static final int FORCE_BT_CAR_DOCK = 6;
427    public static final int FORCE_BT_DESK_DOCK = 7;
428    public static final int FORCE_ANALOG_DOCK = 8;
429    public static final int FORCE_DIGITAL_DOCK = 9;
430    public static final int FORCE_NO_BT_A2DP = 10;
431    public static final int FORCE_SYSTEM_ENFORCED = 11;
432    private static final int NUM_FORCE_CONFIG = 12;
433    public static final int FORCE_DEFAULT = FORCE_NONE;
434
435    // usage for setForceUse, must match AudioSystem::force_use
436    public static final int FOR_COMMUNICATION = 0;
437    public static final int FOR_MEDIA = 1;
438    public static final int FOR_RECORD = 2;
439    public static final int FOR_DOCK = 3;
440    public static final int FOR_SYSTEM = 4;
441    private static final int NUM_FORCE_USE = 5;
442
443    // usage for AudioRecord.startRecordingSync(), must match AudioSystem::sync_event_t
444    public static final int SYNC_EVENT_NONE = 0;
445    public static final int SYNC_EVENT_PRESENTATION_COMPLETE = 1;
446
447    public static native int setDeviceConnectionState(int device, int state, String device_address);
448    public static native int getDeviceConnectionState(int device, String device_address);
449    public static native int setPhoneState(int state);
450    public static native int setForceUse(int usage, int config);
451    public static native int getForceUse(int usage);
452    public static native int initStreamVolume(int stream, int indexMin, int indexMax);
453    public static native int setStreamVolumeIndex(int stream, int index, int device);
454    public static native int getStreamVolumeIndex(int stream, int device);
455    public static native int setMasterVolume(float value);
456    public static native float getMasterVolume();
457    public static native int setMasterMute(boolean mute);
458    public static native boolean getMasterMute();
459    public static native int getDevicesForStream(int stream);
460
461    // helpers for android.media.AudioManager.getProperty(), see description there for meaning
462    public static native int getPrimaryOutputSamplingRate();
463    public static native int getPrimaryOutputFrameCount();
464    public static native int getOutputLatency(int stream);
465
466    public static native int setLowRamDevice(boolean isLowRamDevice);
467    public static native int checkAudioFlinger();
468
469    public static native int listAudioPorts(ArrayList<AudioPort> ports, int[] generation);
470    public static native int createAudioPatch(AudioPatch[] patch,
471                                            AudioPortConfig[] sources, AudioPortConfig[] sinks);
472    public static native int releaseAudioPatch(AudioPatch patch);
473    public static native int listAudioPatches(ArrayList<AudioPatch> patches, int[] generation);
474    public static native int setAudioPortConfig(AudioPortConfig config);
475}
476
477