| 1 | /*************************************************************************** |
|---|
| 2 | * (c)2004-2011 Broadcom Corporation |
|---|
| 3 | * |
|---|
| 4 | * This program is the proprietary software of Broadcom Corporation and/or its licensors, |
|---|
| 5 | * and may only be used, duplicated, modified or distributed pursuant to the terms and |
|---|
| 6 | * conditions of a separate, written license agreement executed between you and Broadcom |
|---|
| 7 | * (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants |
|---|
| 8 | * no license (express or implied), right to use, or waiver of any kind with respect to the |
|---|
| 9 | * Software, and Broadcom expressly reserves all rights in and to the Software and all |
|---|
| 10 | * intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU |
|---|
| 11 | * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY |
|---|
| 12 | * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. |
|---|
| 13 | * |
|---|
| 14 | * Except as expressly set forth in the Authorized License, |
|---|
| 15 | * |
|---|
| 16 | * 1. This program, including its structure, sequence and organization, constitutes the valuable trade |
|---|
| 17 | * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof, |
|---|
| 18 | * and to use this information only in connection with your use of Broadcom integrated circuit products. |
|---|
| 19 | * |
|---|
| 20 | * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
|---|
| 21 | * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR |
|---|
| 22 | * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO |
|---|
| 23 | * THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES |
|---|
| 24 | * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, |
|---|
| 25 | * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION |
|---|
| 26 | * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF |
|---|
| 27 | * USE OR PERFORMANCE OF THE SOFTWARE. |
|---|
| 28 | * |
|---|
| 29 | * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS |
|---|
| 30 | * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR |
|---|
| 31 | * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR |
|---|
| 32 | * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF |
|---|
| 33 | * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT |
|---|
| 34 | * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE |
|---|
| 35 | * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF |
|---|
| 36 | * ANY LIMITED REMEDY. |
|---|
| 37 | * |
|---|
| 38 | * $brcm_Workfile: nexus_audio_capture.h $ |
|---|
| 39 | * $brcm_Revision: 7 $ |
|---|
| 40 | * $brcm_Date: 5/23/11 6:49p $ |
|---|
| 41 | * |
|---|
| 42 | * API Description: |
|---|
| 43 | * API name: AudioCapture |
|---|
| 44 | * Specific APIs related to PCM audio capture. This supports capture |
|---|
| 45 | * of data into memory from a decoder or other source. |
|---|
| 46 | * |
|---|
| 47 | * Revision History: |
|---|
| 48 | * |
|---|
| 49 | * $brcm_Log: /nexus/modules/audio/7400/include/nexus_audio_capture.h $ |
|---|
| 50 | * |
|---|
| 51 | * 7 5/23/11 6:49p jgarrett |
|---|
| 52 | * SW7425-402: Adding multichannel capture support |
|---|
| 53 | * |
|---|
| 54 | * 6 4/22/11 10:43a erickson |
|---|
| 55 | * SW7420-1148: remove attr{shutdown=NEXUS_AudioInput_Shutdown} |
|---|
| 56 | * |
|---|
| 57 | * 5 12/14/10 3:18p erickson |
|---|
| 58 | * SW7420-1285: add null_allowed attribute |
|---|
| 59 | * |
|---|
| 60 | * 4 8/10/10 3:58p erickson |
|---|
| 61 | * SW7420-934: rename NEXUS_AudioCapture_WriteComplete to |
|---|
| 62 | * NEXUS_AudioCapture_ReadComplete |
|---|
| 63 | * |
|---|
| 64 | * 3 8/28/09 4:00p jgarrett |
|---|
| 65 | * SW7405-2928: Adding multichannel capture support |
|---|
| 66 | * |
|---|
| 67 | * 2 10/6/08 4:16a jgarrett |
|---|
| 68 | * PR 46143: Adding mixed mono capture option |
|---|
| 69 | * |
|---|
| 70 | * 1 7/11/08 10:30a jgarrett |
|---|
| 71 | * PR 44645: Adding capture API |
|---|
| 72 | * |
|---|
| 73 | ***************************************************************************/ |
|---|
| 74 | #ifndef NEXUS_AUDIO_CAPTURE_H__ |
|---|
| 75 | #define NEXUS_AUDIO_CAPTURE_H__ |
|---|
| 76 | |
|---|
| 77 | #include "nexus_types.h" |
|---|
| 78 | #include "nexus_audio_types.h" |
|---|
| 79 | |
|---|
| 80 | /*=************************************ |
|---|
| 81 | Interface: AudioCapture |
|---|
| 82 | |
|---|
| 83 | Header file: nexus_audio_capture.h |
|---|
| 84 | |
|---|
| 85 | Module: Audio |
|---|
| 86 | |
|---|
| 87 | Description: Capture audio PCM data |
|---|
| 88 | |
|---|
| 89 | **************************************/ |
|---|
| 90 | |
|---|
| 91 | #ifdef __cplusplus |
|---|
| 92 | extern "C" { |
|---|
| 93 | #endif |
|---|
| 94 | |
|---|
| 95 | /*************************************************************************** |
|---|
| 96 | Summary: |
|---|
| 97 | Handle for audio capture |
|---|
| 98 | ***************************************************************************/ |
|---|
| 99 | typedef struct NEXUS_AudioCapture *NEXUS_AudioCaptureHandle; |
|---|
| 100 | |
|---|
| 101 | /*************************************************************************** |
|---|
| 102 | Summary: |
|---|
| 103 | Audio Capture Channel Open Settings |
|---|
| 104 | |
|---|
| 105 | Description: |
|---|
| 106 | Audio Capture Channel Open Settings |
|---|
| 107 | |
|---|
| 108 | See Also: |
|---|
| 109 | NEXUS_AudioCaptureStartSettings |
|---|
| 110 | ***************************************************************************/ |
|---|
| 111 | typedef struct NEXUS_AudioCaptureOpenSettings |
|---|
| 112 | { |
|---|
| 113 | size_t fifoSize; /* FIFO size in bytes. This value is a total FIFO size to hold |
|---|
| 114 | all channels of data interleaved into a single buffer. |
|---|
| 115 | If not set, a default size will be used. */ |
|---|
| 116 | size_t threshold; /* FIFO data callback threshold in bytes. When the amount of data |
|---|
| 117 | remaining in the FIFO drops below this level, the dataCallback |
|---|
| 118 | routine provided in NEXUS_AudioCaptureStartSettings will be called. |
|---|
| 119 | If this value is 0, a default threshold percentage will be used. */ |
|---|
| 120 | NEXUS_AudioMultichannelFormat multichannelFormat; /* This defines the maximum width of data that can be captured. |
|---|
| 121 | Default is NEXUS_AudioMultichannelFormat_eStereo to capture stereo |
|---|
| 122 | data. 5.1 or 7.1 will increase the number of buffers allocated. */ |
|---|
| 123 | } NEXUS_AudioCaptureOpenSettings; |
|---|
| 124 | |
|---|
| 125 | /*************************************************************************** |
|---|
| 126 | Summary: |
|---|
| 127 | Get default settings for opening an audio capture channel |
|---|
| 128 | ***************************************************************************/ |
|---|
| 129 | void NEXUS_AudioCapture_GetDefaultOpenSettings( |
|---|
| 130 | NEXUS_AudioCaptureOpenSettings *pSettings /* [out] default settings */ |
|---|
| 131 | ); |
|---|
| 132 | |
|---|
| 133 | /*************************************************************************** |
|---|
| 134 | Summary: |
|---|
| 135 | Open an audio capture channel |
|---|
| 136 | |
|---|
| 137 | Description: |
|---|
| 138 | The captured data will be formatted with the settings provided in |
|---|
| 139 | NEXUS_AudioCaptureSettings. The sample rate of the data is determined by |
|---|
| 140 | the sample rate of the input data. For example, if the decoder is outputting |
|---|
| 141 | 48kHz, the data will be the same sample rate. If the decoder is not active, |
|---|
| 142 | the output will be 48kHz. Data will automatically start flowing once the |
|---|
| 143 | source device starts and stop when the source device stops. |
|---|
| 144 | ***************************************************************************/ |
|---|
| 145 | NEXUS_AudioCaptureHandle NEXUS_AudioCapture_Open( /* attr{destructor=NEXUS_AudioCapture_Close} */ |
|---|
| 146 | unsigned index, |
|---|
| 147 | const NEXUS_AudioCaptureOpenSettings *pSettings /* attr{null_allowed=y} */ |
|---|
| 148 | ); |
|---|
| 149 | |
|---|
| 150 | /*************************************************************************** |
|---|
| 151 | Summary: |
|---|
| 152 | Close an audio capture channel |
|---|
| 153 | ***************************************************************************/ |
|---|
| 154 | void NEXUS_AudioCapture_Close( |
|---|
| 155 | NEXUS_AudioCaptureHandle handle |
|---|
| 156 | ); |
|---|
| 157 | |
|---|
| 158 | /*************************************************************************** |
|---|
| 159 | Summary: |
|---|
| 160 | Enumeration for capture data format |
|---|
| 161 | |
|---|
| 162 | Description: |
|---|
| 163 | Captured data will always be stored in host endian mode. |
|---|
| 164 | |
|---|
| 165 | For 16-bit data: |
|---|
| 166 | Address Byte 0 1 2 3 |
|---|
| 167 | |
|---|
| 168 | ----------- |
|---|
| 169 | Little-Endian |R0|R1|L0|L1| |
|---|
| 170 | ----------- |
|---|
| 171 | |
|---|
| 172 | ----------- |
|---|
| 173 | Big-Endian |L1|L0|R1|R0| |
|---|
| 174 | ----------- |
|---|
| 175 | |
|---|
| 176 | For 24-bit Data: |
|---|
| 177 | Address Byte 0 1 2 3 4 5 6 7 |
|---|
| 178 | |
|---|
| 179 | ----------- ----------- |
|---|
| 180 | Little-Endian |L0|L1|L2|00||R0|R1|R2|00| |
|---|
| 181 | ----------- ----------- |
|---|
| 182 | |
|---|
| 183 | ----------- ----------- |
|---|
| 184 | Big-Endian |L2|L1|L0|00||R2|R1|R0|00| |
|---|
| 185 | ----------- ----------- |
|---|
| 186 | ***************************************************************************/ |
|---|
| 187 | typedef enum NEXUS_AudioCaptureFormat |
|---|
| 188 | { |
|---|
| 189 | NEXUS_AudioCaptureFormat_e16BitStereo, /* Stereo, 16 bits per sample interleaved into a 32-bit word. */ |
|---|
| 190 | NEXUS_AudioCaptureFormat_e24BitStereo, /* Stereo, 24 bits per sample. The data is aligned to 32-bits, |
|---|
| 191 | left-justified. Left and right channels will interleave |
|---|
| 192 | one sample per 32-bit word. */ |
|---|
| 193 | NEXUS_AudioCaptureFormat_e16BitMonoLeft, /* Mono, 16 bits per sample interleaved into a 32-bit word. Left channel samples only. */ |
|---|
| 194 | NEXUS_AudioCaptureFormat_e16BitMonoRight, /* Mono, 16 bits per sample interleaved into a 32-bit word. Right channel samples only. */ |
|---|
| 195 | NEXUS_AudioCaptureFormat_e16BitMono, /* Mono, 16 bits per sample interleaved into a 32-bit word. Left and Right channels mixed. */ |
|---|
| 196 | NEXUS_AudioCaptureFormat_e24Bit5_1, /* 5.1 Multichannel, 24 bits per sample. The data is aligned to 32-bits, |
|---|
| 197 | left-justified. Channels will interleave |
|---|
| 198 | one sample per 32-bit word, ordered L,R,Ls,Rs,C,LFE. */ |
|---|
| 199 | NEXUS_AudioCaptureFormat_eMax |
|---|
| 200 | } NEXUS_AudioCaptureFormat; |
|---|
| 201 | |
|---|
| 202 | /*************************************************************************** |
|---|
| 203 | Summary: |
|---|
| 204 | Audio Capture Channel Settings |
|---|
| 205 | |
|---|
| 206 | Description: |
|---|
| 207 | Audio Capture Channel Settings. Please note, some members may only be |
|---|
| 208 | changed while the capture channel is disconnected from all inputs. |
|---|
| 209 | ***************************************************************************/ |
|---|
| 210 | typedef struct NEXUS_AudioCaptureSettings |
|---|
| 211 | { |
|---|
| 212 | NEXUS_AudioCaptureFormat format; /* Captured data format. Default is 16bit stereo. |
|---|
| 213 | This value is ignored for compressed data, and |
|---|
| 214 | can not be changed while connected to any inputs. */ |
|---|
| 215 | } NEXUS_AudioCaptureSettings; |
|---|
| 216 | |
|---|
| 217 | /*************************************************************************** |
|---|
| 218 | Summary: |
|---|
| 219 | Get Audio Capture Channel Settings |
|---|
| 220 | ***************************************************************************/ |
|---|
| 221 | void NEXUS_AudioCapture_GetSettings( |
|---|
| 222 | NEXUS_AudioCaptureHandle handle, |
|---|
| 223 | NEXUS_AudioCaptureSettings *pSettings /* [out] */ |
|---|
| 224 | ); |
|---|
| 225 | |
|---|
| 226 | /*************************************************************************** |
|---|
| 227 | Summary: |
|---|
| 228 | Set Audio Capture Channel Settings |
|---|
| 229 | ***************************************************************************/ |
|---|
| 230 | NEXUS_Error NEXUS_AudioCapture_SetSettings( |
|---|
| 231 | NEXUS_AudioCaptureHandle handle, |
|---|
| 232 | const NEXUS_AudioCaptureSettings *pSettings |
|---|
| 233 | ); |
|---|
| 234 | |
|---|
| 235 | /*************************************************************************** |
|---|
| 236 | Summary: |
|---|
| 237 | Audio Capture Channel Start Settings |
|---|
| 238 | |
|---|
| 239 | Description: |
|---|
| 240 | Audio Capture Channel Start Settings |
|---|
| 241 | |
|---|
| 242 | See Also: |
|---|
| 243 | NEXUS_AudioCaptureStartSettings |
|---|
| 244 | ***************************************************************************/ |
|---|
| 245 | typedef struct NEXUS_AudioCaptureStartSettings |
|---|
| 246 | { |
|---|
| 247 | NEXUS_CallbackDesc dataCallback; /* Callback when data becomes available. User should call NEXUS_AudioCapture_GetBuffer. |
|---|
| 248 | You will not receive another callback until NEXUS_AudioCapture_GetBuffer is called. */ |
|---|
| 249 | } NEXUS_AudioCaptureStartSettings; |
|---|
| 250 | |
|---|
| 251 | /*************************************************************************** |
|---|
| 252 | Summary: |
|---|
| 253 | Get current setting of the audio capture channel |
|---|
| 254 | ***************************************************************************/ |
|---|
| 255 | void NEXUS_AudioCapture_GetDefaultStartSettings( |
|---|
| 256 | NEXUS_AudioCaptureStartSettings *pSettings /* [out] default settings */ |
|---|
| 257 | ); |
|---|
| 258 | |
|---|
| 259 | /*************************************************************************** |
|---|
| 260 | Summary: |
|---|
| 261 | Start capturing data. |
|---|
| 262 | |
|---|
| 263 | Decription: |
|---|
| 264 | An input must be connected prior to starting. |
|---|
| 265 | |
|---|
| 266 | See Also: |
|---|
| 267 | NEXUS_AudioCapture_Stop |
|---|
| 268 | NEXUS_AudioCapture_GetConnector |
|---|
| 269 | ***************************************************************************/ |
|---|
| 270 | NEXUS_Error NEXUS_AudioCapture_Start( |
|---|
| 271 | NEXUS_AudioCaptureHandle handle, |
|---|
| 272 | const NEXUS_AudioCaptureStartSettings *pSettings |
|---|
| 273 | ); |
|---|
| 274 | |
|---|
| 275 | /*************************************************************************** |
|---|
| 276 | Summary: |
|---|
| 277 | Stop capturing data. |
|---|
| 278 | ***************************************************************************/ |
|---|
| 279 | void NEXUS_AudioCapture_Stop( |
|---|
| 280 | NEXUS_AudioCaptureHandle handle |
|---|
| 281 | ); |
|---|
| 282 | |
|---|
| 283 | /*************************************************************************** |
|---|
| 284 | Summary: |
|---|
| 285 | Get a pointer and size for the next location in the buffer that contains data |
|---|
| 286 | |
|---|
| 287 | Description: |
|---|
| 288 | NEXUS_AudioCapture_GetBuffer is non-destructive. You can safely call it |
|---|
| 289 | multiple times. |
|---|
| 290 | ***************************************************************************/ |
|---|
| 291 | NEXUS_Error NEXUS_AudioCapture_GetBuffer( |
|---|
| 292 | NEXUS_AudioCaptureHandle handle, |
|---|
| 293 | void **ppBuffer, /* [out] attr{memory=cached} pointer to memory mapped |
|---|
| 294 | region that contains captured data. */ |
|---|
| 295 | size_t *pSize /* [out] total number of readable, contiguous bytes which the buffers are pointing to */ |
|---|
| 296 | ); |
|---|
| 297 | |
|---|
| 298 | /*************************************************************************** |
|---|
| 299 | Summary: |
|---|
| 300 | Notify AudioCapture how much data removed from the buffer. |
|---|
| 301 | |
|---|
| 302 | Description: |
|---|
| 303 | You can only call NEXUS_AudioCapture_ReadComplete once after a |
|---|
| 304 | NEXUS_AudioCapture_GetBuffer call. After calling it, you must call |
|---|
| 305 | NEXUS_AudioCapture_GetBuffer before reading more data. |
|---|
| 306 | ***************************************************************************/ |
|---|
| 307 | NEXUS_Error NEXUS_AudioCapture_ReadComplete( |
|---|
| 308 | NEXUS_AudioCaptureHandle handle, |
|---|
| 309 | size_t amountWritten /* The number of bytes read from the buffer */ |
|---|
| 310 | ); |
|---|
| 311 | |
|---|
| 312 | /* backward compatibility */ |
|---|
| 313 | #define NEXUS_AudioCapture_WriteComplete NEXUS_AudioCapture_ReadComplete |
|---|
| 314 | |
|---|
| 315 | /*************************************************************************** |
|---|
| 316 | Summary: |
|---|
| 317 | Get an audio connector to attach this output to a source. |
|---|
| 318 | |
|---|
| 319 | Description: |
|---|
| 320 | Capture may be connected to a stereo source device or a compressed source |
|---|
| 321 | device, depending on the data format desired. |
|---|
| 322 | **************************************************************************/ |
|---|
| 323 | NEXUS_AudioOutput NEXUS_AudioCapture_GetConnector( |
|---|
| 324 | NEXUS_AudioCaptureHandle handle |
|---|
| 325 | ); |
|---|
| 326 | |
|---|
| 327 | #ifdef __cplusplus |
|---|
| 328 | } |
|---|
| 329 | #endif |
|---|
| 330 | #endif /* #ifndef NEXUS_AUDIO_CAPTURE_H__ */ |
|---|
| 331 | |
|---|