Changeset 89504 in vbox
- Timestamp:
- Jun 4, 2021 11:30:46 AM (3 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostAudioAlsa.cpp
r89500 r89504 939 939 940 940 /** 941 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 942 */ 943 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHstAudAlsaHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 944 PPDMAUDIOBACKENDSTREAM pStream) 945 { 946 RT_NOREF(pInterface); 947 PDRVHSTAUDALSASTREAM pStreamALSA = (PDRVHSTAUDALSASTREAM)pStream; 948 AssertPtrReturn(pStreamALSA, PDMHOSTAUDIOSTREAMSTATE_INVALID); 949 950 PDMHOSTAUDIOSTREAMSTATE enmStreamState = PDMHOSTAUDIOSTREAMSTATE_OKAY; 951 snd_pcm_state_t enmAlsaState = snd_pcm_state(pStreamALSA->hPCM); 952 if (enmAlsaState == SND_PCM_STATE_DRAINING) 953 { 954 /* We're operating in non-blocking mode, so we must (at least for a demux 955 config) call snd_pcm_drain again to drive it forward. Otherwise we 956 might be stuck in the drain state forever. */ 957 Log5Func(("Calling snd_pcm_drain again...\n")); 958 snd_pcm_drain(pStreamALSA->hPCM); 959 enmAlsaState = snd_pcm_state(pStreamALSA->hPCM); 960 } 961 962 if (enmAlsaState == SND_PCM_STATE_DRAINING) 963 enmStreamState = PDMHOSTAUDIOSTREAMSTATE_DRAINING; 964 #if (((SND_LIB_MAJOR) << 16) | ((SND_LIB_MAJOR) << 8) | (SND_LIB_SUBMINOR)) >= 0x10002 /* was added in 1.0.2 */ 965 else if (enmAlsaState == SND_PCM_STATE_DISCONNECTED) 966 enmStreamState = PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING; 967 #endif 968 969 Log5Func(("Stream '%s': ALSA state=%s -> %s\n", 970 pStreamALSA->Cfg.szName, snd_pcm_state_name(enmAlsaState), PDMHostAudioStreamStateGetName(enmStreamState) )); 971 return enmStreamState; 972 } 973 974 975 /** 941 976 * Returns the available audio frames queued. 942 977 * … … 986 1021 *pcFramesAvail = 0; 987 1022 return rc; 988 }989 990 991 /**992 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}993 */994 static DECLCALLBACK(uint32_t) drvHstAudAlsaHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)995 {996 RT_NOREF(pInterface);997 PDRVHSTAUDALSASTREAM pStreamALSA = (PDRVHSTAUDALSASTREAM)pStream;998 999 uint32_t cbAvail = 0;1000 snd_pcm_sframes_t cFramesAvail = 0;1001 int rc = alsaStreamGetAvail(pStreamALSA->hPCM, &cFramesAvail);1002 if (RT_SUCCESS(rc))1003 cbAvail = PDMAudioPropsFramesToBytes(&pStreamALSA->Cfg.Props, cFramesAvail);1004 1005 return cbAvail;1006 }1007 1008 1009 /**1010 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}1011 */1012 static DECLCALLBACK(uint32_t) drvHstAudAlsaHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)1013 {1014 RT_NOREF(pInterface);1015 PDRVHSTAUDALSASTREAM pStreamALSA = (PDRVHSTAUDALSASTREAM)pStream;1016 1017 uint32_t cbAvail = 0;1018 snd_pcm_sframes_t cFramesAvail = 0;1019 int rc = alsaStreamGetAvail(pStreamALSA->hPCM, &cFramesAvail);1020 if (RT_SUCCESS(rc))1021 cbAvail = PDMAudioPropsFramesToBytes(&pStreamALSA->Cfg.Props, cFramesAvail);1022 1023 return cbAvail;1024 1023 } 1025 1024 … … 1084 1083 1085 1084 /** 1086 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 1087 */ 1088 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHstAudAlsaHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 1089 PPDMAUDIOBACKENDSTREAM pStream) 1085 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable} 1086 */ 1087 static DECLCALLBACK(uint32_t) drvHstAudAlsaHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 1090 1088 { 1091 1089 RT_NOREF(pInterface); 1092 1090 PDRVHSTAUDALSASTREAM pStreamALSA = (PDRVHSTAUDALSASTREAM)pStream; 1093 AssertPtrReturn(pStreamALSA, PDMHOSTAUDIOSTREAMSTATE_INVALID); 1094 1095 PDMHOSTAUDIOSTREAMSTATE enmStreamState = PDMHOSTAUDIOSTREAMSTATE_OKAY; 1096 snd_pcm_state_t enmAlsaState = snd_pcm_state(pStreamALSA->hPCM); 1097 if (enmAlsaState == SND_PCM_STATE_DRAINING) 1098 { 1099 /* We're operating in non-blocking mode, so we must (at least for a demux 1100 config) call snd_pcm_drain again to drive it forward. Otherwise we 1101 might be stuck in the drain state forever. */ 1102 Log5Func(("Calling snd_pcm_drain again...\n")); 1103 snd_pcm_drain(pStreamALSA->hPCM); 1104 enmAlsaState = snd_pcm_state(pStreamALSA->hPCM); 1105 } 1106 1107 if (enmAlsaState == SND_PCM_STATE_DRAINING) 1108 enmStreamState = PDMHOSTAUDIOSTREAMSTATE_DRAINING; 1109 #if (((SND_LIB_MAJOR) << 16) | ((SND_LIB_MAJOR) << 8) | (SND_LIB_SUBMINOR)) >= 0x10002 /* was added in 1.0.2 */ 1110 else if (enmAlsaState == SND_PCM_STATE_DISCONNECTED) 1111 enmStreamState = PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING; 1112 #endif 1113 1114 Log5Func(("Stream '%s': ALSA state=%s -> %s\n", 1115 pStreamALSA->Cfg.szName, snd_pcm_state_name(enmAlsaState), PDMHostAudioStreamStateGetName(enmStreamState) )); 1116 return enmStreamState; 1091 1092 uint32_t cbAvail = 0; 1093 snd_pcm_sframes_t cFramesAvail = 0; 1094 int rc = alsaStreamGetAvail(pStreamALSA->hPCM, &cFramesAvail); 1095 if (RT_SUCCESS(rc)) 1096 cbAvail = PDMAudioPropsFramesToBytes(&pStreamALSA->Cfg.Props, cFramesAvail); 1097 1098 return cbAvail; 1117 1099 } 1118 1100 … … 1231 1213 *pcbWritten = 0; 1232 1214 return rc; 1215 } 1216 1217 1218 /** 1219 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 1220 */ 1221 static DECLCALLBACK(uint32_t) drvHstAudAlsaHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 1222 { 1223 RT_NOREF(pInterface); 1224 PDRVHSTAUDALSASTREAM pStreamALSA = (PDRVHSTAUDALSASTREAM)pStream; 1225 1226 uint32_t cbAvail = 0; 1227 snd_pcm_sframes_t cFramesAvail = 0; 1228 int rc = alsaStreamGetAvail(pStreamALSA->hPCM, &cFramesAvail); 1229 if (RT_SUCCESS(rc)) 1230 cbAvail = PDMAudioPropsFramesToBytes(&pStreamALSA->Cfg.Props, cFramesAvail); 1231 1232 return cbAvail; 1233 1233 } 1234 1234 … … 1413 1413 pThis->IHostAudio.pfnStreamNotifyDeviceChanged = NULL; 1414 1414 pThis->IHostAudio.pfnStreamControl = drvHstAudAlsaHA_StreamControl; 1415 pThis->IHostAudio.pfnStreamGetReadable = drvHstAudAlsaHA_StreamGetReadable;1416 pThis->IHostAudio.pfnStreamGetWritable = drvHstAudAlsaHA_StreamGetWritable;1417 1415 pThis->IHostAudio.pfnStreamGetPending = drvHstAudAlsaHA_StreamGetPending; 1418 1416 pThis->IHostAudio.pfnStreamGetState = drvHstAudAlsaHA_StreamGetState; 1417 pThis->IHostAudio.pfnStreamGetWritable = drvHstAudAlsaHA_StreamGetWritable; 1419 1418 pThis->IHostAudio.pfnStreamPlay = drvHstAudAlsaHA_StreamPlay; 1419 pThis->IHostAudio.pfnStreamGetReadable = drvHstAudAlsaHA_StreamGetReadable; 1420 1420 pThis->IHostAudio.pfnStreamCapture = drvHstAudAlsaHA_StreamCapture; 1421 1421 -
trunk/src/VBox/Devices/Audio/DrvHostAudioDSound.cpp
r89500 r89504 2228 2228 2229 2229 /** 2230 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}2231 */2232 static DECLCALLBACK(uint32_t) drvHostDSoundHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)2233 {2234 /*PDRVHOSTDSOUND pThis = RT_FROM_MEMBER(pInterface, DRVHOSTDSOUND, IHostAudio); */ RT_NOREF(pInterface);2235 PDSOUNDSTREAM pStreamDS = (PDSOUNDSTREAM)pStream;2236 AssertPtrReturn(pStreamDS, 0);2237 Assert(pStreamDS->Cfg.enmDir == PDMAUDIODIR_IN);2238 2239 if (pStreamDS->fEnabled)2240 {2241 /* This is the same calculation as for StreamGetPending. */2242 AssertPtr(pStreamDS->In.pDSCB);2243 DWORD offCaptureCursor = 0;2244 DWORD offReadCursor = 0;2245 HRESULT hrc = IDirectSoundCaptureBuffer_GetCurrentPosition(pStreamDS->In.pDSCB, &offCaptureCursor, &offReadCursor);2246 if (SUCCEEDED(hrc))2247 {2248 uint32_t cbPending = dsoundRingDistance(offCaptureCursor, offReadCursor, pStreamDS->cbBufSize);2249 Log3Func(("cbPending=%RU32\n", cbPending));2250 return cbPending;2251 }2252 AssertMsgFailed(("hrc=%Rhrc\n", hrc));2253 }2254 2255 return 0;2256 }2257 2258 2259 /**2260 2230 * Retrieves the number of free bytes available for writing to a DirectSound output stream. 2261 2231 * … … 2339 2309 2340 2310 /** 2341 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable} 2342 */ 2343 static DECLCALLBACK(uint32_t) drvHostDSoundHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 2344 { 2345 PDRVHOSTDSOUND pThis = RT_FROM_MEMBER(pInterface, DRVHOSTDSOUND, IHostAudio); 2346 PDSOUNDSTREAM pStreamDS = (PDSOUNDSTREAM)pStream; 2347 AssertPtrReturn(pStreamDS, 0); 2348 LogFlowFunc(("Stream '%s' {%s}\n", pStreamDS->Cfg.szName, drvHostDSoundStreamStatusString(pStreamDS))); 2349 2350 DWORD cbFree = 0; 2351 DWORD offIgn = 0; 2352 int rc = dsoundGetFreeOut(pThis, pStreamDS, &cbFree, &offIgn); 2353 AssertRCReturn(rc, 0); 2354 2355 return cbFree; 2311 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 2312 */ 2313 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHostDSoundHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 2314 PPDMAUDIOBACKENDSTREAM pStream) 2315 { 2316 RT_NOREF(pInterface); 2317 PDSOUNDSTREAM pStreamDS = (PDSOUNDSTREAM)pStream; 2318 AssertPtrReturn(pStreamDS, PDMHOSTAUDIOSTREAMSTATE_INVALID); 2319 2320 if ( pStreamDS->Cfg.enmDir != PDMAUDIODIR_OUT 2321 || !pStreamDS->Out.fDrain) 2322 { 2323 LogFlowFunc(("returns OKAY for '%s' {%s}\n", pStreamDS->Cfg.szName, drvHostDSoundStreamStatusString(pStreamDS))); 2324 return PDMHOSTAUDIOSTREAMSTATE_OKAY; 2325 } 2326 LogFlowFunc(("returns DRAINING for '%s' {%s}\n", pStreamDS->Cfg.szName, drvHostDSoundStreamStatusString(pStreamDS))); 2327 return PDMHOSTAUDIOSTREAMSTATE_DRAINING; 2356 2328 } 2357 2329 … … 2390 2362 2391 2363 /** 2392 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 2393 */ 2394 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHostDSoundHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 2395 PPDMAUDIOBACKENDSTREAM pStream) 2396 { 2397 RT_NOREF(pInterface); 2398 PDSOUNDSTREAM pStreamDS = (PDSOUNDSTREAM)pStream; 2399 AssertPtrReturn(pStreamDS, PDMHOSTAUDIOSTREAMSTATE_INVALID); 2400 2401 if ( pStreamDS->Cfg.enmDir != PDMAUDIODIR_OUT 2402 || !pStreamDS->Out.fDrain) 2403 { 2404 LogFlowFunc(("returns OKAY for '%s' {%s}\n", pStreamDS->Cfg.szName, drvHostDSoundStreamStatusString(pStreamDS))); 2405 return PDMHOSTAUDIOSTREAMSTATE_OKAY; 2406 } 2407 LogFlowFunc(("returns DRAINING for '%s' {%s}\n", pStreamDS->Cfg.szName, drvHostDSoundStreamStatusString(pStreamDS))); 2408 return PDMHOSTAUDIOSTREAMSTATE_DRAINING; 2364 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable} 2365 */ 2366 static DECLCALLBACK(uint32_t) drvHostDSoundHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 2367 { 2368 PDRVHOSTDSOUND pThis = RT_FROM_MEMBER(pInterface, DRVHOSTDSOUND, IHostAudio); 2369 PDSOUNDSTREAM pStreamDS = (PDSOUNDSTREAM)pStream; 2370 AssertPtrReturn(pStreamDS, 0); 2371 LogFlowFunc(("Stream '%s' {%s}\n", pStreamDS->Cfg.szName, drvHostDSoundStreamStatusString(pStreamDS))); 2372 2373 DWORD cbFree = 0; 2374 DWORD offIgn = 0; 2375 int rc = dsoundGetFreeOut(pThis, pStreamDS, &cbFree, &offIgn); 2376 AssertRCReturn(rc, 0); 2377 2378 return cbFree; 2409 2379 } 2410 2380 … … 2533 2503 2534 2504 return VINF_SUCCESS; 2505 } 2506 2507 2508 /** 2509 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 2510 */ 2511 static DECLCALLBACK(uint32_t) drvHostDSoundHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 2512 { 2513 /*PDRVHOSTDSOUND pThis = RT_FROM_MEMBER(pInterface, DRVHOSTDSOUND, IHostAudio); */ RT_NOREF(pInterface); 2514 PDSOUNDSTREAM pStreamDS = (PDSOUNDSTREAM)pStream; 2515 AssertPtrReturn(pStreamDS, 0); 2516 Assert(pStreamDS->Cfg.enmDir == PDMAUDIODIR_IN); 2517 2518 if (pStreamDS->fEnabled) 2519 { 2520 /* This is the same calculation as for StreamGetPending. */ 2521 AssertPtr(pStreamDS->In.pDSCB); 2522 DWORD offCaptureCursor = 0; 2523 DWORD offReadCursor = 0; 2524 HRESULT hrc = IDirectSoundCaptureBuffer_GetCurrentPosition(pStreamDS->In.pDSCB, &offCaptureCursor, &offReadCursor); 2525 if (SUCCEEDED(hrc)) 2526 { 2527 uint32_t cbPending = dsoundRingDistance(offCaptureCursor, offReadCursor, pStreamDS->cbBufSize); 2528 Log3Func(("cbPending=%RU32\n", cbPending)); 2529 return cbPending; 2530 } 2531 AssertMsgFailed(("hrc=%Rhrc\n", hrc)); 2532 } 2533 2534 return 0; 2535 2535 } 2536 2536 … … 2773 2773 pThis->IHostAudio.pfnStreamNotifyDeviceChanged = NULL; 2774 2774 pThis->IHostAudio.pfnStreamControl = drvHostDSoundHA_StreamControl; 2775 pThis->IHostAudio.pfnStreamGetState = drvHostDSoundHA_StreamGetState; 2776 pThis->IHostAudio.pfnStreamGetPending = NULL; 2777 pThis->IHostAudio.pfnStreamGetWritable = drvHostDSoundHA_StreamGetWritable; 2778 pThis->IHostAudio.pfnStreamPlay = drvHostDSoundHA_StreamPlay; 2775 2779 pThis->IHostAudio.pfnStreamGetReadable = drvHostDSoundHA_StreamGetReadable; 2776 pThis->IHostAudio.pfnStreamGetWritable = drvHostDSoundHA_StreamGetWritable;2777 pThis->IHostAudio.pfnStreamGetPending = NULL;2778 pThis->IHostAudio.pfnStreamGetState = drvHostDSoundHA_StreamGetState;2779 pThis->IHostAudio.pfnStreamPlay = drvHostDSoundHA_StreamPlay;2780 2780 pThis->IHostAudio.pfnStreamCapture = drvHostDSoundHA_StreamCapture; 2781 2781 -
trunk/src/VBox/Devices/Audio/DrvHostAudioDebug.cpp
r89487 r89504 193 193 194 194 /** 195 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 196 */ 197 static DECLCALLBACK(uint32_t) drvHstAudDebugHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 198 { 199 RT_NOREF(pInterface); 200 PDRVHSTAUDDEBUGSTREAM pStreamDbg = (PDRVHSTAUDDEBUGSTREAM)pStream; 201 202 return PDMAudioPropsMilliToBytes(&pStreamDbg->Cfg.Props, 10 /*ms*/); 195 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 196 */ 197 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHstAudDebugHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 198 PPDMAUDIOBACKENDSTREAM pStream) 199 { 200 RT_NOREF(pInterface); 201 AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID); 202 return PDMHOSTAUDIOSTREAMSTATE_OKAY; 203 } 204 205 206 /** 207 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetPending} 208 */ 209 static DECLCALLBACK(uint32_t) drvHstAudDebugHA_StreamGetPending(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 210 { 211 RT_NOREF(pInterface, pStream); 212 return 0; 203 213 } 204 214 … … 211 221 RT_NOREF(pInterface, pStream); 212 222 return UINT32_MAX; 213 }214 215 216 /**217 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetPending}218 */219 static DECLCALLBACK(uint32_t) drvHstAudDebugHA_StreamGetPending(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)220 {221 RT_NOREF(pInterface, pStream);222 return 0;223 }224 225 226 /**227 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState}228 */229 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHstAudDebugHA_StreamGetState(PPDMIHOSTAUDIO pInterface,230 PPDMAUDIOBACKENDSTREAM pStream)231 {232 RT_NOREF(pInterface);233 AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID);234 return PDMHOSTAUDIOSTREAMSTATE_OKAY;235 223 } 236 224 … … 251 239 LogRelMax(32, ("DebugAudio: Writing output failed with %Rrc\n", rc)); 252 240 return rc; 241 } 242 243 244 /** 245 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 246 */ 247 static DECLCALLBACK(uint32_t) drvHstAudDebugHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 248 { 249 RT_NOREF(pInterface); 250 PDRVHSTAUDDEBUGSTREAM pStreamDbg = (PDRVHSTAUDDEBUGSTREAM)pStream; 251 252 return PDMAudioPropsMilliToBytes(&pStreamDbg->Cfg.Props, 10 /*ms*/); 253 253 } 254 254 … … 327 327 pThis->IHostAudio.pfnStreamNotifyDeviceChanged = NULL; 328 328 pThis->IHostAudio.pfnStreamControl = drvHstAudDebugHA_StreamControl; 329 pThis->IHostAudio.pfnStreamGetState = drvHstAudDebugHA_StreamGetState; 330 pThis->IHostAudio.pfnStreamGetPending = drvHstAudDebugHA_StreamGetPending; 331 pThis->IHostAudio.pfnStreamGetWritable = drvHstAudDebugHA_StreamGetWritable; 332 pThis->IHostAudio.pfnStreamPlay = drvHstAudDebugHA_StreamPlay; 329 333 pThis->IHostAudio.pfnStreamGetReadable = drvHstAudDebugHA_StreamGetReadable; 330 pThis->IHostAudio.pfnStreamGetWritable = drvHstAudDebugHA_StreamGetWritable;331 pThis->IHostAudio.pfnStreamGetPending = drvHstAudDebugHA_StreamGetPending;332 pThis->IHostAudio.pfnStreamGetState = drvHstAudDebugHA_StreamGetState;333 pThis->IHostAudio.pfnStreamPlay = drvHstAudDebugHA_StreamPlay;334 334 pThis->IHostAudio.pfnStreamCapture = drvHstAudDebugHA_StreamCapture; 335 335 -
trunk/src/VBox/Devices/Audio/DrvHostAudioNull.cpp
r89489 r89504 150 150 151 151 /** 152 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}153 */154 static DECLCALLBACK(uint32_t) drvHstAudNullHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)155 {156 RT_NOREF(pInterface, pStream);157 /** @todo rate limit this? */158 return UINT32_MAX;159 }160 161 162 /**163 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}164 */165 static DECLCALLBACK(uint32_t) drvHstAudNullHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)166 {167 RT_NOREF(pInterface, pStream);168 return UINT32_MAX;169 }170 171 172 /**173 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetPending}174 */175 static DECLCALLBACK(uint32_t) drvHstAudNullHA_StreamGetPending(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)176 {177 RT_NOREF(pInterface, pStream);178 return 0;179 }180 181 182 /**183 152 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 184 153 */ … … 199 168 200 169 /** 170 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetPending} 171 */ 172 static DECLCALLBACK(uint32_t) drvHstAudNullHA_StreamGetPending(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 173 { 174 RT_NOREF(pInterface, pStream); 175 return 0; 176 } 177 178 179 /** 180 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable} 181 */ 182 static DECLCALLBACK(uint32_t) drvHstAudNullHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 183 { 184 RT_NOREF(pInterface, pStream); 185 return UINT32_MAX; 186 } 187 188 189 /** 201 190 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay} 202 191 */ … … 209 198 *pcbWritten = cbBuf; 210 199 return VINF_SUCCESS; 200 } 201 202 203 /** 204 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 205 */ 206 static DECLCALLBACK(uint32_t) drvHstAudNullHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 207 { 208 RT_NOREF(pInterface, pStream); 209 /** @todo rate limit this? */ 210 return UINT32_MAX; 211 211 } 212 212 -
trunk/src/VBox/Devices/Audio/DrvHostAudioOss.cpp
r89487 r89504 677 677 678 678 /** 679 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}680 */681 static DECLCALLBACK(uint32_t) drvHstAudOssHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)682 {683 RT_NOREF(pInterface, pStream);684 Log4Func(("returns UINT32_MAX\n"));685 return UINT32_MAX;686 }687 688 689 /**690 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}691 */692 static DECLCALLBACK(uint32_t) drvHstAudOssHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)693 {694 RT_NOREF(pInterface);695 PDRVHSTAUDOSSSTREAM pStreamOSS = (PDRVHSTAUDOSSSTREAM)pStream;696 AssertPtr(pStreamOSS);697 698 /*699 * Note! This logic was found in StreamPlay and corrected a little.700 *701 * The logic here must match what StreamPlay does.702 */703 audio_buf_info BufInfo = { 0, 0, 0, 0 };704 int rc2 = ioctl(pStreamOSS->hFile, SNDCTL_DSP_GETOSPACE, &BufInfo);705 AssertMsgReturn(rc2 >= 0, ("SNDCTL_DSP_GETOSPACE failed: %s (%d)\n", strerror(errno), errno), 0);706 707 #if 0 /** @todo we could return BufInfo.bytes here iff StreamPlay didn't use the fragmented approach */708 /** @todo r=bird: WTF do we make a fuss over BufInfo.bytes for when we don't709 * even use it?!? */710 AssertLogRelMsgReturn(BufInfo.bytes >= 0, ("OSS: Warning: Invalid available size: %d\n", BufInfo.bytes), VERR_INTERNAL_ERROR_3);711 if ((unsigned)BufInfo.bytes > cbBuf)712 {713 LogRel2(("OSS: Warning: Too big output size (%d > %RU32), limiting to %RU32\n", BufInfo.bytes, cbBuf, cbBuf));714 BufInfo.bytes = cbBuf;715 /* Keep going. */716 }717 #endif718 719 uint32_t cbRet = (uint32_t)(BufInfo.fragments * BufInfo.fragsize);720 Log4Func(("returns %#x (%u)\n", cbRet, cbRet));721 return cbRet;722 }723 724 725 /**726 679 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 727 680 */ … … 739 692 740 693 /** 694 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable} 695 */ 696 static DECLCALLBACK(uint32_t) drvHstAudOssHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 697 { 698 RT_NOREF(pInterface); 699 PDRVHSTAUDOSSSTREAM pStreamOSS = (PDRVHSTAUDOSSSTREAM)pStream; 700 AssertPtr(pStreamOSS); 701 702 /* 703 * Note! This logic was found in StreamPlay and corrected a little. 704 * 705 * The logic here must match what StreamPlay does. 706 */ 707 audio_buf_info BufInfo = { 0, 0, 0, 0 }; 708 int rc2 = ioctl(pStreamOSS->hFile, SNDCTL_DSP_GETOSPACE, &BufInfo); 709 AssertMsgReturn(rc2 >= 0, ("SNDCTL_DSP_GETOSPACE failed: %s (%d)\n", strerror(errno), errno), 0); 710 711 #if 0 /** @todo we could return BufInfo.bytes here iff StreamPlay didn't use the fragmented approach */ 712 /** @todo r=bird: WTF do we make a fuss over BufInfo.bytes for when we don't 713 * even use it?!? */ 714 AssertLogRelMsgReturn(BufInfo.bytes >= 0, ("OSS: Warning: Invalid available size: %d\n", BufInfo.bytes), VERR_INTERNAL_ERROR_3); 715 if ((unsigned)BufInfo.bytes > cbBuf) 716 { 717 LogRel2(("OSS: Warning: Too big output size (%d > %RU32), limiting to %RU32\n", BufInfo.bytes, cbBuf, cbBuf)); 718 BufInfo.bytes = cbBuf; 719 /* Keep going. */ 720 } 721 #endif 722 723 uint32_t cbRet = (uint32_t)(BufInfo.fragments * BufInfo.fragsize); 724 Log4Func(("returns %#x (%u)\n", cbRet, cbRet)); 725 return cbRet; 726 } 727 728 729 /** 741 730 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay} 742 731 */ … … 820 809 *pcbWritten = offChunk; 821 810 return VINF_SUCCESS; 811 } 812 813 814 /** 815 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 816 */ 817 static DECLCALLBACK(uint32_t) drvHstAudOssHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 818 { 819 RT_NOREF(pInterface, pStream); 820 Log4Func(("returns UINT32_MAX\n")); 821 return UINT32_MAX; 822 822 } 823 823 … … 913 913 pThis->IHostAudio.pfnStreamNotifyDeviceChanged = NULL; 914 914 pThis->IHostAudio.pfnStreamControl = drvHstAudOssHA_StreamControl; 915 pThis->IHostAudio.pfnStreamGetState = drvHstAudOssHA_StreamGetState; 916 pThis->IHostAudio.pfnStreamGetPending = NULL; 917 pThis->IHostAudio.pfnStreamGetWritable = drvHstAudOssHA_StreamGetWritable; 918 pThis->IHostAudio.pfnStreamPlay = drvHstAudOssHA_StreamPlay; 915 919 pThis->IHostAudio.pfnStreamGetReadable = drvHstAudOssHA_StreamGetReadable; 916 pThis->IHostAudio.pfnStreamGetWritable = drvHstAudOssHA_StreamGetWritable;917 pThis->IHostAudio.pfnStreamGetPending = NULL;918 pThis->IHostAudio.pfnStreamGetState = drvHstAudOssHA_StreamGetState;919 pThis->IHostAudio.pfnStreamPlay = drvHstAudOssHA_StreamPlay;920 920 pThis->IHostAudio.pfnStreamCapture = drvHstAudOssHA_StreamCapture; 921 921 -
trunk/src/VBox/Devices/Audio/DrvHostAudioPulseAudio.cpp
r89500 r89504 1590 1590 1591 1591 /** 1592 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}1593 */1594 static DECLCALLBACK(uint32_t) drvHstAudPaHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)1595 {1596 PDRVHSTAUDPA pThis = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio);1597 PDRVHSTAUDPASTREAM pStreamPA = (PDRVHSTAUDPASTREAM)pStream;1598 uint32_t cbReadable = 0;1599 if (pStreamPA->Cfg.enmDir == PDMAUDIODIR_IN)1600 {1601 pa_threaded_mainloop_lock(pThis->pMainLoop);1602 1603 pa_stream_state_t const enmState = pa_stream_get_state(pStreamPA->pStream);1604 if (PA_STREAM_IS_GOOD(enmState))1605 {1606 size_t cbReadablePa = pa_stream_readable_size(pStreamPA->pStream);1607 if (cbReadablePa != (size_t)-1)1608 cbReadable = (uint32_t)cbReadablePa;1609 else1610 drvHstAudPaError(pThis, "pa_stream_readable_size failed on '%s'", pStreamPA->Cfg.szName);1611 }1612 else1613 LogFunc(("non-good stream state: %d\n", enmState));1614 1615 pa_threaded_mainloop_unlock(pThis->pMainLoop);1616 }1617 Log3Func(("returns %#x (%u)\n", cbReadable, cbReadable));1618 return cbReadable;1619 }1620 1621 1622 /**1623 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}1624 */1625 static DECLCALLBACK(uint32_t) drvHstAudPaHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)1626 {1627 PDRVHSTAUDPA pThis = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio);1628 PDRVHSTAUDPASTREAM pStreamPA = (PDRVHSTAUDPASTREAM)pStream;1629 uint32_t cbWritable = 0;1630 if (pStreamPA->Cfg.enmDir == PDMAUDIODIR_OUT)1631 {1632 pa_threaded_mainloop_lock(pThis->pMainLoop);1633 1634 pa_stream_state_t const enmState = pa_stream_get_state(pStreamPA->pStream);1635 if (PA_STREAM_IS_GOOD(enmState))1636 {1637 size_t cbWritablePa = pa_stream_writable_size(pStreamPA->pStream);1638 if (cbWritablePa != (size_t)-1)1639 cbWritable = cbWritablePa <= UINT32_MAX ? (uint32_t)cbWritablePa : UINT32_MAX;1640 else1641 drvHstAudPaError(pThis, "pa_stream_writable_size failed on '%s'", pStreamPA->Cfg.szName);1642 }1643 else1644 LogFunc(("non-good stream state: %d\n", enmState));1645 1646 pa_threaded_mainloop_unlock(pThis->pMainLoop);1647 }1648 Log3Func(("returns %#x (%u) [max=%#RX32 min=%#RX32]\n",1649 cbWritable, cbWritable, pStreamPA->BufAttr.maxlength, pStreamPA->BufAttr.minreq));1650 return cbWritable;1651 }1652 1653 1654 /**1655 1592 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 1656 1593 */ … … 1699 1636 1700 1637 /** 1638 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable} 1639 */ 1640 static DECLCALLBACK(uint32_t) drvHstAudPaHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 1641 { 1642 PDRVHSTAUDPA pThis = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio); 1643 PDRVHSTAUDPASTREAM pStreamPA = (PDRVHSTAUDPASTREAM)pStream; 1644 uint32_t cbWritable = 0; 1645 if (pStreamPA->Cfg.enmDir == PDMAUDIODIR_OUT) 1646 { 1647 pa_threaded_mainloop_lock(pThis->pMainLoop); 1648 1649 pa_stream_state_t const enmState = pa_stream_get_state(pStreamPA->pStream); 1650 if (PA_STREAM_IS_GOOD(enmState)) 1651 { 1652 size_t cbWritablePa = pa_stream_writable_size(pStreamPA->pStream); 1653 if (cbWritablePa != (size_t)-1) 1654 cbWritable = cbWritablePa <= UINT32_MAX ? (uint32_t)cbWritablePa : UINT32_MAX; 1655 else 1656 drvHstAudPaError(pThis, "pa_stream_writable_size failed on '%s'", pStreamPA->Cfg.szName); 1657 } 1658 else 1659 LogFunc(("non-good stream state: %d\n", enmState)); 1660 1661 pa_threaded_mainloop_unlock(pThis->pMainLoop); 1662 } 1663 Log3Func(("returns %#x (%u) [max=%#RX32 min=%#RX32]\n", 1664 cbWritable, cbWritable, pStreamPA->BufAttr.maxlength, pStreamPA->BufAttr.minreq)); 1665 return cbWritable; 1666 } 1667 1668 1669 /** 1701 1670 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay} 1702 1671 */ … … 1774 1743 Log3Func(("returns %Rrc *pcbWritten=%#x iLoop=%u\n", rc, cbTotalWritten, iLoop)); 1775 1744 return rc; 1745 } 1746 1747 1748 /** 1749 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 1750 */ 1751 static DECLCALLBACK(uint32_t) drvHstAudPaHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 1752 { 1753 PDRVHSTAUDPA pThis = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio); 1754 PDRVHSTAUDPASTREAM pStreamPA = (PDRVHSTAUDPASTREAM)pStream; 1755 uint32_t cbReadable = 0; 1756 if (pStreamPA->Cfg.enmDir == PDMAUDIODIR_IN) 1757 { 1758 pa_threaded_mainloop_lock(pThis->pMainLoop); 1759 1760 pa_stream_state_t const enmState = pa_stream_get_state(pStreamPA->pStream); 1761 if (PA_STREAM_IS_GOOD(enmState)) 1762 { 1763 size_t cbReadablePa = pa_stream_readable_size(pStreamPA->pStream); 1764 if (cbReadablePa != (size_t)-1) 1765 cbReadable = (uint32_t)cbReadablePa; 1766 else 1767 drvHstAudPaError(pThis, "pa_stream_readable_size failed on '%s'", pStreamPA->Cfg.szName); 1768 } 1769 else 1770 LogFunc(("non-good stream state: %d\n", enmState)); 1771 1772 pa_threaded_mainloop_unlock(pThis->pMainLoop); 1773 } 1774 Log3Func(("returns %#x (%u)\n", cbReadable, cbReadable)); 1775 return cbReadable; 1776 1776 } 1777 1777 … … 2043 2043 pThis->IHostAudio.pfnStreamNotifyDeviceChanged = NULL; 2044 2044 pThis->IHostAudio.pfnStreamControl = drvHstAudPaHA_StreamControl; 2045 pThis->IHostAudio.pfnStreamGetState = drvHstAudPaHA_StreamGetState; 2046 pThis->IHostAudio.pfnStreamGetPending = NULL; 2047 pThis->IHostAudio.pfnStreamGetWritable = drvHstAudPaHA_StreamGetWritable; 2048 pThis->IHostAudio.pfnStreamPlay = drvHstAudPaHA_StreamPlay; 2045 2049 pThis->IHostAudio.pfnStreamGetReadable = drvHstAudPaHA_StreamGetReadable; 2046 pThis->IHostAudio.pfnStreamGetWritable = drvHstAudPaHA_StreamGetWritable;2047 pThis->IHostAudio.pfnStreamGetPending = NULL;2048 pThis->IHostAudio.pfnStreamGetState = drvHstAudPaHA_StreamGetState;2049 pThis->IHostAudio.pfnStreamPlay = drvHstAudPaHA_StreamPlay;2050 2050 pThis->IHostAudio.pfnStreamCapture = drvHstAudPaHA_StreamCapture; 2051 2051 -
trunk/src/VBox/Devices/Audio/DrvHostAudioWasApi.cpp
r89500 r89504 2375 2375 2376 2376 /** 2377 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 2378 */ 2379 static DECLCALLBACK(uint32_t) drvHostAudioWasHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 2377 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 2378 */ 2379 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHostAudioWasHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 2380 PPDMAUDIOBACKENDSTREAM pStream) 2380 2381 { 2381 2382 RT_NOREF(pInterface); 2382 2383 PDRVHOSTAUDIOWASSTREAM pStreamWas = (PDRVHOSTAUDIOWASSTREAM)pStream; 2383 AssertPtrReturn(pStreamWas, 0); 2384 Assert(pStreamWas->Cfg.enmDir == PDMAUDIODIR_IN); 2385 2386 uint32_t cbReadable = 0; 2387 RTCritSectEnter(&pStreamWas->CritSect); 2388 2389 if (pStreamWas->pDevCfg->pIAudioCaptureClient /* paranoia */) 2390 { 2391 UINT32 cFramesPending = 0; 2392 HRESULT hrc = pStreamWas->pDevCfg->pIAudioClient->GetCurrentPadding(&cFramesPending); 2393 if (SUCCEEDED(hrc)) 2394 { 2395 /* An unreleased buffer is included in the pending frame count, so subtract 2396 whatever we've got hanging around since the previous pfnStreamCapture call. */ 2397 AssertMsgStmt(cFramesPending >= pStreamWas->cFramesCaptureToRelease, 2398 ("%#x vs %#x\n", cFramesPending, pStreamWas->cFramesCaptureToRelease), 2399 cFramesPending = pStreamWas->cFramesCaptureToRelease); 2400 cFramesPending -= pStreamWas->cFramesCaptureToRelease; 2401 2402 /* Add what we've got left in said buffer. */ 2403 uint32_t cFramesCurPacket = PDMAudioPropsBytesToFrames(&pStreamWas->Cfg.Props, pStreamWas->cbCapture); 2404 cFramesPending += cFramesCurPacket; 2405 2406 /* Paranoia: Make sure we don't exceed the buffer size. */ 2407 AssertMsgStmt(cFramesPending <= pStreamWas->Cfg.Backend.cFramesBufferSize, 2408 ("cFramesPending=%#x cFramesCaptureToRelease=%#x cFramesCurPacket=%#x cFramesBufferSize=%#x\n", 2409 cFramesPending, pStreamWas->cFramesCaptureToRelease, cFramesCurPacket, 2410 pStreamWas->Cfg.Backend.cFramesBufferSize), 2411 cFramesPending = pStreamWas->Cfg.Backend.cFramesBufferSize); 2412 2413 cbReadable = PDMAudioPropsFramesToBytes(&pStreamWas->Cfg.Props, cFramesPending); 2414 } 2384 AssertPtrReturn(pStreamWas, PDMHOSTAUDIOSTREAMSTATE_INVALID); 2385 2386 PDMHOSTAUDIOSTREAMSTATE enmState; 2387 AssertPtr(pStreamWas->pDevCfg); 2388 if (pStreamWas->pDevCfg /*paranoia*/) 2389 { 2390 if (RT_SUCCESS(pStreamWas->pDevCfg->rcSetup)) 2391 { 2392 if (!pStreamWas->fDraining) 2393 enmState = PDMHOSTAUDIOSTREAMSTATE_OKAY; 2394 else 2395 { 2396 Assert(pStreamWas->Cfg.enmDir == PDMAUDIODIR_OUT); 2397 enmState = PDMHOSTAUDIOSTREAMSTATE_DRAINING; 2398 } 2399 } 2400 else if ( pStreamWas->pDevCfg->rcSetup == VERR_AUDIO_STREAM_INIT_IN_PROGRESS 2401 || pStreamWas->fSwitchingDevice ) 2402 enmState = PDMHOSTAUDIOSTREAMSTATE_INITIALIZING; 2415 2403 else 2416 LogRelMax(64, ("WasAPI: GetCurrentPadding failed on '%s': %Rhrc\n", pStreamWas->Cfg.szName, hrc)); 2417 } 2418 2419 RTCritSectLeave(&pStreamWas->CritSect); 2420 2421 LogFlowFunc(("returns %#x (%u) {%s}\n", cbReadable, cbReadable, drvHostWasStreamStatusString(pStreamWas))); 2422 return cbReadable; 2423 } 2424 2425 2426 /** 2427 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable} 2428 */ 2429 static DECLCALLBACK(uint32_t) drvHostAudioWasHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 2430 { 2431 RT_NOREF(pInterface); 2432 PDRVHOSTAUDIOWASSTREAM pStreamWas = (PDRVHOSTAUDIOWASSTREAM)pStream; 2433 AssertPtrReturn(pStreamWas, 0); 2434 LogFlowFunc(("Stream '%s' {%s}\n", pStreamWas->Cfg.szName, drvHostWasStreamStatusString(pStreamWas))); 2435 Assert(pStreamWas->Cfg.enmDir == PDMAUDIODIR_OUT); 2436 2437 uint32_t cbWritable = 0; 2438 RTCritSectEnter(&pStreamWas->CritSect); 2439 2440 if ( pStreamWas->Cfg.enmDir == PDMAUDIODIR_OUT 2441 && pStreamWas->pDevCfg->pIAudioClient /* paranoia */) 2442 { 2443 UINT32 cFramesPending = 0; 2444 HRESULT hrc = pStreamWas->pDevCfg->pIAudioClient->GetCurrentPadding(&cFramesPending); 2445 if (SUCCEEDED(hrc)) 2446 { 2447 if (cFramesPending < pStreamWas->Cfg.Backend.cFramesBufferSize) 2448 cbWritable = PDMAudioPropsFramesToBytes(&pStreamWas->Cfg.Props, 2449 pStreamWas->Cfg.Backend.cFramesBufferSize - cFramesPending); 2450 else if (cFramesPending > pStreamWas->Cfg.Backend.cFramesBufferSize) 2451 { 2452 LogRelMax(64, ("WasAPI: Warning! GetCurrentPadding('%s') return too high: cFramesPending=%#x > cFramesBufferSize=%#x\n", 2453 pStreamWas->Cfg.szName, cFramesPending, pStreamWas->Cfg.Backend.cFramesBufferSize)); 2454 AssertMsgFailed(("cFramesPending=%#x > cFramesBufferSize=%#x\n", 2455 cFramesPending, pStreamWas->Cfg.Backend.cFramesBufferSize)); 2456 } 2457 } 2458 else 2459 LogRelMax(64, ("WasAPI: GetCurrentPadding failed on '%s': %Rhrc\n", pStreamWas->Cfg.szName, hrc)); 2460 } 2461 2462 RTCritSectLeave(&pStreamWas->CritSect); 2463 2464 LogFlowFunc(("returns %#x (%u) {%s}\n", cbWritable, cbWritable, drvHostWasStreamStatusString(pStreamWas))); 2465 return cbWritable; 2404 enmState = PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING; 2405 } 2406 else if (pStreamWas->fSwitchingDevice) 2407 enmState = PDMHOSTAUDIOSTREAMSTATE_INITIALIZING; 2408 else 2409 enmState = PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING; 2410 2411 LogFlowFunc(("returns %d for '%s' {%s}\n", enmState, pStreamWas->Cfg.szName, drvHostWasStreamStatusString(pStreamWas))); 2412 return enmState; 2466 2413 } 2467 2414 … … 2508 2455 2509 2456 /** 2510 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 2511 */ 2512 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHostAudioWasHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 2513 PPDMAUDIOBACKENDSTREAM pStream) 2457 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable} 2458 */ 2459 static DECLCALLBACK(uint32_t) drvHostAudioWasHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 2514 2460 { 2515 2461 RT_NOREF(pInterface); 2516 2462 PDRVHOSTAUDIOWASSTREAM pStreamWas = (PDRVHOSTAUDIOWASSTREAM)pStream; 2517 AssertPtrReturn(pStreamWas, PDMHOSTAUDIOSTREAMSTATE_INVALID); 2518 2519 PDMHOSTAUDIOSTREAMSTATE enmState; 2520 AssertPtr(pStreamWas->pDevCfg); 2521 if (pStreamWas->pDevCfg /*paranoia*/) 2522 { 2523 if (RT_SUCCESS(pStreamWas->pDevCfg->rcSetup)) 2524 { 2525 if (!pStreamWas->fDraining) 2526 enmState = PDMHOSTAUDIOSTREAMSTATE_OKAY; 2527 else 2463 AssertPtrReturn(pStreamWas, 0); 2464 LogFlowFunc(("Stream '%s' {%s}\n", pStreamWas->Cfg.szName, drvHostWasStreamStatusString(pStreamWas))); 2465 Assert(pStreamWas->Cfg.enmDir == PDMAUDIODIR_OUT); 2466 2467 uint32_t cbWritable = 0; 2468 RTCritSectEnter(&pStreamWas->CritSect); 2469 2470 if ( pStreamWas->Cfg.enmDir == PDMAUDIODIR_OUT 2471 && pStreamWas->pDevCfg->pIAudioClient /* paranoia */) 2472 { 2473 UINT32 cFramesPending = 0; 2474 HRESULT hrc = pStreamWas->pDevCfg->pIAudioClient->GetCurrentPadding(&cFramesPending); 2475 if (SUCCEEDED(hrc)) 2476 { 2477 if (cFramesPending < pStreamWas->Cfg.Backend.cFramesBufferSize) 2478 cbWritable = PDMAudioPropsFramesToBytes(&pStreamWas->Cfg.Props, 2479 pStreamWas->Cfg.Backend.cFramesBufferSize - cFramesPending); 2480 else if (cFramesPending > pStreamWas->Cfg.Backend.cFramesBufferSize) 2528 2481 { 2529 Assert(pStreamWas->Cfg.enmDir == PDMAUDIODIR_OUT); 2530 enmState = PDMHOSTAUDIOSTREAMSTATE_DRAINING; 2482 LogRelMax(64, ("WasAPI: Warning! GetCurrentPadding('%s') return too high: cFramesPending=%#x > cFramesBufferSize=%#x\n", 2483 pStreamWas->Cfg.szName, cFramesPending, pStreamWas->Cfg.Backend.cFramesBufferSize)); 2484 AssertMsgFailed(("cFramesPending=%#x > cFramesBufferSize=%#x\n", 2485 cFramesPending, pStreamWas->Cfg.Backend.cFramesBufferSize)); 2531 2486 } 2532 2487 } 2533 else if ( pStreamWas->pDevCfg->rcSetup == VERR_AUDIO_STREAM_INIT_IN_PROGRESS2534 || pStreamWas->fSwitchingDevice )2535 enmState = PDMHOSTAUDIOSTREAMSTATE_INITIALIZING;2536 2488 else 2537 enmState = PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING; 2538 } 2539 else if (pStreamWas->fSwitchingDevice) 2540 enmState = PDMHOSTAUDIOSTREAMSTATE_INITIALIZING; 2541 else 2542 enmState = PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING; 2543 2544 LogFlowFunc(("returns %d for '%s' {%s}\n", enmState, pStreamWas->Cfg.szName, drvHostWasStreamStatusString(pStreamWas))); 2545 return enmState; 2489 LogRelMax(64, ("WasAPI: GetCurrentPadding failed on '%s': %Rhrc\n", pStreamWas->Cfg.szName, hrc)); 2490 } 2491 2492 RTCritSectLeave(&pStreamWas->CritSect); 2493 2494 LogFlowFunc(("returns %#x (%u) {%s}\n", cbWritable, cbWritable, drvHostWasStreamStatusString(pStreamWas))); 2495 return cbWritable; 2546 2496 } 2547 2497 … … 2702 2652 msPrev ? msNow - msPrev : 0, msPrev, pStreamWas->msLastTransfer, drvHostWasStreamStatusString(pStreamWas) )); 2703 2653 return rc; 2654 } 2655 2656 2657 /** 2658 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 2659 */ 2660 static DECLCALLBACK(uint32_t) drvHostAudioWasHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 2661 { 2662 RT_NOREF(pInterface); 2663 PDRVHOSTAUDIOWASSTREAM pStreamWas = (PDRVHOSTAUDIOWASSTREAM)pStream; 2664 AssertPtrReturn(pStreamWas, 0); 2665 Assert(pStreamWas->Cfg.enmDir == PDMAUDIODIR_IN); 2666 2667 uint32_t cbReadable = 0; 2668 RTCritSectEnter(&pStreamWas->CritSect); 2669 2670 if (pStreamWas->pDevCfg->pIAudioCaptureClient /* paranoia */) 2671 { 2672 UINT32 cFramesPending = 0; 2673 HRESULT hrc = pStreamWas->pDevCfg->pIAudioClient->GetCurrentPadding(&cFramesPending); 2674 if (SUCCEEDED(hrc)) 2675 { 2676 /* An unreleased buffer is included in the pending frame count, so subtract 2677 whatever we've got hanging around since the previous pfnStreamCapture call. */ 2678 AssertMsgStmt(cFramesPending >= pStreamWas->cFramesCaptureToRelease, 2679 ("%#x vs %#x\n", cFramesPending, pStreamWas->cFramesCaptureToRelease), 2680 cFramesPending = pStreamWas->cFramesCaptureToRelease); 2681 cFramesPending -= pStreamWas->cFramesCaptureToRelease; 2682 2683 /* Add what we've got left in said buffer. */ 2684 uint32_t cFramesCurPacket = PDMAudioPropsBytesToFrames(&pStreamWas->Cfg.Props, pStreamWas->cbCapture); 2685 cFramesPending += cFramesCurPacket; 2686 2687 /* Paranoia: Make sure we don't exceed the buffer size. */ 2688 AssertMsgStmt(cFramesPending <= pStreamWas->Cfg.Backend.cFramesBufferSize, 2689 ("cFramesPending=%#x cFramesCaptureToRelease=%#x cFramesCurPacket=%#x cFramesBufferSize=%#x\n", 2690 cFramesPending, pStreamWas->cFramesCaptureToRelease, cFramesCurPacket, 2691 pStreamWas->Cfg.Backend.cFramesBufferSize), 2692 cFramesPending = pStreamWas->Cfg.Backend.cFramesBufferSize); 2693 2694 cbReadable = PDMAudioPropsFramesToBytes(&pStreamWas->Cfg.Props, cFramesPending); 2695 } 2696 else 2697 LogRelMax(64, ("WasAPI: GetCurrentPadding failed on '%s': %Rhrc\n", pStreamWas->Cfg.szName, hrc)); 2698 } 2699 2700 RTCritSectLeave(&pStreamWas->CritSect); 2701 2702 LogFlowFunc(("returns %#x (%u) {%s}\n", cbReadable, cbReadable, drvHostWasStreamStatusString(pStreamWas))); 2703 return cbReadable; 2704 2704 } 2705 2705 … … 3030 3030 pThis->IHostAudio.pfnStreamNotifyDeviceChanged = drvHostAudioWasHA_StreamNotifyDeviceChanged; 3031 3031 pThis->IHostAudio.pfnStreamControl = drvHostAudioWasHA_StreamControl; 3032 pThis->IHostAudio.pfnStreamGetState = drvHostAudioWasHA_StreamGetState; 3033 pThis->IHostAudio.pfnStreamGetPending = drvHostAudioWasHA_StreamGetPending; 3034 pThis->IHostAudio.pfnStreamGetWritable = drvHostAudioWasHA_StreamGetWritable; 3035 pThis->IHostAudio.pfnStreamPlay = drvHostAudioWasHA_StreamPlay; 3032 3036 pThis->IHostAudio.pfnStreamGetReadable = drvHostAudioWasHA_StreamGetReadable; 3033 pThis->IHostAudio.pfnStreamGetWritable = drvHostAudioWasHA_StreamGetWritable;3034 pThis->IHostAudio.pfnStreamGetPending = drvHostAudioWasHA_StreamGetPending;3035 pThis->IHostAudio.pfnStreamGetState = drvHostAudioWasHA_StreamGetState;3036 pThis->IHostAudio.pfnStreamPlay = drvHostAudioWasHA_StreamPlay;3037 3037 pThis->IHostAudio.pfnStreamCapture = drvHostAudioWasHA_StreamCapture; 3038 3038 -
trunk/src/VBox/Main/src-client/DrvAudioRec.cpp
r89487 r89504 592 592 593 593 /** 594 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}595 */596 static DECLCALLBACK(uint32_t) drvAudioVideoRecHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)597 {598 RT_NOREF(pInterface, pStream);599 return 0; /* Video capturing does not provide any input. */600 }601 602 603 /**604 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}605 */606 static DECLCALLBACK(uint32_t) drvAudioVideoRecHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)607 {608 RT_NOREF(pInterface, pStream);609 return UINT32_MAX;610 }611 612 613 /**614 594 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 615 595 */ … … 620 600 AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID); 621 601 return PDMHOSTAUDIOSTREAMSTATE_OKAY; 602 } 603 604 605 /** 606 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable} 607 */ 608 static DECLCALLBACK(uint32_t) drvAudioVideoRecHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 609 { 610 RT_NOREF(pInterface, pStream); 611 return UINT32_MAX; 622 612 } 623 613 … … 791 781 LogFlowFunc(("csReadTotal=%RU32, rc=%Rrc\n", cbWrittenTotal, rc)); 792 782 return rc; 783 } 784 785 786 /** 787 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 788 */ 789 static DECLCALLBACK(uint32_t) drvAudioVideoRecHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 790 { 791 RT_NOREF(pInterface, pStream); 792 return 0; /* Video capturing does not provide any input. */ 793 793 } 794 794 … … 1115 1115 pThis->IHostAudio.pfnStreamNotifyDeviceChanged = NULL; 1116 1116 pThis->IHostAudio.pfnStreamControl = drvAudioVideoRecHA_StreamControl; 1117 pThis->IHostAudio.pfnStreamGetState = drvAudioVideoRecHA_StreamGetState; 1118 pThis->IHostAudio.pfnStreamGetPending = NULL; 1119 pThis->IHostAudio.pfnStreamGetWritable = drvAudioVideoRecHA_StreamGetWritable; 1120 pThis->IHostAudio.pfnStreamPlay = drvAudioVideoRecHA_StreamPlay; 1117 1121 pThis->IHostAudio.pfnStreamGetReadable = drvAudioVideoRecHA_StreamGetReadable; 1118 pThis->IHostAudio.pfnStreamGetWritable = drvAudioVideoRecHA_StreamGetWritable;1119 pThis->IHostAudio.pfnStreamGetPending = NULL;1120 pThis->IHostAudio.pfnStreamGetState = drvAudioVideoRecHA_StreamGetState;1121 pThis->IHostAudio.pfnStreamPlay = drvAudioVideoRecHA_StreamPlay;1122 1122 pThis->IHostAudio.pfnStreamCapture = drvAudioVideoRecHA_StreamCapture; 1123 1123 -
trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp
r89489 r89504 557 557 558 558 /** 559 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 560 */ 561 static DECLCALLBACK(uint32_t) drvAudioVrdeHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 562 { 563 RT_NOREF(pInterface); 564 PVRDESTREAM pStreamVRDE = (PVRDESTREAM)pStream; 565 566 if (pStreamVRDE->Cfg.enmDir == PDMAUDIODIR_IN) 567 { 568 /* Return frames instead of bytes here 569 * (since we specified PDMAUDIOSTREAMLAYOUT_RAW as the audio data layout). */ 570 return PDMAudioPropsBytesToFrames(&pStreamVRDE->Cfg.Props, (uint32_t)RTCircBufUsed(pStreamVRDE->In.pCircBuf)); 571 } 572 return 0; 559 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 560 */ 561 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvAudioVrdeHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 562 PPDMAUDIOBACKENDSTREAM pStream) 563 { 564 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio); 565 AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID); 566 567 return pDrv->cClients > 0 ? PDMHOSTAUDIOSTREAMSTATE_OKAY : PDMHOSTAUDIOSTREAMSTATE_INACTIVE; 573 568 } 574 569 … … 586 581 return _16K * sizeof(int64_t) * 2; 587 582 return 0; 588 }589 590 591 /**592 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState}593 */594 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvAudioVrdeHA_StreamGetState(PPDMIHOSTAUDIO pInterface,595 PPDMAUDIOBACKENDSTREAM pStream)596 {597 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);598 AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID);599 600 return pDrv->cClients > 0 ? PDMHOSTAUDIOSTREAMSTATE_OKAY : PDMHOSTAUDIOSTREAMSTATE_INACTIVE;601 583 } 602 584 … … 641 623 Assert(*pcbWritten == cbBuf); 642 624 return VINF_SUCCESS; 625 } 626 627 628 /** 629 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 630 */ 631 static DECLCALLBACK(uint32_t) drvAudioVrdeHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 632 { 633 RT_NOREF(pInterface); 634 PVRDESTREAM pStreamVRDE = (PVRDESTREAM)pStream; 635 636 if (pStreamVRDE->Cfg.enmDir == PDMAUDIODIR_IN) 637 { 638 /* Return frames instead of bytes here 639 * (since we specified PDMAUDIOSTREAMLAYOUT_RAW as the audio data layout). */ 640 return PDMAudioPropsBytesToFrames(&pStreamVRDE->Cfg.Props, (uint32_t)RTCircBufUsed(pStreamVRDE->In.pCircBuf)); 641 } 642 return 0; 643 643 } 644 644 … … 777 777 pThis->IHostAudio.pfnStreamNotifyDeviceChanged = NULL; 778 778 pThis->IHostAudio.pfnStreamControl = drvAudioVrdeHA_StreamControl; 779 pThis->IHostAudio.pfnStreamGetState = drvAudioVrdeHA_StreamGetState; 780 pThis->IHostAudio.pfnStreamGetPending = NULL; 781 pThis->IHostAudio.pfnStreamGetWritable = drvAudioVrdeHA_StreamGetWritable; 782 pThis->IHostAudio.pfnStreamPlay = drvAudioVrdeHA_StreamPlay; 779 783 pThis->IHostAudio.pfnStreamGetReadable = drvAudioVrdeHA_StreamGetReadable; 780 pThis->IHostAudio.pfnStreamGetWritable = drvAudioVrdeHA_StreamGetWritable;781 pThis->IHostAudio.pfnStreamGetPending = NULL;782 pThis->IHostAudio.pfnStreamGetState = drvAudioVrdeHA_StreamGetState;783 pThis->IHostAudio.pfnStreamPlay = drvAudioVrdeHA_StreamPlay;784 784 pThis->IHostAudio.pfnStreamCapture = drvAudioVrdeHA_StreamCapture; 785 785
Note:
See TracChangeset
for help on using the changeset viewer.