Changeset 88356 in vbox for trunk/include/VBox/vmm
- Timestamp:
- Apr 4, 2021 10:45:13 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 143603
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/pdmaudioifs.h
r88307 r88356 85 85 * Audio input / output data gets handed off to/from the device emulation in an 86 86 * unmodified (raw) way. The actual audio frame / sample conversion is done via 87 * the PDMAUDIOMIXBUF API.87 * the AUDIOMIXBUF API. 88 88 * 89 89 * This concentrates the audio data processing in one place and makes it easier … … 192 192 |PDMAUDIOSTREAM | |PDMIAUDIOCONNECTOR | 193 193 |-------------------------| |-------------------------| 194 | PDMAUDIOMIXBUF|+------>|PDMAUDIOSTREAM Host |194 |AUDIOMIXBUF |+------>|PDMAUDIOSTREAM Host | 195 195 |PDMAUDIOSTREAMCFG |+------>|PDMAUDIOSTREAM Guest | 196 196 | | |Device capabilities | … … 904 904 #define PDMAUDIO_VOLUME_MAX (255) 905 905 906 /**907 * Rate processing information of a source & destination audio stream.908 *909 * This is needed because both streams can differ regarding their rates and910 * therefore need to be treated accordingly.911 */912 typedef struct PDMAUDIOSTREAMRATE913 {914 /** Current (absolute) offset in the output (destination) stream.915 * @todo r=bird: Please reveal which unit these members are given in. */916 uint64_t offDst;917 /** Increment for moving offDst for the destination stream.918 * This is needed because the source <-> destination rate might be different. */919 uint64_t uDstInc;920 /** Current (absolute) offset in the input stream. */921 uint32_t offSrc;922 /** Explicit alignment padding. */923 uint32_t u32AlignmentPadding;924 /** Last processed frame of the input stream.925 * Needed for interpolation. */926 PDMAUDIOFRAME SrcFrameLast;927 } PDMAUDIOSTREAMRATE;928 /** Pointer to rate processing information of a stream. */929 typedef PDMAUDIOSTREAMRATE *PPDMAUDIOSTREAMRATE;930 931 /**932 * Mixing buffer volume parameters.933 *934 * The volume values are in fixed point style and must be converted to/from935 * before using with e.g. PDMAUDIOVOLUME.936 */937 typedef struct PDMAUDMIXBUFVOL938 {939 /** Set to @c true if this stream is muted, @c false if not. */940 bool fMuted;941 /** Left volume to apply during conversion.942 * Pass 0 to convert the original values. May not apply to all conversion functions. */943 uint32_t uLeft;944 /** Right volume to apply during conversion.945 * Pass 0 to convert the original values. May not apply to all conversion functions. */946 uint32_t uRight;947 } PDMAUDMIXBUFVOL;948 /** Pointer to mixing buffer volument parameters. */949 typedef PDMAUDMIXBUFVOL *PPDMAUDMIXBUFVOL;950 951 /*952 * Frame conversion parameters for the audioMixBufConvFromXXX / audioMixBufConvToXXX functions.953 */954 typedef struct PDMAUDMIXBUFCONVOPTS955 {956 /** Number of audio frames to convert. */957 uint32_t cFrames;958 union959 {960 struct961 {962 /** Volume to use for conversion. */963 PDMAUDMIXBUFVOL Volume;964 } From;965 } RT_UNION_NM(u);966 } PDMAUDMIXBUFCONVOPTS;967 /** Pointer to conversion parameters for the audio mixer. */968 typedef PDMAUDMIXBUFCONVOPTS *PPDMAUDMIXBUFCONVOPTS;969 /** Pointer to const conversion parameters for the audio mixer. */970 typedef PDMAUDMIXBUFCONVOPTS const *PCPDMAUDMIXBUFCONVOPTS;971 972 /**973 * @note All internal handling is done in audio frames, not in bytes!974 * @todo r=bird: What does this node actually apply to?975 */976 typedef uint32_t PDMAUDIOMIXBUFFMT;977 typedef PDMAUDIOMIXBUFFMT *PPDMAUDIOMIXBUFFMT;978 979 /**980 * Convertion-from function used by the PDM audio buffer mixer.981 *982 * @returns Number of audio frames returned.983 * @param paDst Where to return the converted frames.984 * @param pvSrc The source frame bytes.985 * @param cbSrc Number of bytes to convert.986 * @param pOpts Conversion options.987 * @todo r=bird: The @a paDst size is presumable given in @a pOpts->cFrames?988 */989 typedef DECLCALLBACKTYPE(uint32_t, FNPDMAUDIOMIXBUFCONVFROM,(PPDMAUDIOFRAME paDst, const void *pvSrc, uint32_t cbSrc,990 PCPDMAUDMIXBUFCONVOPTS pOpts));991 /** Pointer to a convertion-from function used by the PDM audio buffer mixer. */992 typedef FNPDMAUDIOMIXBUFCONVFROM *PFNPDMAUDIOMIXBUFCONVFROM;993 994 /**995 * Convertion-to function used by the PDM audio buffer mixer.996 *997 * @param pvDst Output buffer.998 * @param paSrc The input frames.999 * @param pOpts Conversion options.1000 * @todo r=bird: The @a paSrc size is presumable given in @a pOpts->cFrames and1001 * this implicitly gives the pvDst size too, right?1002 */1003 typedef DECLCALLBACKTYPE(void, FNPDMAUDIOMIXBUFCONVTO,(void *pvDst, PCPDMAUDIOFRAME paSrc, PCPDMAUDMIXBUFCONVOPTS pOpts));1004 /** Pointer to a convertion-to function used by the PDM audio buffer mixer. */1005 typedef FNPDMAUDIOMIXBUFCONVTO *PFNPDMAUDIOMIXBUFCONVTO;1006 1007 /** Pointer to audio mixing buffer. */1008 typedef struct PDMAUDIOMIXBUF *PPDMAUDIOMIXBUF;1009 1010 /**1011 * Audio mixing buffer.1012 */1013 typedef struct PDMAUDIOMIXBUF1014 {1015 /** Magic value (PDMAUDIOMIXBUF_MAGIC). */1016 uint32_t uMagic;1017 uint8_t abPadding[4];1018 /* ???Undocumented??? */1019 RTLISTNODE Node;1020 /** Name of the buffer. */1021 char *pszName;1022 /** Frame buffer. */1023 PPDMAUDIOFRAME pFrames;1024 /** Size of the frame buffer (in audio frames). */1025 uint32_t cFrames;1026 /** The current read position (in frames). */1027 uint32_t offRead;1028 /** The current write position (in frames). */1029 uint32_t offWrite;1030 /** Total frames already mixed down to the parent buffer (if any).1031 *1032 * Always starting at the parent's offRead position.1033 * @note Count always is specified in parent frames, as the sample count can1034 * differ between parent and child. */1035 uint32_t cMixed;1036 /** How much audio frames are currently being used in this buffer.1037 * @note This also is known as the distance in ring buffer terms. */1038 uint32_t cUsed;1039 /** Number of children mix buffers kept in lstChildren. */1040 uint32_t cChildren;1041 /** List of children mix buffers to keep in sync with (if being a parent buffer). */1042 RTLISTANCHOR lstChildren;1043 /** Pointer to parent buffer (if any). */1044 PPDMAUDIOMIXBUF pParent;1045 /** Intermediate structure for buffer conversion tasks. */1046 PPDMAUDIOSTREAMRATE pRate;1047 /** Internal representation of current volume used for mixing. */1048 PDMAUDMIXBUFVOL Volume;1049 /** This buffer's audio format.1050 * @todo r=bird: This seems to be a value created by AUDMIXBUF_AUDIO_FMT_MAKE(),1051 * which is not define here. Does this structure really belong here at1052 * all? */1053 PDMAUDIOMIXBUFFMT uAudioFmt;1054 /** Audio input properties.1055 * @note There is only one set of audio properties here because we have one1056 * mixer buffer for the guest side and a separate one for the host side.1057 * @todo r=bird: Why exactly do we need to use separate mixer buffers?1058 * Couldn't we just have different conversion fuctions and save the1059 * extra copying? */1060 PDMAUDIOPCMPROPS Props;1061 /** Standard conversion-to function for set uAudioFmt. */1062 PFNPDMAUDIOMIXBUFCONVTO pfnConvTo;1063 /** Standard conversion-from function for set uAudioFmt. */1064 PFNPDMAUDIOMIXBUFCONVFROM pfnConvFrom;1065 1066 /** Ratio of the associated parent stream's frequency by this stream's1067 * frequency (1<<32), represented as a signed 64 bit integer.1068 *1069 * For example, if the parent stream has a frequency of 44 khZ, and this1070 * stream has a frequency of 11 kHz, the ration then would be1071 * (44/11 * (1 << 32)).1072 *1073 * Currently this does not get changed once assigned. */1074 int64_t iFreqRatio;1075 } PDMAUDIOMIXBUF;1076 1077 /** Magic value for PDMAUDIOMIXBUF. */1078 #define PDMAUDIOMIXBUF_MAGIC PDM_VERSION_MAKE(0xa0d2, 1, 0)1079 906 1080 907 /** @name PDMAUDIOFILE_FLAGS_XXX … … 1190 1017 } PDMAUDIOBACKENDSTS; 1191 1018 1192 /** 1193 * The specifics for an audio input stream. 1194 * 1195 * Do not use directly, use PDMAUDIOSTREAM instead. 1196 */ 1197 typedef struct PDMAUDIOSTREAMIN 1198 { 1199 struct 1200 { 1201 /** File for writing stream reads. */ 1202 PPDMAUDIOFILE pFileStreamRead; 1203 /** File for writing non-interleaved captures. */ 1204 PPDMAUDIOFILE pFileCaptureNonInterleaved; 1205 } Dbg; 1206 struct 1207 { 1208 STAMCOUNTER TotalFramesCaptured; 1209 STAMCOUNTER AvgFramesCaptured; 1210 STAMCOUNTER TotalTimesCaptured; 1211 STAMCOUNTER TotalFramesRead; 1212 STAMCOUNTER AvgFramesRead; 1213 STAMCOUNTER TotalTimesRead; 1214 } Stats; 1215 } PDMAUDIOSTREAMIN; 1216 /** Pointer to the specifics for an audio input stream. */ 1217 typedef PDMAUDIOSTREAMIN *PPDMAUDIOSTREAMIN; 1218 1219 /** 1220 * The specifics for an audio output stream. 1221 * 1222 * Do not use directly, use PDMAUDIOSTREAM instead. 1223 */ 1224 typedef struct PDMAUDIOSTREAMOUT 1225 { 1226 struct 1227 { 1228 /** File for writing stream writes. */ 1229 PPDMAUDIOFILE pFileStreamWrite; 1230 /** File for writing stream playback. */ 1231 PPDMAUDIOFILE pFilePlayNonInterleaved; 1232 } Dbg; 1233 struct 1234 { 1235 STAMCOUNTER TotalFramesPlayed; 1236 STAMCOUNTER AvgFramesPlayed; 1237 STAMCOUNTER TotalTimesPlayed; 1238 STAMCOUNTER TotalFramesWritten; 1239 STAMCOUNTER AvgFramesWritten; 1240 STAMCOUNTER TotalTimesWritten; 1241 uint32_t cbBackendWritableBefore; 1242 uint32_t cbBackendWritableAfter; 1243 } Stats; 1244 /** Hack alert: Max writable amount reported by the backend. 1245 * This is used to aid buffer underrun detection in DrvAudio while playing. 1246 * Ideally, the backend should have a method for querying number of buffered 1247 * bytes instead. However this will do for now. */ 1248 uint32_t cbBackendMaxWritable; 1249 } PDMAUDIOSTREAMOUT; 1250 /** Pointer to the specifics for an audio output stream. */ 1251 typedef PDMAUDIOSTREAMOUT *PPDMAUDIOSTREAMOUT; 1252 1253 /** Pointer to an audio stream. */ 1254 typedef struct PDMAUDIOSTREAM *PPDMAUDIOSTREAM; 1255 1256 /** 1257 * Audio stream context. 1258 * Needed for separating data from the guest and host side (per stream). 1259 */ 1260 typedef struct PDMAUDIOSTREAMCTX 1261 { 1262 /** The stream's audio configuration. */ 1263 PDMAUDIOSTREAMCFG Cfg; 1264 /** This stream's mixing buffer. */ 1265 PDMAUDIOMIXBUF MixBuf; 1266 } PDMAUDIOSTREAMCTX; 1267 1268 /** Pointer to an audio stream context. */ 1269 typedef struct PDMAUDIOSTREAM *PPDMAUDIOSTREAMCTX; 1019 /** @name PDMAUDIOSTREAM_CREATE_F_XXX 1020 * @{ */ 1021 /** Does not need any mixing buffers, the device takes care of all conversion. */ 1022 #define PDMAUDIOSTREAM_CREATE_F_NO_MIXBUF RT_BIT_32(0) 1023 /** @} */ 1270 1024 1271 1025 /** @name PDMAUDIOSTREAM_WARN_FLAGS_XXX … … 1284 1038 /** Magic value (PDMAUDIOSTREAM_MAGIC). */ 1285 1039 uint32_t uMagic; 1286 /** Size (in bytes) of the backend-specific stream data. */1287 uint32_t cbBackend;1288 /** List entry (some DrvAudio internal list). */1289 RTLISTNODE ListEntry;1290 1040 /** Number of references to this stream. 1291 1041 * Only can be destroyed when the reference count reaches 0. */ 1292 uint32_t cRefs; 1293 /** Number of (re-)tries while re-initializing the stream. */ 1294 uint32_t cTriesReInit; 1295 /** Warnings shown already in the release log. 1296 * See PDMAUDIOSTREAM_WARN_FLAGS_XXX. */ 1297 uint32_t fWarningsShown; 1042 uint32_t volatile cRefs; 1298 1043 /** Stream status flag. */ 1299 1044 PDMAUDIOSTREAMSTS fStatus; 1300 1045 /** Audio direction of this stream. */ 1301 1046 PDMAUDIODIR enmDir; 1302 /** For output streams this indicates whether the stream has reached 1303 * its playback threshold, e.g. is playing audio. 1304 * For input streams this indicates whether the stream has enough input 1305 * data to actually start reading audio. */ 1306 bool fThresholdReached; 1307 bool afPadding[3]; 1308 /** The guest side of the stream. */ 1309 PDMAUDIOSTREAMCTX Guest; 1310 /** The host side of the stream. */ 1311 PDMAUDIOSTREAMCTX Host; 1312 /** Timestamp (in ns) since last trying to re-initialize. 1313 * Might be 0 if has not been tried yet. */ 1314 uint64_t tsLastReInitNs; 1315 /** Timestamp (in ns) since last iteration. */ 1316 uint64_t tsLastIteratedNs; 1317 /** Timestamp (in ns) since last playback / capture. */ 1318 uint64_t tsLastPlayedCapturedNs; 1319 /** Timestamp (in ns) since last read (input streams) or 1320 * write (output streams). */ 1321 uint64_t tsLastReadWrittenNs; 1322 /** Data to backend-specific stream data. 1323 * This data block will be casted by the backend to access its backend-dependent data. 1324 * 1325 * That way the backends do not have access to the audio connector's data. */ 1326 void *pvBackend; 1047 /** Size (in bytes) of the backend-specific stream data. */ 1048 uint32_t cbBackend; 1049 /** Warnings shown already in the release log. 1050 * See PDMAUDIOSTREAM_WARN_FLAGS_XXX. */ 1051 uint32_t fWarningsShown; 1327 1052 1328 1053 /** Name of this stream. */ 1329 1054 char szName[64]; 1330 1331 /** Union for input/output specifics depending on enmDir. */1332 union1333 {1334 PDMAUDIOSTREAMIN In;1335 PDMAUDIOSTREAMOUT Out;1336 } RT_UNION_NM(u);1337 1055 } PDMAUDIOSTREAM; 1056 /** Pointer to an audio stream. */ 1057 typedef struct PDMAUDIOSTREAM *PPDMAUDIOSTREAM; 1058 /** Pointer to a const audio stream. */ 1059 typedef struct PDMAUDIOSTREAM const *PCPDMAUDIOSTREAM; 1338 1060 1339 1061 /** Magic value for PDMAUDIOSTREAM. */ 1340 #define PDMAUDIOSTREAM_MAGIC PDM_VERSION_MAKE(0xa0d3, 1, 1)1062 #define PDMAUDIOSTREAM_MAGIC PDM_VERSION_MAKE(0xa0d3, 2, 0) 1341 1063 1342 1064 … … 1522 1244 * @returns VBox status code. 1523 1245 * @param pInterface Pointer to the interface structure containing the called function pointer. 1246 * @param fFlags PDMAUDIOSTREAM_CREATE_F_XXX. 1524 1247 * @param pCfgHost Stream configuration for host side. 1525 1248 * @param pCfgGuest Stream configuration for guest side. … … 1528 1251 * modified the DrvAudio... 1529 1252 */ 1530 DECLR3CALLBACKMEMBER(int, pfnStreamCreate, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAMCFG pCfgHost,1253 DECLR3CALLBACKMEMBER(int, pfnStreamCreate, (PPDMIAUDIOCONNECTOR pInterface, uint32_t fFlags, PPDMAUDIOSTREAMCFG pCfgHost, 1531 1254 PPDMAUDIOSTREAMCFG pCfgGuest, PPDMAUDIOSTREAM *ppStream)); 1532 1255 … … 1673 1396 * @param paCallbacks Pointer to array of callbacks to register. 1674 1397 * @param cCallbacks Number of callbacks to register. 1398 * 1399 * @todo r=bird: Total misdesign. See more notes in drvAudioBackendCallback on 1400 * the subject. 1675 1401 */ 1676 1402 DECLR3CALLBACKMEMBER(int, pfnRegisterCallbacks, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOCBRECORD paCallbacks, … … 1680 1406 1681 1407 /** PDMIAUDIOCONNECTOR interface ID. */ 1682 #define PDMIAUDIOCONNECTOR_IID " 00e704ef-0078-4bb6-0005-a5fd000ded9f"1408 #define PDMIAUDIOCONNECTOR_IID "23c23c64-89aa-43b1-b20e-ba6881ab5746" 1683 1409 1684 1410
Note:
See TracChangeset
for help on using the changeset viewer.