Changeset 88044 in vbox
- Timestamp:
- Mar 9, 2021 1:18:37 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/pdmaudioifs.h
r88041 r88044 352 352 /** 353 353 * Audio device info (enumeration result). 354 * @sa PDMAUDIO DEVICEENUM, PDMIHOSTAUDIO::pfnGetDevices354 * @sa PDMAUDIOHOSTENUM, PDMIHOSTAUDIO::pfnGetDevices 355 355 */ 356 356 typedef struct PDMAUDIODEVICE 357 357 { 358 /** List entry (like PDMAUDIO DEVICEENUM::LstDevices). */358 /** List entry (like PDMAUDIOHOSTENUM::LstDevices). */ 359 359 RTLISTNODE Node; 360 360 /** Magic value (PDMAUDIODEVICE_MAGIC). */ … … 404 404 405 405 /** 406 * A naudio device enumeration result.406 * A host audio device enumeration result. 407 407 * 408 408 * @sa PDMIHOSTAUDIO::pfnGetDevices 409 409 */ 410 typedef struct PDMAUDIODEVICEENUM 411 { 410 typedef struct PDMAUDIOHOSTENUM 411 { 412 /** Magic value (PDMAUDIOHOSTENUM_MAGIC). */ 413 uint32_t uMagic; 414 /** Number of audio devices in the list. */ 415 uint32_t cDevices; 412 416 /** List of audio devices (PDMAUDIODEVICE). */ 413 417 RTLISTANCHOR LstDevices; 414 /** Number of audio devices in the list. */ 415 uint32_t cDevices; 416 } PDMAUDIODEVICEENUM; 418 } PDMAUDIOHOSTENUM; 417 419 /** Pointer to an audio device enumeration result. */ 418 typedef PDMAUDIO DEVICEENUM *PPDMAUDIODEVICEENUM;420 typedef PDMAUDIOHOSTENUM *PPDMAUDIOHOSTENUM; 419 421 /** Pointer to a const audio device enumeration result. */ 420 typedef PDMAUDIODEVICEENUM const *PCPDMAUDIODEVICEENUM; 422 typedef PDMAUDIOHOSTENUM const *PCPDMAUDIOHOSTENUM; 423 424 /** Magic for the host audio device enumeration. (Herbert Jeffrey "Herbie" Hancock) */ 425 #define PDMAUDIOHOSTENUM_MAGIC UINT32_C(0x19400412) 426 421 427 422 428 /** … … 1652 1658 * @param pDeviceEnum Where to return the enumerated audio devices. 1653 1659 */ 1654 DECLR3CALLBACKMEMBER(int, pfnGetDevices, (PPDMIHOSTAUDIO pInterface, PPDMAUDIO DEVICEENUM pDeviceEnum));1660 DECLR3CALLBACKMEMBER(int, pfnGetDevices, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOHOSTENUM pDeviceEnum)); 1655 1661 1656 1662 /** -
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r88031 r88044 51 51 *********************************************************************************************************************************/ 52 52 #ifdef VBOX_WITH_AUDIO_ENUM 53 static int drvAudioDevicesEnumerateInternal(PDRVAUDIO pThis, bool fLog, PPDMAUDIO DEVICEENUM pDevEnum);53 static int drvAudioDevicesEnumerateInternal(PDRVAUDIO pThis, bool fLog, PPDMAUDIOHOSTENUM pDevEnum); 54 54 #endif 55 55 … … 2153 2153 * @param pDevEnum Where to store the device enumeration. 2154 2154 */ 2155 static int drvAudioDevicesEnumerateInternal(PDRVAUDIO pThis, bool fLog, PPDMAUDIO DEVICEENUM pDevEnum)2155 static int drvAudioDevicesEnumerateInternal(PDRVAUDIO pThis, bool fLog, PPDMAUDIOHOSTENUM pDevEnum) 2156 2156 { 2157 2157 AssertReturn(RTCritSectIsOwned(&pThis->CritSect) == false, VERR_WRONG_ORDER); … … 2164 2164 if (pThis->pHostDrvAudio->pfnGetDevices) 2165 2165 { 2166 PDMAUDIO DEVICEENUM DevEnum;2166 PDMAUDIOHOSTENUM DevEnum; 2167 2167 rc = pThis->pHostDrvAudio->pfnGetDevices(pThis->pHostDrvAudio, &DevEnum); 2168 2168 if (RT_SUCCESS(rc)) … … 2190 2190 2191 2191 if (pDevEnum) 2192 rc = DrvAudioHlpDeviceEnumCopy(pDevEnum, &DevEnum);2193 2194 DrvAudioHlpDeviceEnumFree(&DevEnum);2192 rc = PDMAudioHostEnumCopy(pDevEnum, &DevEnum, PDMAUDIODIR_INVALID /*all*/, true /*fOnlyCoreData*/); 2193 2194 PDMAudioHostEnumDelete(&DevEnum); 2195 2195 } 2196 2196 else -
trunk/src/VBox/Devices/Audio/DrvAudio.h
r88041 r88044 211 211 PPDMAUDIODEVICE PDMAudioDeviceAlloc(size_t cb); 212 212 void PDMAudioDeviceFree(PPDMAUDIODEVICE pDev); 213 PPDMAUDIODEVICE PDMAudioDeviceDup(const PPDMAUDIODEVICE pDev, bool f CopyUserData);213 PPDMAUDIODEVICE PDMAudioDeviceDup(const PPDMAUDIODEVICE pDev, bool fOnlyCoreData); 214 214 /** @} */ 215 215 216 216 /** @name Audio device enumeration methods. 217 217 * @{ */ 218 int DrvAudioHlpDeviceEnumInit(PPDMAUDIODEVICEENUM pDevEnm); 219 void DrvAudioHlpDeviceEnumFree(PPDMAUDIODEVICEENUM pDevEnm); 220 int DrvAudioHlpDeviceEnumAdd(PPDMAUDIODEVICEENUM pDevEnm, PPDMAUDIODEVICE pDev); 221 /*PPDMAUDIODEVICEENUM DrvAudioHlpDeviceEnumDup(const PPDMAUDIODEVICEENUM pDevEnm); - unused */ 222 int DrvAudioHlpDeviceEnumCopy(PPDMAUDIODEVICEENUM pDstDevEnm, PCPDMAUDIODEVICEENUM pSrcDevEnm); 223 int DrvAudioHlpDeviceEnumCopyEx(PPDMAUDIODEVICEENUM pDstDevEnm, PCPDMAUDIODEVICEENUM pSrcDevEnm, PDMAUDIODIR enmUsage, bool fCopyUserData); 224 PPDMAUDIODEVICE DrvAudioHlpDeviceEnumGetDefaultDevice(PCPDMAUDIODEVICEENUM pDevEnm, PDMAUDIODIR enmDir); 225 uint32_t DrvAudioHlpDeviceEnumGetDeviceCount(PCPDMAUDIODEVICEENUM pDevEnm, PDMAUDIODIR enmUsage); 226 void DrvAudioHlpDeviceEnumLog(PCPDMAUDIODEVICEENUM pDevEnm, const char *pszDesc); 218 void PDMAudioHostEnumInit(PPDMAUDIOHOSTENUM pDevEnm); 219 void PDMAudioHostEnumDelete(PPDMAUDIOHOSTENUM pDevEnm); 220 void PDMAudioHostEnumAppend(PPDMAUDIOHOSTENUM pDevEnm, PPDMAUDIODEVICE pDev); 221 int PDMAudioHostEnumCopy(PPDMAUDIOHOSTENUM pDstDevEnm, PCPDMAUDIOHOSTENUM pSrcDevEnm, 222 PDMAUDIODIR enmUsage, bool fOnlyCoreData); 223 PPDMAUDIODEVICE PDMAudioHostEnumGetDefault(PCPDMAUDIOHOSTENUM pDevEnm, PDMAUDIODIR enmDir); 224 uint32_t PDMAudioHostEnumCountMatching(PCPDMAUDIOHOSTENUM pDevEnm, PDMAUDIODIR enmUsage); 225 void PDMAudioHostEnumLog(PCPDMAUDIOHOSTENUM pDevEnm, const char *pszDesc); 227 226 /** @} */ 228 227 -
trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp
r88041 r88044 193 193 * @returns Duplicated audio device entry on success, or NULL on failure. 194 194 * @param pDev The audio device enum entry to duplicate. 195 * @param f CopyUserData Whether to also copy the user data portion or not.196 */ 197 PPDMAUDIODEVICE PDMAudioDeviceDup(PPDMAUDIODEVICE pDev, bool f CopyUserData)195 * @param fOnlyCoreData 196 */ 197 PPDMAUDIODEVICE PDMAudioDeviceDup(PPDMAUDIODEVICE pDev, bool fOnlyCoreData) 198 198 { 199 199 AssertPtrReturn(pDev, NULL); 200 200 Assert(pDev->uMagic == PDMAUDIODEVICE_MAGIC); 201 Assert( !fCopyUserData || !(pDev->fFlags & PDMAUDIODEV_FLAGS_NO_DUP));202 203 uint32_t cbToDup = f CopyUserData ? pDev->cbSelf : sizeof(PDMAUDIODEVICE);201 Assert(fOnlyCoreData || !(pDev->fFlags & PDMAUDIODEV_FLAGS_NO_DUP)); 202 203 uint32_t cbToDup = fOnlyCoreData ? sizeof(PDMAUDIODEVICE) : pDev->cbSelf; 204 204 AssertReturn(cbToDup >= sizeof(*pDev), NULL); 205 205 … … 216 216 217 217 /** 218 * Initializes an audio device enumeration structure. 219 * 220 * @returns IPRT status code. 221 * @param pDevEnm Device enumeration to initialize. 222 */ 223 int DrvAudioHlpDeviceEnumInit(PPDMAUDIODEVICEENUM pDevEnm) 224 { 225 AssertPtrReturn(pDevEnm, VERR_INVALID_POINTER); 226 218 * Initializes a host audio device enumeration. 219 * 220 * @param pDevEnm The enumeration to initialize. 221 */ 222 void PDMAudioHostEnumInit(PPDMAUDIOHOSTENUM pDevEnm) 223 { 224 AssertPtr(pDevEnm); 225 226 pDevEnm->uMagic = PDMAUDIOHOSTENUM_MAGIC; 227 pDevEnm->cDevices = 0; 227 228 RTListInit(&pDevEnm->LstDevices); 228 pDevEnm->cDevices = 0; 229 230 return VINF_SUCCESS; 231 } 232 233 /** 234 * Frees audio device enumeration data. 235 * 236 * @param pDevEnm Device enumeration to destroy. 237 */ 238 void DrvAudioHlpDeviceEnumFree(PPDMAUDIODEVICEENUM pDevEnm) 239 { 240 if (!pDevEnm) 241 return; 242 243 PPDMAUDIODEVICE pDev, pDevNext; 244 RTListForEachSafe(&pDevEnm->LstDevices, pDev, pDevNext, PDMAUDIODEVICE, Node) 245 { 246 RTListNodeRemove(&pDev->Node); 247 248 PDMAudioDeviceFree(pDev); 249 250 pDevEnm->cDevices--; 251 } 252 253 /* Sanity. */ 254 Assert(RTListIsEmpty(&pDevEnm->LstDevices)); 255 Assert(pDevEnm->cDevices == 0); 229 } 230 231 /** 232 * Deletes the host audio device enumeration and frees all device entries 233 * associated with it. 234 * 235 * The user must call PDMAudioHostEnumInit again to use it again. 236 * 237 * @param pDevEnm The host audio device enumeration to delete. 238 */ 239 void PDMAudioHostEnumDelete(PPDMAUDIOHOSTENUM pDevEnm) 240 { 241 if (pDevEnm) 242 { 243 AssertPtr(pDevEnm); 244 AssertReturnVoid(pDevEnm->uMagic == PDMAUDIOHOSTENUM_MAGIC); 245 246 PPDMAUDIODEVICE pDev, pDevNext; 247 RTListForEachSafe(&pDevEnm->LstDevices, pDev, pDevNext, PDMAUDIODEVICE, Node) 248 { 249 RTListNodeRemove(&pDev->Node); 250 251 PDMAudioDeviceFree(pDev); 252 253 pDevEnm->cDevices--; 254 } 255 256 /* Sanity. */ 257 Assert(RTListIsEmpty(&pDevEnm->LstDevices)); 258 Assert(pDevEnm->cDevices == 0); 259 260 pDevEnm->uMagic = ~PDMAUDIOHOSTENUM_MAGIC; 261 } 256 262 } 257 263 … … 259 265 * Adds an audio device to a device enumeration. 260 266 * 261 * @return IPRT status code.262 267 * @param pDevEnm Device enumeration to add device to. 263 268 * @param pDev Device to add. The pointer will be owned by the device enumeration then. 264 269 */ 265 int DrvAudioHlpDeviceEnumAdd(PPDMAUDIODEVICEENUM pDevEnm, PPDMAUDIODEVICE pDev) 266 { 267 AssertPtrReturn(pDevEnm, VERR_INVALID_POINTER); 268 AssertPtrReturn(pDev, VERR_INVALID_POINTER); 270 void PDMAudioHostEnumAppend(PPDMAUDIOHOSTENUM pDevEnm, PPDMAUDIODEVICE pDev) 271 { 272 AssertPtr(pDevEnm); 273 AssertPtr(pDev); 274 Assert(pDevEnm->uMagic == PDMAUDIOHOSTENUM_MAGIC); 269 275 270 276 RTListAppend(&pDevEnm->LstDevices, &pDev->Node); 271 277 pDevEnm->cDevices++; 272 273 return VINF_SUCCESS; 274 } 275 276 #if 0 /* unused, duplicated by copy */ 277 /** 278 * Duplicates a device enumeration. 279 * 280 * @returns Duplicated device enumeration, or NULL on failure. 281 * Must be free'd with DrvAudioHlpDeviceEnumFree(). 282 * @param pDevEnm Device enumeration to duplicate. 283 */ 284 PPDMAUDIODEVICEENUM DrvAudioHlpDeviceEnumDup(const PPDMAUDIODEVICEENUM pDevEnm) 285 { 286 AssertPtrReturn(pDevEnm, NULL); 287 288 PPDMAUDIODEVICEENUM pDevEnmDup = (PPDMAUDIODEVICEENUM)RTMemAlloc(sizeof(PDMAUDIODEVICEENUM)); 289 if (!pDevEnmDup) 290 return NULL; 291 292 int rc2 = DrvAudioHlpDeviceEnumInit(pDevEnmDup); 293 AssertRC(rc2); 294 295 PPDMAUDIODEVICE pDev; 296 RTListForEach(&pDevEnm->LstDevices, pDev, PDMAUDIODEVICE, Node) 297 { 298 PPDMAUDIODEVICE pDevDup = PDMAudioDeviceDup(pDev, true /* fCopyUserData */); 299 if (!pDevDup) 300 { 301 rc2 = VERR_NO_MEMORY; 302 break; 303 } 304 305 rc2 = DrvAudioHlpDeviceEnumAdd(pDevEnmDup, pDevDup); 306 if (RT_FAILURE(rc2)) 307 { 308 PDMAudioDeviceFree(pDevDup); 309 break; 310 } 311 } 312 313 if (RT_FAILURE(rc2)) 314 { 315 DrvAudioHlpDeviceEnumFree(pDevEnmDup); 316 pDevEnmDup = NULL; 317 } 318 319 return pDevEnmDup; 320 } 321 #endif /* unused */ 322 323 /** 324 * Copies device enumeration entries from the source to the destination enumeration. 278 } 279 280 /** 281 * Appends copies of matching host device entries from one to another enumeration. 325 282 * 326 283 * @returns IPRT status code. 327 * @param pDstDevEnm Destination enumeration to store enumeration entries into. 328 * @param pSrcDevEnm Source enumeration to use. 329 * @param enmUsage The usage to match for copying. Use 330 * PDMAUDIODIR_INVALID to match all entries. 331 * @param fCopyUserData Whether to also copy the user data portion or not. 332 */ 333 int DrvAudioHlpDeviceEnumCopyEx(PPDMAUDIODEVICEENUM pDstDevEnm, PCPDMAUDIODEVICEENUM pSrcDevEnm, 334 PDMAUDIODIR enmUsage, bool fCopyUserData) 284 * @param pDstDevEnm The target to append copies of matching device to. 285 * @param pSrcDevEnm The source to copy matching devices from. 286 * @param enmUsage The usage to match for copying. 287 * Use PDMAUDIODIR_INVALID to match all entries. 288 * @param fOnlyCoreData Set this to only copy the PDMAUDIODEVICE part. 289 * Careful with passing @c false here as not all 290 * backends have data that can be copied. 291 */ 292 int PDMAudioHostEnumCopy(PPDMAUDIOHOSTENUM pDstDevEnm, PCPDMAUDIOHOSTENUM pSrcDevEnm, 293 PDMAUDIODIR enmUsage, bool fOnlyCoreData) 335 294 { 336 295 AssertPtrReturn(pDstDevEnm, VERR_INVALID_POINTER); 296 AssertReturn(pDstDevEnm->uMagic == PDMAUDIOHOSTENUM_MAGIC, VERR_WRONG_ORDER); 297 337 298 AssertPtrReturn(pSrcDevEnm, VERR_INVALID_POINTER); 299 AssertReturn(pSrcDevEnm->uMagic == PDMAUDIOHOSTENUM_MAGIC, VERR_WRONG_ORDER); 338 300 339 301 PPDMAUDIODEVICE pSrcDev; … … 343 305 || enmUsage == PDMAUDIODIR_INVALID /*all*/) 344 306 { 345 PPDMAUDIODEVICE pDstDev = PDMAudioDeviceDup(pSrcDev, f CopyUserData);307 PPDMAUDIODEVICE pDstDev = PDMAudioDeviceDup(pSrcDev, fOnlyCoreData); 346 308 AssertReturn(pDstDev, VERR_NO_MEMORY); 347 309 348 int rc = DrvAudioHlpDeviceEnumAdd(pDstDevEnm, pDstDev); 349 AssertRCReturnStmt(rc, PDMAudioDeviceFree(pDstDev), VERR_NO_MEMORY); 310 PDMAudioHostEnumAppend(pDstDevEnm, pDstDev); 350 311 } 351 312 } 352 313 353 314 return VINF_SUCCESS; 354 }355 356 /**357 * Copies all device enumeration entries from the source to the destination enumeration.358 *359 * @note Does *not* copy the user-specific data assigned to a device enumeration360 * entry. To do so, use DrvAudioHlpDeviceEnumCopyEx().361 *362 * @returns IPRT status code.363 * @param pDstDevEnm Destination enumeration to store enumeration entries into.364 * @param pSrcDevEnm Source enumeration to use.365 */366 int DrvAudioHlpDeviceEnumCopy(PPDMAUDIODEVICEENUM pDstDevEnm, PCPDMAUDIODEVICEENUM pSrcDevEnm)367 {368 return DrvAudioHlpDeviceEnumCopyEx(pDstDevEnm, pSrcDevEnm, PDMAUDIODIR_INVALID /*all*/, false /* fCopyUserData */);369 315 } 370 316 … … 381 327 * PDMAUDIODEV_FLAGS_DEFAULT set. 382 328 */ 383 PPDMAUDIODEVICE DrvAudioHlpDeviceEnumGetDefaultDevice(PCPDMAUDIODEVICEENUM pDevEnm, PDMAUDIODIR enmUsage)329 PPDMAUDIODEVICE PDMAudioHostEnumGetDefault(PCPDMAUDIOHOSTENUM pDevEnm, PDMAUDIODIR enmUsage) 384 330 { 385 331 AssertPtrReturn(pDevEnm, NULL); 332 AssertReturn(pDevEnm->uMagic == PDMAUDIOHOSTENUM_MAGIC, NULL); 386 333 387 334 PPDMAUDIODEVICE pDev; … … 391 338 { 392 339 if ( enmUsage == pDev->enmUsage 393 || enmUsage 340 || enmUsage == PDMAUDIODIR_INVALID) 394 341 return pDev; 395 342 } … … 407 354 * Pass PDMAUDIODIR_INVALID to get the total number of devices. 408 355 */ 409 uint32_t DrvAudioHlpDeviceEnumGetDeviceCount(PCPDMAUDIODEVICEENUM pDevEnm, PDMAUDIODIR enmUsage)356 uint32_t PDMAudioHostEnumCountMatching(PCPDMAUDIOHOSTENUM pDevEnm, PDMAUDIODIR enmUsage) 410 357 { 411 358 AssertPtrReturn(pDevEnm, 0); 359 AssertReturn(pDevEnm->uMagic == PDMAUDIOHOSTENUM_MAGIC, 0); 412 360 413 361 if (enmUsage == PDMAUDIODIR_INVALID) … … 431 379 * @param pszDesc Logging description (prefix). 432 380 */ 433 void DrvAudioHlpDeviceEnumLog(PCPDMAUDIODEVICEENUM pDevEnm, const char *pszDesc) 434 { 381 void PDMAudioHostEnumLog(PCPDMAUDIOHOSTENUM pDevEnm, const char *pszDesc) 382 { 383 AssertPtrReturnVoid(pDevEnm); 435 384 AssertPtrReturnVoid(pszDesc); 436 Assert PtrReturnVoid(pDevEnm);385 AssertReturnVoid(pDevEnm->uMagic == PDMAUDIOHOSTENUM_MAGIC); 437 386 438 387 LogFunc(("%s: %RU32 devices\n", pszDesc, pDevEnm->cDevices)); -
trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp
r88042 r88044 100 100 RTCRITSECT CritSect; 101 101 /** Current (last reported) device enumeration. */ 102 PDMAUDIO DEVICEENUM Devices;102 PDMAUDIOHOSTENUM Devices; 103 103 /** Pointer to the currently used input device in the device enumeration. 104 104 * Can be NULL if none assigned. */ … … 487 487 * @param pDevEnm Where to store the enumerated devices. 488 488 */ 489 static int coreAudioDevicesEnumerate(PDRVHOSTCOREAUDIO pThis, PDMAUDIODIR enmUsage, PPDMAUDIO DEVICEENUM pDevEnm)489 static int coreAudioDevicesEnumerate(PDRVHOSTCOREAUDIO pThis, PDMAUDIODIR enmUsage, PPDMAUDIOHOSTENUM pDevEnm) 490 490 { 491 491 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 533 533 break; 534 534 535 rc = DrvAudioHlpDeviceEnumInit(pDevEnm); 536 if (RT_FAILURE(rc)) 537 break; 535 PDMAudioHostEnumInit(pDevEnm); 538 536 539 537 UInt16 cDevices = uSize / sizeof(AudioDeviceID); … … 663 661 664 662 /* Add the device to the enumeration. */ 665 rc = DrvAudioHlpDeviceEnumAdd(pDevEnm, &pDev->Core); 666 if (RT_FAILURE(rc)) 667 break; 663 PDMAudioHostEnumAppend(pDevEnm, &pDev->Core); 668 664 669 665 /* NULL device pointer because it's now part of the device enumeration. */ … … 683 679 #ifdef LOG_ENABLED 684 680 LogFunc(("Devices for pDevEnm=%p, enmUsage=%RU32:\n", pDevEnm, enmUsage)); 685 DrvAudioHlpDeviceEnumLog(pDevEnm, "Core Audio");681 PDMAudioHostEnumLog(pDevEnm, "Core Audio"); 686 682 #endif 687 683 } 688 684 else 689 DrvAudioHlpDeviceEnumFree(pDevEnm);685 PDMAudioHostEnumDelete(pDevEnm); 690 686 691 687 LogFlowFuncLeaveRC(rc); … … 704 700 * @param deviceID Device ID to search. 705 701 */ 706 bool coreAudioDevicesHasDevice(PPDMAUDIO DEVICEENUM pEnmSrc, AudioDeviceID deviceID)702 bool coreAudioDevicesHasDevice(PPDMAUDIOHOSTENUM pEnmSrc, AudioDeviceID deviceID) 707 703 { 708 704 PCOREAUDIODEVICEDATA pDevSrc; … … 725 721 * @param pEnmDst Where to store the device enumeration list. 726 722 */ 727 int coreAudioDevicesEnumerateAll(PDRVHOSTCOREAUDIO pThis, PPDMAUDIO DEVICEENUM pEnmDst)728 { 729 PDMAUDIO DEVICEENUM devEnmIn;723 int coreAudioDevicesEnumerateAll(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOHOSTENUM pEnmDst) 724 { 725 PDMAUDIOHOSTENUM devEnmIn; 730 726 int rc = coreAudioDevicesEnumerate(pThis, PDMAUDIODIR_IN, &devEnmIn); 731 727 if (RT_SUCCESS(rc)) 732 728 { 733 PDMAUDIO DEVICEENUM devEnmOut;729 PDMAUDIOHOSTENUM devEnmOut; 734 730 rc = coreAudioDevicesEnumerate(pThis, PDMAUDIODIR_OUT, &devEnmOut); 735 731 if (RT_SUCCESS(rc)) … … 742 738 * at the same time. 743 739 */ 744 745 rc = DrvAudioHlpDeviceEnumInit(pEnmDst); 740 PDMAudioHostEnumInit(pEnmDst); 741 PCOREAUDIODEVICEDATA pDevSrcIn; 742 RTListForEach(&devEnmIn.LstDevices, pDevSrcIn, COREAUDIODEVICEDATA, Core.Node) 743 { 744 PCOREAUDIODEVICEDATA pDevDst = (PCOREAUDIODEVICEDATA)PDMAudioDeviceAlloc(sizeof(*pDevDst)); 745 if (!pDevDst) 746 { 747 rc = VERR_NO_MEMORY; 748 break; 749 } 750 751 coreAudioDeviceDataInit(pDevDst, pDevSrcIn->deviceID, true /* fIsInput */, pThis); 752 753 RTStrCopy(pDevDst->Core.szName, sizeof(pDevDst->Core.szName), pDevSrcIn->Core.szName); 754 755 pDevDst->Core.enmUsage = PDMAUDIODIR_IN; /* Input device by default (simplex). */ 756 pDevDst->Core.cMaxInputChannels = pDevSrcIn->Core.cMaxInputChannels; 757 758 /* Handle flags. */ 759 if (pDevSrcIn->Core.fFlags & PDMAUDIODEV_FLAGS_DEFAULT) 760 pDevDst->Core.fFlags |= PDMAUDIODEV_FLAGS_DEFAULT; 761 /** @todo Handle hot plugging? */ 762 763 /* 764 * Now search through the list of all found output devices and check if we found 765 * an output device with the same device ID as the currently handled input device. 766 * 767 * If found, this means we have to treat that device as a duplex device then. 768 */ 769 PCOREAUDIODEVICEDATA pDevSrcOut; 770 RTListForEach(&devEnmOut.LstDevices, pDevSrcOut, COREAUDIODEVICEDATA, Core.Node) 771 { 772 if (pDevSrcIn->deviceID == pDevSrcOut->deviceID) 773 { 774 pDevDst->Core.enmUsage = PDMAUDIODIR_DUPLEX; 775 pDevDst->Core.cMaxOutputChannels = pDevSrcOut->Core.cMaxOutputChannels; 776 777 if (pDevSrcOut->Core.fFlags & PDMAUDIODEV_FLAGS_DEFAULT) 778 pDevDst->Core.fFlags |= PDMAUDIODEV_FLAGS_DEFAULT; 779 break; 780 } 781 } 782 783 if (RT_SUCCESS(rc)) 784 PDMAudioHostEnumAppend(pEnmDst, &pDevDst->Core); 785 else 786 { 787 PDMAudioDeviceFree(&pDevDst->Core); 788 pDevDst = NULL; 789 } 790 } 791 746 792 if (RT_SUCCESS(rc)) 747 793 { 748 PCOREAUDIODEVICEDATA pDevSrcIn; 749 RTListForEach(&devEnmIn.LstDevices, pDevSrcIn, COREAUDIODEVICEDATA, Core.Node) 794 /* 795 * As a last step, add all remaining output devices which have not been handled in the loop above, 796 * that is, all output devices which operate in simplex mode. 797 */ 798 PCOREAUDIODEVICEDATA pDevSrcOut; 799 RTListForEach(&devEnmOut.LstDevices, pDevSrcOut, COREAUDIODEVICEDATA, Core.Node) 750 800 { 801 if (coreAudioDevicesHasDevice(pEnmDst, pDevSrcOut->deviceID)) 802 continue; /* Already in our list, skip. */ 803 751 804 PCOREAUDIODEVICEDATA pDevDst = (PCOREAUDIODEVICEDATA)PDMAudioDeviceAlloc(sizeof(*pDevDst)); 752 805 if (!pDevDst) … … 756 809 } 757 810 758 coreAudioDeviceDataInit(pDevDst, pDevSrcIn->deviceID, true /* fIsInput */, pThis); 759 760 RTStrCopy(pDevDst->Core.szName, sizeof(pDevDst->Core.szName), pDevSrcIn->Core.szName); 761 762 pDevDst->Core.enmUsage = PDMAUDIODIR_IN; /* Input device by default (simplex). */ 763 pDevDst->Core.cMaxInputChannels = pDevSrcIn->Core.cMaxInputChannels; 811 coreAudioDeviceDataInit(pDevDst, pDevSrcOut->deviceID, false /* fIsInput */, pThis); 812 813 RTStrCopy(pDevDst->Core.szName, sizeof(pDevDst->Core.szName), pDevSrcOut->Core.szName); 814 815 pDevDst->Core.enmUsage = PDMAUDIODIR_OUT; 816 pDevDst->Core.cMaxOutputChannels = pDevSrcOut->Core.cMaxOutputChannels; 817 818 pDevDst->deviceID = pDevSrcOut->deviceID; 764 819 765 820 /* Handle flags. */ 766 if (pDevSrc In->Core.fFlags & PDMAUDIODEV_FLAGS_DEFAULT)821 if (pDevSrcOut->Core.fFlags & PDMAUDIODEV_FLAGS_DEFAULT) 767 822 pDevDst->Core.fFlags |= PDMAUDIODEV_FLAGS_DEFAULT; 768 823 /** @todo Handle hot plugging? */ 769 824 770 /* 771 * Now search through the list of all found output devices and check if we found 772 * an output device with the same device ID as the currently handled input device. 773 * 774 * If found, this means we have to treat that device as a duplex device then. 775 */ 776 PCOREAUDIODEVICEDATA pDevSrcOut; 777 RTListForEach(&devEnmOut.LstDevices, pDevSrcOut, COREAUDIODEVICEDATA, Core.Node) 778 { 779 if (pDevSrcIn->deviceID == pDevSrcOut->deviceID) 780 { 781 pDevDst->Core.enmUsage = PDMAUDIODIR_DUPLEX; 782 pDevDst->Core.cMaxOutputChannels = pDevSrcOut->Core.cMaxOutputChannels; 783 784 if (pDevSrcOut->Core.fFlags & PDMAUDIODEV_FLAGS_DEFAULT) 785 pDevDst->Core.fFlags |= PDMAUDIODEV_FLAGS_DEFAULT; 786 break; 787 } 788 } 789 790 if (RT_SUCCESS(rc)) 791 rc = DrvAudioHlpDeviceEnumAdd(pEnmDst, &pDevDst->Core); 792 else 793 { 794 PDMAudioDeviceFree(&pDevDst->Core); 795 pDevDst = NULL; 796 } 825 PDMAudioHostEnumAppend(pEnmDst, &pDevDst->Core); 797 826 } 798 799 if (RT_SUCCESS(rc))800 {801 /*802 * As a last step, add all remaining output devices which have not been handled in the loop above,803 * that is, all output devices which operate in simplex mode.804 */805 PCOREAUDIODEVICEDATA pDevSrcOut;806 RTListForEach(&devEnmOut.LstDevices, pDevSrcOut, COREAUDIODEVICEDATA, Core.Node)807 {808 if (coreAudioDevicesHasDevice(pEnmDst, pDevSrcOut->deviceID))809 continue; /* Already in our list, skip. */810 811 PCOREAUDIODEVICEDATA pDevDst = (PCOREAUDIODEVICEDATA)PDMAudioDeviceAlloc(sizeof(*pDevDst));812 if (!pDevDst)813 {814 rc = VERR_NO_MEMORY;815 break;816 }817 818 coreAudioDeviceDataInit(pDevDst, pDevSrcOut->deviceID, false /* fIsInput */, pThis);819 820 RTStrCopy(pDevDst->Core.szName, sizeof(pDevDst->Core.szName), pDevSrcOut->Core.szName);821 822 pDevDst->Core.enmUsage = PDMAUDIODIR_OUT;823 pDevDst->Core.cMaxOutputChannels = pDevSrcOut->Core.cMaxOutputChannels;824 825 pDevDst->deviceID = pDevSrcOut->deviceID;826 827 /* Handle flags. */828 if (pDevSrcOut->Core.fFlags & PDMAUDIODEV_FLAGS_DEFAULT)829 pDevDst->Core.fFlags |= PDMAUDIODEV_FLAGS_DEFAULT;830 /** @todo Handle hot plugging? */831 832 rc = DrvAudioHlpDeviceEnumAdd(pEnmDst, &pDevDst->Core);833 if (RT_FAILURE(rc))834 {835 PDMAudioDeviceFree(&pDevDst->Core);836 break;837 }838 }839 }840 841 if (RT_FAILURE(rc))842 DrvAudioHlpDeviceEnumFree(pEnmDst);843 827 } 844 828 845 DrvAudioHlpDeviceEnumFree(&devEnmOut); 846 } 847 848 DrvAudioHlpDeviceEnumFree(&devEnmIn); 829 if (RT_FAILURE(rc)) 830 PDMAudioHostEnumDelete(pEnmDst); 831 832 PDMAudioHostEnumDelete(&devEnmOut); 833 } 834 835 PDMAudioHostEnumDelete(&devEnmIn); 849 836 } 850 837 851 838 #ifdef LOG_ENABLED 852 839 if (RT_SUCCESS(rc)) 853 DrvAudioHlpDeviceEnumLog(pEnmDst, "Core Audio (Final)");840 PDMAudioHostEnumLog(pEnmDst, "Core Audio (Final)"); 854 841 #endif 855 842 … … 1841 1828 1842 1829 /* Remove old / stale device entries. */ 1843 DrvAudioHlpDeviceEnumFree(&pThis->Devices);1830 PDMAudioHostEnumDelete(&pThis->Devices); 1844 1831 1845 1832 /* Enumerate all devices internally. */ … … 1850 1837 * Default input device. 1851 1838 */ 1852 pThis->pDefaultDevIn = (PCOREAUDIODEVICEDATA) DrvAudioHlpDeviceEnumGetDefaultDevice(&pThis->Devices, PDMAUDIODIR_IN);1839 pThis->pDefaultDevIn = (PCOREAUDIODEVICEDATA)PDMAudioHostEnumGetDefault(&pThis->Devices, PDMAUDIODIR_IN); 1853 1840 if (pThis->pDefaultDevIn) 1854 1841 { … … 1863 1850 * Default output device. 1864 1851 */ 1865 pThis->pDefaultDevOut = (PCOREAUDIODEVICEDATA) DrvAudioHlpDeviceEnumGetDefaultDevice(&pThis->Devices, PDMAUDIODIR_OUT);1852 pThis->pDefaultDevOut = (PCOREAUDIODEVICEDATA)PDMAudioHostEnumGetDefault(&pThis->Devices, PDMAUDIODIR_OUT); 1866 1853 if (pThis->pDefaultDevOut) 1867 1854 { … … 2167 2154 2168 2155 /* For Core Audio we provide one stream per device for now. */ 2169 pBackendCfg->cMaxStreamsIn = DrvAudioHlpDeviceEnumGetDeviceCount(&pThis->Devices, PDMAUDIODIR_IN);2170 pBackendCfg->cMaxStreamsOut = DrvAudioHlpDeviceEnumGetDeviceCount(&pThis->Devices, PDMAUDIODIR_OUT);2156 pBackendCfg->cMaxStreamsIn = PDMAudioHostEnumCountMatching(&pThis->Devices, PDMAUDIODIR_IN); 2157 pBackendCfg->cMaxStreamsOut = PDMAudioHostEnumCountMatching(&pThis->Devices, PDMAUDIODIR_OUT); 2171 2158 2172 2159 LogFlowFunc(("Returning %Rrc\n", VINF_SUCCESS)); … … 2178 2165 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetDevices} 2179 2166 */ 2180 static DECLCALLBACK(int) drvHostCoreAudioHA_GetDevices(PPDMIHOSTAUDIO pInterface, PPDMAUDIO DEVICEENUM pDeviceEnum)2167 static DECLCALLBACK(int) drvHostCoreAudioHA_GetDevices(PPDMIHOSTAUDIO pInterface, PPDMAUDIOHOSTENUM pDeviceEnum) 2181 2168 { 2182 2169 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 2194 2181 { 2195 2182 /* Return a copy with only PDMAUDIODEVICE, none of the extra bits in COREAUDIODEVICEDATA. */ 2196 rc = DrvAudioHlpDeviceEnumInit(pDeviceEnum); 2197 if (RT_SUCCESS(rc)) 2198 rc = DrvAudioHlpDeviceEnumCopy(pDeviceEnum, &pThis->Devices); 2199 2183 PDMAudioHostEnumInit(pDeviceEnum); 2184 rc = PDMAudioHostEnumCopy(pDeviceEnum, &pThis->Devices, PDMAUDIODIR_INVALID /*all*/, true /*fOnlyCoreData*/); 2200 2185 if (RT_FAILURE(rc)) 2201 DrvAudioHlpDeviceEnumFree(pDeviceEnum);2186 PDMAudioHostEnumDelete(pDeviceEnum); 2202 2187 } 2203 2188 } … … 2497 2482 PDRVHOSTCOREAUDIO pThis = PDMIHOSTAUDIO_2_DRVHOSTCOREAUDIO(pInterface); 2498 2483 2499 int rc = DrvAudioHlpDeviceEnumInit(&pThis->Devices); 2500 if (RT_SUCCESS(rc)) 2501 { 2502 /* Do the first (initial) internal device enumeration. */ 2503 rc = coreAudioEnumerateDevices(pThis); 2504 } 2505 2484 PDMAudioHostEnumInit(&pThis->Devices); 2485 /* Do the first (initial) internal device enumeration. */ 2486 int rc = coreAudioEnumerateDevices(pThis); 2506 2487 if (RT_SUCCESS(rc)) 2507 2488 { -
trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp
r88041 r88044 200 200 uint32_t fFlags; 201 201 /** Pointer to device list to populate. */ 202 PPDMAUDIO DEVICEENUM pDevEnm;202 PPDMAUDIOHOSTENUM pDevEnm; 203 203 } DSOUNDENUMCBCTX, *PDSOUNDENUMCBCTX; 204 204 … … 214 214 DSOUNDHOSTCFG Cfg; 215 215 /** List of devices of last enumeration. */ 216 PDMAUDIO DEVICEENUM DeviceEnum;216 PDMAUDIOHOSTENUM DeviceEnum; 217 217 /** Whether this backend supports any audio input. */ 218 218 bool fEnabledIn; … … 246 246 static HRESULT directSoundCaptureStop(PDRVHOSTDSOUND pThis, PDSOUNDSTREAM pStreamDS, bool fFlush); 247 247 248 static int dsoundDevicesEnumerate(PDRVHOSTDSOUND pThis, PDMAUDIO DEVICEENUM pDevEnm, uint32_t fEnum);248 static int dsoundDevicesEnumerate(PDRVHOSTDSOUND pThis, PDMAUDIOHOSTENUM pDevEnm, uint32_t fEnum); 249 249 250 250 static int dsoundStreamEnable(PDRVHOSTDSOUND pThis, PDSOUNDSTREAM pStreamDS, bool fEnable); … … 1577 1577 AssertPtrReturn(pEnumCtx , FALSE); 1578 1578 1579 PPDMAUDIO DEVICEENUM pDevEnm = pEnumCtx->pDevEnm;1579 PPDMAUDIOHOSTENUM pDevEnm = pEnumCtx->pDevEnm; 1580 1580 AssertPtrReturn(pDevEnm, FALSE); 1581 1581 … … 1604 1604 memcpy(&pDev->Guid, pGUID, sizeof(pDev->Guid)); 1605 1605 1606 rc = DrvAudioHlpDeviceEnumAdd(pDevEnm, &pDev->Core); 1607 if (RT_SUCCESS(rc)) 1608 { 1609 /* Note: Querying the actual device information will be done at some 1610 * later point in time outside this enumeration callback to prevent 1611 * DSound hangs. */ 1612 return TRUE; 1613 } 1606 PDMAudioHostEnumAppend(pDevEnm, &pDev->Core); 1607 1608 /* Note: Querying the actual device information will be done at some 1609 * later point in time outside this enumeration callback to prevent 1610 * DSound hangs. */ 1611 return TRUE; 1614 1612 } 1615 1613 PDMAudioDeviceFree(&pDev->Core); … … 1638 1636 AssertPtrReturn(pEnumCtx , FALSE); 1639 1637 1640 PPDMAUDIO DEVICEENUM pDevEnm = pEnumCtx->pDevEnm;1638 PPDMAUDIOHOSTENUM pDevEnm = pEnumCtx->pDevEnm; 1641 1639 AssertPtrReturn(pDevEnm, FALSE); 1642 1640 … … 1662 1660 memcpy(&pDev->Guid, pGUID, sizeof(pDev->Guid)); 1663 1661 1664 rc = DrvAudioHlpDeviceEnumAdd(pDevEnm, &pDev->Core); 1665 if (RT_SUCCESS(rc)) 1666 { 1667 /* Note: Querying the actual device information will be done at some 1668 * later point in time outside this enumeration callback to prevent 1669 * DSound hangs. */ 1670 return TRUE; 1671 } 1662 PDMAudioHostEnumAppend(pDevEnm, &pDev->Core); 1663 1664 /* Note: Querying the actual device information will be done at some 1665 * later point in time outside this enumeration callback to prevent 1666 * DSound hangs. */ 1667 return TRUE; 1672 1668 } 1673 1669 PDMAudioDeviceFree(&pDev->Core); … … 1787 1783 * @param pDevEnm Where to store the enumerated devices. 1788 1784 */ 1789 static int dsoundDevicesEnumerate(PDRVHOSTDSOUND pThis, PPDMAUDIO DEVICEENUM pDevEnm)1785 static int dsoundDevicesEnumerate(PDRVHOSTDSOUND pThis, PPDMAUDIOHOSTENUM pDevEnm) 1790 1786 { 1791 1787 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 1880 1876 } 1881 1877 #endif 1882 pThis->fEnabledIn = DrvAudioHlpDeviceEnumGetDeviceCount(&pThis->DeviceEnum, PDMAUDIODIR_IN) != 0;1883 pThis->fEnabledOut = DrvAudioHlpDeviceEnumGetDeviceCount(&pThis->DeviceEnum, PDMAUDIODIR_OUT) != 0;1878 pThis->fEnabledIn = PDMAudioHostEnumCountMatching(&pThis->DeviceEnum, PDMAUDIODIR_IN) != 0; 1879 pThis->fEnabledOut = PDMAudioHostEnumCountMatching(&pThis->DeviceEnum, PDMAUDIODIR_OUT) != 0; 1884 1880 } 1885 1881 … … 2234 2230 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetDevices} 2235 2231 */ 2236 static DECLCALLBACK(int) drvHostDSoundHA_GetDevices(PPDMIHOSTAUDIO pInterface, PPDMAUDIO DEVICEENUM pDeviceEnum)2232 static DECLCALLBACK(int) drvHostDSoundHA_GetDevices(PPDMIHOSTAUDIO pInterface, PPDMAUDIOHOSTENUM pDeviceEnum) 2237 2233 { 2238 2234 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 2244 2240 if (RT_SUCCESS(rc)) 2245 2241 { 2246 rc = DrvAudioHlpDeviceEnumInit(pDeviceEnum); 2247 if (RT_SUCCESS(rc)) 2248 { 2249 rc = dsoundDevicesEnumerate(pThis, pDeviceEnum); 2250 if (RT_FAILURE(rc)) 2251 DrvAudioHlpDeviceEnumFree(pDeviceEnum); 2252 } 2242 PDMAudioHostEnumInit(pDeviceEnum); 2243 rc = dsoundDevicesEnumerate(pThis, pDeviceEnum); 2244 if (RT_FAILURE(rc)) 2245 PDMAudioHostEnumDelete(pDeviceEnum); 2253 2246 2254 2247 int rc2 = RTCritSectLeave(&pThis->CritSect); … … 2630 2623 #endif 2631 2624 2632 DrvAudioHlpDeviceEnumFree(&pThis->DeviceEnum);2625 PDMAudioHostEnumDelete(&pThis->DeviceEnum); 2633 2626 2634 2627 if (pThis->pDrvIns) … … 2697 2690 * Init the static parts. 2698 2691 */ 2699 DrvAudioHlpDeviceEnumInit(&pThis->DeviceEnum);2692 PDMAudioHostEnumInit(&pThis->DeviceEnum); 2700 2693 2701 2694 pThis->fEnabledIn = false;
Note:
See TracChangeset
for help on using the changeset viewer.