Changeset 63360 in vbox
- Timestamp:
- Aug 12, 2016 1:58:38 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/pdmaudioifs.h
r62965 r63360 262 262 /** @todo Use RT_LE2H_*? */ 263 263 PDMAUDIOENDIANNESS enmEndianness; 264 /** Size of audio sample buffer. */ 265 uint32_t cSamples; 264 266 } PDMAUDIOSTREAMCFG, *PPDMAUDIOSTREAMCFG; 265 267 … … 904 906 * Assigns all needed interface callbacks for an audio backend. 905 907 * 906 * @param a_ NamePrefix The function name prefix.907 */ 908 #define PDMAUDIO_IHOSTAUDIO_CALLBACKS(a_ NamePrefix) \908 * @param a_Prefix The function name prefix. 909 */ 910 #define PDMAUDIO_IHOSTAUDIO_CALLBACKS(a_Prefix) \ 909 911 do { \ 910 pThis->IHostAudio.pfnInit = RT_CONCAT(a_ NamePrefix,Init); \911 pThis->IHostAudio.pfnShutdown = RT_CONCAT(a_ NamePrefix,Shutdown); \912 pThis->IHostAudio.pfnGetConfig = RT_CONCAT(a_ NamePrefix,GetConfig); \913 pThis->IHostAudio.pfnGetStatus = RT_CONCAT(a_ NamePrefix,GetStatus); \914 pThis->IHostAudio.pfnStreamCreate = RT_CONCAT(a_ NamePrefix,StreamCreate); \915 pThis->IHostAudio.pfnStreamDestroy = RT_CONCAT(a_ NamePrefix,StreamDestroy); \916 pThis->IHostAudio.pfnStreamControl = RT_CONCAT(a_ NamePrefix,StreamControl); \917 pThis->IHostAudio.pfnStreamGetStatus = RT_CONCAT(a_ NamePrefix,StreamGetStatus); \918 pThis->IHostAudio.pfnStreamIterate = RT_CONCAT(a_ NamePrefix,StreamIterate); \919 pThis->IHostAudio.pfnStreamPlay = RT_CONCAT(a_ NamePrefix,StreamPlay); \920 pThis->IHostAudio.pfnStreamCapture = RT_CONCAT(a_ NamePrefix,StreamCapture); \912 pThis->IHostAudio.pfnInit = RT_CONCAT(a_Prefix,Init); \ 913 pThis->IHostAudio.pfnShutdown = RT_CONCAT(a_Prefix,Shutdown); \ 914 pThis->IHostAudio.pfnGetConfig = RT_CONCAT(a_Prefix,GetConfig); \ 915 pThis->IHostAudio.pfnGetStatus = RT_CONCAT(a_Prefix,GetStatus); \ 916 pThis->IHostAudio.pfnStreamCreate = RT_CONCAT(a_Prefix,StreamCreate); \ 917 pThis->IHostAudio.pfnStreamDestroy = RT_CONCAT(a_Prefix,StreamDestroy); \ 918 pThis->IHostAudio.pfnStreamControl = RT_CONCAT(a_Prefix,StreamControl); \ 919 pThis->IHostAudio.pfnStreamGetStatus = RT_CONCAT(a_Prefix,StreamGetStatus); \ 920 pThis->IHostAudio.pfnStreamIterate = RT_CONCAT(a_Prefix,StreamIterate); \ 921 pThis->IHostAudio.pfnStreamPlay = RT_CONCAT(a_Prefix,StreamPlay); \ 922 pThis->IHostAudio.pfnStreamCapture = RT_CONCAT(a_Prefix,StreamCapture); \ 921 923 } while (0) 924 925 #define PDMAUDIO_IHOSTAUDIO_FN_RET_INIT int 926 #define PDMAUDIO_IHOSTAUDIO_FN_PARAMS_INIT (PPDMIHOSTAUDIO pInterface) 927 928 #define PDMAUDIO_IHOSTAUDIO_FN_RET_SHUTDOWN void 929 #define PDMAUDIO_IHOSTAUDIO_FN_PARAMS_SHUTDOWN (PPDMIHOSTAUDIO pInterface) 930 931 #define PDMAUDIO_IHOSTAUDIO_FN_RET_GETCONFIG int 932 #define PDMAUDIO_IHOSTAUDIO_FN_PARAMS_GETCONFIG (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pBackendCfg) 933 934 #define PDMAUDIO_IHOSTAUDIO_FN_RET_GETSTATUS PDMAUDIOBACKENDSTS 935 #define PDMAUDIO_IHOSTAUDIO_FN_PARAMS_GETSTATUS (PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir) 936 937 #define PDMAUDIO_IHOSTAUDIO_FN_RET_STREAMCREATE int 938 #define PDMAUDIO_IHOSTAUDIO_FN_PARAMS_STREAMCREATE (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 939 940 #define PDMAUDIO_IHOSTAUDIO_FN_RET_STREAMDESTROY int 941 #define PDMAUDIO_IHOSTAUDIO_FN_PARAMS_STREAMDESTROY (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 942 943 #define PDMAUDIO_IHOSTAUDIO_FN_RET_STREAMCONTROL int 944 #define PDMAUDIO_IHOSTAUDIO_FN_PARAMS_STREAMCONTROL (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 945 946 #define PDMAUDIO_IHOSTAUDIO_FN_RET_STREAMGETSTATUS PDMAUDIOSTRMSTS 947 #define PDMAUDIO_IHOSTAUDIO_FN_PARAMS_STREAMGETSTATUS (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 948 949 #define PDMAUDIO_IHOSTAUDIO_FN_RET_STREAMITERATE int 950 #define PDMAUDIO_IHOSTAUDIO_FN_PARAMS_STREAMITERATE (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 951 952 #define PDMAUDIO_IHOSTAUDIO_FN_RET_STREAMPLAY int 953 #define PDMAUDIO_IHOSTAUDIO_FN_PARAMS_STREAMPLAY (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten) 954 955 #define PDMAUDIO_IHOSTAUDIO_FN_RET_STREAMCAPTURE int 956 #define PDMAUDIO_IHOSTAUDIO_FN_PARAMS_STREAMCAPTURE (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead) 957 958 #define PDMAUDIO_IHOSTAUDIO_DEF_FN(a_Prefix, a_Func) \ 959 static DECLCALLBACK(PDMAUDIO_IHOSTAUDIO_FN_RET_##a_Func) a_Prefix PDMAUDIO_IHOSTAUDIO_FN_PARAMS_##a_Func 960 961 #define PDMAUDIO_IHOSTAUDIO_EMIT_INIT(a_Prefix) PDMAUDIO_IHOSTAUDIO_DEF_FN(RT_CONCAT(a_Prefix, Init), INIT) 962 #define PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(a_Prefix) PDMAUDIO_IHOSTAUDIO_DEF_FN(RT_CONCAT(a_Prefix, Shutdown), SHUTDOWN) 963 #define PDMAUDIO_IHOSTAUDIO_EMIT_GETCONFIG(a_Prefix) PDMAUDIO_IHOSTAUDIO_DEF_FN(RT_CONCAT(a_Prefix, GetConfig), GETCONFIG) 964 #define PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(a_Prefix) PDMAUDIO_IHOSTAUDIO_DEF_FN(RT_CONCAT(a_Prefix, GetStatus), GETSTATUS) 965 #define PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCREATE(a_Prefix) PDMAUDIO_IHOSTAUDIO_DEF_FN(RT_CONCAT(a_Prefix, StreamCreate), STREAMCREATE) 966 #define PDMAUDIO_IHOSTAUDIO_EMIT_STREAMDESTROY(a_Prefix) PDMAUDIO_IHOSTAUDIO_DEF_FN(RT_CONCAT(a_Prefix, StreamDestroy), STREAMDESTROY) 967 #define PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCONTROL(a_Prefix) PDMAUDIO_IHOSTAUDIO_DEF_FN(RT_CONCAT(a_Prefix, StreamControl), STREAMCONTROL) 968 #define PDMAUDIO_IHOSTAUDIO_EMIT_STREAMGETSTATUS(a_Prefix) PDMAUDIO_IHOSTAUDIO_DEF_FN(RT_CONCAT(a_Prefix, StreamGetStatus), STREAMGETSTATUS) 969 #define PDMAUDIO_IHOSTAUDIO_EMIT_STREAMITERATE(a_Prefix) PDMAUDIO_IHOSTAUDIO_DEF_FN(RT_CONCAT(a_Prefix, StreamIterate), STREAMITERATE) 970 #define PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(a_Prefix) PDMAUDIO_IHOSTAUDIO_DEF_FN(RT_CONCAT(a_Prefix, StreamPlay), STREAMPLAY) 971 #define PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCAPTURE(a_Prefix) PDMAUDIO_IHOSTAUDIO_DEF_FN(RT_CONCAT(a_Prefix, StreamCapture), STREAMCAPTURE) 922 972 923 973 /** Pointer to a host audio interface. */ … … 934 984 * @param pInterface Pointer to the interface structure containing the called function pointer. 935 985 */ 936 DECLR3CALLBACKMEMBER( int, pfnInit, (PPDMIHOSTAUDIO pInterface));986 DECLR3CALLBACKMEMBER(PDMAUDIO_IHOSTAUDIO_FN_RET_INIT, pfnInit, PDMAUDIO_IHOSTAUDIO_FN_PARAMS_INIT); 937 987 938 988 /** … … 942 992 * @param pInterface Pointer to the interface structure containing the called function pointer. 943 993 */ 944 DECLR3CALLBACKMEMBER( void, pfnShutdown, (PPDMIHOSTAUDIO pInterface));994 DECLR3CALLBACKMEMBER(PDMAUDIO_IHOSTAUDIO_FN_RET_SHUTDOWN, pfnShutdown, PDMAUDIO_IHOSTAUDIO_FN_PARAMS_SHUTDOWN); 945 995 946 996 /** … … 951 1001 * @param pBackendCfg Pointer where to store the backend audio configuration to. 952 1002 */ 953 DECLR3CALLBACKMEMBER( int, pfnGetConfig, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pBackendCfg));1003 DECLR3CALLBACKMEMBER(PDMAUDIO_IHOSTAUDIO_FN_RET_GETCONFIG, pfnGetConfig, PDMAUDIO_IHOSTAUDIO_FN_PARAMS_GETCONFIG); 954 1004 955 1005 /** … … 960 1010 * @param enmDir Audio direction to get status for. Pass PDMAUDIODIR_ANY for overall status. 961 1011 */ 962 DECLR3CALLBACKMEMBER(PDMAUDIOBACKENDSTS, pfnGetStatus, (PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir)); 963 964 /** 965 * Creates an audio stream. 1012 DECLR3CALLBACKMEMBER(PDMAUDIO_IHOSTAUDIO_FN_RET_GETSTATUS, pfnGetStatus, PDMAUDIO_IHOSTAUDIO_FN_PARAMS_GETSTATUS); 1013 1014 /** 1015 * Creates an audio stream using the requested stream configuration. 1016 * If a backend is not able to create this configuration, it will return its best match in the acquired configuration 1017 * structure on success. 966 1018 * 967 1019 * @returns VBox status code. 968 1020 * @param pInterface Pointer to the interface structure containing the called function pointer. 969 1021 * @param pStream Pointer to audio stream. 970 * @param p StreamCfg Pointer tostream configuration.971 * @param p cSamples Returns how many samples the backend can handle. Optional.972 */ 973 DECLR3CALLBACKMEMBER( int, pfnStreamCreate, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples));1022 * @param pCfgReq Pointer to requested stream configuration. 1023 * @param pCfgAcq Pointer to acquired stream configuration. 1024 */ 1025 DECLR3CALLBACKMEMBER(PDMAUDIO_IHOSTAUDIO_FN_RET_STREAMCREATE, pfnStreamCreate, PDMAUDIO_IHOSTAUDIO_FN_PARAMS_STREAMCREATE); 974 1026 975 1027 /** … … 980 1032 * @param pStream Pointer to audio stream. 981 1033 */ 982 DECLR3CALLBACKMEMBER( int, pfnStreamDestroy, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream));1034 DECLR3CALLBACKMEMBER(PDMAUDIO_IHOSTAUDIO_FN_RET_STREAMDESTROY, pfnStreamDestroy, PDMAUDIO_IHOSTAUDIO_FN_PARAMS_STREAMDESTROY); 983 1035 984 1036 /** … … 990 1042 * @param enmStreamCmd The stream command to issue. 991 1043 */ 992 DECLR3CALLBACKMEMBER( int, pfnStreamControl, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd));1044 DECLR3CALLBACKMEMBER(PDMAUDIO_IHOSTAUDIO_FN_RET_STREAMCONTROL, pfnStreamControl, PDMAUDIO_IHOSTAUDIO_FN_PARAMS_STREAMCONTROL); 993 1045 994 1046 /** 995 1047 * Returns whether the specified audio direction in the backend is enabled or not. 996 1048 * 1049 * @returns PDMAUDIOSTRMSTS 997 1050 * @param pInterface Pointer to the interface structure containing the called function pointer. 998 1051 * @param enmDir Audio direction to check status for. 999 1052 */ 1000 DECLR3CALLBACKMEMBER(PDMAUDIOSTRMSTS, pfnStreamGetStatus, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)); 1001 1002 /** 1003 ** @todo Docs! 1004 */ 1005 DECLR3CALLBACKMEMBER(int, pfnStreamIterate, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)); 1006 1007 /** 1008 * Plays an audio (output) stream. 1053 DECLR3CALLBACKMEMBER(PDMAUDIO_IHOSTAUDIO_FN_RET_STREAMGETSTATUS, pfnStreamGetStatus, PDMAUDIO_IHOSTAUDIO_FN_PARAMS_STREAMGETSTATUS); 1054 1055 /** 1056 * Gives the host backend the chance to do some (necessary) iteration work. 1009 1057 * 1010 1058 * @returns VBox status code. 1011 1059 * @param pInterface Pointer to the interface structure containing the called function pointer. 1012 1060 * @param pStream Pointer to audio stream. 1013 * @param pcSamplesPlayed Pointer to number of samples captured. 1014 */ 1015 DECLR3CALLBACKMEMBER(int, pfnStreamPlay, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesPlayed)); 1016 1017 /** 1018 * Captures an audio (input) stream. 1061 */ 1062 DECLR3CALLBACKMEMBER(PDMAUDIO_IHOSTAUDIO_FN_RET_STREAMITERATE, pfnStreamIterate, PDMAUDIO_IHOSTAUDIO_FN_PARAMS_STREAMITERATE); 1063 1064 /** 1065 * Plays (writes to) an audio (output) stream. 1019 1066 * 1020 1067 * @returns VBox status code. 1021 1068 * @param pInterface Pointer to the interface structure containing the called function pointer. 1022 1069 * @param pStream Pointer to audio stream. 1023 * @param pcSamplesCaptured Pointer to number of samples captured. 1024 */ 1025 DECLR3CALLBACKMEMBER(int, pfnStreamCapture, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesCaptured)); 1070 * @param pvBuf Pointer to audio data buffer to play. 1071 * @param cbBuf Size (in bytes) of audio data buffer. 1072 * @param pcbWritten Returns number of bytes written. Optional. 1073 */ 1074 DECLR3CALLBACKMEMBER(PDMAUDIO_IHOSTAUDIO_FN_RET_STREAMPLAY, pfnStreamPlay, PDMAUDIO_IHOSTAUDIO_FN_PARAMS_STREAMPLAY); 1075 1076 /** 1077 * Captures (reads from) an audio (input) stream. 1078 * 1079 * @returns VBox status code. 1080 * @param pInterface Pointer to the interface structure containing the called function pointer. 1081 * @param pStream Pointer to audio stream. 1082 * @param pvBuf Buffer where to store read audio data. 1083 * @param cbBuf Size (in bytes) of buffer. 1084 * @param pcbRead Returns number of bytes read. Optional. 1085 */ 1086 DECLR3CALLBACKMEMBER(PDMAUDIO_IHOSTAUDIO_FN_RET_STREAMCAPTURE, pfnStreamCapture, PDMAUDIO_IHOSTAUDIO_FN_PARAMS_STREAMCAPTURE); 1026 1087 1027 1088 } PDMIHOSTAUDIO; 1028 1089 1029 1090 /** PDMIHOSTAUDIO interface ID. */ 1030 #define PDMIHOSTAUDIO_IID " 96AC69D0-F301-42AC-8F1D-1E19BA808887"1091 #define PDMIHOSTAUDIO_IID "C3B069D4-0543-474B-AE81-769B3E8F40DA" 1031 1092 1032 1093 /** @} */ -
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r63212 r63360 521 521 */ 522 522 523 /* Make the acquired host configuration the requested host configuration by default. */ 524 PDMAUDIOSTREAMCFG CfgAcq; 525 memcpy(&CfgAcq, pCfgHost, sizeof(PDMAUDIOSTREAMCFG)); 526 523 527 uint32_t cSamples = 0; 524 int rc = pThis->pHostDrvAudio->pfnStreamCreate(pThis->pHostDrvAudio, pHstStream, pCfgHost, &cSamples); 528 int rc = pThis->pHostDrvAudio->pfnStreamCreate(pThis->pHostDrvAudio, pHstStream, 529 pCfgHost /* pCfgReq */, &CfgAcq /* pCfgAcq */); 525 530 if (RT_SUCCESS(rc)) 526 531 { … … 1028 1033 { 1029 1034 AssertPtr(pThis->pHostDrvAudio->pfnStreamPlay); 1030 rc = pThis->pHostDrvAudio->pfnStreamPlay(pThis->pHostDrvAudio, pHstStream, &cSamplesPlayed); 1035 rc = pThis->pHostDrvAudio->pfnStreamPlay(pThis->pHostDrvAudio, pHstStream, NULL /* pvBuf */, 0 /* cbBuf */, 1036 &cSamplesPlayed); 1031 1037 if (RT_FAILURE(rc)) 1032 1038 { … … 1135 1141 && (strmSts & PDMAUDIOSTRMSTS_FLAG_DATA_READABLE)) 1136 1142 { 1137 rc = pThis->pHostDrvAudio->pfnStreamCapture(pThis->pHostDrvAudio, pHstStream, &cSamplesCaptured); 1143 rc = pThis->pHostDrvAudio->pfnStreamCapture(pThis->pHostDrvAudio, pHstStream, NULL /* pvBuf */, 0 /* cbBuf */, 1144 &cSamplesCaptured); 1138 1145 if (RT_FAILURE(rc)) 1139 1146 { -
trunk/src/VBox/Devices/Audio/DrvHostALSAAudio.cpp
r63214 r63360 220 220 } 221 221 222 222 223 static int alsaALSAToAudioFmt(snd_pcm_format_t fmt, 223 224 PDMAUDIOFMT *pFmt, PDMAUDIOENDIANNESS *pEndianness) … … 295 296 return VINF_SUCCESS; 296 297 } 298 297 299 298 300 static int alsaGetSampleShift(snd_pcm_format_t fmt, unsigned *puShift) … … 329 331 } 330 332 333 331 334 static int alsaStreamSetThreshold(snd_pcm_t *phPCM, snd_pcm_uframes_t threshold) 332 335 { … … 383 386 } 384 387 388 385 389 static int alsaStreamClose(snd_pcm_t **pphPCM) 386 390 { … … 404 408 } 405 409 410 406 411 #if 0 /* After Beta. */ 407 412 static int alsaSetHWParams(snd_pcm_t *phPCM, PALSAAUDIOSTREAMCFG pCfg) … … 532 537 return rc; 533 538 } 539 540 534 541 static int alsaSetSWParams(snd_pcm_t *phPCM, PALSAAUDIOCFG pCfg) 535 542 { … … 594 601 } 595 602 #endif 603 596 604 597 605 static int alsaStreamOpen(bool fIn, PALSAAUDIOSTREAMCFG pCfgReq, PALSAAUDIOSTREAMCFG pCfgObt, snd_pcm_t **pphPCM) … … 884 892 } 885 893 894 886 895 #ifdef DEBUG 887 896 static void alsaDbgErrorHandler(const char *file, int line, const char *function, … … 893 902 #endif 894 903 904 895 905 static int alsaStreamGetAvail(snd_pcm_t *phPCM, snd_pcm_sframes_t *pFramesAvail) 896 906 { … … 922 932 } 923 933 934 924 935 static int alsaStreamRecover(snd_pcm_t *phPCM) 925 936 { … … 936 947 } 937 948 949 938 950 static int alsaStreamResume(snd_pcm_t *phPCM) 939 951 { … … 950 962 } 951 963 964 952 965 static int drvHostALSAAudioStreamCtl(snd_pcm_t *phPCM, bool fPause) 953 966 { … … 975 988 } 976 989 977 static DECLCALLBACK(int) drvHostALSAAudioInit(PPDMIHOSTAUDIO pInterface) 990 991 /** 992 * @interface_method_impl{PDMIHOSTAUDIO,pfnInit} 993 */ 994 PDMAUDIO_IHOSTAUDIO_EMIT_INIT(drvHostALSAAudio) 978 995 { 979 996 NOREF(pInterface); … … 994 1011 } 995 1012 996 static DECLCALLBACK(int) drvHostALSAAudioStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 997 uint32_t *pcSamplesCaptured) 998 { 999 NOREF(pInterface); 1000 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1013 1014 /** 1015 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture} 1016 */ 1017 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCAPTURE(drvHostALSAAudio) 1018 { 1019 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1020 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1021 /* pcbRead is optional. */ 1001 1022 1002 1023 PALSAAUDIOSTREAMIN pThisStream = (PALSAAUDIOSTREAMIN)pStream; … … 1036 1057 if (!cAvail) 1037 1058 { 1038 if (pc SamplesCaptured)1039 *pc SamplesCaptured = 0;1059 if (pcbRead) 1060 *pcbRead = 0; 1040 1061 return VINF_SUCCESS; 1041 1062 } … … 1134 1155 &cProcessed); 1135 1156 1136 if (pc SamplesCaptured)1137 *pc SamplesCaptured = cWrittenTotal;1157 if (pcbRead) 1158 *pcbRead = cWrittenTotal; 1138 1159 1139 1160 LogFlowFunc(("cWrittenTotal=%RU32 (%RU32 processed), rc=%Rrc\n", … … 1145 1166 } 1146 1167 1147 static DECLCALLBACK(int) drvHostALSAAudioStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 1148 uint32_t *pcSamplesPlayed) 1149 { 1150 NOREF(pInterface); 1151 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1168 /** 1169 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay} 1170 */ 1171 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(drvHostALSAAudio) 1172 { 1173 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1174 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1175 /* pcbWritten is optional. */ 1152 1176 1153 1177 PALSAAUDIOSTREAMOUT pThisStream = (PALSAAUDIOSTREAMOUT)pStream; … … 1255 1279 AudioMixBufFinish(&pStream->MixBuf, cReadTotal); 1256 1280 1257 if (pc SamplesPlayed)1258 *pc SamplesPlayed= cReadTotal;1281 if (pcbWritten) 1282 *pcbWritten = cReadTotal; 1259 1283 1260 1284 LogFlowFunc(("cReadTotal=%RU32 (%RU32 bytes), rc=%Rrc\n", … … 1266 1290 } 1267 1291 1292 1268 1293 static int alsaDestroyStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 1269 1294 { … … 1284 1309 } 1285 1310 1311 1286 1312 static int alsaDestroyStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 1287 1313 { … … 1302 1328 } 1303 1329 1330 1304 1331 static int alsaCreateStreamOut(PPDMIHOSTAUDIO pInterface, 1305 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, 1306 uint32_t *pcSamples) 1307 { 1308 NOREF(pInterface); 1309 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1310 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 1311 1332 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 1333 { 1312 1334 PALSAAUDIOSTREAMOUT pThisStream = (PALSAAUDIOSTREAMOUT)pStream; 1335 1313 1336 snd_pcm_t *phPCM = NULL; 1314 1337 … … 1318 1341 { 1319 1342 ALSAAUDIOSTREAMCFG req; 1320 req.fmt = alsaAudioFmtToALSA(pCfg ->enmFormat);1321 req.freq = pCfg ->uHz;1322 req.nchannels = pCfg ->cChannels;1343 req.fmt = alsaAudioFmtToALSA(pCfgReq->enmFormat); 1344 req.freq = pCfgReq->uHz; 1345 req.nchannels = pCfgReq->cChannels; 1323 1346 req.period_size = s_ALSAConf.period_size_out; 1324 1347 req.buffer_size = s_ALSAConf.buffer_size_out; … … 1335 1358 break; 1336 1359 1337 PDMAUDIOSTREAMCFG streamCfg; 1338 streamCfg.uHz = obt.freq; 1339 streamCfg.cChannels = obt.nchannels; 1340 streamCfg.enmFormat = enmFormat; 1341 streamCfg.enmEndianness = enmEnd; 1342 1343 rc = DrvAudioHlpStreamCfgToProps(&streamCfg, &pStream->Props); 1360 pCfgAcq->uHz = obt.freq; 1361 pCfgAcq->cChannels = obt.nchannels; 1362 pCfgAcq->enmFormat = enmFormat; 1363 pCfgAcq->enmEndianness = enmEnd; 1364 pCfgAcq->cSamples = obt.samples * 4; 1365 1366 PDMPCMPROPS Props; 1367 rc = DrvAudioHlpStreamCfgToProps(pCfgAcq, &Props); 1344 1368 if (RT_FAILURE(rc)) 1345 1369 break; 1346 1370 1347 1371 AssertBreakStmt(obt.samples, rc = VERR_INVALID_PARAMETER); 1348 size_t cbBuf = obt.samples * (1 << pStream->Props.cShift);1372 size_t cbBuf = obt.samples * (1 << Props.cShift); /** @todo Get rid of using Props! */ 1349 1373 AssertBreakStmt(cbBuf, rc = VERR_INVALID_PARAMETER); 1350 1374 pThisStream->pvBuf = RTMemAlloc(cbBuf); … … 1352 1376 { 1353 1377 LogRel(("ALSA: Not enough memory for output DAC buffer (%RU32 samples, each %d bytes)\n", 1354 obt.samples, 1 << pStream->Props.cShift));1378 obt.samples, 1 << Props.cShift)); 1355 1379 rc = VERR_NO_MEMORY; 1356 1380 break; 1357 1381 } 1358 1382 1359 pThisStream->cbBuf = cbBuf; 1360 pThisStream->phPCM = phPCM; 1361 1362 if (pcSamples) 1363 *pcSamples = obt.samples * 4; 1383 pThisStream->cbBuf = cbBuf; 1384 pThisStream->phPCM = phPCM; 1364 1385 } 1365 1386 while (0); … … 1372 1393 } 1373 1394 1395 1374 1396 static int alsaCreateStreamIn(PPDMIHOSTAUDIO pInterface, 1375 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 1376 { 1377 NOREF(pInterface); 1378 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1379 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 1380 1397 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 1398 { 1381 1399 int rc; 1382 1400 … … 1387 1405 { 1388 1406 ALSAAUDIOSTREAMCFG req; 1389 req.fmt = alsaAudioFmtToALSA(pCfg ->enmFormat);1390 req.freq = pCfg ->uHz;1391 req.nchannels = pCfg ->cChannels;1407 req.fmt = alsaAudioFmtToALSA(pCfgReq->enmFormat); 1408 req.freq = pCfgReq->uHz; 1409 req.nchannels = pCfgReq->cChannels; 1392 1410 req.period_size = s_ALSAConf.period_size_in; 1393 1411 req.buffer_size = s_ALSAConf.buffer_size_in; … … 1404 1422 break; 1405 1423 1406 PDMAUDIOSTREAMCFG streamCfg; 1407 streamCfg.uHz = obt.freq; 1408 streamCfg.cChannels = obt.nchannels; 1409 streamCfg.enmFormat = enmFormat; 1410 streamCfg.enmEndianness = enmEnd; 1411 1412 rc = DrvAudioHlpStreamCfgToProps(&streamCfg, &pStream->Props); 1424 pCfgAcq->uHz = obt.freq; 1425 pCfgAcq->cChannels = obt.nchannels; 1426 pCfgAcq->enmFormat = enmFormat; 1427 pCfgAcq->enmEndianness = enmEnd; 1428 pCfgAcq->cSamples = obt.samples; 1429 1430 PDMPCMPROPS Props; 1431 rc = DrvAudioHlpStreamCfgToProps(pCfgAcq, &Props); 1413 1432 if (RT_FAILURE(rc)) 1414 1433 break; 1415 1434 1416 1435 AssertBreakStmt(obt.samples, rc = VERR_INVALID_PARAMETER); 1417 size_t cbBuf = obt.samples * (1 << pStream->Props.cShift);1436 size_t cbBuf = obt.samples * (1 << Props.cShift); /** @todo Get rid of using Props! */ 1418 1437 AssertBreakStmt(cbBuf, rc = VERR_INVALID_PARAMETER); 1419 1438 pThisStream->pvBuf = RTMemAlloc(cbBuf); … … 1421 1440 { 1422 1441 LogRel(("ALSA: Not enough memory for input ADC buffer (%RU32 samples, each %d bytes)\n", 1423 obt.samples, 1 << pStream->Props.cShift));1442 obt.samples, 1 << Props.cShift)); 1424 1443 rc = VERR_NO_MEMORY; 1425 1444 break; 1426 1445 } 1427 1446 1428 pThisStream->cbBuf = cbBuf; 1429 pThisStream->phPCM = phPCM; 1430 1431 if (pcSamples) 1432 *pcSamples = obt.samples; 1447 pThisStream->cbBuf = cbBuf; 1448 pThisStream->phPCM = phPCM; 1433 1449 } 1434 1450 while (0); … … 1440 1456 return rc; 1441 1457 } 1458 1442 1459 1443 1460 static int alsaControlStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, … … 1472 1489 } 1473 1490 1491 1474 1492 static int alsaControlStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 1475 1493 PDMAUDIOSTREAMCMD enmStreamCmd) … … 1503 1521 } 1504 1522 1505 static DECLCALLBACK(int) drvHostALSAAudioGetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pCfg) 1523 1524 /** 1525 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetConfig} 1526 */ 1527 PDMAUDIO_IHOSTAUDIO_EMIT_GETCONFIG(drvHostALSAAudio) 1506 1528 { 1507 1529 NOREF(pInterface); 1508 AssertPtrReturn(p Cfg, VERR_INVALID_POINTER);1509 1510 p Cfg->cbStreamIn = sizeof(ALSAAUDIOSTREAMIN);1511 p Cfg->cbStreamOut = sizeof(ALSAAUDIOSTREAMOUT);1512 1513 p Cfg->cSources = 0;1514 p Cfg->cSinks = 0;1530 AssertPtrReturn(pBackendCfg, VERR_INVALID_POINTER); 1531 1532 pBackendCfg->cbStreamIn = sizeof(ALSAAUDIOSTREAMIN); 1533 pBackendCfg->cbStreamOut = sizeof(ALSAAUDIOSTREAMOUT); 1534 1535 pBackendCfg->cSources = 0; 1536 pBackendCfg->cSinks = 0; 1515 1537 1516 1538 /* Enumerate sound devices. */ … … 1537 1559 { 1538 1560 if (!RTStrICmp("input", pszIOID)) 1539 p Cfg->cSources++;1561 pBackendCfg->cSources++; 1540 1562 else if (!RTStrICmp("output", pszIOID)) 1541 p Cfg->cSinks++;1563 pBackendCfg->cSinks++; 1542 1564 } 1543 1565 else /* NULL means bidirectional, input + output. */ 1544 1566 { 1545 p Cfg->cSources++;1546 p Cfg->cSinks++;1567 pBackendCfg->cSources++; 1568 pBackendCfg->cSinks++; 1547 1569 } 1548 1570 … … 1563 1585 } 1564 1586 1565 LogRel2(("ALSA: Found %RU8 host playback devices\n", p Cfg->cSinks));1566 LogRel2(("ALSA: Found %RU8 host capturing devices\n", p Cfg->cSources));1587 LogRel2(("ALSA: Found %RU8 host playback devices\n", pBackendCfg->cSinks)); 1588 LogRel2(("ALSA: Found %RU8 host capturing devices\n", pBackendCfg->cSources)); 1567 1589 1568 1590 snd_device_name_free_hint((void **)pszHints); … … 1573 1595 1574 1596 /* ALSA allows exactly one input and one output used at a time for the selected device(s). */ 1575 p Cfg->cMaxStreamsIn = 1;1576 p Cfg->cMaxStreamsOut = 1;1597 pBackendCfg->cMaxStreamsIn = 1; 1598 pBackendCfg->cMaxStreamsOut = 1; 1577 1599 1578 1600 return VINF_SUCCESS; 1579 1601 } 1580 1602 1581 static DECLCALLBACK(void) drvHostALSAAudioShutdown(PPDMIHOSTAUDIO pInterface) 1603 1604 /** 1605 * @interface_method_impl{PDMIHOSTAUDIO,pfnShutdown} 1606 */ 1607 PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(drvHostALSAAudio) 1582 1608 { 1583 1609 NOREF(pInterface); 1584 1610 } 1585 1611 1586 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvHostALSAAudioGetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir) 1612 1613 /** 1614 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus} 1615 */ 1616 PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(drvHostALSAAudio) 1587 1617 { 1588 1618 RT_NOREF(enmDir); … … 1592 1622 } 1593 1623 1594 static DECLCALLBACK(int) drvHostALSAAudioStreamCreate(PPDMIHOSTAUDIO pInterface, 1595 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 1624 1625 /** 1626 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate} 1627 */ 1628 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCREATE(drvHostALSAAudio) 1596 1629 { 1597 1630 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1598 1631 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1599 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 1632 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); 1633 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER); 1600 1634 1601 1635 int rc; 1602 if (pCfg ->enmDir == PDMAUDIODIR_IN)1603 rc = alsaCreateStreamIn(pInterface, pStream, pCfg , pcSamples);1636 if (pCfgReq->enmDir == PDMAUDIODIR_IN) 1637 rc = alsaCreateStreamIn(pInterface, pStream, pCfgReq, pCfgAcq); 1604 1638 else 1605 rc = alsaCreateStreamOut(pInterface, pStream, pCfg , pcSamples);1639 rc = alsaCreateStreamOut(pInterface, pStream, pCfgReq, pCfgAcq); 1606 1640 1607 1641 LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc)); … … 1609 1643 } 1610 1644 1611 static DECLCALLBACK(int) drvHostALSAAudioStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 1645 1646 /** 1647 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy} 1648 */ 1649 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMDESTROY(drvHostALSAAudio) 1612 1650 { 1613 1651 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 1623 1661 } 1624 1662 1625 static DECLCALLBACK(int) drvHostALSAAudioStreamControl(PPDMIHOSTAUDIO pInterface, 1626 PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 1663 1664 /** 1665 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl} 1666 */ 1667 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCONTROL(drvHostALSAAudio) 1627 1668 { 1628 1669 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 1640 1681 } 1641 1682 1642 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostALSAAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 1683 1684 /** 1685 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus} 1686 */ 1687 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMGETSTATUS(drvHostALSAAudio) 1643 1688 { 1644 1689 NOREF(pInterface); … … 1669 1714 } 1670 1715 1671 static DECLCALLBACK(int) drvHostALSAAudioStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 1716 1717 /** 1718 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamIterate} 1719 */ 1720 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMITERATE(drvHostALSAAudio) 1672 1721 { 1673 1722 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 1679 1728 return VINF_SUCCESS; 1680 1729 } 1730 1681 1731 1682 1732 /** … … 1692 1742 return NULL; 1693 1743 } 1744 1694 1745 1695 1746 /** … … 1716 1767 return VINF_SUCCESS; 1717 1768 } 1769 1718 1770 1719 1771 /** -
trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp
r62337 r63360 388 388 389 389 390 static int coreAudioInitIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, uint32_t *pcSamples);391 static int coreAudioInitOut(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, uint32_t *pcSamples);390 static int coreAudioInitIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq); 391 static int coreAudioInitOut(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq); 392 392 static int coreAudioControlStreamIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd); 393 393 static int coreAudioControlStreamOut(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd); 394 static int coreAudioCreateStreamIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg , uint32_t *pcSamples);395 static int coreAudioCreateStreamOut(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg , uint32_t *pcSamples);394 static int coreAudioCreateStreamIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq); 395 static int coreAudioCreateStreamOut(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq); 396 396 static int coreAudioDestroyStreamIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream); 397 397 static int coreAudioDestroyStreamOut(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream); … … 1093 1093 1094 1094 /** @todo Eventually split up this function, as this already is huge! */ 1095 static int coreAudioInitIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, uint32_t *pcSamples) 1096 { 1095 static int coreAudioInitIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, 1096 PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 1097 { 1098 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 1099 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1100 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); 1101 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER); 1102 1097 1103 int rc = VINF_SUCCESS; 1098 1104 … … 1485 1491 LogFunc(("cSamples=%RU32\n", cSamples)); 1486 1492 1487 if (p cSamples)1488 *pcSamples = cSamples;1493 if (pCfgAcq) 1494 pCfgAcq->cSamples = cSamples; 1489 1495 } 1490 1496 else … … 1508 1514 1509 1515 /** @todo Eventually split up this function, as this already is huge! */ 1510 static int coreAudioInitOut(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, uint32_t *pcSamples) 1511 { 1516 static int coreAudioInitOut(PDRVHOSTCOREAUDIO pThis, 1517 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 1518 { 1519 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 1520 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1521 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); 1522 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER); 1523 1512 1524 int rc = VINF_SUCCESS; 1513 1525 … … 1788 1800 LogFunc(("cSamples=%RU32\n", cSamples)); 1789 1801 1790 if (p cSamples)1791 *pcSamples = cSamples;1802 if (pCfgAcq) 1803 pCfgAcq->cSamples = cSamples; 1792 1804 } 1793 1805 else … … 1895 1907 static DECLCALLBACK(int) drvHostCoreAudioInit(PPDMIHOSTAUDIO pInterface) 1896 1908 { 1897 NOREF(pInterface);1909 RT_NOREF(pInterface); 1898 1910 1899 1911 LogFlowFuncEnter(); … … 1903 1915 1904 1916 static DECLCALLBACK(int) drvHostCoreAudioStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 1905 uint32_t *pcSamplesCaptured) 1906 { 1917 void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead) 1918 { 1919 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1920 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1921 /* pcbRead is optional. */ 1922 1907 1923 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface); 1908 1924 PDRVHOSTCOREAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTCOREAUDIO); … … 1916 1932 if (ASMAtomicReadU32(&pStreamIn->status) != CA_STATUS_INIT) 1917 1933 { 1918 if (pc SamplesCaptured)1919 *pc SamplesCaptured = 0;1934 if (pcbRead) 1935 *pcbRead = 0; 1920 1936 return VINF_SUCCESS; 1921 1937 } … … 1995 2011 LogFlowFunc(("%RU32 samples captured\n", cCaptured)); 1996 2012 1997 if (pc SamplesCaptured)1998 *pc SamplesCaptured = cCaptured;2013 if (pcbRead) 2014 *pcbRead = cCaptured; 1999 2015 } 2000 2016 … … 2005 2021 } 2006 2022 2007 static DECLCALLBACK(int) drvHostCoreAudioStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 2008 uint32_t *pcSamplesPlayed) 2009 { 2023 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(drvHostCoreAudio) 2024 { 2025 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 2026 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 2027 /* pcbWritten is optional. */ 2028 2010 2029 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface); 2011 2030 PDRVHOSTCOREAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTCOREAUDIO); … … 2018 2037 if (!cLive) /* Not live samples to play? Bail out. */ 2019 2038 { 2020 if (pc SamplesPlayed)2021 *pc SamplesPlayed= 0;2039 if (pcbWritten) 2040 *pcbWritten = 0; 2022 2041 return VINF_SUCCESS; 2023 2042 } … … 2074 2093 Log3Func(("cReadTotal=%RU32 (%RU32 bytes)\n", cReadTotal, cbReadTotal)); 2075 2094 2076 if (pc SamplesPlayed)2077 *pc SamplesPlayed= cReadTotal;2095 if (pcbWritten) 2096 *pcbWritten = cReadTotal; 2078 2097 } 2079 2098 … … 2449 2468 2450 2469 static int coreAudioCreateStreamIn(PDRVHOSTCOREAUDIO pThis, 2451 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 2452 { 2470 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 2471 { 2472 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 2473 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 2474 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); 2475 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER); 2476 2453 2477 PCOREAUDIOSTREAMIN pStreamIn = (PCOREAUDIOSTREAMIN)pStream; 2454 2478 2455 LogFlowFunc(("enmRecSource=%RU32\n", pCfg ->DestSource.Source));2479 LogFlowFunc(("enmRecSource=%RU32\n", pCfgReq->DestSource.Source)); 2456 2480 2457 2481 pStreamIn->deviceID = kAudioDeviceUnknown; … … 2471 2495 bool fDeviceByUser = false; /* Do we use a device which was set by the user? */ 2472 2496 2473 /* Initialize the hardware info section with the audio settings */ 2474 int rc = DrvAudioHlpStreamCfgToProps(pCfg, &pStreamIn->Stream.Props); 2497 #if 0 2498 /* Try to find the audio device set by the user */ 2499 if (DeviceUID.pszInputDeviceUID) 2500 { 2501 pStreamIn->deviceID = drvHostCoreAudioDeviceUIDtoID(DeviceUID.pszInputDeviceUID); 2502 /* Not fatal */ 2503 if (pStreamIn->deviceID == kAudioDeviceUnknown) 2504 LogRel(("CoreAudio: Unable to find recording device %s. Falling back to the default audio device. \n", DeviceUID.pszInputDeviceUID)); 2505 else 2506 fDeviceByUser = true; 2507 } 2508 #endif 2509 int rc = coreAudioInitIn(pThis, &pStreamIn->Stream, pCfgReq, pCfgAcq); 2475 2510 if (RT_SUCCESS(rc)) 2476 2511 { 2477 #if 0 2478 /* Try to find the audio device set by the user */ 2479 if (DeviceUID.pszInputDeviceUID) 2480 { 2481 pStreamIn->deviceID = drvHostCoreAudioDeviceUIDtoID(DeviceUID.pszInputDeviceUID); 2482 /* Not fatal */ 2483 if (pStreamIn->deviceID == kAudioDeviceUnknown) 2484 LogRel(("CoreAudio: Unable to find recording device %s. Falling back to the default audio device. \n", DeviceUID.pszInputDeviceUID)); 2512 OSStatus err; 2513 2514 /* When the devices isn't forced by the user, we want default device change notifications. */ 2515 if (!fDeviceByUser) 2516 { 2517 if (!pStreamIn->fDefDevChgListReg) 2518 { 2519 AudioObjectPropertyAddress propAdr = { kAudioHardwarePropertyDefaultInputDevice, kAudioObjectPropertyScopeGlobal, 2520 kAudioObjectPropertyElementMaster }; 2521 err = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &propAdr, 2522 coreAudioDefaultDeviceChanged, &pStreamIn->cbCtx); 2523 if ( err == noErr 2524 || err == kAudioHardwareIllegalOperationError) 2525 { 2526 pStreamIn->fDefDevChgListReg = true; 2527 } 2528 else 2529 LogRel(("CoreAudio: Failed to add the default recording device changed listener (%RI32)\n", err)); 2530 } 2531 } 2532 2533 if ( !pStreamIn->fDevStateChgListReg 2534 && (pStreamIn->deviceID != kAudioDeviceUnknown)) 2535 { 2536 /* Register callback for being notified if the device stops being alive. */ 2537 AudioObjectPropertyAddress propAdr = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal, 2538 kAudioObjectPropertyElementMaster }; 2539 err = AudioObjectAddPropertyListener(pStreamIn->deviceID, &propAdr, drvHostCoreAudioDeviceStateChanged, 2540 &pStreamIn->cbCtx); 2541 if (err == noErr) 2542 { 2543 pStreamIn->fDevStateChgListReg = true; 2544 } 2485 2545 else 2486 fDeviceByUser = true; 2487 } 2488 #endif 2489 rc = coreAudioInitIn(pThis, &pStreamIn->Stream, pcSamples); 2490 } 2491 2492 OSStatus err; 2493 2494 /* When the devices isn't forced by the user, we want default device change notifications. */ 2495 if (!fDeviceByUser) 2496 { 2497 if (!pStreamIn->fDefDevChgListReg) 2498 { 2499 AudioObjectPropertyAddress propAdr = { kAudioHardwarePropertyDefaultInputDevice, kAudioObjectPropertyScopeGlobal, 2500 kAudioObjectPropertyElementMaster }; 2501 err = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &propAdr, 2502 coreAudioDefaultDeviceChanged, &pStreamIn->cbCtx); 2503 if ( err == noErr 2504 || err == kAudioHardwareIllegalOperationError) 2505 { 2506 pStreamIn->fDefDevChgListReg = true; 2507 } 2508 else 2509 LogRel(("CoreAudio: Failed to add the default recording device changed listener (%RI32)\n", err)); 2510 } 2511 } 2512 2513 if ( !pStreamIn->fDevStateChgListReg 2514 && (pStreamIn->deviceID != kAudioDeviceUnknown)) 2515 { 2516 /* Register callback for being notified if the device stops being alive. */ 2517 AudioObjectPropertyAddress propAdr = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal, 2518 kAudioObjectPropertyElementMaster }; 2519 err = AudioObjectAddPropertyListener(pStreamIn->deviceID, &propAdr, drvHostCoreAudioDeviceStateChanged, 2520 &pStreamIn->cbCtx); 2521 if (err == noErr) 2522 { 2523 pStreamIn->fDevStateChgListReg = true; 2524 } 2525 else 2526 LogRel(("CoreAudio: Failed to add the recording device state changed listener (%RI32)\n", err)); 2546 LogRel(("CoreAudio: Failed to add the recording device state changed listener (%RI32)\n", err)); 2547 } 2527 2548 } 2528 2549 … … 2532 2553 2533 2554 static int coreAudioCreateStreamOut(PDRVHOSTCOREAUDIO pThis, 2534 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, 2535 uint32_t *pcSamples) 2536 { 2555 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 2556 { 2557 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 2558 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 2559 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); 2560 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER); 2561 2537 2562 PCOREAUDIOSTREAMOUT pStreamOut = (PCOREAUDIOSTREAMOUT)pStream; 2538 2563 … … 2553 2578 bool fDeviceByUser = false; /* Do we use a device which was set by the user? */ 2554 2579 2555 /* If a stream configuration is given, apply that to the stream. */ 2556 int rc = DrvAudioHlpStreamCfgToProps(pCfg, &pStreamOut->Stream.Props); 2580 #if 0 2581 /* Try to find the audio device set by the user. Use 2582 * export VBOX_COREAUDIO_OUTPUT_DEVICE_UID=AppleHDAEngineOutput:0 2583 * to set it. */ 2584 if (DeviceUID.pszOutputDeviceUID) 2585 { 2586 pStreamOut->audioDeviceId = drvHostCoreAudioDeviceUIDtoID(DeviceUID.pszOutputDeviceUID); 2587 /* Not fatal */ 2588 if (pStreamOut->audioDeviceId == kAudioDeviceUnknown) 2589 LogRel(("CoreAudio: Unable to find playback device %s. Falling back to the default audio device. \n", DeviceUID.pszOutputDeviceUID)); 2590 else 2591 fDeviceByUser = true; 2592 } 2593 #endif 2594 int rc = coreAudioInitOut(pThis, pStream, pCfgReq, pCfgAcq); 2557 2595 if (RT_SUCCESS(rc)) 2558 2596 { 2559 #if 0 2560 /* Try to find the audio device set by the user. Use 2561 * export VBOX_COREAUDIO_OUTPUT_DEVICE_UID=AppleHDAEngineOutput:0 2562 * to set it. */ 2563 if (DeviceUID.pszOutputDeviceUID) 2564 { 2565 pStreamOut->audioDeviceId = drvHostCoreAudioDeviceUIDtoID(DeviceUID.pszOutputDeviceUID); 2566 /* Not fatal */ 2567 if (pStreamOut->audioDeviceId == kAudioDeviceUnknown) 2568 LogRel(("CoreAudio: Unable to find playback device %s. Falling back to the default audio device. \n", DeviceUID.pszOutputDeviceUID)); 2597 OSStatus err; 2598 2599 /* When the devices isn't forced by the user, we want default device change notifications. */ 2600 if (!fDeviceByUser) 2601 { 2602 AudioObjectPropertyAddress propAdr = { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal, 2603 kAudioObjectPropertyElementMaster }; 2604 err = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &propAdr, 2605 coreAudioDefaultDeviceChanged, &pStreamOut->cbCtx); 2606 if (err == noErr) 2607 { 2608 pStreamOut->fDefDevChgListReg = true; 2609 } 2569 2610 else 2570 fDeviceByUser = true; 2571 } 2572 #endif 2573 rc = coreAudioInitOut(pThis, pStream, pcSamples); 2574 } 2575 2576 OSStatus err; 2577 2578 /* When the devices isn't forced by the user, we want default device change notifications. */ 2579 if (!fDeviceByUser) 2580 { 2581 AudioObjectPropertyAddress propAdr = { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal, 2582 kAudioObjectPropertyElementMaster }; 2583 err = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &propAdr, 2584 coreAudioDefaultDeviceChanged, &pStreamOut->cbCtx); 2585 if (err == noErr) 2586 { 2587 pStreamOut->fDefDevChgListReg = true; 2588 } 2589 else 2590 LogRel(("CoreAudio: Failed to add the default playback device changed listener (%RI32)\n", err)); 2591 } 2592 2593 if ( !pStreamOut->fDevStateChgListReg 2594 && (pStreamOut->deviceID != kAudioDeviceUnknown)) 2595 { 2596 /* Register callback for being notified if the device stops being alive. */ 2597 AudioObjectPropertyAddress propAdr = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal, 2598 kAudioObjectPropertyElementMaster }; 2599 err = AudioObjectAddPropertyListener(pStreamOut->deviceID, &propAdr, drvHostCoreAudioDeviceStateChanged, 2600 (void *)&pStreamOut->cbCtx); 2601 if (err == noErr) 2602 { 2603 pStreamOut->fDevStateChgListReg = true; 2604 } 2605 else 2606 LogRel(("CoreAudio: Failed to add the playback device state changed listener (%RI32)\n", err)); 2611 LogRel(("CoreAudio: Failed to add the default playback device changed listener (%RI32)\n", err)); 2612 } 2613 2614 if ( !pStreamOut->fDevStateChgListReg 2615 && (pStreamOut->deviceID != kAudioDeviceUnknown)) 2616 { 2617 /* Register callback for being notified if the device stops being alive. */ 2618 AudioObjectPropertyAddress propAdr = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal, 2619 kAudioObjectPropertyElementMaster }; 2620 err = AudioObjectAddPropertyListener(pStreamOut->deviceID, &propAdr, drvHostCoreAudioDeviceStateChanged, 2621 (void *)&pStreamOut->cbCtx); 2622 if (err == noErr) 2623 { 2624 pStreamOut->fDevStateChgListReg = true; 2625 } 2626 else 2627 LogRel(("CoreAudio: Failed to add the playback device state changed listener (%RI32)\n", err)); 2628 } 2607 2629 } 2608 2630 … … 2611 2633 } 2612 2634 2613 static DECLCALLBACK(int) drvHostCoreAudioGetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pCfg)2614 { 2615 AssertPtrReturn(pInterface, VERR_INVALID_POINTER);2616 AssertPtrReturn(p Cfg,VERR_INVALID_POINTER);2635 PDMAUDIO_IHOSTAUDIO_EMIT_GETCONFIG(drvHostCoreAudio) 2636 { 2637 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 2638 AssertPtrReturn(pBackendCfg, VERR_INVALID_POINTER); 2617 2639 2618 2640 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface); 2619 2641 PDRVHOSTCOREAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTCOREAUDIO); 2620 2642 2621 return coreAudioUpdateStatusInternalEx(pThis, p Cfg, 0 /* fEnum */);2622 } 2623 2624 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvHostCoreAudioGetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir)2643 return coreAudioUpdateStatusInternalEx(pThis, pBackendCfg, 0 /* fEnum */); 2644 } 2645 2646 PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(drvHostCoreAudio) 2625 2647 { 2626 2648 AssertPtrReturn(pInterface, PDMAUDIOBACKENDSTS_UNKNOWN); … … 2629 2651 } 2630 2652 2631 static DECLCALLBACK(int) drvHostCoreAudioStreamCreate(PPDMIHOSTAUDIO pInterface, 2632 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 2653 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCREATE(drvHostCoreAudio) 2633 2654 { 2634 2655 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 2635 2656 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 2636 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 2657 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); 2658 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER); 2637 2659 2638 2660 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface); … … 2640 2662 2641 2663 int rc; 2642 if (pCfg ->enmDir == PDMAUDIODIR_IN)2643 rc = coreAudioCreateStreamIn(pThis, pStream, pCfg , pcSamples);2664 if (pCfgReq->enmDir == PDMAUDIODIR_IN) 2665 rc = coreAudioCreateStreamIn(pThis, pStream, pCfgReq, pCfgAcq); 2644 2666 else 2645 rc = coreAudioCreateStreamOut(pThis, pStream, pCfg , pcSamples);2667 rc = coreAudioCreateStreamOut(pThis, pStream, pCfgReq, pCfgAcq); 2646 2668 2647 2669 LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc)); … … 2649 2671 } 2650 2672 2651 static DECLCALLBACK(int) drvHostCoreAudioStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)2673 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMDESTROY(drvHostCoreAudio) 2652 2674 { 2653 2675 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 2666 2688 } 2667 2689 2668 static DECLCALLBACK(int) drvHostCoreAudioStreamControl(PPDMIHOSTAUDIO pInterface, 2669 PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 2690 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCONTROL(drvHostCoreAudio) 2670 2691 { 2671 2692 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 2686 2707 } 2687 2708 2688 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostCoreAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)2689 { 2690 NOREF(pInterface);2709 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMGETSTATUS(drvHostCoreAudio) 2710 { 2711 RT_NOREF(pInterface); 2691 2712 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 2692 2713 … … 2721 2742 } 2722 2743 2723 static DECLCALLBACK(int) drvHostCoreAudioStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)2744 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMITERATE(drvHostCoreAudio) 2724 2745 { 2725 2746 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 2730 2751 } 2731 2752 2732 static DECLCALLBACK(void) drvHostCoreAudioShutdown(PPDMIHOSTAUDIO pInterface)2733 { 2734 NOREF(pInterface);2753 PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(drvHostCoreAudio) 2754 { 2755 RT_NOREF(pInterface); 2735 2756 } 2736 2757 … … 2746 2767 } 2747 2768 2748 2769 /* Construct a DirectSound Audio driver instance. 2749 2770 * 2750 2771 * @copydoc FNPDMDRVCONSTRUCT -
trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp
r62979 r63360 217 217 } 218 218 219 219 220 static int dsoundWaveFmtFromCfg(PPDMAUDIOSTREAMCFG pCfg, PWAVEFORMATEX pFmt) 220 221 { … … 259 260 return VINF_SUCCESS; 260 261 } 262 261 263 262 264 static int dsoundGetPosOut(PDRVHOSTDSOUND pThis, … … 305 307 } 306 308 309 307 310 static char *dsoundGUIDToUtf8StrA(LPCGUID pGUID) 308 311 { … … 323 326 return RTStrDup("{Default device}"); 324 327 } 328 325 329 326 330 /** … … 347 351 } 348 352 353 349 354 static HRESULT directSoundPlayRestore(PDRVHOSTDSOUND pThis, LPDIRECTSOUNDBUFFER8 pDSB) 350 355 { … … 356 361 } 357 362 363 358 364 static HRESULT directSoundPlayUnlock(PDRVHOSTDSOUND pThis, LPDIRECTSOUNDBUFFER8 pDSB, 359 365 PVOID pv1, PVOID pv2, … … 367 373 } 368 374 375 369 376 static HRESULT directSoundCaptureUnlock(LPDIRECTSOUNDCAPTUREBUFFER8 pDSCB, 370 377 PVOID pv1, PVOID pv2, … … 376 383 return hr; 377 384 } 385 378 386 379 387 static HRESULT directSoundPlayLock(PDRVHOSTDSOUND pThis, … … 413 421 } 414 422 423 415 424 static HRESULT directSoundCaptureLock(LPDIRECTSOUNDCAPTUREBUFFER8 pDSCB, PPDMPCMPROPS pProps, 416 425 DWORD dwOffset, DWORD dwBytes, … … 463 472 } 464 473 474 465 475 static HRESULT directSoundPlayInterfaceCreate(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMOUT pDSoundStream) 466 476 { … … 501 511 return hr; 502 512 } 513 503 514 504 515 static HRESULT directSoundPlayClose(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMOUT pDSoundStream) … … 543 554 return hr; 544 555 } 556 545 557 546 558 static HRESULT directSoundPlayOpen(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMOUT pDSoundStream) … … 727 739 } 728 740 741 729 742 static void dsoundPlayClearSamples(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMOUT pDSoundStream) 730 743 { … … 753 766 } 754 767 768 755 769 static HRESULT directSoundPlayGetStatus(PDRVHOSTDSOUND pThis, LPDIRECTSOUNDBUFFER8 pDSB, DWORD *pdwStatus) 756 770 { … … 786 800 } 787 801 802 788 803 static HRESULT directSoundPlayStop(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMOUT pDSoundStream) 789 804 { … … 823 838 return hr; 824 839 } 840 825 841 826 842 static HRESULT directSoundPlayStart(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMOUT pDSoundStream) … … 941 957 } 942 958 959 943 960 static void directSoundCaptureInterfaceRelease(PDSOUNDSTREAMIN pDSoundStream) 944 961 { … … 950 967 } 951 968 } 969 952 970 953 971 static HRESULT directSoundCaptureInterfaceCreate(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMIN pDSoundStream) … … 984 1002 } 985 1003 1004 986 1005 static HRESULT directSoundCaptureClose(PDSOUNDSTREAMIN pDSoundStream) 987 1006 { … … 1010 1029 return hr; 1011 1030 } 1031 1012 1032 1013 1033 static HRESULT directSoundCaptureOpen(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMIN pDSoundStream) … … 1143 1163 } 1144 1164 1165 1145 1166 static HRESULT directSoundCaptureStop(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMIN pDSoundStream) 1146 1167 { … … 1169 1190 return hr; 1170 1191 } 1192 1171 1193 1172 1194 static HRESULT directSoundCaptureStart(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMIN pDSoundStream) … … 1213 1235 } 1214 1236 1237 1215 1238 static int dsoundDevAdd(PRTLISTANCHOR pList, LPGUID pGUID, LPCWSTR pwszDescription, PDSOUNDDEV *ppDev) 1216 1239 { … … 1236 1259 } 1237 1260 1261 1238 1262 static void dsoundDeviceRemove(PDSOUNDDEV pDev) 1239 1263 { … … 1248 1272 } 1249 1273 } 1274 1250 1275 1251 1276 static void dsoundLogDevice(const char *pszType, LPGUID pGUID, LPCWSTR pwszDescription, LPCWSTR pwszModule) … … 1257 1282 } 1258 1283 1284 1259 1285 static BOOL CALLBACK dsoundDevicesEnumCbPlayback(LPGUID pGUID, LPCWSTR pwszDescription, LPCWSTR pwszModule, PVOID lpContext) 1260 1286 { … … 1282 1308 } 1283 1309 1310 1284 1311 static BOOL CALLBACK dsoundDevicesEnumCbCapture(LPGUID pGUID, LPCWSTR pwszDescription, LPCWSTR pwszModule, PVOID lpContext) 1285 1312 { … … 1303 1330 return TRUE; 1304 1331 } 1332 1305 1333 1306 1334 /** … … 1358 1386 } 1359 1387 1388 1360 1389 /** 1361 1390 * Updates this host driver's internal status, according to the global, overall input/output … … 1406 1435 } 1407 1436 1437 1408 1438 static void dsoundUpdateStatusInternal(PDRVHOSTDSOUND pThis) 1409 1439 { … … 1411 1441 } 1412 1442 1413 static int dsoundCreateStreamOut(PDRVHOSTDSOUND pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 1414 { 1415 LogFlowFunc(("pStream=%p, pCfg=%p\n", pStream, pCfg)); 1443 1444 static int dsoundCreateStreamOut(PDRVHOSTDSOUND pThis, PPDMAUDIOSTREAM pStream, 1445 PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 1446 { 1447 LogFlowFunc(("pStream=%p, pCfg=%p\n", pStream, pCfgReq)); 1416 1448 PDSOUNDSTREAMOUT pDSoundStream = (PDSOUNDSTREAMOUT)pStream; 1417 1449 1418 pDSoundStream->streamCfg = *pCfg ;1450 pDSoundStream->streamCfg = *pCfgReq; 1419 1451 pDSoundStream->streamCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS; 1420 1452 … … 1428 1460 pDSoundStream->cMaxSamplesInBuffer = 0; 1429 1461 1430 if (p cSamples)1431 *pcSamples = pThis->cfg.cbBufferOut >> pStream->Props.cShift;1462 if (pCfgAcq) 1463 pCfgAcq->cSamples = pThis->cfg.cbBufferOut >> pStream->Props.cShift; /** @todo Get rid of using Props! */ 1432 1464 1433 1465 /* Try to open playback in case the device is already there. */ … … 1497 1529 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay} 1498 1530 */ 1499 static DECLCALLBACK(int) drvHostDSoundStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesPlayed)1531 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(drvHostDSound) 1500 1532 { 1501 1533 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1502 1534 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1503 /* pc SamplesPlayed is optional. */1504 1505 PDRVHOSTDSOUND pThis= PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);1535 /* pcbRead is optional. */ 1536 1537 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface); 1506 1538 PDSOUNDSTREAMOUT pDSoundStream = (PDSOUNDSTREAMOUT)pStream; 1507 1539 … … 1634 1666 if (RT_FAILURE(rc)) 1635 1667 dsoundUpdateStatusInternal(pThis); 1636 else if (pc SamplesPlayed)1637 *pc SamplesPlayed = cReadTotal;1668 else if (pcbRead) 1669 *pcbRead = cReadTotal; 1638 1670 1639 1671 LogFlowFuncLeaveRC(rc); 1640 1672 return rc; 1641 1673 } 1674 1642 1675 1643 1676 static int dsoundDestroyStreamOut(PDRVHOSTDSOUND pThis, PPDMAUDIOSTREAM pStream) … … 1656 1689 } 1657 1690 1658 static int dsoundCreateStreamIn(PDRVHOSTDSOUND pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 1691 static int dsoundCreateStreamIn(PDRVHOSTDSOUND pThis, PPDMAUDIOSTREAM pStream, 1692 PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 1659 1693 { 1660 1694 PDSOUNDSTREAMIN pDSoundStream = (PDSOUNDSTREAMIN)pStream; 1661 1695 1662 LogFlowFunc(("pStream=%p, pCfg=%p, enmRecSource=%ld\n", pStream, pCfg , pCfg->DestSource.Source));1663 1664 memcpy(&pDSoundStream->streamCfg, pCfg , sizeof(PDMAUDIOSTREAMCFG));1696 LogFlowFunc(("pStream=%p, pCfg=%p, enmRecSource=%ld\n", pStream, pCfgReq, pCfgReq->DestSource.Source)); 1697 1698 memcpy(&pDSoundStream->streamCfg, pCfgReq, sizeof(PDMAUDIOSTREAMCFG)); 1665 1699 1666 1700 /** @todo caller should already init Props? */ 1667 int rc = DrvAudioHlpStreamCfgToProps(&pDSoundStream->streamCfg, &pStream->Props); 1701 int rc = DrvAudioHlpStreamCfgToProps(&pDSoundStream->streamCfg, &pStream->Props); /** @todo Get rid of using Props! */ 1668 1702 if (RT_SUCCESS(rc)) 1669 1703 { … … 1673 1707 pDSoundStream->pDSC = NULL; 1674 1708 pDSoundStream->pDSCB = NULL; 1675 pDSoundStream->enmRecSource = pCfg ->DestSource.Source;1709 pDSoundStream->enmRecSource = pCfgReq->DestSource.Source; 1676 1710 pDSoundStream->hrLastCapture = S_OK; 1677 1711 1678 if (p cSamples)1679 *pcSamples = pThis->cfg.cbBufferIn >> pStream->Props.cShift;1712 if (pCfgAcq) 1713 pCfgAcq->cSamples = pThis->cfg.cbBufferIn >> pStream->Props.cShift; /** @todo Get rid of using Props! */ 1680 1714 1681 1715 /* Try to open capture in case the device is already there. */ 1682 directSoundCaptureOpen(pThis, pDSoundStream); 1716 directSoundCaptureOpen(pThis, pDSoundStream); /** @todo r=andy Why not checking the result here?? */ 1683 1717 } 1684 1718 else … … 1746 1780 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture} 1747 1781 */ 1748 static DECLCALLBACK(int) drvHostDSoundStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 1749 uint32_t *pcSamplesCaptured) 1782 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCAPTURE(drvHostDSound) 1750 1783 { 1751 1784 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface); … … 1861 1894 if (RT_FAILURE(rc)) 1862 1895 dsoundUpdateStatusInternal(pThis); 1863 else if (pc SamplesCaptured)1864 *pc SamplesCaptured= cSamplesProcessed;1896 else if (pcbWritten) 1897 *pcbWritten = cSamplesProcessed; 1865 1898 1866 1899 LogFlowFuncLeaveRC(rc); … … 1885 1918 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetConfig} 1886 1919 */ 1887 static DECLCALLBACK(int) drvHostDSoundGetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pCfg)1888 { 1889 AssertPtrReturn(pInterface, VERR_INVALID_POINTER);1890 AssertPtrReturn(p Cfg,VERR_INVALID_POINTER);1920 PDMAUDIO_IHOSTAUDIO_EMIT_GETCONFIG(drvHostDSound) 1921 { 1922 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1923 AssertPtrReturn(pBackendCfg, VERR_INVALID_POINTER); 1891 1924 1892 1925 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface); 1893 1926 1894 dsoundUpdateStatusInternalEx(pThis, p Cfg, 0 /* fEnum */);1927 dsoundUpdateStatusInternalEx(pThis, pBackendCfg, 0 /* fEnum */); 1895 1928 1896 1929 return VINF_SUCCESS; … … 2012 2045 * @interface_method_impl{PDMIHOSTAUDIO,pfnShutdown} 2013 2046 */ 2014 static DECLCALLBACK(void) drvHostDSoundShutdown(PPDMIHOSTAUDIO pInterface)2047 PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(drvHostDSound) 2015 2048 { 2016 2049 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface); … … 2044 2077 * @interface_method_impl{PDMIHOSTAUDIO,pfnInit} 2045 2078 */ 2046 static DECLCALLBACK(int) drvHostDSoundInit(PPDMIHOSTAUDIO pInterface)2079 PDMAUDIO_IHOSTAUDIO_EMIT_INIT(drvHostDSound) 2047 2080 { 2048 2081 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface); … … 2139 2172 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus} 2140 2173 */ 2141 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvHostDSoundGetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir)2174 PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(drvHostDSound) 2142 2175 { 2143 2176 RT_NOREF(enmDir); … … 2151 2184 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate} 2152 2185 */ 2153 static DECLCALLBACK(int)2154 drvHostDSoundStreamCreate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 2155 { 2156 AssertPtrReturn(p Interface, VERR_INVALID_POINTER);2157 AssertPtrReturn(p Stream,VERR_INVALID_POINTER);2158 AssertPtrReturn(pCfg ,VERR_INVALID_POINTER);2159 AssertPtrNullReturn(pcSamples, VERR_INVALID_POINTER); 2186 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCREATE(drvHostDSound) 2187 { 2188 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 2189 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 2190 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); 2191 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER); 2192 2160 2193 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface); 2161 2194 2162 2195 int rc; 2163 if (pCfg ->enmDir == PDMAUDIODIR_IN)2164 rc = dsoundCreateStreamIn(pThis, pStream, pCfg , pcSamples);2196 if (pCfgReq->enmDir == PDMAUDIODIR_IN) 2197 rc = dsoundCreateStreamIn(pThis, pStream, pCfgReq, pCfgAcq); 2165 2198 else 2166 rc = dsoundCreateStreamOut(pThis, pStream, pCfg, pcSamples); 2167 2168 LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc)); 2199 rc = dsoundCreateStreamOut(pThis, pStream, pCfgReq, pCfgAcq); 2200 2169 2201 return rc; 2170 2202 } … … 2174 2206 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy} 2175 2207 */ 2176 static DECLCALLBACK(int) drvHostDSoundStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)2208 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMDESTROY(drvHostDSound) 2177 2209 { 2178 2210 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 2179 2211 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 2212 2180 2213 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface); 2181 2214 … … 2193 2226 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl} 2194 2227 */ 2195 static DECLCALLBACK(int) 2196 drvHostDSoundStreamControl(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 2228 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCONTROL(drvHostDSound) 2197 2229 { 2198 2230 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 2199 2231 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 2232 2200 2233 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface); 2201 2234 … … 2215 2248 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 2216 2249 */ 2217 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostDSoundStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)2250 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMGETSTATUS(drvHostDSound) 2218 2251 { 2219 2252 AssertPtrReturn(pInterface, PDMAUDIOSTRMSTS_FLAG_NONE); … … 2254 2287 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamIterate} 2255 2288 */ 2256 static DECLCALLBACK(int) drvHostDSoundStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)2289 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMITERATE(drvHostDSound) 2257 2290 { 2258 2291 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 2368 2401 return VINF_SUCCESS; 2369 2402 } 2403 2370 2404 2371 2405 /** -
trunk/src/VBox/Devices/Audio/DrvHostDebugAudio.cpp
r62973 r63360 72 72 73 73 74 static DECLCALLBACK(int) drvHostDebugAudioGetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pCfg) 75 { 76 NOREF(pInterface); 77 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 78 79 pCfg->cbStreamOut = sizeof(DEBUGAUDIOSTREAM); 80 pCfg->cbStreamIn = sizeof(DEBUGAUDIOSTREAM); 74 /** 75 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetConfig} 76 */ 77 PDMAUDIO_IHOSTAUDIO_EMIT_GETCONFIG(drvHostDebugAudio) 78 { 79 NOREF(pInterface); 80 AssertPtrReturn(pBackendCfg, VERR_INVALID_POINTER); 81 82 pBackendCfg->cbStreamOut = sizeof(DEBUGAUDIOSTREAM); 83 pBackendCfg->cbStreamIn = sizeof(DEBUGAUDIOSTREAM); 81 84 82 85 /* The NULL backend has exactly one input source and one output sink. */ 83 pCfg->cSources = 1; 84 pCfg->cSinks = 1; 85 86 pCfg->cMaxStreamsOut = 1; /* Output */ 87 pCfg->cMaxStreamsIn = 2; /* Line input + microphone input. */ 88 89 return VINF_SUCCESS; 90 } 91 92 static DECLCALLBACK(int) drvHostDebugAudioInit(PPDMIHOSTAUDIO pInterface) 86 pBackendCfg->cSources = 1; 87 pBackendCfg->cSinks = 1; 88 89 pBackendCfg->cMaxStreamsOut = 1; /* Output */ 90 pBackendCfg->cMaxStreamsIn = 2; /* Line input + microphone input. */ 91 92 return VINF_SUCCESS; 93 } 94 95 96 /** 97 * @interface_method_impl{PDMIHOSTAUDIO,pfnInit} 98 */ 99 PDMAUDIO_IHOSTAUDIO_EMIT_INIT(drvHostDebugAudio) 93 100 { 94 101 NOREF(pInterface); … … 98 105 } 99 106 107 108 /** 109 * @interface_method_impl{PDMIHOSTAUDIO,pfnShutdown} 110 */ 111 PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(drvHostDebugAudio) 112 { 113 NOREF(pInterface); 114 } 115 116 117 /** 118 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus} 119 */ 120 PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(drvHostDebugAudio) 121 { 122 RT_NOREF(enmDir); 123 AssertPtrReturn(pInterface, PDMAUDIOBACKENDSTS_UNKNOWN); 124 125 return PDMAUDIOBACKENDSTS_RUNNING; 126 } 127 128 100 129 static int debugCreateStreamIn(PPDMIHOSTAUDIO pInterface, 101 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg , uint32_t *pcSamples)130 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 102 131 { 103 132 NOREF(pInterface); 104 133 105 134 /* Just adopt the wanted stream configuration. */ 106 int rc = DrvAudioHlpStreamCfgToProps(pCfg , &pStream->Props);135 int rc = DrvAudioHlpStreamCfgToProps(pCfgReq, &pStream->Props); 107 136 if (RT_SUCCESS(rc)) 108 137 { 109 if (p cSamples)110 *pcSamples = _1K;138 if (pCfgAcq) 139 pCfgAcq->cSamples = _1K; 111 140 } 112 141 … … 115 144 } 116 145 146 117 147 static int debugCreateStreamOut(PPDMIHOSTAUDIO pInterface, 118 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, 119 uint32_t *pcSamples) 148 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 120 149 { 121 150 NOREF(pInterface); … … 125 154 /* Just adopt the wanted stream configuration. */ 126 155 PDMPCMPROPS Props; 127 int rc = DrvAudioHlpStreamCfgToProps(pCfg , &Props);156 int rc = DrvAudioHlpStreamCfgToProps(pCfgReq, &Props); 128 157 if (RT_SUCCESS(rc)) 129 158 { … … 152 181 if (RT_SUCCESS(rc)) 153 182 { 154 if (p cSamples)155 *pcSamples = pDbgStream->Out.cMaxSamplesInPlayBuffer;183 if (pCfgAcq) 184 pCfgAcq->cSamples = pDbgStream->Out.cMaxSamplesInPlayBuffer; 156 185 } 157 186 … … 160 189 } 161 190 162 static DECLCALLBACK(int) drvHostDebugAudioStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 163 uint32_t *pcSamplesPlayed) 191 192 /** 193 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate} 194 */ 195 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCREATE(drvHostDebugAudio) 196 { 197 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 198 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 199 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); 200 201 int rc; 202 if (pCfgReq->enmDir == PDMAUDIODIR_IN) 203 rc = debugCreateStreamIn( pInterface, pStream, pCfgReq, pCfgAcq); 204 else 205 rc = debugCreateStreamOut(pInterface, pStream, pCfgReq, pCfgAcq); 206 207 LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc)); 208 return rc; 209 } 210 211 212 /** 213 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay} 214 */ 215 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(drvHostDebugAudio) 164 216 { 165 217 PDRVHOSTDEBUGAUDIO pDrv = RT_FROM_MEMBER(pInterface, DRVHOSTDEBUGAUDIO, IHostAudio); … … 215 267 216 268 cSamplesPlayed += cSamplesRead; 217 } ;269 } 218 270 219 271 /* Remember when samples were consumed. */ 220 272 pDbgStream->Out.tsLastPlayed = u64TicksNow; 221 273 222 if (pcSamplesPlayed) 223 *pcSamplesPlayed = cSamplesPlayed; 224 225 return VINF_SUCCESS; 226 } 227 228 static DECLCALLBACK(int) drvHostDebugAudioStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 229 uint32_t *pcSamplesCaptured) 274 if (pcbWritten) 275 *pcbWritten = cSamplesPlayed; 276 277 return VINF_SUCCESS; 278 } 279 280 281 /** 282 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture} 283 */ 284 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCAPTURE(drvHostDebugAudio) 230 285 { 231 286 RT_NOREF(pInterface, pStream); 232 287 233 288 /* Never capture anything. */ 234 if (pcSamplesCaptured) 235 *pcSamplesCaptured = 0; 236 237 return VINF_SUCCESS; 238 } 289 if (pcbRead) 290 *pcbRead = 0; 291 292 return VINF_SUCCESS; 293 } 294 239 295 240 296 static int debugDestroyStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) … … 244 300 return VINF_SUCCESS; 245 301 } 302 246 303 247 304 static int debugDestroyStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) … … 270 327 } 271 328 272 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvHostDebugAudioGetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir)273 {274 RT_NOREF(enmDir);275 AssertPtrReturn(pInterface, PDMAUDIOBACKENDSTS_UNKNOWN);276 277 return PDMAUDIOBACKENDSTS_RUNNING;278 }279 280 static DECLCALLBACK(int) drvHostDebugAudioStreamCreate(PPDMIHOSTAUDIO pInterface,281 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples)282 {283 AssertPtrReturn(pInterface, VERR_INVALID_POINTER);284 AssertPtrReturn(pStream, VERR_INVALID_POINTER);285 AssertPtrReturn(pCfg, VERR_INVALID_POINTER);286 287 int rc;288 if (pCfg->enmDir == PDMAUDIODIR_IN)289 rc = debugCreateStreamIn(pInterface, pStream, pCfg, pcSamples);290 else291 rc = debugCreateStreamOut(pInterface, pStream, pCfg, pcSamples);292 293 LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc));294 return rc;295 }296 329 297 330 static DECLCALLBACK(int) drvHostDebugAudioStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) … … 338 371 } 339 372 373 340 374 /** 341 375 * @interface_method_impl{PDMIBASE,pfnQueryInterface} … … 351 385 } 352 386 353 static DECLCALLBACK(void) drvHostDebugAudioShutdown(PPDMIHOSTAUDIO pInterface)354 {355 NOREF(pInterface);356 }357 387 358 388 /** -
trunk/src/VBox/Devices/Audio/DrvHostNullAudio.cpp
r62970 r63360 93 93 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetConfig} 94 94 */ 95 static DECLCALLBACK(int) drvHostNullAudioGetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pCfg)95 PDMAUDIO_IHOSTAUDIO_EMIT_GETCONFIG(drvHostNullAudio) 96 96 { 97 97 NOREF(pInterface); 98 AssertPtrReturn(p Cfg, VERR_INVALID_POINTER);99 100 p Cfg->cbStreamOut = sizeof(NULLAUDIOSTREAMOUT);101 p Cfg->cbStreamIn = sizeof(NULLAUDIOSTREAMIN);98 AssertPtrReturn(pBackendCfg, VERR_INVALID_POINTER); 99 100 pBackendCfg->cbStreamOut = sizeof(NULLAUDIOSTREAMOUT); 101 pBackendCfg->cbStreamIn = sizeof(NULLAUDIOSTREAMIN); 102 102 103 103 /* The NULL backend has exactly one input source and one output sink. */ 104 p Cfg->cSources = 1;105 p Cfg->cSinks = 1;106 107 p Cfg->cMaxStreamsOut = 1; /* Output */108 p Cfg->cMaxStreamsIn = 2; /* Line input + microphone input. */104 pBackendCfg->cSources = 1; 105 pBackendCfg->cSinks = 1; 106 107 pBackendCfg->cMaxStreamsOut = 1; /* Output */ 108 pBackendCfg->cMaxStreamsIn = 2; /* Line input + microphone input. */ 109 109 110 110 return VINF_SUCCESS; … … 115 115 * @interface_method_impl{PDMIHOSTAUDIO,pfnInit} 116 116 */ 117 static DECLCALLBACK(int) drvHostNullAudioInit(PPDMIHOSTAUDIO pInterface)117 PDMAUDIO_IHOSTAUDIO_EMIT_INIT(drvHostNullAudio) 118 118 { 119 119 NOREF(pInterface); … … 125 125 126 126 /** 127 * @interface_method_impl{PDMIHOSTAUDIO,pfnShutdown} 128 */ 129 PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(drvHostNullAudio) 130 { 131 RT_NOREF(pInterface); 132 } 133 134 135 /** 136 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus} 137 */ 138 PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(drvHostNullAudio) 139 { 140 RT_NOREF(enmDir); 141 AssertPtrReturn(pInterface, PDMAUDIOBACKENDSTS_UNKNOWN); 142 143 return PDMAUDIOBACKENDSTS_RUNNING; 144 } 145 146 147 /** 127 148 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay} 128 149 */ 129 static DECLCALLBACK(int) drvHostNullAudioStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesPlayed)150 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(drvHostNullAudio) 130 151 { 131 152 PDRVHOSTNULLAUDIO pDrv = RT_FROM_MEMBER(pInterface, DRVHOSTNULLAUDIO, IHostAudio); … … 159 180 AudioMixBufFinish(&pStream->MixBuf, cSamplesToRead); 160 181 161 if (pc SamplesPlayed)162 *pc SamplesPlayed= cSamplesToRead;182 if (pcbWritten) 183 *pcbWritten = cSamplesToRead; 163 184 164 185 return VINF_SUCCESS; … … 169 190 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture} 170 191 */ 171 static DECLCALLBACK(int) 172 drvHostNullAudioStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesCaptured) 192 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCAPTURE(drvHostNullAudio) 173 193 { 174 194 RT_NOREF(pInterface, pStream); 175 195 176 196 /* Never capture anything. */ 177 if (pcSamplesCaptured) 178 *pcSamplesCaptured = 0; 179 180 return VINF_SUCCESS; 181 } 182 183 184 /** 185 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus} 186 */ 187 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvHostNullAudioGetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir) 188 { 189 RT_NOREF(enmDir); 190 AssertPtrReturn(pInterface, PDMAUDIOBACKENDSTS_UNKNOWN); 191 192 return PDMAUDIOBACKENDSTS_RUNNING; 193 } 194 195 196 static int nullCreateStreamIn(PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 197 if (pcbRead) 198 *pcbRead = 0; 199 200 return VINF_SUCCESS; 201 } 202 203 204 static int nullCreateStreamIn(PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 197 205 { 198 206 /* Just adopt the wanted stream configuration. */ 199 int rc = DrvAudioHlpStreamCfgToProps(pCfg , &pStream->Props);207 int rc = DrvAudioHlpStreamCfgToProps(pCfgReq, &pStream->Props); 200 208 if (RT_SUCCESS(rc)) 201 209 { 202 if (p cSamples)203 *pcSamples = _1K;210 if (pCfgAcq) 211 pCfgAcq->cSamples = _1K; 204 212 } 205 213 … … 209 217 210 218 211 static int nullCreateStreamOut(PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg , uint32_t *pcSamples)219 static int nullCreateStreamOut(PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 212 220 { 213 221 /* Just adopt the wanted stream configuration. */ 214 int rc = DrvAudioHlpStreamCfgToProps(pCfg , &pStream->Props);222 int rc = DrvAudioHlpStreamCfgToProps(pCfgReq, &pStream->Props); 215 223 if (RT_SUCCESS(rc)) 216 224 { 217 225 PNULLAUDIOSTREAMOUT pNullStream = RT_FROM_MEMBER(pStream, NULLAUDIOSTREAMOUT, Stream); 226 218 227 pNullStream->u64TicksLast = 0; 219 228 pNullStream->cMaxSamplesInPlayBuffer = _1K; 229 220 230 pNullStream->pbPlayBuffer = (uint8_t *)RTMemAlloc(_1K << pStream->Props.cShift); 221 231 if (pNullStream->pbPlayBuffer) 222 232 { 223 if (p cSamples)224 *pcSamples = pNullStream->cMaxSamplesInPlayBuffer;233 if (pCfgAcq) 234 pCfgAcq->cSamples = pNullStream->cMaxSamplesInPlayBuffer; 225 235 } 226 236 else … … 236 246 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate} 237 247 */ 238 static DECLCALLBACK(int) 239 drvHostNullAudioStreamCreate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 248 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCREATE(drvHostNullAudio) 240 249 { 241 250 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 242 251 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 243 AssertPtrReturn(pCfg ,VERR_INVALID_POINTER);252 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); 244 253 245 254 int rc; 246 if (pCfg ->enmDir == PDMAUDIODIR_IN)247 rc = nullCreateStreamIn( pStream, pCfg , pcSamples);255 if (pCfgReq->enmDir == PDMAUDIODIR_IN) 256 rc = nullCreateStreamIn( pStream, pCfgReq, pCfgAcq); 248 257 else 249 rc = nullCreateStreamOut(pStream, pCfg , pcSamples);258 rc = nullCreateStreamOut(pStream, pCfgReq, pCfgAcq); 250 259 251 260 LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc)); … … 279 288 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy} 280 289 */ 281 static DECLCALLBACK(int) drvHostNullAudioStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)290 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMDESTROY(drvHostNullAudio) 282 291 { 283 292 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 297 306 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl} 298 307 */ 299 static DECLCALLBACK(int) 300 drvHostNullAudioStreamControl(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 308 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCONTROL(drvHostNullAudio) 301 309 { 302 310 RT_NOREF(enmStreamCmd); … … 313 321 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 314 322 */ 315 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostNullAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)323 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMGETSTATUS(drvHostNullAudio) 316 324 { 317 325 RT_NOREF(pInterface, pStream); … … 324 332 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamIterate} 325 333 */ 326 static DECLCALLBACK(int) drvHostNullAudioStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)334 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMITERATE(drvHostNullAudio) 327 335 { 328 336 NOREF(pInterface); … … 330 338 331 339 return VINF_SUCCESS; 332 }333 334 335 /**336 * @interface_method_impl{PDMIHOSTAUDIO,pfnShutdown}337 */338 static DECLCALLBACK(void) drvHostNullAudioShutdown(PPDMIHOSTAUDIO pInterface)339 {340 RT_NOREF(pInterface);341 340 } 342 341 … … 382 381 return VINF_SUCCESS; 383 382 } 383 384 384 385 385 /** -
trunk/src/VBox/Devices/Audio/DrvHostOSSAudio.cpp
r63212 r63360 149 149 } 150 150 151 151 152 static uint32_t lsbindex(uint32_t u) 152 153 { 153 154 return popcount ((u&-u)-1); 154 155 } 156 155 157 156 158 static int ossAudioFmtToOSS(PDMAUDIOFMT fmt) … … 177 179 return AFMT_U8; 178 180 } 181 179 182 180 183 static int ossOSSToAudioFmt(int fmt, PDMAUDIOFMT *pFmt, PDMAUDIOENDIANNESS *pENDIANNESS) … … 226 229 } 227 230 231 228 232 static int ossStreamClose(int *phFile) 229 233 { … … 246 250 } 247 251 252 248 253 static int ossStreamOpen(const char *pszDev, int fOpen, POSSAUDIOSTREAMCFG pReq, POSSAUDIOSTREAMCFG pObt, int *phFile) 249 254 { 250 AssertPtrReturn(pszDev, VERR_INVALID_POINTER);251 AssertPtrReturn(pReq, VERR_INVALID_POINTER);252 AssertPtrReturn(pObt, VERR_INVALID_POINTER);253 AssertPtrReturn(phFile, VERR_INVALID_POINTER);254 255 255 int rc; 256 256 … … 336 336 } 337 337 338 static int ossControlStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 339 PDMAUDIOSTREAMCMD enmStreamCmd) 340 { 341 NOREF(pInterface); 342 NOREF(pStream); 343 NOREF(enmStreamCmd); 338 339 static int ossControlStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 340 { 344 341 345 342 /** @todo Nothing to do here right now!? */ … … 348 345 } 349 346 350 static int ossControlStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 351 PDMAUDIOSTREAMCMD enmStreamCmd) 352 { 353 NOREF(pInterface); 354 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 355 356 POSSAUDIOSTREAMOUT pThisStream = (POSSAUDIOSTREAMOUT)pStream; 347 348 static int ossControlStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 349 { 350 POSSAUDIOSTREAMOUT pStreamOut = (POSSAUDIOSTREAMOUT)pStream; 357 351 358 352 #ifdef RT_OS_L4 359 353 return VINF_SUCCESS; 360 354 #else 361 if (!p ThisStream->fMemMapped)355 if (!pStreamOut->fMemMapped) 362 356 return VINF_SUCCESS; 363 357 #endif … … 370 364 case PDMAUDIOSTREAMCMD_RESUME: 371 365 { 372 DrvAudioHlpClearBuf(&pStream->Props, 373 pThisStream->pvBuf, pThisStream->cbBuf, AudioMixBufSize(&pStream->MixBuf));366 DrvAudioHlpClearBuf(&pStream->Props, /** @todo Get rid of using Props! */ 367 pStreamOut->pvBuf, pStreamOut->cbBuf, AudioMixBufSize(&pStream->MixBuf)); 374 368 375 369 mask = PCM_ENABLE_OUTPUT; 376 if (ioctl(p ThisStream->hFile, SNDCTL_DSP_SETTRIGGER, &mask) < 0)370 if (ioctl(pStreamOut->hFile, SNDCTL_DSP_SETTRIGGER, &mask) < 0) 377 371 { 378 372 LogRel(("OSS: Failed to enable output stream: %s\n", strerror(errno))); … … 387 381 { 388 382 mask = 0; 389 if (ioctl(p ThisStream->hFile, SNDCTL_DSP_SETTRIGGER, &mask) < 0)383 if (ioctl(pStreamOut->hFile, SNDCTL_DSP_SETTRIGGER, &mask) < 0) 390 384 { 391 385 LogRel(("OSS: Failed to disable output stream: %s\n", strerror(errno))); … … 406 400 } 407 401 408 static DECLCALLBACK(int) drvHostOSSAudioInit(PPDMIHOSTAUDIO pInterface) 409 { 410 NOREF(pInterface); 402 403 /** 404 * @interface_method_impl{PDMIHOSTAUDIO,pfnInit} 405 */ 406 PDMAUDIO_IHOSTAUDIO_EMIT_INIT(drvHostOSSAudio) 407 { 408 RT_NOREF(pInterface); 411 409 412 410 LogFlowFuncEnter(); … … 415 413 } 416 414 417 static DECLCALLBACK(int) drvHostOSSAudioStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 418 uint32_t *pcSamplesCaptured) 419 { 420 NOREF(pInterface); 415 416 /** 417 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture} 418 */ 419 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCAPTURE(drvHostOSSAudio) 420 { 421 RT_NOREF(pInterface); 421 422 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 422 423 … … 494 495 rc = AudioMixBufMixToParent(&pStream->MixBuf, cWrittenTotal, &cProcessed); 495 496 496 if (pc SamplesCaptured)497 *pc SamplesCaptured = cWrittenTotal;497 if (pcbRead) 498 *pcbRead = cWrittenTotal; 498 499 499 500 LogFlowFunc(("cWrittenTotal=%RU32 (%RU32 processed), rc=%Rrc\n", … … 505 506 } 506 507 508 507 509 static int ossDestroyStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 508 510 { 509 NOREF(pInterface);510 AssertPtrReturn(pStream, VERR_INVALID_POINTER);511 512 511 POSSAUDIOSTREAMIN pStrm = (POSSAUDIOSTREAMIN)pStream; 513 512 … … 529 528 } 530 529 530 531 531 static int ossDestroyStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 532 532 { 533 NOREF(pInterface);534 AssertPtrReturn(pStream, VERR_INVALID_POINTER);535 536 533 POSSAUDIOSTREAMOUT pStrm = (POSSAUDIOSTREAMOUT)pStream; 537 534 … … 578 575 } 579 576 580 static DECLCALLBACK(int) drvHostOSSAudioGetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pCfg) 581 { 582 NOREF(pInterface); 583 584 pCfg->cbStreamIn = sizeof(OSSAUDIOSTREAMIN); 585 pCfg->cbStreamOut = sizeof(OSSAUDIOSTREAMOUT); 586 587 pCfg->cSources = 0; 588 pCfg->cSinks = 0; 577 578 /** 579 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetConfig} 580 */ 581 PDMAUDIO_IHOSTAUDIO_EMIT_GETCONFIG(drvHostOSSAudio) 582 { 583 RT_NOREF(pInterface); 584 585 pBackendCfg->cbStreamIn = sizeof(OSSAUDIOSTREAMIN); 586 pBackendCfg->cbStreamOut = sizeof(OSSAUDIOSTREAMOUT); 587 588 pBackendCfg->cSources = 0; 589 pBackendCfg->cSinks = 0; 589 590 590 591 int hFile = open("/dev/dsp", O_WRONLY | O_NONBLOCK, 0); … … 619 620 cDev = ossInfo.numaudios; 620 621 621 p Cfg->cSources = cDev;622 p Cfg->cSinks = cDev;623 624 p Cfg->cMaxStreamsIn = UINT32_MAX;625 p Cfg->cMaxStreamsOut = UINT32_MAX;622 pBackendCfg->cSources = cDev; 623 pBackendCfg->cSinks = cDev; 624 625 pBackendCfg->cMaxStreamsIn = UINT32_MAX; 626 pBackendCfg->cMaxStreamsOut = UINT32_MAX; 626 627 } 627 628 else … … 630 631 /* Since we cannot query anything, assume that we have at least 631 632 * one input and one output if we found "/dev/dsp" or "/dev/mixer". */ 632 p Cfg->cSources = 1;633 p Cfg->cSinks = 1;634 635 p Cfg->cMaxStreamsIn = UINT32_MAX;636 p Cfg->cMaxStreamsOut = UINT32_MAX;633 pBackendCfg->cSources = 1; 634 pBackendCfg->cSinks = 1; 635 636 pBackendCfg->cMaxStreamsIn = UINT32_MAX; 637 pBackendCfg->cMaxStreamsOut = UINT32_MAX; 637 638 #ifdef VBOX_WITH_AUDIO_OSS_SYSINFO 638 639 } … … 648 649 } 649 650 651 650 652 static int ossCreateStreamIn(PPDMIHOSTAUDIO pInterface, 651 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 652 { 653 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 654 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 655 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 656 653 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 654 { 655 PDRVHOSTOSSAUDIO pThis = PDMIHOSTAUDIO_2_DRVHOSTOSSAUDIO(pInterface); 657 656 POSSAUDIOSTREAMIN pStrm = (POSSAUDIOSTREAMIN)pStream; 658 657 … … 665 664 666 665 OSSAUDIOSTREAMCFG reqStream, obtStream; 667 reqStream.enmFormat = pCfg ->enmFormat;668 reqStream.uFreq = pCfg ->uHz;669 reqStream.cChannels = pCfg ->cChannels;666 reqStream.enmFormat = pCfgReq->enmFormat; 667 reqStream.uFreq = pCfgReq->uHz; 668 reqStream.cChannels = pCfgReq->cChannels; 670 669 reqStream.cFragments = s_OSSConf.nfrags; 671 670 reqStream.cbFragmentSize = s_OSSConf.fragsize; … … 674 673 if (RT_SUCCESS(rc)) 675 674 { 676 if (obtStream.cFragments * obtStream.cbFragmentSize & pStream->Props.uAlign) 677 LogRel(("OSS: Warning: Misaligned capturing buffer: Size = %zu, Alignment = %u\n", 678 obtStream.cFragments * obtStream.cbFragmentSize, 679 pStream->Props.uAlign + 1)); 680 681 PDMAUDIOSTREAMCFG streamCfg; 682 streamCfg.enmFormat = obtStream.enmFormat; 683 streamCfg.uHz = obtStream.uFreq; 684 streamCfg.cChannels = pCfg->cChannels; 685 streamCfg.enmEndianness = obtStream.enmENDIANNESS; 686 687 rc = DrvAudioHlpStreamCfgToProps(&streamCfg, &pStream->Props); 675 pCfgAcq->enmFormat = obtStream.enmFormat; 676 pCfgAcq->uHz = obtStream.uFreq; 677 pCfgAcq->cChannels = pCfgReq->cChannels; /** @todo r=andy Why not using obtStream? */ 678 pCfgAcq->enmEndianness = obtStream.enmENDIANNESS; 679 680 PDMPCMPROPS Props; 681 rc = DrvAudioHlpStreamCfgToProps(pCfgAcq, &Props); 688 682 if (RT_SUCCESS(rc)) 689 683 { 690 cSamples = (obtStream.cFragments * obtStream.cbFragmentSize) 691 >> pStream->Props.cShift; 684 if (obtStream.cFragments * obtStream.cbFragmentSize & Props.uAlign) 685 { 686 LogRel(("OSS: Warning: Misaligned capturing buffer: Size = %zu, Alignment = %u\n", 687 obtStream.cFragments * obtStream.cbFragmentSize, Props.uAlign + 1)); 688 } 689 690 cSamples = (obtStream.cFragments * obtStream.cbFragmentSize) >> Props.cShift; 692 691 if (!cSamples) 693 692 rc = VERR_INVALID_PARAMETER; 694 693 } 695 } 696 697 if (RT_SUCCESS(rc)) 698 { 699 size_t cbSample = (1 << pStream->Props.cShift); 700 701 size_t cbBuf = cSamples * cbSample; 702 void *pvBuf = RTMemAlloc(cbBuf); 703 if (!pvBuf) 704 { 705 LogRel(("OSS: Failed allocating capturing buffer with %RU32 samples (%zu bytes per sample)\n", 706 cSamples, cbSample)); 707 rc = VERR_NO_MEMORY; 708 break; 709 } 710 711 pStrm->hFile = hFile; 712 pStrm->pvBuf = pvBuf; 713 pStrm->cbBuf = cbBuf; 714 715 if (pcSamples) 716 *pcSamples = cSamples; 694 695 if (RT_SUCCESS(rc)) 696 { 697 size_t cbSample = (1 << Props.cShift); 698 699 size_t cbBuf = cSamples * cbSample; 700 void *pvBuf = RTMemAlloc(cbBuf); 701 if (!pvBuf) 702 { 703 LogRel(("OSS: Failed allocating capturing buffer with %RU32 samples (%zu bytes per sample)\n", 704 cSamples, cbSample)); 705 rc = VERR_NO_MEMORY; 706 break; 707 } 708 709 pStrm->hFile = hFile; 710 pStrm->pvBuf = pvBuf; 711 pStrm->cbBuf = cbBuf; 712 713 pCfgAcq->cSamples = cSamples; 714 } 717 715 } 718 716 … … 726 724 } 727 725 726 728 727 static int ossCreateStreamOut(PPDMIHOSTAUDIO pInterface, 729 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, 730 uint32_t *pcSamples) 731 { 732 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 733 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 734 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 735 728 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 729 { 730 PDRVHOSTOSSAUDIO pThis = PDMIHOSTAUDIO_2_DRVHOSTOSSAUDIO(pInterface); 736 731 POSSAUDIOSTREAMOUT pStrm = (POSSAUDIOSTREAMOUT)pStream; 737 732 … … 744 739 745 740 OSSAUDIOSTREAMCFG reqStream, obtStream; 746 reqStream.enmFormat = pCfg ->enmFormat;747 reqStream.uFreq = pCfg ->uHz;748 reqStream.cChannels = pCfg ->cChannels;741 reqStream.enmFormat = pCfgReq->enmFormat; 742 reqStream.uFreq = pCfgReq->uHz; 743 reqStream.cChannels = pCfgReq->cChannels; 749 744 reqStream.cFragments = s_OSSConf.nfrags; 750 745 reqStream.cbFragmentSize = s_OSSConf.fragsize; 751 746 747 PDMPCMPROPS Props; 748 RT_ZERO(Props); 749 752 750 rc = ossStreamOpen(s_OSSConf.devpath_out, O_WRONLY | O_NONBLOCK, &reqStream, &obtStream, &hFile); 753 751 if (RT_SUCCESS(rc)) 754 752 { 755 if (obtStream.cFragments * obtStream.cbFragmentSize & pStream->Props.uAlign) 756 LogRel(("OSS: Warning: Misaligned playback buffer: Size = %zu, Alignment = %u\n", 757 obtStream.cFragments * obtStream.cbFragmentSize, 758 pStream->Props.uAlign + 1)); 759 760 PDMAUDIOSTREAMCFG streamCfg; 761 streamCfg.enmFormat = obtStream.enmFormat; 762 streamCfg.uHz = obtStream.uFreq; 763 streamCfg.cChannels = pCfg->cChannels; 764 streamCfg.enmEndianness = obtStream.enmENDIANNESS; 765 766 rc = DrvAudioHlpStreamCfgToProps(&streamCfg, &pStream->Props); 753 pCfgAcq->enmFormat = obtStream.enmFormat; 754 pCfgAcq->uHz = obtStream.uFreq; 755 pCfgAcq->cChannels = pCfgReq->cChannels; /** @todo r=andy Why not using obtStream? */ 756 pCfgAcq->enmEndianness = obtStream.enmENDIANNESS; 757 758 rc = DrvAudioHlpStreamCfgToProps(pCfgReq, &Props); 767 759 if (RT_SUCCESS(rc)) 768 cSamples = (obtStream.cFragments * obtStream.cbFragmentSize) 769 >> pStream->Props.cShift; 760 { 761 cSamples = (obtStream.cFragments * obtStream.cbFragmentSize) >> Props.cShift; 762 763 if (obtStream.cFragments * obtStream.cbFragmentSize & Props.uAlign) 764 { 765 LogRel(("OSS: Warning: Misaligned playback buffer: Size = %zu, Alignment = %u\n", 766 obtStream.cFragments * obtStream.cbFragmentSize, Props.uAlign + 1)); 767 } 768 } 770 769 } 771 770 … … 774 773 pStrm->fMemMapped = false; 775 774 776 size_t cbSamples = cSamples << pStream->Props.cShift;775 size_t cbSamples = cSamples << Props.cShift; 777 776 Assert(cbSamples); 778 777 … … 839 838 } 840 839 #endif 841 if (pcSamples) 842 *pcSamples = cSamples; 840 pCfgAcq->cSamples = cSamples; 843 841 } 844 842 … … 852 850 } 853 851 854 static DECLCALLBACK(int) drvHostOSSAudioStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesPlayed) 855 { 856 NOREF(pInterface); 852 853 /** 854 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay} 855 */ 856 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(drvHostOSSAudio) 857 { 858 RT_NOREF(pInterface); 857 859 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 858 860 … … 865 867 do 866 868 { 867 size_t cbBuf = AudioMixBufSizeBytes(&pStream->MixBuf);869 size_t cbBufSize = AudioMixBufSizeBytes(&pStream->MixBuf); 868 870 869 871 uint32_t cLive = AudioMixBufLive(&pStream->MixBuf); … … 891 893 cbData = cntinfo.ptr - pStrm->old_optr; 892 894 else 893 cbData = cbBuf + cntinfo.ptr - pStrm->old_optr;895 cbData = cbBufSize + cntinfo.ptr - pStrm->old_optr; 894 896 Assert(cbData); 895 897 … … 909 911 } 910 912 911 if ((size_t)abinfo.bytes > cbBuf )912 { 913 LogFlowFunc(("Warning: Invalid available size, size=%d, bufsize=%zu\n", abinfo.bytes, cbBuf ));914 abinfo.bytes = cbBuf ;913 if ((size_t)abinfo.bytes > cbBufSize) 914 { 915 LogFlowFunc(("Warning: Invalid available size, size=%d, bufsize=%zu\n", abinfo.bytes, cbBufSize)); 916 abinfo.bytes = cbBufSize; 915 917 /* Keep going. */ 916 918 } … … 918 920 if (abinfo.bytes < 0) 919 921 { 920 LogFlowFunc(("Warning: Invalid available size, size=%d, bufsize=%zu\n", abinfo.bytes, cbBuf ));922 LogFlowFunc(("Warning: Invalid available size, size=%d, bufsize=%zu\n", abinfo.bytes, cbBufSize)); 921 923 rc = VERR_INVALID_PARAMETER; 922 924 break; … … 967 969 AudioMixBufFinish(&pStream->MixBuf, cReadTotal); 968 970 969 if (pc SamplesPlayed)970 *pc SamplesPlayed= cReadTotal;971 if (pcbWritten) 972 *pcbWritten = cReadTotal; 971 973 972 974 LogFlowFunc(("cReadTotal=%RU32 (%RU32 bytes), rc=%Rrc\n", cReadTotal, cbReadTotal, rc)); … … 977 979 } 978 980 979 static DECLCALLBACK(void) drvHostOSSAudioShutdown(PPDMIHOSTAUDIO pInterface) 980 { 981 NOREF(pInterface); 982 } 983 984 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvHostOSSAudioGetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir) 981 982 /** 983 * @interface_method_impl{PDMIHOSTAUDIO,pfnShutdown} 984 */ 985 PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(drvHostOSSAudio) 986 { 987 RT_NOREF(pInterface); 988 } 989 990 991 /** 992 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus} 993 */ 994 PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(drvHostOSSAudio) 985 995 { 986 996 AssertPtrReturn(pInterface, PDMAUDIOBACKENDSTS_UNKNOWN); … … 990 1000 } 991 1001 992 static DECLCALLBACK(int) drvHostOSSAudioStreamCreate(PPDMIHOSTAUDIO pInterface, 993 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 1002 1003 /** 1004 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate} 1005 */ 1006 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCREATE(drvHostOSSAudio) 994 1007 { 995 1008 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 996 1009 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 997 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 1010 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); 1011 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER); 998 1012 999 1013 int rc; 1000 if (pCfg ->enmDir == PDMAUDIODIR_IN)1001 rc = ossCreateStreamIn(pInterface, pStream, pCfg , pcSamples);1014 if (pCfgReq->enmDir == PDMAUDIODIR_IN) 1015 rc = ossCreateStreamIn(pInterface, pStream, pCfgReq, pCfgAcq); 1002 1016 else 1003 rc = ossCreateStreamOut(pInterface, pStream, pCfg, pcSamples); 1004 1005 LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc)); 1017 rc = ossCreateStreamOut(pInterface, pStream, pCfgReq, pCfgAcq); 1018 1006 1019 return rc; 1007 1020 } 1008 1021 1009 static DECLCALLBACK(int) drvHostOSSAudioStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 1022 1023 /** 1024 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy} 1025 */ 1026 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMDESTROY(drvHostOSSAudio) 1010 1027 { 1011 1028 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 1021 1038 } 1022 1039 1023 static DECLCALLBACK(int) drvHostOSSAudioStreamControl(PPDMIHOSTAUDIO pInterface, 1024 PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 1040 1041 /** 1042 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl} 1043 */ 1044 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCONTROL(drvHostOSSAudio) 1025 1045 { 1026 1046 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 1038 1058 } 1039 1059 1040 static DECLCALLBACK(int) drvHostOSSAudioStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 1060 1061 /** 1062 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamIterate} 1063 */ 1064 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMITERATE(drvHostOSSAudio) 1041 1065 { 1042 1066 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 1049 1073 } 1050 1074 1051 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostOSSAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 1052 { 1053 NOREF(pInterface); 1054 NOREF(pStream); 1075 1076 /** 1077 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 1078 */ 1079 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMGETSTATUS(drvHostOSSAudio) 1080 { 1081 RT_NOREF(pInterface); 1082 RT_NOREF(pStream); 1055 1083 1056 1084 PDMAUDIOSTRMSTS strmSts = PDMAUDIOSTRMSTS_FLAG_INITIALIZED … … 1063 1091 return strmSts; 1064 1092 } 1093 1065 1094 /** 1066 1095 * @interface_method_impl{PDMIBASE,pfnQueryInterface} … … 1068 1097 static DECLCALLBACK(void *) drvHostOSSAudioQueryInterface(PPDMIBASE pInterface, const char *pszIID) 1069 1098 { 1070 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface); 1071 PDRVHOSTOSSAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTOSSAUDIO); 1099 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface); 1100 PDRVHOSTOSSAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTOSSAUDIO); 1101 1072 1102 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase); 1073 1103 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHOSTAUDIO, &pThis->IHostAudio); -
trunk/src/VBox/Devices/Audio/DrvHostPulseAudio.cpp
r63214 r63360 167 167 static void paStreamCbSuccess(pa_stream *pStream, int fSuccess, void *pvContext); 168 168 169 170 169 171 /** 170 172 * Signal the main loop to abort. Just signalling isn't sufficient as the … … 179 181 pa_threaded_mainloop_signal(pThis->pMainLoop, 0); 180 182 } 183 181 184 182 185 static pa_sample_format_t paFmtToPulse(PDMAUDIOFMT fmt) … … 202 205 } 203 206 207 204 208 static int paPulseToFmt(pa_sample_format_t pulsefmt, 205 209 PDMAUDIOFMT *pFmt, PDMAUDIOENDIANNESS *pEndianness) … … 244 248 } 245 249 250 246 251 /** 247 252 * Synchronously wait until an operation completed. … … 277 282 } 278 283 284 279 285 static int paWaitFor(PDRVHOSTPULSEAUDIO pThis, pa_operation *pOP) 280 286 { 281 287 return paWaitForEx(pThis, pOP, 10 * 1000 /* 10s timeout */); 282 288 } 289 283 290 284 291 /** … … 309 316 } 310 317 318 311 319 /** 312 320 * Callback called when our pa_stream_drain operation was completed. … … 334 342 } 335 343 } 344 336 345 337 346 /** … … 358 367 } 359 368 369 360 370 static void paStreamCbSuccess(pa_stream *pStream, int fSuccess, void *pvUser) 361 371 { … … 372 382 paError(pStrm->pDrv, "Failed to finish stream operation"); 373 383 } 384 374 385 375 386 static int paStreamOpen(PDRVHOSTPULSEAUDIO pThis, bool fIn, const char *pszName, … … 508 519 } 509 520 510 static DECLCALLBACK(int) drvHostPulseAudioInit(PPDMIHOSTAUDIO pInterface) 521 522 /** 523 * @interface_method_impl{PDMIHOSTAUDIO,pfnInit} 524 */ 525 PDMAUDIO_IHOSTAUDIO_EMIT_INIT(drvHostPulseAudio) 511 526 { 512 527 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 616 631 } 617 632 633 618 634 static int paCreateStreamOut(PPDMIHOSTAUDIO pInterface, 619 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 620 { 621 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 622 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 623 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 624 /* pcSamples is optional. */ 625 635 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 636 { 626 637 PDRVHOSTPULSEAUDIO pThis = PDMIHOSTAUDIO_2_DRVHOSTPULSEAUDIO(pInterface); 627 638 PPULSEAUDIOSTREAM pStrm = (PPULSEAUDIOSTREAM)pStream; … … 631 642 pStrm->pDrainOp = NULL; 632 643 633 pStrm->SampleSpec.format = paFmtToPulse(pCfg ->enmFormat);634 pStrm->SampleSpec.rate = pCfg ->uHz;635 pStrm->SampleSpec.channels = pCfg ->cChannels;644 pStrm->SampleSpec.format = paFmtToPulse(pCfgReq->enmFormat); 645 pStrm->SampleSpec.rate = pCfgReq->uHz; 646 pStrm->SampleSpec.channels = pCfgReq->cChannels; 636 647 637 648 /* Note that setting maxlength to -1 does not work on PulseAudio servers … … 648 659 return rc; 649 660 650 PDMAUDIOSTREAMCFG streamCfg;651 661 rc = paPulseToFmt(pStrm->SampleSpec.format, 652 & streamCfg.enmFormat, &streamCfg.enmEndianness);662 &pCfgAcq->enmFormat, &pCfgAcq->enmEndianness); 653 663 if (RT_FAILURE(rc)) 654 664 { … … 657 667 } 658 668 659 streamCfg.uHz = pStrm->SampleSpec.rate;660 streamCfg.cChannels = pStrm->SampleSpec.channels;661 662 rc = DrvAudioHlpStreamCfgToProps( &streamCfg, &pStream->Props);669 pCfgAcq->uHz = pStrm->SampleSpec.rate; 670 pCfgAcq->cChannels = pStrm->SampleSpec.channels; 671 672 rc = DrvAudioHlpStreamCfgToProps(pCfgAcq, &pStream->Props); 663 673 if (RT_SUCCESS(rc)) 664 674 { … … 672 682 pStrm->cbPCMBuf = cbBuf; 673 683 674 uint32_t cSamples = cbBuf >> pStream->Props.cShift; 675 if (pcSamples) 676 *pcSamples = cSamples; 684 pCfgAcq->cSamples = cbBuf >> pStream->Props.cShift; /** @todo Get rid of using Props! */ 677 685 678 686 /* Save pointer to driver instance. */ 679 687 pStrm->pDrv = pThis; 680 681 LogFunc(("cbBuf=%RU32, cSamples=%RU32\n", cbBuf, cSamples));682 688 } 683 689 else … … 692 698 } 693 699 700 694 701 static int paCreateStreamIn(PPDMIHOSTAUDIO pInterface, 695 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 696 { 697 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 698 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 699 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 700 /* pcSamples is optional. */ 701 702 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 703 { 702 704 PDRVHOSTPULSEAUDIO pThis = PDMIHOSTAUDIO_2_DRVHOSTPULSEAUDIO(pInterface); 703 705 PPULSEAUDIOSTREAM pStrm = (PPULSEAUDIOSTREAM)pStream; 704 706 705 pStrm->SampleSpec.format = paFmtToPulse(pCfg ->enmFormat);706 pStrm->SampleSpec.rate = pCfg ->uHz;707 pStrm->SampleSpec.channels = pCfg ->cChannels;707 pStrm->SampleSpec.format = paFmtToPulse(pCfgReq->enmFormat); 708 pStrm->SampleSpec.rate = pCfgReq->uHz; 709 pStrm->SampleSpec.channels = pCfgReq->cChannels; 708 710 709 711 /* XXX check these values */ … … 718 720 return rc; 719 721 720 PDMAUDIOSTREAMCFG streamCfg; 721 rc = paPulseToFmt(pStrm->SampleSpec.format, &streamCfg.enmFormat, 722 &streamCfg.enmEndianness); 722 rc = paPulseToFmt(pStrm->SampleSpec.format, &pCfgAcq->enmFormat, 723 &pCfgAcq->enmEndianness); 723 724 if (RT_FAILURE(rc)) 724 725 { … … 727 728 } 728 729 729 streamCfg.uHz = pStrm->SampleSpec.rate;730 streamCfg.cChannels = pStrm->SampleSpec.channels;731 732 rc = DrvAudioHlpStreamCfgToProps( &streamCfg, &pStream->Props);730 pCfgAcq->uHz = pStrm->SampleSpec.rate; 731 pCfgAcq->cChannels = pStrm->SampleSpec.channels; 732 733 rc = DrvAudioHlpStreamCfgToProps(pCfgAcq, &pStream->Props); 733 734 if (RT_SUCCESS(rc)) 734 735 { 735 uint32_t cSamples = RT_MIN(pStrm->BufAttr.fragsize * 10, pStrm->BufAttr.maxlength) 736 >> pStream->Props.cShift; 737 738 LogFunc(("uHz=%RU32, cChannels=%RU8, cShift=%RU8, cSamples=%RU32\n", 739 pStream->Props.uHz, pStream->Props.cChannels, pStream->Props.cShift, cSamples)); 736 pCfgAcq->cSamples = RT_MIN(pStrm->BufAttr.fragsize * 10, pStrm->BufAttr.maxlength) 737 >> pStream->Props.cShift; /** @todo Get rid of using Props! */ 740 738 741 739 /* Save pointer to driver instance. */ 742 740 pStrm->pDrv = pThis; 743 741 pStrm->pu8PeekBuf = NULL; 744 745 if (pcSamples)746 *pcSamples = cSamples;747 742 } 748 743 … … 751 746 } 752 747 753 static DECLCALLBACK(int) drvHostPulseAudioStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 754 uint32_t *pcSamplesCaptured) 748 749 /** 750 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture} 751 */ 752 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCAPTURE(drvHostPulseAudio) 755 753 { 756 754 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 757 755 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 758 /* pc SamplesPlayed is optional. */756 /* pcbRead is optional. */ 759 757 760 758 PDRVHOSTPULSEAUDIO pThis = PDMIHOSTAUDIO_2_DRVHOSTPULSEAUDIO(pInterface); … … 780 778 if (!cbAvail) /* No data? Bail out. */ 781 779 { 782 if (pc SamplesCaptured)783 *pc SamplesCaptured = 0;780 if (pcbRead) 781 *pcbRead = 0; 784 782 return VINF_SUCCESS; 785 783 } … … 861 859 rc = AudioMixBufMixToParent(&pStream->MixBuf, cWrittenTotal, 862 860 &cProcessed);*/ 863 864 if (pcSamplesCaptured) 865 *pcSamplesCaptured = cWrittenTotal; 861 if (pcbRead) 862 *pcbRead = cWrittenTotal; 866 863 867 864 LogFlowFunc(("cWrittenTotal=%RU32 (%RU32 processed), rc=%Rrc\n", … … 873 870 } 874 871 875 static DECLCALLBACK(int) drvHostPulseAudioStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 876 uint32_t *pcSamplesPlayed) 877 { 878 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 879 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 880 /* pcSamplesPlayed is optional. */ 872 873 /** 874 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay} 875 */ 876 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(drvHostPulseAudio) 877 { 878 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 879 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 880 /* pcbWritten is optional. */ 881 881 882 882 PDRVHOSTPULSEAUDIO pThis = PDMIHOSTAUDIO_2_DRVHOSTPULSEAUDIO(pInterface); … … 890 890 { 891 891 LogFlowFunc(("No live samples, skipping\n")); 892 if (pc SamplesPlayed)893 *pc SamplesPlayed= 0;892 if (pcbWritten) 893 *pcbWritten = 0; 894 894 return VINF_SUCCESS; 895 895 } … … 949 949 AudioMixBufFinish(&pStream->MixBuf, cReadTotal); 950 950 951 if (pc SamplesPlayed)952 *pc SamplesPlayed= cReadTotal;951 if (pcbWritten) 952 *pcbWritten = cReadTotal; 953 953 954 954 LogFlowFunc(("cReadTotal=%RU32 (%RU32 bytes), rc=%Rrc\n", cReadTotal, cbReadTotal, rc)); … … 959 959 } 960 960 961 961 962 /** @todo Implement va handling. */ 962 963 static int paError(PDRVHOSTPULSEAUDIO pThis, const char *szMsg) … … 974 975 return VERR_GENERAL_FAILURE; 975 976 } 977 976 978 977 979 static void paEnumSinkCb(pa_context *pCtx, const pa_sink_info *pInfo, int eol, void *pvUserData) … … 995 997 } 996 998 999 997 1000 static void paEnumSourceCb(pa_context *pCtx, const pa_source_info *pInfo, int eol, void *pvUserData) 998 1001 { … … 1015 1018 } 1016 1019 1020 1017 1021 static void paEnumServerCb(pa_context *pCtx, const pa_server_info *pInfo, void *pvUserData) 1018 1022 { … … 1040 1044 pa_threaded_mainloop_signal(pThis->pMainLoop, 0); 1041 1045 } 1046 1042 1047 1043 1048 static int paEnumerate(PDRVHOSTPULSEAUDIO pThis, PPDMAUDIOBACKENDCFG pCfg, uint32_t fEnum) … … 1134 1139 } 1135 1140 1141 1136 1142 static int paDestroyStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 1137 1143 { … … 1158 1164 return VINF_SUCCESS; 1159 1165 } 1166 1160 1167 1161 1168 static int paDestroyStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) … … 1197 1204 return VINF_SUCCESS; 1198 1205 } 1206 1199 1207 1200 1208 static int paControlStreamOut(PPDMIHOSTAUDIO pInterface, … … 1261 1269 } 1262 1270 1271 1263 1272 static int paControlStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 1264 1273 PDMAUDIOSTREAMCMD enmStreamCmd) … … 1309 1318 } 1310 1319 1311 static DECLCALLBACK(void) drvHostPulseAudioShutdown(PPDMIHOSTAUDIO pInterface) 1320 1321 /** 1322 * @interface_method_impl{PDMIHOSTAUDIO,pfnShutdown} 1323 */ 1324 PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(drvHostPulseAudio) 1312 1325 { 1313 1326 AssertPtrReturnVoid(pInterface); … … 1336 1349 } 1337 1350 1338 static DECLCALLBACK(int) drvHostPulseAudioGetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pCfg) 1339 { 1340 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1341 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 1351 1352 /** 1353 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetConfig} 1354 */ 1355 PDMAUDIO_IHOSTAUDIO_EMIT_GETCONFIG(drvHostPulseAudio) 1356 { 1357 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1358 AssertPtrReturn(pBackendCfg, VERR_INVALID_POINTER); 1342 1359 1343 1360 PDRVHOSTPULSEAUDIO pThis = PDMIHOSTAUDIO_2_DRVHOSTPULSEAUDIO(pInterface); 1344 1361 1345 return paEnumerate(pThis, pCfg, PULSEAUDIOENUMCBFLAGS_LOG /* fEnum */); 1346 } 1347 1348 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvHostPulseAudioGetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir) 1362 return paEnumerate(pThis, pBackendCfg, PULSEAUDIOENUMCBFLAGS_LOG /* fEnum */); 1363 } 1364 1365 1366 /** 1367 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus} 1368 */ 1369 PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(drvHostPulseAudio) 1349 1370 { 1350 1371 RT_NOREF(enmDir); … … 1354 1375 } 1355 1376 1356 static DECLCALLBACK(int) drvHostPulseAudioStreamCreate(PPDMIHOSTAUDIO pInterface, 1357 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 1377 1378 /** 1379 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate} 1380 */ 1381 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCREATE(drvHostPulseAudio) 1358 1382 { 1359 1383 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1360 1384 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1361 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 1385 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); 1386 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER); 1362 1387 1363 1388 int rc; 1364 if (pCfg ->enmDir == PDMAUDIODIR_IN)1365 rc = paCreateStreamIn(pInterface, pStream, pCfg , pcSamples);1389 if (pCfgReq->enmDir == PDMAUDIODIR_IN) 1390 rc = paCreateStreamIn(pInterface, pStream, pCfgReq, pCfgAcq); 1366 1391 else if (pStream->enmDir == PDMAUDIODIR_OUT) 1367 rc = paCreateStreamOut(pInterface, pStream, pCfg , pcSamples);1392 rc = paCreateStreamOut(pInterface, pStream, pCfgReq, pCfgAcq); 1368 1393 else 1369 1394 AssertFailedReturn(VERR_NOT_IMPLEMENTED); 1370 1395 1371 LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc));1372 1396 return rc; 1373 1397 } 1374 1398 1375 static DECLCALLBACK(int) drvHostPulseAudioStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 1399 1400 /** 1401 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy} 1402 */ 1403 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMDESTROY(drvHostPulseAudio) 1376 1404 { 1377 1405 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1378 1406 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1379 1380 LogFlowFunc(("%s\n", pStream->szName));1381 1407 1382 1408 int rc; … … 1388 1414 AssertFailedReturn(VERR_NOT_IMPLEMENTED); 1389 1415 1390 LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc));1391 1416 return rc; 1392 1417 } 1393 1418 1394 static DECLCALLBACK(int) drvHostPulseAudioStreamControl(PPDMIHOSTAUDIO pInterface, 1395 PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 1419 1420 /** 1421 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl} 1422 */ 1423 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCONTROL(drvHostPulseAudio) 1396 1424 { 1397 1425 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 1408 1436 AssertFailedReturn(VERR_NOT_IMPLEMENTED); 1409 1437 1410 LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc));1411 1438 return rc; 1412 1439 } 1413 1440 1414 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostPulseAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 1441 1442 /** 1443 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 1444 */ 1445 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMGETSTATUS(drvHostPulseAudio) 1415 1446 { 1416 1447 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 1449 1480 } 1450 1481 1451 static DECLCALLBACK(int) drvHostPulseAudioStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 1482 1483 /** 1484 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetConfig} 1485 */ 1486 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMITERATE(drvHostPulseAudio) 1452 1487 { 1453 1488 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1454 1489 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1490 1455 1491 LogFlowFuncEnter(); 1456 1492 … … 1458 1494 return VINF_SUCCESS; 1459 1495 } 1496 1460 1497 1461 1498 /** -
trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp
r63244 r63360 85 85 86 86 87 87 88 static int vrdeCreateStreamIn(PPDMIHOSTAUDIO pInterface, 88 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 89 { 90 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio); 91 AssertPtrReturn(pDrv, VERR_INVALID_POINTER); 92 89 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 90 { 91 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 92 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 93 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); 94 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER); 95 96 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio); 93 97 PVRDESTREAMIN pVRDEStrmIn = (PVRDESTREAMIN)pStream; 94 AssertPtrReturn(pVRDEStrmIn, VERR_INVALID_POINTER); 95 96 if (pcSamples) 97 *pcSamples = _4K; /** @todo Make this configurable. */ 98 99 return DrvAudioHlpStreamCfgToProps(pCfg, &pVRDEStrmIn->Stream.Props); 100 } 98 99 if (pCfgAcq) 100 pCfgAcq->cSamples = _4K; /** @todo Make this configurable. */ 101 102 LogFlowFuncLeaveRC(VINF_SUCCESS); 103 return VINF_SUCCESS; 104 } 105 101 106 102 107 static int vrdeCreateStreamOut(PPDMIHOSTAUDIO pInterface, 103 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 104 { 105 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio); 106 AssertPtrReturn(pDrv, VERR_INVALID_POINTER); 107 108 LogFlowFunc(("pStream=%p, pCfg=%p\n", pStream, pCfg)); 109 108 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 109 { 110 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 111 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 112 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); 113 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER); 114 115 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio); 110 116 PVRDESTREAMOUT pVRDEStrmOut = (PVRDESTREAMOUT)pStream; 111 AssertPtrReturn(pVRDEStrmOut, VERR_INVALID_POINTER); 112 113 if (pcSamples) 114 *pcSamples = _4K; /** @todo Make this configurable. */ 115 116 return DrvAudioHlpStreamCfgToProps(pCfg, &pVRDEStrmOut->Stream.Props); 117 } 117 118 if (pCfgAcq) 119 pCfgAcq->cSamples = _4K; /** @todo Make this configurable. */ 120 121 LogFlowFuncLeaveRC(VINF_SUCCESS); 122 return VINF_SUCCESS; 123 } 124 118 125 119 126 static int vrdeControlStreamOut(PPDMIHOSTAUDIO pInterface, … … 133 140 return VINF_SUCCESS; 134 141 } 142 135 143 136 144 static int vrdeControlStreamIn(PPDMIHOSTAUDIO pInterface, … … 174 182 } 175 183 176 static DECLCALLBACK(int) drvAudioVRDEInit(PPDMIHOSTAUDIO pInterface) 184 185 /** 186 * @interface_method_impl{PDMIHOSTAUDIO,pfnInit} 187 */ 188 PDMAUDIO_IHOSTAUDIO_EMIT_INIT(drvAudioVRDE) 177 189 { 178 190 RT_NOREF(pInterface); … … 182 194 } 183 195 184 /** 185 * {FIXME - Missing brief description - FIXME} 186 * 187 * Transfers audio input formerly sent by a connected RDP client / VRDE backend 188 * (using the onVRDEInputXXX methods) over to the VRDE host (VM). The audio device 189 * emulation then will read and send the data to the guest. 190 * 191 * @return IPRT status code. 192 * @param pInterface 193 * @param pStream 194 * @param pcSamplesCaptured 195 */ 196 static DECLCALLBACK(int) drvAudioVRDEStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 197 uint32_t *pcSamplesCaptured) 196 197 /** 198 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture} 199 */ 200 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCAPTURE(drvAudioVRDE) 198 201 { 199 202 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 200 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 201 AssertPtrReturn(pcSamplesCaptured, VERR_INVALID_POINTER); 202 203 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio); 204 AssertPtrReturn(pDrv, VERR_INVALID_POINTER); 205 203 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 204 /* pcbRead is optional. */ 205 206 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio); 206 207 PVRDESTREAMIN pVRDEStrmIn = (PVRDESTREAMIN)pStream; 207 AssertPtrReturn(pVRDEStrmIn, VERR_INVALID_POINTER);208 208 209 209 /** @todo Use CritSect! */ … … 222 222 if (RT_SUCCESS(rc)) 223 223 { 224 *pcSamplesCaptured = cProcessed;225 226 224 Assert(pVRDEStrmIn->cSamplesCaptured >= cProcessed); 227 225 pVRDEStrmIn->cSamplesCaptured -= cProcessed; 226 227 if (pcbRead) 228 *pcbRead = cProcessed; 228 229 } 229 230 … … 232 233 } 233 234 234 /** 235 * Transfers VM audio output to remote client. 236 * 237 * Transfers VM audio output over to the VRDE instance for playing remotely 238 * on the client. 239 * 240 * @return IPRT status code. 241 * @param pInterface 242 * @param pStream 243 * @param pcSamplesPlayed 244 */ 245 static DECLCALLBACK(int) drvAudioVRDEStreamPlay(PPDMIHOSTAUDIO pInterface, 246 PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesPlayed) 235 236 /** 237 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay} 238 */ 239 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(drvAudioVRDE) 247 240 { 248 241 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 249 242 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 250 /* pcSamplesPlayed is optional. */ 251 252 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio); 253 AssertPtrReturn(pDrv, VERR_INVALID_POINTER); 254 243 /* pcbWritten is optional. */ 244 245 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio); 255 246 PVRDESTREAMOUT pVRDEStrmOut = (PVRDESTREAMOUT)pStream; 256 AssertPtrReturn(pVRDEStrmOut, VERR_INVALID_POINTER);257 247 258 248 uint32_t cLive = AudioMixBufLive(&pStream->MixBuf); … … 316 306 * VRDP server actually did process those. 317 307 */ 318 if (pc SamplesPlayed)319 *pc SamplesPlayed= cReadTotal;308 if (pcbWritten) 309 *pcbWritten = cReadTotal; 320 310 321 311 LogFlowFunc(("cReadTotal=%RU32, rc=%Rrc\n", cReadTotal, rc)); 322 312 return rc; 323 313 } 314 324 315 325 316 static int vrdeDestroyStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) … … 335 326 } 336 327 328 337 329 static int vrdeDestroyStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 338 330 { … … 344 336 } 345 337 346 static DECLCALLBACK(int) drvAudioVRDEGetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pCfg) 338 339 /** 340 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetConfig} 341 */ 342 PDMAUDIO_IHOSTAUDIO_EMIT_GETCONFIG(drvAudioVRDE) 347 343 { 348 344 NOREF(pInterface); 349 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 350 351 pCfg->cbStreamOut = sizeof(VRDESTREAMOUT); 352 pCfg->cbStreamIn = sizeof(VRDESTREAMIN); 353 pCfg->cMaxStreamsIn = UINT32_MAX; 354 pCfg->cMaxStreamsOut = UINT32_MAX; 355 pCfg->cSources = 1; 356 pCfg->cSinks = 1; 357 358 return VINF_SUCCESS; 359 } 360 361 static DECLCALLBACK(void) drvAudioVRDEShutdown(PPDMIHOSTAUDIO pInterface) 345 AssertPtrReturn(pBackendCfg, VERR_INVALID_POINTER); 346 347 pBackendCfg->cbStreamOut = sizeof(VRDESTREAMOUT); 348 pBackendCfg->cbStreamIn = sizeof(VRDESTREAMIN); 349 pBackendCfg->cMaxStreamsIn = UINT32_MAX; 350 pBackendCfg->cMaxStreamsOut = UINT32_MAX; 351 pBackendCfg->cSources = 1; 352 pBackendCfg->cSinks = 1; 353 354 return VINF_SUCCESS; 355 } 356 357 358 /** 359 * @interface_method_impl{PDMIHOSTAUDIO,pfnShutdown} 360 */ 361 PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(drvAudioVRDE) 362 362 { 363 363 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio); … … 368 368 } 369 369 370 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvAudioVRDEGetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir) 370 371 /** 372 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus} 373 */ 374 PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(drvAudioVRDE) 371 375 { 372 376 RT_NOREF(enmDir); … … 376 380 } 377 381 378 static DECLCALLBACK(int) drvAudioVRDEStreamCreate(PPDMIHOSTAUDIO pInterface, 379 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 382 383 /** 384 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate} 385 */ 386 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCREATE(drvAudioVRDE) 380 387 { 381 388 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 382 389 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 383 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 390 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); 391 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER); 384 392 385 393 int rc; 386 if (pCfg ->enmDir == PDMAUDIODIR_IN)387 rc = vrdeCreateStreamIn(pInterface, pStream, pCfg , pcSamples);394 if (pCfgReq->enmDir == PDMAUDIODIR_IN) 395 rc = vrdeCreateStreamIn(pInterface, pStream, pCfgReq, pCfgAcq); 388 396 else 389 rc = vrdeCreateStreamOut(pInterface, pStream, pCfg, pcSamples); 390 391 LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc)); 397 rc = vrdeCreateStreamOut(pInterface, pStream, pCfgReq, pCfgAcq); 398 392 399 return rc; 393 400 } 394 401 395 static DECLCALLBACK(int) drvAudioVRDEStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 402 403 /** 404 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy} 405 */ 406 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMDESTROY(drvAudioVRDE) 396 407 { 397 408 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 407 418 } 408 419 409 static DECLCALLBACK(int) drvAudioVRDEStreamControl(PPDMIHOSTAUDIO pInterface, 410 PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 420 421 /** 422 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl} 423 */ 424 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCONTROL(drvAudioVRDE) 411 425 { 412 426 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 424 438 } 425 439 426 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvAudioVRDEStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 440 441 /** 442 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 443 */ 444 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMGETSTATUS(drvAudioVRDE) 427 445 { 428 446 NOREF(pInterface); … … 433 451 } 434 452 435 static DECLCALLBACK(int) drvAudioVRDEStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 453 454 /** 455 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamIterate} 456 */ 457 PDMAUDIO_IHOSTAUDIO_EMIT_STREAMITERATE(drvAudioVRDE) 436 458 { 437 459 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 443 465 return VINF_SUCCESS; 444 466 } 467 445 468 446 469 /** … … 457 480 } 458 481 482 459 483 AudioVRDE::AudioVRDE(Console *pConsole) 460 484 : mpDrv(NULL), … … 462 486 { 463 487 } 488 464 489 465 490 AudioVRDE::~AudioVRDE(void) … … 472 497 } 473 498 499 474 500 int AudioVRDE::onVRDEControl(bool fEnable, uint32_t uFlags) 475 501 { … … 484 510 return VINF_SUCCESS; /* Never veto. */ 485 511 } 512 486 513 487 514 /** … … 515 542 } 516 543 544 517 545 int AudioVRDE::onVRDEInputData(void *pvContext, const void *pvData, uint32_t cbData) 518 546 { … … 535 563 } 536 564 565 537 566 int AudioVRDE::onVRDEInputEnd(void *pvContext) 538 567 { … … 541 570 return VINF_SUCCESS; 542 571 } 572 543 573 544 574 int AudioVRDE::onVRDEInputIntercept(bool fEnabled) … … 547 577 return VINF_SUCCESS; /* Never veto. */ 548 578 } 579 549 580 550 581 /** … … 557 588 { 558 589 RT_NOREF(fFlags); 590 559 591 PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns); 560 592 PDRVAUDIOVRDE pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIOVRDE); 593 561 594 AssertPtrReturn(pDrvIns, VERR_INVALID_POINTER); 562 595 AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
Note:
See TracChangeset
for help on using the changeset viewer.