Changeset 68468 in vbox
- Timestamp:
- Aug 18, 2017 1:57:08 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/pdmaudioifs.h
r68402 r68468 933 933 934 934 /** 935 * Audio callback types. 936 * Those callbacks are being sent from the backends to the audio connector. 937 */ 938 typedef enum PDMAUDIOCBTYPE 935 * Enumeration for an audio callback source. 936 */ 937 typedef enum PDMAUDIOCBSOURCE 939 938 { 940 939 /** Invalid, do not use. */ 941 PDMAUDIOCBTYPE_INVALID = 0, 942 /** The backend's status has changed. */ 943 PDMAUDIOCBTYPE_STATUS, 944 /** One or more host audio devices have changed. */ 945 PDMAUDIOCBTYPE_DEVICES_CHANGED, 940 PDMAUDIOCBSOURCE_INVALID = 0, 941 /** Device emulation. */ 942 PDMAUDIOCBSOURCE_DEVICE = 1, 943 /** Audio connector interface. */ 944 PDMAUDIOCBSOURCE_CONNECTOR = 2, 945 /** Backend (lower). */ 946 PDMAUDIOCBSOURCE_BACKEND = 3, 947 /** Hack to blow the type up to 32-bit. */ 948 PDMAUDIOCBSOURCE_32BIT_HACK = 0x7fffffff 949 } PDMAUDIOCBSOURCE; 950 951 /** 952 * Audio device callback types. 953 * Those callbacks are being sent from the audio connector -> device emulation. 954 */ 955 typedef enum PDMAUDIODEVICECBTYPE 956 { 957 /** Invalid, do not use. */ 958 PDMAUDIODEVICECBTYPE_INVALID = 0, 946 959 /** Data is availabe as input for passing to the device emulation. */ 947 PDMAUDIO CBTYPE_DATA_INPUT,960 PDMAUDIODEVICECBTYPE_DATA_INPUT, 948 961 /** Free data for the device emulation to write to the backend. */ 949 PDMAUDIOCBTYPE_DATA_OUTPUT 950 } PDMAUDIOCBTYPE; 951 952 /** 953 * Callback data for audio input. 954 */ 955 typedef struct PDMAUDIOCBDATA_DATA_INPUT 962 PDMAUDIODEVICECBTYPE_DATA_OUTPUT, 963 /** Hack to blow the type up to 32-bit. */ 964 PDMAUDIODEVICECBTYPE_32BIT_HACK = 0x7fffffff 965 } PDMAUDIODEVICECBTYPE; 966 967 /** 968 * Device callback data for audio input. 969 */ 970 typedef struct PDMAUDIODEVICECBDATA_DATA_INPUT 956 971 { 957 972 /** Input: How many bytes are availabe as input for passing … … 960 975 /** Output: How many bytes have been read. */ 961 976 uint32_t cbOutRead; 962 } PDMAUDIO CBDATA_DATA_INPUT, *PPDMAUDIOCBDATA_DATA_INPUT;963 964 /** 965 * Callback data for audio output.966 */ 967 typedef struct PDMAUDIO CBDATA_DATA_OUTPUT977 } PDMAUDIODEVICECBDATA_DATA_INPUT, *PPDMAUDIODEVICECBDATA_DATA_INPUT; 978 979 /** 980 * Device callback data for audio output. 981 */ 982 typedef struct PDMAUDIODEVICECBDATA_DATA_OUTPUT 968 983 { 969 984 /** Input: How many bytes are free for the device emulation to write. */ … … 971 986 /** Output: How many bytes were written by the device emulation. */ 972 987 uint32_t cbOutWritten; 973 } PDMAUDIOCBDATA_DATA_OUTPUT, *PPDMAUDIOCBDATA_DATA_OUTPUT; 988 } PDMAUDIODEVICECBDATA_DATA_OUTPUT, *PPDMAUDIODEVICECBDATA_DATA_OUTPUT; 989 990 /** 991 * Audio backend callback types. 992 * Those callbacks are being sent from the backend -> audio connector. 993 */ 994 typedef enum PDMAUDIOBACKENDCBTYPE 995 { 996 /** Invalid, do not use. */ 997 PDMAUDIOBACKENDCBTYPE_INVALID = 0, 998 /** The backend's status has changed. */ 999 PDMAUDIOBACKENDCBTYPE_STATUS, 1000 /** One or more host audio devices have changed. */ 1001 PDMAUDIOBACKENDCBTYPE_DEVICES_CHANGED, 1002 /** Hack to blow the type up to 32-bit. */ 1003 PDMAUDIOBACKENDCBTYPE_32BIT_HACK = 0x7fffffff 1004 } PDMAUDIOBACKENDCBTYPE; 974 1005 975 1006 /** Pointer to a host audio interface. */ … … 977 1008 978 1009 /** 979 * Host audio (backend) callback function. 1010 * Host audio callback function. 1011 * This function will be called from a backend to communicate with the host audio interface. 980 1012 * 981 1013 * @returns IPRT status code. … … 985 1017 * @param cbUser Size (in bytes) of user argument. 986 1018 */ 987 typedef DECLCALLBACK(int) FNPDMHOSTAUDIOCALLBACK(PPDMDRVINS pDrvIns, PDMAUDIO CBTYPE enmType, void *pvUser, size_t cbUser);1019 typedef DECLCALLBACK(int) FNPDMHOSTAUDIOCALLBACK(PPDMDRVINS pDrvIns, PDMAUDIOBACKENDCBTYPE enmType, void *pvUser, size_t cbUser); 988 1020 /** Pointer to a FNPDMHOSTAUDIOCALLBACK(). */ 989 1021 typedef FNPDMHOSTAUDIOCALLBACK *PFNPDMHOSTAUDIOCALLBACK; 990 1022 991 #ifdef VBOX_WITH_AUDIO_DEVICE_CALLBACKS 992 /** 993 * Structure for keeping a registered audio callback around. 994 */ 995 typedef struct PDMAUDIOCALLBACK 1023 /** 1024 * Audio callback registration record. 1025 */ 1026 typedef struct PDMAUDIOCBRECORD 996 1027 { 997 1028 /** List node. */ 998 1029 RTLISTANCHOR Node; 999 /** Callback type. */ 1000 PDMAUDIOCBTYPE enmType; 1030 /** Callback source. */ 1031 PDMAUDIOCBSOURCE enmSource; 1032 /** Callback type, based on the given source. */ 1033 union 1034 { 1035 /** Device callback stuff. */ 1036 struct 1037 { 1038 PDMAUDIODEVICECBTYPE enmType; 1039 } Device; 1040 }; 1001 1041 /** Pointer to context data. Optional. */ 1002 1042 void *pvCtx; … … 1004 1044 * Must be 0 if pvCtx is NULL. */ 1005 1045 size_t cbCtx; 1006 /** Actual callback function to call. */ 1007 PFNPDMAUDIOCALLBACK pFn; 1008 } PDMAUDIOCALLBACK, *PPDMAUDIOCALLBACK; 1009 #endif /* VBOX_WITH_AUDIO_DEVICE_CALLBACKS */ 1046 } PDMAUDIOCBRECORD, *PPDMAUDIOCBRECORD; 1010 1047 1011 1048 #define PPDMAUDIOBACKENDSTREAM void * … … 1171 1208 DECLR3CALLBACKMEMBER(int, pfnStreamCapture, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, uint32_t *pcFramesCaptured)); 1172 1209 1173 #ifdef VBOX_WITH_AUDIO_DEVICE_CALLBACKS 1174 DECLR3CALLBACKMEMBER(int, pfnRegisterCallbacks, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOCALLBACK paCallbacks, size_t cCallbacks)); 1175 DECLR3CALLBACKMEMBER(int, pfnCallback, (PPDMIAUDIOCONNECTOR pInterface, PDMAUDIOCBTYPE enmType, void *pvUser, size_t cbUser)); 1176 #endif 1210 /** 1211 * Registers (device) callbacks. 1212 * This is handy for letting the device emulation know of certain events, e.g. processing input / output data 1213 * or configuration changes. 1214 * 1215 * @returns VBox status code. 1216 * @param pInterface Pointer to the interface structure containing the called function pointer. 1217 * @param paCallbacks Pointer to array of callbacks to register. 1218 * @param cCallbacks Number of callbacks to register. 1219 */ 1220 DECLR3CALLBACKMEMBER(int, pfnRegisterCallbacks, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOCBRECORD paCallbacks, size_t cCallbacks)); 1177 1221 1178 1222 } PDMIAUDIOCONNECTOR; 1179 1223 1180 1224 /** PDMIAUDIOCONNECTOR interface ID. */ 1181 #define PDMIAUDIOCONNECTOR_IID " FF2044D1-F8D9-4F42-BE9E-0E9AD14F4552"1225 #define PDMIAUDIOCONNECTOR_IID "344ABC57-659E-4B21-8C25-69ED9FAD490D" 1182 1226 1183 1227 /** -
trunk/src/VBox/Devices/Audio/DevHDA.cpp
r68389 r68468 2649 2649 #else /* VBOX_WITH_AUDIO_HDA_CALLBACKS */ 2650 2650 2651 static DECLCALLBACK(int) hdaCallbackInput(PDMAUDIO CBTYPE enmType, void *pvCtx, size_t cbCtx, void *pvUser, size_t cbUser)2651 static DECLCALLBACK(int) hdaCallbackInput(PDMAUDIOBACKENDCBTYPE enmType, void *pvCtx, size_t cbCtx, void *pvUser, size_t cbUser) 2652 2652 { 2653 2653 Assert(enmType == PDMAUDIOCALLBACKTYPE_INPUT); … … 2666 2666 } 2667 2667 2668 static DECLCALLBACK(int) hdaCallbackOutput(PDMAUDIO CBTYPE enmType, void *pvCtx, size_t cbCtx, void *pvUser, size_t cbUser)2668 static DECLCALLBACK(int) hdaCallbackOutput(PDMAUDIOBACKENDCBTYPE enmType, void *pvCtx, size_t cbCtx, void *pvUser, size_t cbUser) 2669 2669 { 2670 2670 Assert(enmType == PDMAUDIOCALLBACKTYPE_OUTPUT); … … 4771 4771 continue; 4772 4772 4773 PDMAUDIOC ALLBACKAudioCallbacks[2];4773 PDMAUDIOCBRECORD AudioCallbacks[2]; 4774 4774 4775 4775 HDACALLBACKCTX Ctx = { pThis, pDrv }; -
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r68415 r68468 3696 3696 continue; 3697 3697 3698 PDMAUDIOC ALLBACKAudioCallbacks[2];3698 PDMAUDIOCBRECORD AudioCallbacks[2]; 3699 3699 3700 3700 AC97CALLBACKCTX Ctx = { pThis, pDrv }; -
trunk/src/VBox/Devices/Audio/DevSB16.cpp
r68389 r68468 2524 2524 continue; 2525 2525 2526 PDMAUDIOC ALLBACKAudioCallbacks[2];2526 PDMAUDIOCBRECORD AudioCallbacks[2]; 2527 2527 2528 2528 SB16CALLBACKCTX Ctx = { pThis, pDrv }; -
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r68387 r68468 1859 1859 } 1860 1860 1861 #ifdef VBOX_WITH_AUDIO_ DEVICE_CALLBACKS1861 #ifdef VBOX_WITH_AUDIO_CALLBACKS 1862 1862 /** 1863 1863 * Duplicates an audio callback. … … 1866 1866 * @param pCB Callback to duplicate. 1867 1867 */ 1868 static PPDMAUDIOC ALLBACK drvAudioCallbackDuplicate(PPDMAUDIOCALLBACKpCB)1868 static PPDMAUDIOCBRECORD drvAudioCallbackDuplicate(PPDMAUDIOCBRECORD pCB) 1869 1869 { 1870 1870 AssertPtrReturn(pCB, NULL); 1871 1871 1872 PPDMAUDIOC ALLBACK pCBCopy = (PPDMAUDIOCALLBACK)RTMemDup((void *)pCB, sizeof(PDMAUDIOCALLBACK));1872 PPDMAUDIOCBRECORD pCBCopy = (PPDMAUDIOCBRECORD)RTMemDup((void *)pCB, sizeof(PDMAUDIOCBRECORD)); 1873 1873 if (!pCBCopy) 1874 1874 return NULL; … … 1894 1894 * @param pCB Callback to destroy. 1895 1895 */ 1896 static void drvAudioCallbackDestroy(PPDMAUDIOC ALLBACKpCB)1896 static void drvAudioCallbackDestroy(PPDMAUDIOCBRECORD pCB) 1897 1897 { 1898 1898 if (!pCB) … … 1912 1912 */ 1913 1913 static DECLCALLBACK(int) drvAudioRegisterCallbacks(PPDMIAUDIOCONNECTOR pInterface, 1914 PPDMAUDIOC ALLBACKpaCallbacks, size_t cCallbacks)1914 PPDMAUDIOCBRECORD paCallbacks, size_t cCallbacks) 1915 1915 { 1916 1916 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 1926 1926 for (size_t i = 0; i < cCallbacks; i++) 1927 1927 { 1928 PPDMAUDIOC ALLBACKpCB = drvAudioCallbackDuplicate(&paCallbacks[i]);1928 PPDMAUDIOCBRECORD pCB = drvAudioCallbackDuplicate(&paCallbacks[i]); 1929 1929 if (!pCB) 1930 1930 { … … 1933 1933 } 1934 1934 1935 switch (pCB->enmType) 1936 { 1937 case PDMAUDIOCBTYPE_DATA_INPUT: 1938 RTListAppend(&pThis->lstCBIn, &pCB->Node); 1935 switch (pCB->enmSource) 1936 { 1937 case PDMAUDIOCBSOURCE_DEVICE: 1938 { 1939 switch (pCB->Device.enmType) 1940 { 1941 case PDMAUDIODEVICECBTYPE_DATA_INPUT: 1942 RTListAppend(&pThis->lstCBIn, &pCB->Node); 1943 break; 1944 1945 case PDMAUDIODEVICECBTYPE_DATA_OUTPUT: 1946 RTListAppend(&pThis->lstCBOut, &pCB->Node); 1947 break; 1948 1949 default: 1950 AssertMsgFailed(("Not supported\n")); 1951 break; 1952 } 1953 1939 1954 break; 1940 1941 case PDMAUDIOCBTYPE_DATA_OUTPUT: 1942 RTListAppend(&pThis->lstCBOut, &pCB->Node); 1943 break; 1955 } 1944 1956 1945 1957 default: 1946 1947 1958 AssertMsgFailed(("Not supported\n")); 1959 break; 1948 1960 } 1949 1961 } … … 1957 1969 return rc; 1958 1970 } 1959 1960 /** 1961 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnCallback} 1962 */ 1963 static DECLCALLBACK(int) drvAudioCallback(PPDMIAUDIOCONNECTOR pInterface, PDMAUDIOCBTYPE enmType, 1964 void *pvUser, size_t cbUser) 1965 { 1966 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1967 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 1968 AssertReturn(cbUser, VERR_INVALID_PARAMETER); 1969 1970 PDRVAUDIO pThis = PDMIAUDIOCONNECTOR_2_DRVAUDIO(pInterface); 1971 PRTLISTANCHOR pListAnchor = NULL; 1972 1973 switch (enmType) 1974 { 1975 case PDMAUDIOCBTYPE_DATA_INPUT: 1976 pListAnchor = &pThis->lstCBIn; 1977 break; 1978 1979 case PDMAUDIOCBTYPE_DATA_OUTPUT: 1980 pListAnchor = &pThis->lstCBOut; 1981 break; 1982 1983 default: 1984 AssertMsgFailed(("Not supported\n")); 1985 break; 1986 } 1987 1988 if (pListAnchor) 1989 { 1990 PPDMAUDIOCALLBACK pCB; 1991 RTListForEach(pListAnchor, pCB, PDMAUDIOCALLBACK, Node) 1992 { 1993 Assert(pCB->enmType == enmType); 1994 int rc2 = pCB->pfnCallback(enmType, pCB->pvCtx, pCB->cbCtx, pvUser, cbUser); 1995 if (RT_FAILURE(rc2)) 1996 LogFunc(("Failed with %Rrc\n", rc2)); 1997 } 1998 1999 return VINF_SUCCESS; 2000 } 2001 2002 return VERR_NOT_SUPPORTED; 2003 } 2004 #endif /* VBOX_WITH_AUDIO_DEVICE_CALLBACKS */ 1971 #endif /* VBOX_WITH_AUDIO_CALLBACKS */ 2005 1972 2006 1973 #ifdef VBOX_WITH_AUDIO_CALLBACKS … … 2015 1982 */ 2016 1983 static DECLCALLBACK(int) drvAudioBackendCallback(PPDMDRVINS pDrvIns, 2017 PDMAUDIO CBTYPE enmType, void *pvUser, size_t cbUser)1984 PDMAUDIOBACKENDCBTYPE enmType, void *pvUser, size_t cbUser) 2018 1985 { 2019 1986 AssertPtrReturn(pDrvIns, VERR_INVALID_POINTER); … … 2034 2001 switch (enmType) 2035 2002 { 2036 case PDMAUDIO CBTYPE_DEVICES_CHANGED:2003 case PDMAUDIOBACKENDCBTYPE_DEVICES_CHANGED: 2037 2004 LogRel(("Audio: Host audio device configuration has changed\n")); 2038 2005 rc = drvAudioScheduleReInitInternal(pThis); … … 3179 3146 RTListInit(&pThis->lstHstStreams); 3180 3147 RTListInit(&pThis->lstGstStreams); 3181 #ifdef VBOX_WITH_AUDIO_ DEVICE_CALLBACKS3148 #ifdef VBOX_WITH_AUDIO_CALLBACKS 3182 3149 RTListInit(&pThis->lstCBIn); 3183 3150 RTListInit(&pThis->lstCBOut); … … 3207 3174 pThis->IAudioConnector.pfnStreamPlay = drvAudioStreamPlay; 3208 3175 pThis->IAudioConnector.pfnStreamCapture = drvAudioStreamCapture; 3209 #ifdef VBOX_WITH_AUDIO_ DEVICE_CALLBACKS3176 #ifdef VBOX_WITH_AUDIO_CALLBACKS 3210 3177 pThis->IAudioConnector.pfnRegisterCallbacks = drvAudioRegisterCallbacks; 3211 pThis->IAudioConnector.pfnCallback = drvAudioCallback;3212 3178 #endif 3213 3179 … … 3339 3305 Assert(RTListIsEmpty(&pThis->lstGstStreams)); 3340 3306 3341 #ifdef VBOX_WITH_AUDIO_ DEVICE_CALLBACKS3307 #ifdef VBOX_WITH_AUDIO_CALLBACKS 3342 3308 /* 3343 * Destroy devicecallbacks, if any.3309 * Destroy callbacks, if any. 3344 3310 */ 3345 PPDMAUDIOC ALLBACKpCB, pCBNext;3346 RTListForEachSafe(&pThis->lstCBIn, pCB, pCBNext, PDMAUDIOC ALLBACK, Node)3311 PPDMAUDIOCBRECORD pCB, pCBNext; 3312 RTListForEachSafe(&pThis->lstCBIn, pCB, pCBNext, PDMAUDIOCBRECORD, Node) 3347 3313 drvAudioCallbackDestroy(pCB); 3348 3314 3349 RTListForEachSafe(&pThis->lstCBOut, pCB, pCBNext, PDMAUDIOC ALLBACK, Node)3315 RTListForEachSafe(&pThis->lstCBOut, pCB, pCBNext, PDMAUDIOCBRECORD, Node) 3350 3316 drvAudioCallbackDestroy(pCB); 3351 3317 #endif -
trunk/src/VBox/Devices/Audio/DrvAudio.h
r68136 r68468 121 121 /** Audio configuration settings retrieved from the backend. */ 122 122 PDMAUDIOBACKENDCFG BackendCfg; 123 #ifdef VBOX_WITH_AUDIO_ DEVICE_CALLBACKS123 #ifdef VBOX_WITH_AUDIO_CALLBACKS 124 124 /** @todo Use a map with primary key set to the callback type? */ 125 125 RTLISTANCHOR lstCBIn; -
trunk/src/VBox/Devices/Makefile.kmk
r68233 r68468 591 591 # tell the emulation when and how to process data. 592 592 if 0 593 VBOX_DEFS += VBOX_WITH_AUDIO_DEVICE_CALLBACKS594 593 VBOX_DEFS += VBOX_WITH_AUDIO_SB16_CALLBACKS 595 594 VBOX_DEFS += VBOX_WITH_AUDIO_AC97_CALLBACKS
Note:
See TracChangeset
for help on using the changeset viewer.