1 /******************************************************************************
3 * Copyright (C) 2009-2012 Broadcom Corporation
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 ******************************************************************************/
19 /*****************************************************************************
21 * Filename: audio_a2dp_hw.h
25 *****************************************************************************/
27 #ifndef AUDIO_A2DP_HW_H
28 #define AUDIO_A2DP_HW_H
30 /*****************************************************************************
32 ******************************************************************************/
34 #define A2DP_AUDIO_HARDWARE_INTERFACE "audio.a2dp"
35 #define A2DP_CTRL_PATH "/data/misc/bluedroid/.a2dp_ctrl"
36 #define A2DP_DATA_PATH "/data/misc/bluedroid/.a2dp_data"
38 #define AUDIO_STREAM_DEFAULT_RATE 44100
39 #define AUDIO_STREAM_DEFAULT_FORMAT AUDIO_FORMAT_PCM_16_BIT
40 #define AUDIO_STREAM_DEFAULT_CHANNEL_FLAG AUDIO_CHANNEL_OUT_STEREO
42 // AUDIO_STREAM_OUTPUT_BUFFER_SZ controls the size of the audio socket buffer.
43 // If one assumes the write buffer is always full during normal BT playback,
44 // then increasing this value increases our playback latency.
46 // FIXME: AUDIO_STREAM_OUTPUT_BUFFER_SZ should be controlled by the actual audio
47 // sample rate rather than being constant.
49 // FIXME: The BT HAL should consume data at a constant rate.
50 // AudioFlinger assumes that the HAL draws data at a constant rate, which is true
51 // for most audio devices; however, the BT engine reads data at a variable rate
52 // (over the short term), which confuses both AudioFlinger as well as applications
53 // which deliver data at a (generally) fixed rate.
55 // 20 * 512 is not sufficient size to smooth the variability for some BT devices,
56 // resulting in mixer sleep and throttling. We increase this to 28 * 512 to help
57 // reduce the effect of variable data consumption.
58 #define AUDIO_STREAM_OUTPUT_BUFFER_SZ (28*512)
60 // AUDIO_STREAM_OUTPUT_BUFFER_PERIODS controls how the socket buffer is divided
61 // for AudioFlinger data delivery. The AudioFlinger mixer delivers data in chunks
62 // of AUDIO_STREAM_OUTPUT_BUFFER_SZ / AUDIO_STREAM_OUTPUT_BUFFER_PERIODS. If
63 // the number of periods is 2, the socket buffer represents "double buffering"
64 // of the AudioFlinger mixer buffer.
66 // In general, AUDIO_STREAM_OUTPUT_BUFFER_PERIODS * 16 * 4 should be a divisor of
67 // AUDIO_STREAM_OUTPUT_BUFFER_SZ.
69 // These values should be chosen such that
71 // AUDIO_STREAM_BUFFER_SIZE * 1000 / (AUDIO_STREAM_OUTPUT_BUFFER_PERIODS
72 // * AUDIO_STREAM_DEFAULT_RATE * 4) > 20 (ms)
74 // to avoid introducing the FastMixer in AudioFlinger. Using the FastMixer results in
75 // unnecessary latency and CPU overhead for Bluetooth.
76 #define AUDIO_STREAM_OUTPUT_BUFFER_PERIODS 4
78 #define AUDIO_SKT_DISCONNECTED (-1)
82 A2DP_CTRL_CMD_CHECK_READY,
85 A2DP_CTRL_CMD_SUSPEND,
86 A2DP_CTRL_GET_AUDIO_CONFIG,
87 A2DP_CTRL_CMD_OFFLOAD_START,
91 A2DP_CTRL_ACK_SUCCESS,
92 A2DP_CTRL_ACK_FAILURE,
93 A2DP_CTRL_ACK_INCALL_FAILURE, /* Failure when in Call*/
94 A2DP_CTRL_ACK_UNSUPPORTED
98 /*****************************************************************************
99 ** Type definitions for callback functions
100 ******************************************************************************/
102 /*****************************************************************************
103 ** Type definitions and return values
104 ******************************************************************************/
106 /*****************************************************************************
107 ** Extern variables and functions
108 ******************************************************************************/
110 /*****************************************************************************
112 ******************************************************************************/
115 /*****************************************************************************
123 ******************************************************************************/
125 #endif /* A2DP_AUDIO_HW_H */