- Timestamp:
- Jul 27, 2016 4:31:50 PM (8 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r62585 r62605 61 61 62 62 63 /** 64 * Creates an audio sink and attaches it to the given mixer. 65 * 66 * @returns IPRT status code. 67 * @param pMixer Mixer to attach created sink to. 68 * @param pszName Name of the sink to create. 69 * @param enmDir Direction of the sink to create. 70 * @param ppSink Pointer which returns the created sink on success. 71 */ 63 72 int AudioMixerCreateSink(PAUDIOMIXER pMixer, const char *pszName, AUDMIXSINKDIR enmDir, PAUDMIXSINK *ppSink) 64 73 { … … 110 119 } 111 120 112 int AudioMixerCreate(const char *pszName, uint32_t uFlags, PAUDIOMIXER *ppMixer) 121 /** 122 * Creates an audio mixer. 123 * 124 * @returns IPRT status code. 125 * @param pszName Name of the audio mixer. 126 * @param fFlags Creation flags. Not used at the moment and must be 0. 127 * @param ppMixer Pointer which returns the created mixer object. 128 */ 129 int AudioMixerCreate(const char *pszName, uint32_t fFlags, PAUDIOMIXER *ppMixer) 113 130 { 114 131 AssertPtrReturn(pszName, VERR_INVALID_POINTER); 115 /** @todo Add f lagvalidation. */132 /** @todo Add fFlags validation. */ 116 133 AssertPtrReturn(ppMixer, VERR_INVALID_POINTER); 117 134 … … 149 166 } 150 167 168 /** 169 * Helper function for the internal debugger to print the mixer's current 170 * state, along with the attached sinks. 171 * 172 * @param pMixer Mixer to print debug output for. 173 * @param pHlp Debug info helper to use. 174 * @param pszArgs Optional arguments. Not being used at the moment. 175 */ 151 176 void AudioMixerDebug(PAUDIOMIXER pMixer, PCDBGFINFOHLP pHlp, const char *pszArgs) 152 177 { … … 165 190 } 166 191 192 /** 193 * Destroys an audio mixer. 194 * 195 * @param pMixer Audio mixer to destroy. 196 */ 167 197 void AudioMixerDestroy(PAUDIOMIXER pMixer) 168 198 { … … 195 225 } 196 226 197 int AudioMixerGetDeviceFormat(PAUDIOMIXER pMixer, PPDMAUDIOSTREAMCFG pCfg) 198 { 199 AssertPtrReturn(pMixer, VERR_INVALID_POINTER); 200 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 201 202 /** @todo Perform a deep copy, if needed. */ 203 *pCfg = pMixer->devFmt; 204 205 return VINF_SUCCESS; 206 } 207 227 /** 228 * Invalidates all internal data, internal version. 229 * 230 * @returns IPRT status code. 231 * @param pMixer Mixer to invalidate data for. 232 */ 208 233 int audioMixerInvalidateInternal(PAUDIOMIXER pMixer) 209 234 { … … 223 248 } 224 249 250 /** 251 * Invalidates all internal data. 252 * 253 * @returns IPRT status code. 254 * @param pMixer Mixer to invalidate data for. 255 */ 225 256 void AudioMixerInvalidate(PAUDIOMIXER pMixer) 226 257 { … … 233 264 } 234 265 266 /** 267 * Removes a formerly attached audio sink for an audio mixer, internal version. 268 * 269 * @returns IPRT status code. 270 * @param pMixer Mixer to remove sink from. 271 * @param pSink Sink to remove. 272 */ 235 273 static int audioMixerRemoveSinkInternal(PAUDIOMIXER pMixer, PAUDMIXSINK pSink) 236 274 { … … 256 294 } 257 295 296 /** 297 * Removes a formerly attached audio sink for an audio mixer. 298 * 299 * @returns IPRT status code. 300 * @param pMixer Mixer to remove sink from. 301 * @param pSink Sink to remove. 302 */ 303 258 304 void AudioMixerRemoveSink(PAUDIOMIXER pMixer, PAUDMIXSINK pSink) 259 305 { 260 306 audioMixerSinkRemoveAllStreamsInternal(pSink); 261 307 audioMixerRemoveSinkInternal(pMixer, pSink); 262 }263 264 int AudioMixerSetDeviceFormat(PAUDIOMIXER pMixer, PPDMAUDIOSTREAMCFG pCfg)265 {266 AssertPtrReturn(pMixer, VERR_INVALID_POINTER);267 AssertPtrReturn(pCfg, VERR_INVALID_POINTER);268 269 /** @todo Perform a deep copy, if needed. */270 pMixer->devFmt = *pCfg;271 272 return VINF_SUCCESS;273 308 } 274 309 … … 298 333 ********************************************************************************************************************************/ 299 334 335 /** 336 * Adds an audio stream to a specific audio sink. 337 * 338 * @returns IPRT status code. 339 * @param pSink Sink to add audio stream to. 340 * @param pStream Stream to add. 341 */ 300 342 int AudioMixerSinkAddStream(PAUDMIXSINK pSink, PAUDMIXSTREAM pStream) 301 343 { … … 384 426 } 385 427 428 /** 429 * Creates an audio mixer stream. 430 * 431 * @returns IPRT status code. 432 * @param pSink Sink to use for creating the stream. 433 * @param pConn Audio connector interface to use. 434 * @param pCfg Audio stream configuration to use. 435 * @param fFlags Stream creation flags. Currently unused, set to 0. 436 * @param ppStream Pointer which receives the the newly created audio stream. 437 */ 386 438 int AudioMixerSinkCreateStream(PAUDMIXSINK pSink, 387 439 PPDMIAUDIOCONNECTOR pConn, PPDMAUDIOSTREAMCFG pCfg, uint32_t fFlags, PAUDMIXSTREAM *ppStream) … … 465 517 } 466 518 519 /** 520 * Static helper function to translate a sink command 521 * to a PDM audio stream command. 522 * 523 * @returns PDM audio stream command, or PDMAUDIOSTREAMCMD_UNKNOWN if not found. 524 * @param enmCmd Mixer sink command to translate. 525 */ 467 526 static PDMAUDIOSTREAMCMD audioMixerSinkToStreamCmd(AUDMIXSINKCMD enmCmd) 468 527 { … … 480 539 } 481 540 541 /** 542 * Controls a mixer sink. 543 * 544 * @returns IPRT status code. 545 * @param pSink Mixer sink to control. 546 * @param enmSinkCmd Sink command to set. 547 */ 482 548 int AudioMixerSinkCtl(PAUDMIXSINK pSink, AUDMIXSINKCMD enmSinkCmd) 483 549 { … … 518 584 } 519 585 586 /** 587 * Destroys a mixer sink and removes it from the attached mixer (if any). 588 * 589 * @param pSink Mixer sink to destroy. 590 */ 520 591 void AudioMixerSinkDestroy(PAUDMIXSINK pSink) 521 592 { … … 538 609 } 539 610 611 /** 612 * Destroys a mixer sink. 613 * 614 * @param pSink Mixer sink to destroy. 615 */ 540 616 static void audioMixerSinkDestroyInternal(PAUDMIXSINK pSink) 541 617 { … … 570 646 * 571 647 * @returns Amount of bytes ready to be read from the sink. 572 * @param pSink Sink to return number of available samples for.648 * @param pSink Sink to return number of available samples for. 573 649 */ 574 650 uint32_t AudioMixerSinkGetReadable(PAUDMIXSINK pSink) … … 591 667 * 592 668 * @returns Amount of bytes ready to be written to the sink. 593 * @param pSink Sink to return number of available samples for.669 * @param pSink Sink to return number of available samples for. 594 670 */ 595 671 uint32_t AudioMixerSinkGetWritable(PAUDMIXSINK pSink) … … 611 687 * 612 688 * @returns Mixing direction. 613 * @param pSink Sink to return direction for. 614 * 615 * @remark 689 * @param pSink Sink to return direction for. 616 690 */ 617 691 AUDMIXSINKDIR AudioMixerSinkGetDir(PAUDMIXSINK pSink) … … 621 695 } 622 696 697 /** 698 * Returns a specific mixer stream from a sink, based on its index. 699 * 700 * @returns Mixer stream if found, or NULL if not found. 701 * @param pSink Sink to retrieve mixer stream from. 702 * @param uIndex Index of the mixer stream to return. 703 */ 623 704 PAUDMIXSTREAM AudioMixerSinkGetStream(PAUDMIXSINK pSink, uint8_t uIndex) 624 705 { … … 639 720 } 640 721 722 /** 723 * Returns the current status of a mixer sink. 724 * 725 * @returns IPRT status code. 726 * @param pSink Mixer sink to return status for. 727 */ 641 728 AUDMIXSINKSTS AudioMixerSinkGetStatus(PAUDMIXSINK pSink) 642 729 { … … 650 737 } 651 738 739 /** 740 * Returns the number of attached mixer streams to a mixer sink. 741 * 742 * @returns IPRT status code. 743 * @param pSink Mixer sink to return number for. 744 */ 652 745 uint8_t AudioMixerSinkGetStreamCount(PAUDMIXSINK pSink) 653 746 { … … 658 751 } 659 752 753 /** 754 * Reads audio data from a mixer sink. 755 * 756 * @returns IPRT status code. 757 * @param pSink Mixer sink to read data from. 758 * @param enmOp Mixer operation to use for reading the data. 759 * @param pvBuf Buffer where to store the read data. 760 * @param cbBuf Buffer size (in bytes) where to store the data. 761 * @param pcbRead Number of bytes read. Optional. 762 */ 660 763 int AudioMixerSinkRead(PAUDMIXSINK pSink, AUDMIXOP enmOp, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead) 661 764 { … … 744 847 } 745 848 849 /** 850 * Removes a mixer stream from a mixer sink, internal version. 851 * 852 * @returns IPRT status code. 853 * @param pSink Sink to remove mixer stream from. 854 * @param pStream Stream to remove. 855 */ 746 856 static int audioMixerSinkRemoveStreamInternal(PAUDMIXSINK pSink, PAUDMIXSTREAM pStream) 747 857 { … … 773 883 } 774 884 885 /** 886 * Removes a mixer stream from a mixer sink. 887 * 888 * @param pSink Sink to remove mixer stream from. 889 * @param pStream Stream to remove. 890 */ 775 891 void AudioMixerSinkRemoveStream(PAUDMIXSINK pSink, PAUDMIXSTREAM pStream) 776 892 { … … 851 967 } 852 968 969 /** 970 * Sets the audio format of a mixer sink. 971 * 972 * @returns IPRT status code. 973 * @param pSink Sink to set audio format for. 974 * @param pPCMProps Audio format (PCM properties) to set. 975 */ 853 976 int AudioMixerSinkSetFormat(PAUDMIXSINK pSink, PPDMPCMPROPS pPCMProps) 854 977 { … … 909 1032 } 910 1033 1034 /** 1035 * Updates a mixer sink, internal version. 1036 * 1037 * @returns IPRT status code. 1038 * @param pSink Mixer sink to update. 1039 */ 911 1040 static int audioMixerSinkUpdateInternal(PAUDMIXSINK pSink) 912 1041 { … … 1053 1182 } 1054 1183 1184 /** 1185 * Updates (invalidates) a mixer sink. 1186 * 1187 * @returns IPRT status code. 1188 * @param pSink Mixer sink to update. 1189 */ 1055 1190 int AudioMixerSinkUpdate(PAUDMIXSINK pSink) 1056 1191 { … … 1069 1204 } 1070 1205 1206 /** 1207 * Updates the (master) volume of a mixer sink. 1208 * 1209 * @returns IPRT status code. 1210 * @param pSink Mixer sink to update volume for. 1211 * @param pVolMaster Master volume to set. 1212 */ 1071 1213 static int audioMixerSinkUpdateVolume(PAUDMIXSINK pSink, const PPDMAUDIOVOLUME pVolMaster) 1072 1214 { … … 1103 1245 } 1104 1246 1247 /** 1248 * Writes data to a mixer sink. 1249 * 1250 * @returns IPRT status code. 1251 * @param pSink Sink to write data to. 1252 * @param enmOp Mixer operation to use when writing data to the sink. 1253 * @param pvBuf Buffer containing the audio data to write. 1254 * @param cbBuf Size (in bytes) of the buffer containing the audio data. 1255 * @param pcbWritten Number of bytes written. Optional. 1256 */ 1105 1257 int AudioMixerSinkWrite(PAUDMIXSINK pSink, AUDMIXOP enmOp, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten) 1106 1258 { … … 1158 1310 ********************************************************************************************************************************/ 1159 1311 1312 /** 1313 * Controls a mixer stream. 1314 * 1315 * @returns IPRT status code. 1316 * @param pMixStream Mixer stream to control. 1317 * @param enmCmd Mixer stream command to use. 1318 * @param fCtl Additional control flags. Pass 0. 1319 */ 1160 1320 int AudioMixerStreamCtl(PAUDMIXSTREAM pMixStream, PDMAUDIOSTREAMCMD enmCmd, uint32_t fCtl) 1161 1321 { … … 1168 1328 } 1169 1329 1330 /** 1331 * Destroys a mixer stream, internal version. 1332 * 1333 * @param pMixStream Mixer stream to destroy. 1334 */ 1170 1335 static void audioMixerStreamDestroyInternal(PAUDMIXSTREAM pMixStream) 1171 1336 { … … 1197 1362 } 1198 1363 1364 /** 1365 * Destroys a mixer stream. 1366 * 1367 * @param pMixStream Mixer stream to destroy. 1368 */ 1199 1369 void AudioMixerStreamDestroy(PAUDMIXSTREAM pMixStream) 1200 1370 { … … 1228 1398 } 1229 1399 1400 /** 1401 * Returns whether a mixer stream currently is active (playing/recording) or not. 1402 * 1403 * @returns @true if playing/recording, @false if not. 1404 * @param pMixStream Mixer stream to return status for. 1405 */ 1230 1406 bool AudioMixerStreamIsActive(PAUDMIXSTREAM pMixStream) 1231 1407 { … … 1237 1413 } 1238 1414 1415 /** 1416 * Returns whether a mixer stream is valid (e.g. initialized and in a working state) or not. 1417 * 1418 * @returns @true if valid, @false if not. 1419 * @param pMixStream Mixer stream to return status for. 1420 */ 1239 1421 bool AudioMixerStreamIsValid(PAUDMIXSTREAM pMixStream) 1240 1422 { -
trunk/src/VBox/Devices/Audio/AudioMixer.h
r62366 r62605 197 197 /** Invalid operation, do not use. */ 198 198 AUDMIXOP_INVALID = 0, 199 /** Copy data from A to B, overwriting data in B. */ 199 200 AUDMIXOP_COPY, 201 /** Blend data from A with (existing) data in B. */ 200 202 AUDMIXOP_BLEND, 201 203 /** The usual 32-bit hack. */ … … 209 211 int AudioMixerCreateSink(PAUDIOMIXER pMixer, const char *pszName, AUDMIXSINKDIR enmDir, PAUDMIXSINK *ppSink); 210 212 void AudioMixerDestroy(PAUDIOMIXER pMixer); 211 int AudioMixerGetDeviceFormat(PAUDIOMIXER pMixer, PPDMAUDIOSTREAMCFG pCfg);212 213 void AudioMixerInvalidate(PAUDIOMIXER pMixer); 213 214 void AudioMixerRemoveSink(PAUDIOMIXER pMixer, PAUDMIXSINK pSink); 214 int AudioMixerSetDeviceFormat(PAUDIOMIXER pMixer, PPDMAUDIOSTREAMCFG pCfg);215 215 int AudioMixerSetMasterVolume(PAUDIOMIXER pMixer, PPDMAUDIOVOLUME pVol); 216 216 void AudioMixerDebug(PAUDIOMIXER pMixer, PCDBGFINFOHLP pHlp, const char *pszArgs); -
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r62463 r62605 2432 2432 */ 2433 2433 if (pDrv->uLUN == 0) 2434 pDrv->Flags |= PDMAUDIODRVFLAG _PRIMARY;2434 pDrv->Flags |= PDMAUDIODRVFLAGS_PRIMARY; 2435 2435 2436 2436 LogFunc(("LUN#%RU8: pCon=%p, drvFlags=0x%x\n", uLUN, pDrv->pConnector, pDrv->Flags)); … … 2693 2693 if (RT_SUCCESS(rc)) 2694 2694 { 2695 /* Set a default audio format for our mixer. */2696 PDMAUDIOSTREAMCFG streamCfg;2697 streamCfg.uHz = 44100;2698 streamCfg.cChannels = 2;2699 streamCfg.enmFormat = PDMAUDIOFMT_S16;2700 streamCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS;2701 2702 rc = AudioMixerSetDeviceFormat(pThis->pMixer, &streamCfg);2703 AssertRC(rc);2704 2705 2695 /* Add all required audio sinks. */ 2706 2696 int rc2 = AudioMixerCreateSink(pThis->pMixer, "[Playback] PCM Output", AUDMIXSINKDIR_OUTPUT, &pThis->pSinkOutput); … … 2728 2718 * might not worth showing an own error message box in the GUI. 2729 2719 */ 2730 if (!(pDrv->Flags & PDMAUDIODRVFLAG _PRIMARY))2720 if (!(pDrv->Flags & PDMAUDIODRVFLAGS_PRIMARY)) 2731 2721 continue; 2732 2722 … … 2847 2837 /* Only register primary driver. 2848 2838 * The device emulation does the output multiplexing then. */ 2849 if (!(pDrv->Flags & PDMAUDIODRVFLAG _PRIMARY))2839 if (!(pDrv->Flags & PDMAUDIODRVFLAGS_PRIMARY)) 2850 2840 continue; 2851 2841 -
trunk/src/VBox/Devices/Audio/DevIchHda.cpp
r62463 r62605 2856 2856 2857 2857 if ( RT_FAILURE(rc2) 2858 && (pDrv->Flags & PDMAUDIODRVFLAG _PRIMARY)) /* We only care about primary drivers here, the rest may fail. */2858 && (pDrv->Flags & PDMAUDIODRVFLAGS_PRIMARY)) /* We only care about primary drivers here, the rest may fail. */ 2859 2859 { 2860 2860 if (RT_SUCCESS(rc)) … … 5600 5600 */ 5601 5601 if (pDrv->uLUN == 0) 5602 pDrv->Flags |= PDMAUDIODRVFLAG _PRIMARY;5602 pDrv->Flags |= PDMAUDIODRVFLAGS_PRIMARY; 5603 5603 5604 5604 LogFunc(("LUN#%u: pCon=%p, drvFlags=0x%x\n", uLUN, pDrv->pConnector, pDrv->Flags)); … … 5916 5916 if (RT_SUCCESS(rc)) 5917 5917 { 5918 /* Set a default audio format for our mixer. */5919 PDMAUDIOSTREAMCFG streamCfg;5920 streamCfg.uHz = 44100;5921 streamCfg.cChannels = 2;5922 streamCfg.enmFormat = PDMAUDIOFMT_S16;5923 streamCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS;5924 5925 rc = AudioMixerSetDeviceFormat(pThis->pMixer, &streamCfg);5926 AssertRC(rc);5927 5928 5918 /* 5929 5919 * Add mixer output sinks. … … 6012 6002 * might not worth showing an own error message box in the GUI. 6013 6003 */ 6014 if (!(pDrv->Flags & PDMAUDIODRVFLAG _PRIMARY))6004 if (!(pDrv->Flags & PDMAUDIODRVFLAGS_PRIMARY)) 6015 6005 continue; 6016 6006 … … 6221 6211 /* Only register primary driver. 6222 6212 * The device emulation does the output multiplexing then. */ 6223 if (pDrv->Flags != PDMAUDIODRVFLAG _PRIMARY)6213 if (pDrv->Flags != PDMAUDIODRVFLAGS_PRIMARY) 6224 6214 continue; 6225 6215 -
trunk/src/VBox/Devices/Audio/DevSB16.cpp
r62350 r62605 258 258 */ 259 259 if (pDrv->uLUN == 0) 260 pDrv->Flags |= PDMAUDIODRVFLAG _PRIMARY;260 pDrv->Flags |= PDMAUDIODRVFLAGS_PRIMARY; 261 261 262 262 LogFunc(("LUN#%RU8: pCon=%p, drvFlags=0x%x\n", uLUN, pDrv->pConnector, pDrv->Flags)); … … 1851 1851 } 1852 1852 1853 if (pDrv->Flags & PDMAUDIODRVFLAG _PRIMARY)1853 if (pDrv->Flags & PDMAUDIODRVFLAGS_PRIMARY) 1854 1854 { 1855 1855 /* Only do the next DMA transfer if we're able to write the entire … … 2421 2421 * might not worth showing an own error message box in the GUI. 2422 2422 */ 2423 if (!(pDrv->Flags & PDMAUDIODRVFLAG _PRIMARY))2423 if (!(pDrv->Flags & PDMAUDIODRVFLAGS_PRIMARY)) 2424 2424 continue; 2425 2425 … … 2468 2468 /* Only register primary driver. 2469 2469 * The device emulation does the output multiplexing then. */ 2470 if (pDrv->Flags != PDMAUDIODRVFLAG _PRIMARY)2470 if (pDrv->Flags != PDMAUDIODRVFLAGS_PRIMARY) 2471 2471 continue; 2472 2472 -
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r62590 r62605 246 246 #endif /* !VBOX_AUDIO_TESTCASE */ 247 247 248 static DECLCALLBACK(int) drvAudioStreamControl(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 248 /** 249 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamControl} 250 */ 251 static DECLCALLBACK(int) drvAudioStreamControl(PPDMIAUDIOCONNECTOR pInterface, 252 PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 249 253 { 250 254 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 270 274 } 271 275 276 /** 277 * Controls an audio stream. 278 * 279 * @returns IPRT status code. 280 * @param pThis Pointer to driver instance. 281 * @param pStream Stream to control. 282 * @param enmStreamCmd Control command. 283 */ 272 284 static int drvAudioStreamControlInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 273 285 { … … 363 375 } 364 376 377 /** 378 * Controls a stream's backend. 379 * If the stream has no backend available, VERR_NOT_FOUND is returned. 380 * 381 * @returns IPRT status code. 382 * @param pThis Pointer to driver instance. 383 * @param pStream Stream to control. 384 * @param enmStreamCmd Control command. 385 */ 365 386 static int drvAudioStreamControlInternalBackend(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 366 387 { … … 369 390 370 391 PPDMAUDIOSTREAM pHstStream = drvAudioGetHostStream(pStream); 371 AssertPtr(pHstStream); 392 if (!pHstStream) /* Stream does not have a host backend? Bail out. */ 393 return VERR_NOT_FOUND; 372 394 373 395 LogFlowFunc(("[%s] enmStreamCmd=%RU32, fStatus=0x%x\n", pHstStream->szName, enmStreamCmd, pHstStream->fStatus)); … … 375 397 AssertPtr(pThis->pHostDrvAudio); 376 398 377 int rc = VINF_SUCCESS; 378 379 if (RT_SUCCESS(rc)) 380 { 381 switch (enmStreamCmd) 382 { 383 case PDMAUDIOSTREAMCMD_ENABLE: 384 { 385 if (!(pHstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED)) 399 int rc; 400 401 switch (enmStreamCmd) 402 { 403 case PDMAUDIOSTREAMCMD_ENABLE: 404 { 405 if (!(pHstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED)) 406 { 407 LogRel2(("Audio: Enabling stream '%s'\n", pHstStream->szName)); 408 rc = pThis->pHostDrvAudio->pfnStreamControl(pThis->pHostDrvAudio, pHstStream, PDMAUDIOSTREAMCMD_ENABLE); 409 if (RT_SUCCESS(rc)) 386 410 { 387 LogRel2(("Audio: Enabling stream '%s'\n", pHstStream->szName)); 388 rc = pThis->pHostDrvAudio->pfnStreamControl(pThis->pHostDrvAudio, pHstStream, PDMAUDIOSTREAMCMD_ENABLE); 389 if (RT_SUCCESS(rc)) 390 { 391 pHstStream->fStatus |= PDMAUDIOSTRMSTS_FLAG_ENABLED; 392 } 393 else 394 LogRel2(("Audio: Disabling stream '%s' failed with %Rrc\n", pHstStream->szName, rc)); 411 pHstStream->fStatus |= PDMAUDIOSTRMSTS_FLAG_ENABLED; 395 412 } 413 else 414 LogRel2(("Audio: Disabling stream '%s' failed with %Rrc\n", pHstStream->szName, rc)); 415 } 416 break; 417 } 418 419 case PDMAUDIOSTREAMCMD_DISABLE: 420 { 421 if (pHstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED) 422 { 423 LogRel2(("Audio: Disabling stream '%s'\n", pHstStream->szName)); 424 rc = pThis->pHostDrvAudio->pfnStreamControl(pThis->pHostDrvAudio, pHstStream, PDMAUDIOSTREAMCMD_DISABLE); 425 if (RT_SUCCESS(rc)) 426 { 427 pHstStream->fStatus &= ~PDMAUDIOSTRMSTS_FLAG_ENABLED; 428 pHstStream->fStatus &= ~PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE; 429 AudioMixBufReset(&pHstStream->MixBuf); 430 } 431 else 432 LogRel2(("Audio: Disabling stream '%s' failed with %Rrc\n", pHstStream->szName, rc)); 433 } 434 break; 435 } 436 437 case PDMAUDIOSTREAMCMD_PAUSE: 438 { 439 /* Only pause if the stream is enabled. */ 440 if (!(pHstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED)) 396 441 break; 397 } 398 399 case PDMAUDIOSTREAMCMD_DISABLE: 400 { 401 if (pHstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED) 442 443 if (!(pHstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_PAUSED)) 444 { 445 LogRel2(("Audio: Pausing stream '%s'\n", pHstStream->szName)); 446 rc = pThis->pHostDrvAudio->pfnStreamControl(pThis->pHostDrvAudio, pHstStream, PDMAUDIOSTREAMCMD_PAUSE); 447 if (RT_SUCCESS(rc)) 402 448 { 403 LogRel2(("Audio: Disabling stream '%s'\n", pHstStream->szName)); 404 rc = pThis->pHostDrvAudio->pfnStreamControl(pThis->pHostDrvAudio, pHstStream, PDMAUDIOSTREAMCMD_DISABLE); 405 if (RT_SUCCESS(rc)) 406 { 407 pHstStream->fStatus &= ~PDMAUDIOSTRMSTS_FLAG_ENABLED; 408 pHstStream->fStatus &= ~PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE; 409 AudioMixBufReset(&pHstStream->MixBuf); 410 } 411 else 412 LogRel2(("Audio: Disabling stream '%s' failed with %Rrc\n", pHstStream->szName, rc)); 449 pHstStream->fStatus |= PDMAUDIOSTRMSTS_FLAG_PAUSED; 413 450 } 451 else 452 LogRel2(("Audio: Pausing stream '%s' failed with %Rrc\n", pHstStream->szName, rc)); 453 } 454 break; 455 } 456 457 case PDMAUDIOSTREAMCMD_RESUME: 458 { 459 /* Only need to resume if the stream is enabled. */ 460 if (!(pHstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED)) 414 461 break; 415 } 416 417 case PDMAUDIOSTREAMCMD_PAUSE: 418 { 419 /* Only pause if the stream is enabled. */ 420 if (!(pHstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED)) 421 break; 422 423 if (!(pHstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_PAUSED)) 462 463 if (pHstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_PAUSED) 464 { 465 LogRel2(("Audio: Resuming stream '%s'\n", pHstStream->szName)); 466 rc = pThis->pHostDrvAudio->pfnStreamControl(pThis->pHostDrvAudio, pHstStream, PDMAUDIOSTREAMCMD_RESUME); 467 if (RT_SUCCESS(rc)) 424 468 { 425 LogRel2(("Audio: Pausing stream '%s'\n", pHstStream->szName)); 426 rc = pThis->pHostDrvAudio->pfnStreamControl(pThis->pHostDrvAudio, pHstStream, PDMAUDIOSTREAMCMD_PAUSE); 427 if (RT_SUCCESS(rc)) 428 { 429 pHstStream->fStatus |= PDMAUDIOSTRMSTS_FLAG_PAUSED; 430 } 431 else 432 LogRel2(("Audio: Pausing stream '%s' failed with %Rrc\n", pHstStream->szName, rc)); 469 pHstStream->fStatus &= ~PDMAUDIOSTRMSTS_FLAG_PAUSED; 433 470 } 434 break; 435 } 436 437 case PDMAUDIOSTREAMCMD_RESUME: 438 { 439 /* Only need to resume if the stream is enabled. */ 440 if (!(pHstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED)) 441 break; 442 443 if (pHstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_PAUSED) 444 { 445 LogRel2(("Audio: Resuming stream '%s'\n", pHstStream->szName)); 446 rc = pThis->pHostDrvAudio->pfnStreamControl(pThis->pHostDrvAudio, pHstStream, PDMAUDIOSTREAMCMD_RESUME); 447 if (RT_SUCCESS(rc)) 448 { 449 pHstStream->fStatus &= ~PDMAUDIOSTRMSTS_FLAG_PAUSED; 450 } 451 else 452 LogRel2(("Audio: Resuming stream '%s' failed with %Rrc\n", pHstStream->szName, rc)); 453 } 454 break; 455 } 456 457 default: 458 { 459 AssertMsgFailed(("Command %RU32 not implemented\n", enmStreamCmd)); 460 rc = VERR_NOT_IMPLEMENTED; 461 break; 462 } 471 else 472 LogRel2(("Audio: Resuming stream '%s' failed with %Rrc\n", pHstStream->szName, rc)); 473 } 474 break; 475 } 476 477 default: 478 { 479 AssertMsgFailed(("Command %RU32 not implemented\n", enmStreamCmd)); 480 rc = VERR_NOT_IMPLEMENTED; 481 break; 463 482 } 464 483 } … … 470 489 } 471 490 491 /** 492 * Initializes an audio stream with a given host and guest stream configuration. 493 * 494 * @returns IPRT status code. 495 * @param pThis Pointer to driver instance. 496 * @param pStream Stream to initialize. 497 * @param pCfgHost Stream configuration to use for the host side (backend). 498 * @param pCfgGuest Stream configuration to use for the guest side. 499 */ 472 500 static int drvAudioStreamInitInternal(PDRVAUDIO pThis, 473 501 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgHost, PPDMAUDIOSTREAMCFG pCfgGuest) … … 592 620 } 593 621 622 /** 623 * Re-initializes an audio stream with its existing host and guest stream configuration. 624 * 625 * @returns IPRT status code. 626 * @param pThis Pointer to driver instance. 627 * @param pStream Stream to re-initialize. 628 */ 594 629 static int drvAudioStreamReInitInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream) 595 630 { … … 657 692 658 693 /** 659 * Writes VM audio output data from the guest stream into the host stream. 660 * The attached host driver backend then will play out the audio in a 661 * later step then. 662 * 663 * @return IPRT status code. 664 * @return int 665 * @param pThis 666 * @param pGstStrmOut 667 * @param pvBuf 668 * @param cbBuf 669 * @param pcbWritten 694 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamWrite} 670 695 */ 671 696 static DECLCALLBACK(int) drvAudioStreamWrite(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, … … 759 784 } 760 785 786 /** 787 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamAddRef} 788 */ 761 789 static DECLCALLBACK(uint32_t) drvAudioStreamAddRef(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream) 762 790 { … … 769 797 } 770 798 799 /** 800 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamRelease} 801 */ 771 802 static DECLCALLBACK(uint32_t) drvAudioStreamRelease(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream) 772 803 { … … 782 813 } 783 814 815 /** 816 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamIterate} 817 */ 784 818 static DECLCALLBACK(int) drvAudioStreamIterate(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream) 785 819 { … … 806 840 } 807 841 842 /** 843 * Does one iteration of an audio stream. 844 * This function gives the backend the chance of iterating / altering data and 845 * does the actual mixing between the guest <-> host mixing buffers. 846 * 847 * @returns IPRT status code. 848 * @param pThis Pointer to driver instance. 849 * @param pStream Stream to iterate. 850 * 851 * @remark 852 */ 808 853 static int drvAudioStreamIterateInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream) 809 854 { … … 856 901 else if (pHstStream->enmDir == PDMAUDIODIR_OUT) 857 902 { 858 uint32_t cSamplesLive = AudioMixBufLive(&pGstStream->MixBuf); 859 if (!cSamplesLive) /* No live samples at the moment? */ 860 { 861 /* When playing samples, the host is the parent while the guest is the child. 862 * So try mixing not yet mixed guest-side samples to the host-side buffer. */ 863 rc = AudioMixBufMixToParent(&pGstStream->MixBuf, AudioMixBufUsed(&pGstStream->MixBuf), &cSamplesMixed); 864 if ( RT_SUCCESS(rc) 865 && cSamplesMixed) 866 { 867 Log3Func(("[%s] %RU32 samples mixed\n", pHstStream->szName, cSamplesMixed)); 868 } 869 870 if (RT_SUCCESS(rc)) 871 cSamplesLive = AudioMixBufLive(&pGstStream->MixBuf); 872 } 873 874 Log3Func(("[%s] %RU32 live samples\n", pHstStream->szName, cSamplesLive)); 875 876 if (!cSamplesLive) /* No live samples (anymore)? */ 903 /* When playing samples, the host is the parent while the guest is the child. 904 * So try mixing not yet mixed guest-side samples to the host-side buffer. */ 905 rc = AudioMixBufMixToParent(&pGstStream->MixBuf, AudioMixBufUsed(&pGstStream->MixBuf), &cSamplesMixed); 906 if ( RT_SUCCESS(rc) 907 && cSamplesMixed) 908 { 909 Log3Func(("[%s] %RU32 samples mixed, guest has %RU32 samples left (%RU32 live)\n", 910 pHstStream->szName, cSamplesMixed, 911 AudioMixBufUsed(&pGstStream->MixBuf), AudioMixBufLive(&pGstStream->MixBuf))); 912 } 913 914 uint32_t cSamplesLeft = AudioMixBufUsed(&pGstStream->MixBuf); 915 if (!cSamplesLeft) /* No samples (anymore)? */ 877 916 { 878 917 fTryClosePending = true; … … 911 950 } 912 951 952 /** 953 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamPlay} 954 */ 913 955 static DECLCALLBACK(int) drvAudioStreamPlay(PPDMIAUDIOCONNECTOR pInterface, 914 956 PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesPlayed) … … 991 1033 STAM_COUNTER_ADD(&pHstStream->Out.StatSamplesPlayed, cSamplesPlayed); 992 1034 #endif 1035 cSamplesLive = AudioMixBufLive(&pGstStream->MixBuf); 993 1036 } 994 1037 } 995 996 Log3Func(("[%s] strmSts=0x%x, cSamplesPlayed=%RU32, rc=%Rrc\n", pHstStream->szName, strmSts, cSamplesPlayed, rc));997 1038 } 998 1039 … … 1032 1073 } 1033 1074 1075 /** 1076 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamCapture} 1077 */ 1034 1078 static DECLCALLBACK(int) drvAudioStreamCapture(PPDMIAUDIOCONNECTOR pInterface, 1035 1079 PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesCaptured) … … 1120 1164 1121 1165 #ifdef VBOX_WITH_AUDIO_CALLBACKS 1166 /** 1167 * Duplicates an audio callback. 1168 * 1169 * @returns Pointer to duplicated callback, or NULL on failure. 1170 * @param pCB Callback to duplicate. 1171 */ 1122 1172 static PPDMAUDIOCALLBACK drvAudioCallbackDuplicate(PPDMAUDIOCALLBACK pCB) 1123 1173 { 1174 AssertPtrReturn(pCB, VERR_INVALID_POINTER); 1175 1124 1176 PPDMAUDIOCALLBACK pCBCopy = (PPDMAUDIOCALLBACK)RTMemDup((void *)pCB, sizeof(PDMAUDIOCALLBACK)); 1125 1177 if (!pCBCopy) … … 1141 1193 } 1142 1194 1195 /** 1196 * Destroys a given callback. 1197 * 1198 * @param pCB Callback to destroy. 1199 */ 1143 1200 static void drvAudioCallbackDestroy(PPDMAUDIOCALLBACK pCB) 1144 1201 { … … 1155 1212 } 1156 1213 1214 /** 1215 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnRegisterCallbacks} 1216 */ 1157 1217 static DECLCALLBACK(int) drvAudioRegisterCallbacks(PPDMIAUDIOCONNECTOR pInterface, 1158 1218 PPDMAUDIOCALLBACK paCallbacks, size_t cCallbacks) … … 1202 1262 } 1203 1263 1264 /** 1265 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnCallback} 1266 */ 1204 1267 static DECLCALLBACK(int) drvAudioCallback(PPDMIAUDIOCONNECTOR pInterface, PDMAUDIOCALLBACKTYPE enmType, 1205 1268 void *pvUser, size_t cbUser) … … 1305 1368 } 1306 1369 1370 /** 1371 * Handles state changes for all audio streams. 1372 * 1373 * @param pDrvIns Pointer to driver instance. 1374 * @param enmCmd Stream command to set for all streams. 1375 */ 1307 1376 static void drvAudioStateHandler(PPDMDRVINS pDrvIns, PDMAUDIOSTREAMCMD enmCmd) 1308 1377 { … … 1320 1389 } 1321 1390 1322 static DECLCALLBACK(int) drvAudioInit(PCFGMNODE pCfgHandle, PPDMDRVINS pDrvIns) 1391 /** 1392 * Intializes an audio driver instance. 1393 * 1394 * @returns IPRT status code. 1395 * @param pDrvIns Pointer to driver instance. 1396 * @param pCfgHandle CFGM handle to use for configuration. 1397 */ 1398 static int drvAudioInit(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle) 1323 1399 { 1324 1400 AssertPtrReturn(pCfgHandle, VERR_INVALID_POINTER); … … 1342 1418 } 1343 1419 1420 /** 1421 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamRead} 1422 */ 1344 1423 static DECLCALLBACK(int) drvAudioStreamRead(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, 1345 1424 void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead) … … 1432 1511 } 1433 1512 1513 /** 1514 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamCreate} 1515 */ 1434 1516 static DECLCALLBACK(int) drvAudioStreamCreate(PPDMIAUDIOCONNECTOR pInterface, 1435 1517 PPDMAUDIOSTREAMCFG pCfgHost, PPDMAUDIOSTREAMCFG pCfgGuest, … … 1606 1688 } 1607 1689 1690 /** 1691 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnGetConfig} 1692 */ 1608 1693 static DECLCALLBACK(int) drvAudioGetConfig(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOBACKENDCFG pCfg) 1609 1694 { … … 1635 1720 } 1636 1721 1722 /** 1723 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnGetStatus} 1724 */ 1637 1725 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvAudioGetStatus(PPDMIAUDIOCONNECTOR pInterface, PDMAUDIODIR enmDir) 1638 1726 { … … 1661 1749 } 1662 1750 1751 /** 1752 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamGetReadable} 1753 */ 1663 1754 static DECLCALLBACK(uint32_t) drvAudioStreamGetReadable(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream) 1664 1755 { … … 1688 1779 cReadable = AudioMixBufLive(&pGstStream->MixBuf); 1689 1780 1690 Log3Func(("[%s] cbReadable=%RU32\n", pHstStream->szName, cReadable)); 1781 Log3Func(("[%s] cbReadable=%RU32 (%zu bytes)\n", pHstStream->szName, cReadable, 1782 AUDIOMIXBUF_S2B(&pGstStream->MixBuf, cReadable))); 1691 1783 1692 1784 rc2 = RTCritSectLeave(&pThis->CritSect); … … 1697 1789 } 1698 1790 1791 /** 1792 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamGetWritable} 1793 */ 1699 1794 static DECLCALLBACK(uint32_t) drvAudioStreamGetWritable(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream) 1700 1795 { … … 1715 1810 AssertRC(rc2); 1716 1811 1812 AssertMsgFailed(("Guest stream '%s' does not have a host stream attached\n", pStream->szName)); 1717 1813 return 0; 1718 1814 } 1719 1815 1720 1816 PPDMAUDIOSTREAM pGstStream = pHstStream->pPair; 1721 1722 uint32_t cWritable = 0; 1723 1724 if (AudioMixBufLive(&pHstStream->MixBuf) == 0) 1725 cWritable = AudioMixBufFreeBytes(&pGstStream->MixBuf); 1726 1727 Log3Func(("[%s] cWritable=%RU32\n", pHstStream->szName, cWritable)); 1817 AssertPtr(pGstStream); 1818 1819 uint32_t cWritable = AudioMixBufFree(&pGstStream->MixBuf); 1820 1821 Log3Func(("[%s] cWritable=%RU32 (%zu bytes)\n", pHstStream->szName, cWritable, 1822 AUDIOMIXBUF_S2B(&pGstStream->MixBuf, cWritable))); 1728 1823 1729 1824 rc2 = RTCritSectLeave(&pThis->CritSect); … … 1734 1829 } 1735 1830 1831 /** 1832 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamGetStatus} 1833 */ 1736 1834 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvAudioStreamGetStatus(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream) 1737 1835 { … … 1761 1859 } 1762 1860 1861 /** 1862 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamSetVolume} 1863 */ 1763 1864 static DECLCALLBACK(int) drvAudioStreamSetVolume(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, PPDMAUDIOVOLUME pVol) 1764 1865 { … … 1779 1880 } 1780 1881 1882 /** 1883 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamDestroy} 1884 */ 1781 1885 static DECLCALLBACK(int) drvAudioStreamDestroy(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream) 1782 1886 { … … 1855 1959 } 1856 1960 1961 /** 1962 * Calls the backend to give it the chance to destroy its part of the audio stream. 1963 * 1964 * @returns IPRT status code. 1965 * @param pThis Pointer to driver instance. 1966 * @param pHstStream Host audio stream to call the backend destruction for. 1967 */ 1857 1968 static int drvAudioStreamDestroyInternalBackend(PDRVAUDIO pThis, PPDMAUDIOSTREAM pHstStream) 1858 1969 { … … 1881 1992 } 1882 1993 1994 /** 1995 * Destroys an audio stream. 1996 * 1997 * @returns IPRT status code. 1998 * @param pThis Pointer to driver instance. 1999 * @param pStream Pointer to audio stream to destroy. 2000 * That pointer will be invalid after successful destruction. 2001 */ 1883 2002 static int drvAudioStreamDestroyInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream) 1884 2003 { … … 2068 2187 } 2069 2188 2070 rc = drvAudioInit(p CfgHandle, pDrvIns);2189 rc = drvAudioInit(pDrvIns, pCfgHandle); 2071 2190 if (RT_SUCCESS(rc)) 2072 2191 { -
trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp
r62581 r62605 202 202 } 203 203 204 /** 205 * Converts a recording source enumeration to a string. 206 * 207 * @returns Stringified recording source, or "Unknown", if not found. 208 * @param enmRecSrc Recording source to convert. 209 */ 204 210 const char *DrvAudioHlpRecSrcToStr(PDMAUDIORECSOURCE enmRecSrc) 205 211 { … … 281 287 } 282 288 289 /** 290 * Converts an audio format to a string. 291 * 292 * @returns Stringified audio format, or "Unknown", if not found. 293 * @param enmFmt Audio format to convert. 294 */ 283 295 const char *DrvAudioHlpAudFmtToStr(PDMAUDIOFMT enmFmt) 284 296 { … … 308 320 309 321 AssertMsgFailed(("Bogus audio format %ld\n", enmFmt)); 310 return "Invalid"; 311 } 312 322 return "Unknown"; 323 } 324 325 /** 326 * Converts a given string to an audio format. 327 * 328 * @returns Audio format for the given string, or PDMAUDIOFMT_INVALID if not found. 329 * @param pszFmt String to convert to an audio format. 330 */ 313 331 PDMAUDIOFMT DrvAudioHlpStrToAudFmt(const char *pszFmt) 314 332 { … … 332 350 } 333 351 352 /** 353 * Checks whether the given PCM properties are equal with the given 354 * stream configuration. 355 * 356 * @returns @true if equal, @false if not. 357 * @param pProps PCM properties to compare. 358 * @param pCfg Stream configuration to compare. 359 */ 334 360 bool DrvAudioHlpPCMPropsAreEqual(PPDMPCMPROPS pProps, PPDMAUDIOSTREAMCFG pCfg) 335 361 { … … 372 398 } 373 399 400 /** 401 * Checks whether two given PCM properties are equal. 402 * 403 * @returns @true if equal, @false if not. 404 * @param pProps1 First properties to compare. 405 * @param pProps2 Second properties to compare. 406 */ 374 407 bool DrvAudioHlpPCMPropsAreEqual(PPDMPCMPROPS pProps1, PPDMPCMPROPS pProps2) 375 408 { … … 377 410 AssertPtrReturn(pProps2, false); 378 411 379 if (pProps1 == pProps2) 412 if (pProps1 == pProps2) /* If the pointers match, take a shortcut. */ 380 413 return true; 381 414 … … 408 441 } 409 442 443 /** 444 * Checks whether a given stream configuration is valid or not. 445 * 446 * Returns @true if configuration is valid, @false if not. 447 * @param pCfg Stream configuration to check. 448 */ 410 449 bool DrvAudioHlpStreamCfgIsValid(PPDMAUDIOSTREAMCFG pCfg) 411 450 { … … 500 539 } 501 540 541 /** 542 * Prints an audio stream configuration to the debug log. 543 * 544 * @param pCfg Stream configuration to log. 545 */ 502 546 void DrvAudioHlpStreamCfgPrint(PPDMAUDIOSTREAMCFG pCfg) 503 547 { … … 546 590 } 547 591 592 /** 593 * Calculates the audio bit rate of the given bits per sample, the Hz and the number 594 * of audio channels. 595 * 596 * Divide the result by 8 to get the byte rate. 597 * 598 * @returns The calculated bit rate. 599 * @param cBits Number of bits per sample. 600 * @param uHz Hz (Hertz) rate. 601 * @param cChannels Number of audio channels. 602 */ 548 603 uint32_t DrvAudioHlpCalcBitrate(uint8_t cBits, uint32_t uHz, uint8_t cChannels) 549 604 { … … 551 606 } 552 607 608 /** 609 * Calculates the audio bit rate out of a given audio stream configuration. 610 * 611 * Divide the result by 8 to get the byte rate. 612 * 613 * @returns The calculated bit rate. 614 * @param pCfg Audio stream configuration to calculate bit rate for. 615 * 616 * @remark 617 */ 553 618 uint32_t DrvAudioHlpCalcBitrate(PPDMAUDIOSTREAMCFG pCfg) 554 619 { … … 663 728 } 664 729 730 /** 731 * Opens or creates a wave (.WAV) file. 732 * 733 * @returns IPRT status code. 734 * @param pFile Pointer to audio file handle to use. 735 * @param pszFile File path of file to open or create. 736 * @param fOpen Open flags. 737 * @param pProps PCM properties to use. 738 * @param fFlags Audio file flags. 739 */ 665 740 int DrvAudioHlpWAVFileOpen(PPDMAUDIOFILE pFile, const char *pszFile, uint32_t fOpen, PPDMPCMPROPS pProps, 666 741 PDMAUDIOFILEFLAGS fFlags) … … 729 804 } 730 805 806 /** 807 * Closes a wave (.WAV) audio file. 808 * 809 * @returns IPRT status code. 810 * @param pFile Audio file handle to close. 811 */ 731 812 int DrvAudioHlpWAVFileClose(PPDMAUDIOFILE pFile) 732 813 { … … 759 840 } 760 841 842 /** 843 * Returns the raw PCM audio data size of a wave file. 844 * This does *not* include file headers and other data which does 845 * not belong to the actual PCM audio data. 846 * 847 * @returns Size (in bytes) of the raw PCM audio data. 848 * @param pFile Audio file handle to retrieve the audio data size for. 849 */ 761 850 size_t DrvAudioHlpWAVFileGetDataSize(PPDMAUDIOFILE pFile) 762 851 { … … 771 860 } 772 861 862 /** 863 * Write PCM data to a wave (.WAV) file. 864 * 865 * @returns IPRT status code. 866 * @param pFile Audio file handle to write PCM data to. 867 * @param pvBuf Audio data to write. 868 * @param cbBuf Size (in bytes) of audio data to write. 869 * @param fFlags Additional write flags. Not being used at the moment and must be 0. 870 * 871 * @remark 872 */ 773 873 int DrvAudioHlpWAVFileWrite(PPDMAUDIOFILE pFile, const void *pvBuf, size_t cbBuf, uint32_t fFlags) 774 874 { 775 875 AssertPtrReturn(pFile, VERR_INVALID_POINTER); 776 876 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER); 777 /** @todo Validate fFlags. */ 877 878 AssertReturn(fFlags == 0, VERR_INVALID_PARAMETER); /** @todo fFlags are currently not implemented. */ 778 879 779 880 Assert(pFile->enmType == PDMAUDIOFILETYPE_WAV);
Note:
See TracChangeset
for help on using the changeset viewer.