| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2002-2007, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bpvrlib_play.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/9 $ |
|---|
| 12 | * $brcm_Date: 1/23/07 2:05p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * This module implements the playback functionality for pvr using an intermediate |
|---|
| 17 | * ring buffer. It features a programmable buffer location, buffer size, and number |
|---|
| 18 | * of descriptors. It also supports a constant stream by dynamically adding buffers |
|---|
| 19 | * into the transport playback hardware. |
|---|
| 20 | * |
|---|
| 21 | * Revision History: |
|---|
| 22 | * |
|---|
| 23 | * $brcm_Log: /magnum/syslib/pvrlib/bpvrlib_play.h $ |
|---|
| 24 | * |
|---|
| 25 | * Hydra_Software_Devel/9 1/23/07 2:05p erickson |
|---|
| 26 | * PR27252: clarify event usage in pvrlib to avoid WaitForEvent bugs |
|---|
| 27 | * |
|---|
| 28 | * Hydra_Software_Devel/8 6/18/04 11:32a marcusk |
|---|
| 29 | * PR11591: Updated to support returning if descriptor is available when |
|---|
| 30 | * calling BPVRlib_Play_AddDataRequest() |
|---|
| 31 | * |
|---|
| 32 | * Hydra_Software_Devel/7 6/3/04 6:04p marcusk |
|---|
| 33 | * PR11347: Added new functions |
|---|
| 34 | * |
|---|
| 35 | * Hydra_Software_Devel/6 4/8/04 6:31p marcusk |
|---|
| 36 | * PR10543: Added feature to support skip size when updating ring buffer |
|---|
| 37 | * write pointer. |
|---|
| 38 | * |
|---|
| 39 | * Hydra_Software_Devel/5 2/19/04 10:32a vsilyaev |
|---|
| 40 | * PR 8927: Added function to return events used by playback module |
|---|
| 41 | * |
|---|
| 42 | * Hydra_Software_Devel/4 1/21/04 4:43p marcusk |
|---|
| 43 | * PR8927: Fixed to work with latest version of XPT porting interface. |
|---|
| 44 | * Validate channel number. |
|---|
| 45 | * |
|---|
| 46 | * Hydra_Software_Devel/3 1/10/04 10:47a marcusk |
|---|
| 47 | * PR8927: Fixed playback isses. |
|---|
| 48 | * |
|---|
| 49 | * Hydra_Software_Devel/2 1/7/04 6:12p marcusk |
|---|
| 50 | * PR8927: Initial magnum version |
|---|
| 51 | * |
|---|
| 52 | * Hydra_Software_Devel/1 12/10/03 11:00a marcusk |
|---|
| 53 | * PR 8927: Starting with 7115 PVR syslibs. |
|---|
| 54 | * |
|---|
| 55 | * Irvine_BSEAVSW_Devel/17 2/20/03 6:14p marcusk |
|---|
| 56 | * Added pvr_playbackSwitchSyncModes() function. |
|---|
| 57 | * |
|---|
| 58 | * Irvine_HDDemo_Devel/16 7/12/02 10:50a marcusk |
|---|
| 59 | * Added a few functions to override default pause and packet length |
|---|
| 60 | * settings. |
|---|
| 61 | * |
|---|
| 62 | * Irvine_HDDemo_Devel\15 3/21/02 11:26a marcusk |
|---|
| 63 | * Added feature to auto-allocate buffer if p_bfr is set to 0 during the |
|---|
| 64 | * allocate routine. |
|---|
| 65 | * |
|---|
| 66 | * \main\Irvine_HDDemo_Devel\14 3/19/02 12:8p marcusk |
|---|
| 67 | * Added CR/LF at end of file to remove linux warnings. |
|---|
| 68 | * |
|---|
| 69 | ***************************************************************************/ |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | /*================== Module Overview ===================================== |
|---|
| 73 | |
|---|
| 74 | The following general overview describes the playback algorithm: |
|---|
| 75 | |
|---|
| 76 | 1.0 Allocate |
|---|
| 77 | |
|---|
| 78 | - The number of descriptors and buffer address are passed as parameters |
|---|
| 79 | - The ring buffer manager is allocated |
|---|
| 80 | - Array of descriptors is allocated (all descriptors are added to free list) |
|---|
| 81 | |
|---|
| 82 | 1.1 Start Playback |
|---|
| 83 | |
|---|
| 84 | - Playback resync variable is set (used to reset sync detect engine) |
|---|
| 85 | - Configure playback hardware based upon sync mode |
|---|
| 86 | - Playback hardware is started |
|---|
| 87 | |
|---|
| 88 | 1.2 Add Data (not re-entrant for same playback channel) |
|---|
| 89 | |
|---|
| 90 | - Buffer address and size is requested from the ring buffer manager |
|---|
| 91 | (this step may block if there is no space available) |
|---|
| 92 | - Data is copied into specified buffer |
|---|
| 93 | - Ring buffer write offset is updated |
|---|
| 94 | - Data is commited to hardware |
|---|
| 95 | - In the case of no blocking, the amount of data NOT copied is returned |
|---|
| 96 | |
|---|
| 97 | (Alternate 1.2) |
|---|
| 98 | 1.2.1 Request to Add Data (steps 1.2.x not re-entrant for same playback channel) |
|---|
| 99 | |
|---|
| 100 | - Free buffer address and size is requested from the ring buffer manager |
|---|
| 101 | (this step may block if there is no space available) |
|---|
| 102 | |
|---|
| 103 | 1.2.2 Data is copied to specified buffer by calling code |
|---|
| 104 | |
|---|
| 105 | 1.2.3 Write pointer is updated |
|---|
| 106 | |
|---|
| 107 | - Ring buffer write offset is updated |
|---|
| 108 | - Data is commited to hardware |
|---|
| 109 | |
|---|
| 110 | 1.3 Data is Commited To Hardware |
|---|
| 111 | |
|---|
| 112 | - Availability of free descriptor is checked |
|---|
| 113 | (this step may block if there is no space available) |
|---|
| 114 | - Descriptor is obtained from the free list |
|---|
| 115 | - Buffer address and size is programmed into descriptor |
|---|
| 116 | - Descriptor is added to hardware list |
|---|
| 117 | - Descriptor is programmed into playback hardware |
|---|
| 118 | |
|---|
| 119 | 1.4 Hardware Data Complete |
|---|
| 120 | |
|---|
| 121 | - First descriptor is removed from hardware list |
|---|
| 122 | - Event is triggered signaling removal of descriptor |
|---|
| 123 | - Ring buffer read offset is updated |
|---|
| 124 | - Event is triggered signaling freeing of data from ring buffer |
|---|
| 125 | - Descriptor is added to free list |
|---|
| 126 | - Check if next descriptor has also completed (repeat process if necessary) |
|---|
| 127 | |
|---|
| 128 | 1.5 Stop Playback |
|---|
| 129 | |
|---|
| 130 | - Playback hardware is stopped |
|---|
| 131 | - Ring buffer manager is reset |
|---|
| 132 | - All descriptors are moved from hw to the free list |
|---|
| 133 | |
|---|
| 134 | 1.6 Free |
|---|
| 135 | |
|---|
| 136 | - Free descriptor buffer |
|---|
| 137 | - Free ring buffer manager |
|---|
| 138 | |
|---|
| 139 | ================== End Module Overview =================================*/ |
|---|
| 140 | |
|---|
| 141 | #ifndef BPVRLIB_PLAY_H__ |
|---|
| 142 | #define BPVRLIB_PLAY_H__ |
|---|
| 143 | |
|---|
| 144 | #include "bxpt_playback.h" |
|---|
| 145 | |
|---|
| 146 | #ifdef __cplusplus |
|---|
| 147 | extern "C" { |
|---|
| 148 | #endif |
|---|
| 149 | |
|---|
| 150 | /* |
|---|
| 151 | This callback is compatible with the standard 'c' memcpy routine. |
|---|
| 152 | It is used to copy data between a user buffer and the ring |
|---|
| 153 | buffer during a BPVRlib_Play_AddData() function call. |
|---|
| 154 | */ |
|---|
| 155 | typedef void *(*BPVRlib_Play_MemCopyCb)( void *, const void *, size_t ); |
|---|
| 156 | |
|---|
| 157 | /* |
|---|
| 158 | Summary: |
|---|
| 159 | This handle is used to store the context of a pvr record. |
|---|
| 160 | */ |
|---|
| 161 | typedef struct BPVRlib_Play_P_Handle *BPVRlib_Play_Handle; |
|---|
| 162 | |
|---|
| 163 | /* |
|---|
| 164 | Summary: |
|---|
| 165 | This enumeration is used to describe the various types of blocking that can |
|---|
| 166 | be used when performing playback with this module. |
|---|
| 167 | */ |
|---|
| 168 | typedef enum |
|---|
| 169 | { |
|---|
| 170 | BPVRlib_Play_BlockMode_eNone, /* Do not block */ |
|---|
| 171 | BPVRlib_Play_BlockMode_eFreeBuffer, /* Block until free space is available in the buffer */ |
|---|
| 172 | BPVRlib_Play_BlockMode_eFreeDescriptor, /* Block until a descriptor is available (in addition to free space) */ |
|---|
| 173 | BPVRlib_Play_BlockMode_eNoCommit /* Do not commit the buffer to the hardware until later */ |
|---|
| 174 | } BPVRlib_Play_BlockMode; |
|---|
| 175 | |
|---|
| 176 | /* |
|---|
| 177 | The BPVRlib_Play_Stats structure is used to store various statistics that can |
|---|
| 178 | be used to monitor and debug a playback that is in progress. |
|---|
| 179 | Note: All stats are reset when the playback is started or flushed! |
|---|
| 180 | */ |
|---|
| 181 | typedef struct |
|---|
| 182 | { |
|---|
| 183 | size_t numBytesPlayed; /* Number of bytes played back through hardware */ |
|---|
| 184 | size_t numBytesAdded; /* Number of bytes added into ring buffer */ |
|---|
| 185 | size_t bfrSize; /* Total buffer size */ |
|---|
| 186 | size_t readOffset; /* Current read offset */ |
|---|
| 187 | size_t writeOffset; /* Current write offset */ |
|---|
| 188 | size_t hwWriteOffset; /* Current hw write offset (committed to hardware) */ |
|---|
| 189 | size_t numBytesNotCommitted; /* Current number of bytes in the ring buffer that are not committed into hardware */ |
|---|
| 190 | size_t numBytesScatGat; /* Current number of bytes in scatter gather hardware list */ |
|---|
| 191 | uint32_t numFreeDesc; /* Current number of free descriptors */ |
|---|
| 192 | uint32_t numInHwDesc; /* Current number of descriptors being processed by hardware */ |
|---|
| 193 | uint32_t numScatGatDesc; /* Current number of descriptors in hardware on scatter gather list */ |
|---|
| 194 | uint32_t numDesc; /* Total number of descriptors */ |
|---|
| 195 | uint32_t numDescAdded; /* Number of descriptors added in to hardware */ |
|---|
| 196 | uint32_t numDescCompleted; /* Number of descriptors completed by hardware */ |
|---|
| 197 | uint32_t numUnderFlows; /* Number of times the hardware has reached the end of its descriptor list */ |
|---|
| 198 | uint32_t numBufferBlocks; /* Number of times blocking has occurred due to buffer resources */ |
|---|
| 199 | uint32_t numDescBlocks; /* Number of times blocking has occurred due to descriptor resources */ |
|---|
| 200 | uint32_t numTimeouts; /* Number of times blocking has failed due to a timeout */ |
|---|
| 201 | uint32_t numMultiDescDone; /* Number of times multiple descriptors have been completed in a single call */ |
|---|
| 202 | } BPVRlib_Play_Stats; |
|---|
| 203 | |
|---|
| 204 | /* |
|---|
| 205 | The BPVRlib_Play_Events structure is used to return various events used by playback module. |
|---|
| 206 | Those events could be used by an application for non-blocking playback. |
|---|
| 207 | */ |
|---|
| 208 | typedef struct BPVRlib_Play_Events |
|---|
| 209 | { |
|---|
| 210 | BKNI_EventHandle descEvent; /* Event used to signal when descriptor is added to free list */ |
|---|
| 211 | BKNI_EventHandle finishedEvent; /* Event used to signal when the playback has finished */ |
|---|
| 212 | } BPVRlib_Play_Events; |
|---|
| 213 | |
|---|
| 214 | /**************************************************************** |
|---|
| 215 | Summary: |
|---|
| 216 | This function allocates the resources required for a playback. This |
|---|
| 217 | includes a ring buffer manager, descriptor list, etc. The pvrMemCopyCb |
|---|
| 218 | parameter only needs to be valid if the pvr_recordAddData() function is |
|---|
| 219 | going to be used. |
|---|
| 220 | ****************************************************************/ |
|---|
| 221 | BERR_Code BPVRlib_Play_Open( |
|---|
| 222 | BPVRlib_Play_Handle *pPlayHandle, /* [out] context handle */ |
|---|
| 223 | BXPT_Handle xptHandle, /* XPT handle */ |
|---|
| 224 | BXPT_Playback_Handle xptPlayHandle, /* XPT playback handle */ |
|---|
| 225 | BMEM_Handle memHandle, /* Mem handle */ |
|---|
| 226 | BINT_Handle intHandle, /* Int handle */ |
|---|
| 227 | unsigned channelNum, /* playback channel number */ |
|---|
| 228 | uint8_t *p_bfr, /* pointer to buffer that should be used for playback ring buffer, 0 to allocate the buffer internally */ |
|---|
| 229 | size_t bfrSize, /* size of playback ring buffer (in bytes) */ |
|---|
| 230 | uint32_t numDesc, /* number of descriptors to use */ |
|---|
| 231 | BPVRlib_Play_MemCopyCb pvrMemCopyCb /* function pointer for memory copies (optional) */ |
|---|
| 232 | ); |
|---|
| 233 | |
|---|
| 234 | /**************************************************************** |
|---|
| 235 | Summary: |
|---|
| 236 | This function frees any resources used by a playback channel. |
|---|
| 237 | ****************************************************************/ |
|---|
| 238 | BERR_Code BPVRlib_Play_Close( |
|---|
| 239 | BPVRlib_Play_Handle playHandle /* context handle */ |
|---|
| 240 | ); |
|---|
| 241 | |
|---|
| 242 | /**************************************************************** |
|---|
| 243 | Summary: |
|---|
| 244 | This function returns events used by playback module |
|---|
| 245 | Description: |
|---|
| 246 | The events returned by this function cannot be used along with any blocking mode |
|---|
| 247 | other than BPVRlib_Play_BlockMode_eNone. |
|---|
| 248 | ****************************************************************/ |
|---|
| 249 | BERR_Code BPVRlib_Play_GetEvents( |
|---|
| 250 | BPVRlib_Play_Handle playHandle, /* context handle*/ |
|---|
| 251 | BPVRlib_Play_Events *events /* events would be returned in this structure */ |
|---|
| 252 | ); |
|---|
| 253 | |
|---|
| 254 | |
|---|
| 255 | /**************************************************************** |
|---|
| 256 | Summary: |
|---|
| 257 | This function starts a playback. |
|---|
| 258 | ****************************************************************/ |
|---|
| 259 | BERR_Code BPVRlib_Play_Start( |
|---|
| 260 | BPVRlib_Play_Handle playHandle /* context handle */ |
|---|
| 261 | ); |
|---|
| 262 | |
|---|
| 263 | /**************************************************************** |
|---|
| 264 | Summary: |
|---|
| 265 | This function checks if there is any room in the playback ring buffer and |
|---|
| 266 | copies data from the source buffer. If there is no space available in the |
|---|
| 267 | ring buffer this function can optionally block until space is available |
|---|
| 268 | and all data has been copied. It used the pvrMemCopyCb function passed in |
|---|
| 269 | the BPVRlib_Play_Open() function to perform the memory copy. |
|---|
| 270 | ****************************************************************/ |
|---|
| 271 | BERR_Code BPVRlib_Play_AddData( |
|---|
| 272 | BPVRlib_Play_Handle playHandle, /* context handle */ |
|---|
| 273 | uint8_t *p_bfr, /* pointer to source buffer */ |
|---|
| 274 | size_t *p_bfrSize, /* size of source buffer (in bytes) */ |
|---|
| 275 | BPVRlib_Play_BlockMode block /* block mode */ |
|---|
| 276 | ); |
|---|
| 277 | |
|---|
| 278 | /**************************************************************** |
|---|
| 279 | Summary: |
|---|
| 280 | This function checks if there is any room in the playback |
|---|
| 281 | ring buffer. If there is no space available in the ring buffer this |
|---|
| 282 | function can optionally block until space is available. |
|---|
| 283 | |
|---|
| 284 | Description: |
|---|
| 285 | This function will return BERR_TIMEOUT if there is no buffer |
|---|
| 286 | space available OR no descriptors available. It is possible |
|---|
| 287 | to add additional data to the buffer without having descriptors |
|---|
| 288 | available. If this type of operation is desired, the p_bfrSize |
|---|
| 289 | variable should be checked for a non-zero value that signifies |
|---|
| 290 | that buffer space is available. |
|---|
| 291 | ****************************************************************/ |
|---|
| 292 | BERR_Code BPVRlib_Play_AddDataRequest( |
|---|
| 293 | BPVRlib_Play_Handle playHandle, /* context */ |
|---|
| 294 | uint8_t **pp_bfr, /* returns pointer to free space in ring buffer */ |
|---|
| 295 | size_t *p_bfrSize, /* returns size of free space (in bytes) */ |
|---|
| 296 | BPVRlib_Play_BlockMode block /* block mode */ |
|---|
| 297 | ); |
|---|
| 298 | |
|---|
| 299 | /**************************************************************** |
|---|
| 300 | Summary: |
|---|
| 301 | This function updates the write pointer of the ring buffer. |
|---|
| 302 | This function will automatically call the |
|---|
| 303 | BPVRlib_Play_CommitBuffersToHardware() (with the |
|---|
| 304 | block parameter passed through) after the |
|---|
| 305 | write pointer has been updated. |
|---|
| 306 | ****************************************************************/ |
|---|
| 307 | BERR_Code BPVRlib_Play_UpdateWritePointer( |
|---|
| 308 | BPVRlib_Play_Handle playHandle, /* context */ |
|---|
| 309 | size_t bfrSize, /* number of bytes copied into ring buffer */ |
|---|
| 310 | BPVRlib_Play_BlockMode block /* block mode */ |
|---|
| 311 | ); |
|---|
| 312 | |
|---|
| 313 | /**************************************************************** |
|---|
| 314 | Summary: |
|---|
| 315 | This function updates the write pointer of the ring buffer but |
|---|
| 316 | will program the playback hardware to skip the specified number of |
|---|
| 317 | bytes starting at the last ring buffer location returned by |
|---|
| 318 | BPVRlib_Play_AddDataRequest(). The specified bfrSize is |
|---|
| 319 | INCLUSIVE of the skipSize. |
|---|
| 320 | |
|---|
| 321 | This function requires a descriptor to be available so the block |
|---|
| 322 | mode is recommended to be set as |
|---|
| 323 | BPVRlib_Play_BlockMode_eFreeDescriptor. This function is |
|---|
| 324 | usefull when reading blocks of data with specific alignment |
|---|
| 325 | requirements since an extra memory copy is not needed. |
|---|
| 326 | ****************************************************************/ |
|---|
| 327 | BERR_Code BPVRlib_Play_UpdateWritePointerWithSkip( |
|---|
| 328 | BPVRlib_Play_Handle playHandle, /* context */ |
|---|
| 329 | size_t bfrSize, /* number of bytes copied into ring buffer */ |
|---|
| 330 | size_t skipSize, /* number of bytes to skip at the current ring buffer address when programming hardware */ |
|---|
| 331 | BPVRlib_Play_BlockMode block /* block mode */ |
|---|
| 332 | ); |
|---|
| 333 | |
|---|
| 334 | /**************************************************************** |
|---|
| 335 | Summary: |
|---|
| 336 | This function check if descriptors are available |
|---|
| 337 | for loading into the playback hardware. If |
|---|
| 338 | not the function can block until one becomes available. |
|---|
| 339 | Once a descriptor is available, any new data is |
|---|
| 340 | added into the playback hardware. |
|---|
| 341 | If blocking is enabled, this function will not return |
|---|
| 342 | until all data has been committed into hardware. |
|---|
| 343 | ****************************************************************/ |
|---|
| 344 | BERR_Code BPVRlib_Play_CommitBuffersToHardware( |
|---|
| 345 | BPVRlib_Play_Handle playHandle, /* context */ |
|---|
| 346 | BPVRlib_Play_BlockMode block /* block mode */ |
|---|
| 347 | ); |
|---|
| 348 | |
|---|
| 349 | /**************************************************************** |
|---|
| 350 | Summary: |
|---|
| 351 | This function flushes any data currently in the playback ring buffer. |
|---|
| 352 | ****************************************************************/ |
|---|
| 353 | BERR_Code BPVRlib_Play_Flush( |
|---|
| 354 | BPVRlib_Play_Handle playHandle /* context */ |
|---|
| 355 | ); |
|---|
| 356 | |
|---|
| 357 | /**************************************************************** |
|---|
| 358 | Summary: |
|---|
| 359 | This function stops a playback. It also moves all |
|---|
| 360 | descriptors back onto the free list and resets to |
|---|
| 361 | ring buffer to be ready for a new playback. |
|---|
| 362 | ****************************************************************/ |
|---|
| 363 | BERR_Code BPVRlib_Play_Stop( |
|---|
| 364 | BPVRlib_Play_Handle playHandle /* context */ |
|---|
| 365 | ); |
|---|
| 366 | |
|---|
| 367 | /***********************************************************/ /** |
|---|
| 368 | Summary: |
|---|
| 369 | This function returns the number of valid bytes in the |
|---|
| 370 | ring buffer (currently being played back by the hardware). |
|---|
| 371 | ****************************************************************/ |
|---|
| 372 | BERR_Code BPVRlib_Play_GetBufferDepth( |
|---|
| 373 | BPVRlib_Play_Handle playHandle, /* context */ |
|---|
| 374 | size_t *p_bfrDepth /* returns number of valid bytes in the ring buffer */ |
|---|
| 375 | ); |
|---|
| 376 | |
|---|
| 377 | /***********************************************************/ /** |
|---|
| 378 | Summary: |
|---|
| 379 | This function waits for the playback channel to finish. |
|---|
| 380 | Once the playback is done it will return. If the playback |
|---|
| 381 | is stopped or flushed it will return immediately. |
|---|
| 382 | ****************************************************************/ |
|---|
| 383 | BERR_Code BPVRlib_Play_WaitForFinished( |
|---|
| 384 | BPVRlib_Play_Handle playHandle /* context */ |
|---|
| 385 | ); |
|---|
| 386 | |
|---|
| 387 | /***********************************************************/ /** |
|---|
| 388 | Summary: |
|---|
| 389 | This function sets the maximum timeout value allowed when |
|---|
| 390 | waiting for buffer space or descriptors to become available. |
|---|
| 391 | INFINITE is used by default and is the recommended value. |
|---|
| 392 | ****************************************************************/ |
|---|
| 393 | BERR_Code BPVRlib_Play_SetTimeout( |
|---|
| 394 | BPVRlib_Play_Handle playHandle, /* context */ |
|---|
| 395 | uint32_t numMsec /* timeout value in msec */ |
|---|
| 396 | ); |
|---|
| 397 | |
|---|
| 398 | /***********************************************************/ /** |
|---|
| 399 | Summary: |
|---|
| 400 | This function returns the current timeout value |
|---|
| 401 | used when waiting for buffer space or descriptors |
|---|
| 402 | to become available. |
|---|
| 403 | ****************************************************************/ |
|---|
| 404 | BERR_Code BPVRlib_Play_GetTimeout( |
|---|
| 405 | BPVRlib_Play_Handle playHandle, /* context */ |
|---|
| 406 | uint32_t *p_numMsec /* returns current timeout value */ |
|---|
| 407 | ); |
|---|
| 408 | |
|---|
| 409 | /***********************************************************/ /** |
|---|
| 410 | Summary: |
|---|
| 411 | This function returns various playback channel statistics. |
|---|
| 412 | ****************************************************************/ |
|---|
| 413 | BERR_Code BPVRlib_Play_GetStats( |
|---|
| 414 | BPVRlib_Play_Handle playHandle, /* context */ |
|---|
| 415 | BPVRlib_Play_Stats *p_stats /* function fills this structure with statistics */ |
|---|
| 416 | ); |
|---|
| 417 | |
|---|
| 418 | /***********************************************************/ /** |
|---|
| 419 | Summary: |
|---|
| 420 | This function creates a NULL packet. It is created in place starting |
|---|
| 421 | at the location specified. Therefore, the buffer must be at least |
|---|
| 422 | 188 bytes, or memory will be overwritten. |
|---|
| 423 | ****************************************************************/ |
|---|
| 424 | void BPVRlib_Play_GenerateTsNullPacket( |
|---|
| 425 | uint8_t *pkt /* Pointer to buffer that will contain null packet (must be at least 188 bytes) */ |
|---|
| 426 | ); |
|---|
| 427 | |
|---|
| 428 | /***********************************************************/ /** |
|---|
| 429 | Summary: |
|---|
| 430 | This function is an alternate way of adding data to a playback channel |
|---|
| 431 | on a buffer by buffer basis. This allows scatter gather playback |
|---|
| 432 | to be accomplished by loading specified buffers directly into the playback |
|---|
| 433 | channel. |
|---|
| 434 | |
|---|
| 435 | Description: |
|---|
| 436 | The calling code needs to track the number of buffers |
|---|
| 437 | added to playback and use the BPVRlib_Play_IsBufferComplete() function |
|---|
| 438 | to determine when buffers have been completed. Alternatively, |
|---|
| 439 | the numScatGatDesc stat obtained by the BPVRlib_Play_GetStats() |
|---|
| 440 | function can be used to detect when buffers have completed. |
|---|
| 441 | |
|---|
| 442 | Buffers added using this function will be directly accessed by the |
|---|
| 443 | playback hardware. Therefore, buffers must be contiguous and be |
|---|
| 444 | covertable using the BMEM_ConvertAddressToOffset() function. |
|---|
| 445 | This function will not flush the CPU cache (or any other cache |
|---|
| 446 | in the system) so if necessary this should be done before calling |
|---|
| 447 | this function. The calling function cannot reuse the specified |
|---|
| 448 | buffer until playback is done using it. |
|---|
| 449 | |
|---|
| 450 | This function can be called and used at the same time the ring |
|---|
| 451 | buffer is being used. The data will be queued up in the order |
|---|
| 452 | that the various functions were called. |
|---|
| 453 | |
|---|
| 454 | This function requires all data added to the ring buffer to be |
|---|
| 455 | committed to hardware and requires a free descriptor to be |
|---|
| 456 | available. The block parameter can be used to wait for these |
|---|
| 457 | requirements to be satisfied before the function returns. |
|---|
| 458 | ****************************************************************/ |
|---|
| 459 | BERR_Code BPVRlib_Play_AddBuffer( |
|---|
| 460 | BPVRlib_Play_Handle playHandle, /* context handle */ |
|---|
| 461 | const uint8_t *p_bfr, /* pointer to source buffer. must be covertable with the BMEM_ConvertAddressToOffset() function */ |
|---|
| 462 | const size_t bfrSize, /* size of buffer (in bytes) */ |
|---|
| 463 | BPVRlib_Play_BlockMode block /* block mode */ |
|---|
| 464 | ); |
|---|
| 465 | |
|---|
| 466 | /***********************************************************/ /** |
|---|
| 467 | Summary: |
|---|
| 468 | This function is used to detect when scatter gather buffers have |
|---|
| 469 | been completed by the playback hardware since the last call to |
|---|
| 470 | BPVRlib_Play_IsBufferComplete(). |
|---|
| 471 | |
|---|
| 472 | Description: |
|---|
| 473 | After scatter gather buffers have been added to the playback |
|---|
| 474 | channel using the BPVRlib_Play_AddBuffer() this function can |
|---|
| 475 | be used to determine when they have completed. |
|---|
| 476 | |
|---|
| 477 | For example, if two buffers where added, this function would be |
|---|
| 478 | called until both of those buffers were reported complete. |
|---|
| 479 | |
|---|
| 480 | The block parameter can be used to block until one or more buffers |
|---|
| 481 | have been completed. |
|---|
| 482 | ****************************************************************/ |
|---|
| 483 | BERR_Code BPVRlib_Play_IsBufferComplete( |
|---|
| 484 | BPVRlib_Play_Handle playHandle, /* context handle */ |
|---|
| 485 | unsigned *p_bfrsCompleted, /* number of scatter gather buffers completed since last call to BPVRlib_Play_BufferComplete() */ |
|---|
| 486 | BPVRlib_Play_BlockMode block /* block mode */ |
|---|
| 487 | ); |
|---|
| 488 | |
|---|
| 489 | #ifdef __cplusplus |
|---|
| 490 | } |
|---|
| 491 | #endif |
|---|
| 492 | |
|---|
| 493 | #endif |
|---|
| 494 | |
|---|