VirtualBox

Changeset 63360 in vbox


Ignore:
Timestamp:
Aug 12, 2016 1:58:38 PM (8 years ago)
Author:
vboxsync
Message:

Audio: Added more defines / documentation for the host interfaces to keep the maintenance effort to a minimum in the future, misc. cleanup.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmaudioifs.h

    r62965 r63360  
    262262    /** @todo Use RT_LE2H_*? */
    263263    PDMAUDIOENDIANNESS       enmEndianness;
     264    /** Size of audio sample buffer. */
     265    uint32_t                 cSamples;
    264266} PDMAUDIOSTREAMCFG, *PPDMAUDIOSTREAMCFG;
    265267
     
    904906 * Assigns all needed interface callbacks for an audio backend.
    905907 *
    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) \
    909911    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); \
    921923    } 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)
    922972
    923973/** Pointer to a host audio interface. */
     
    934984     * @param   pInterface          Pointer to the interface structure containing the called function pointer.
    935985     */
    936     DECLR3CALLBACKMEMBER(int, pfnInit, (PPDMIHOSTAUDIO pInterface));
     986    DECLR3CALLBACKMEMBER(PDMAUDIO_IHOSTAUDIO_FN_RET_INIT, pfnInit, PDMAUDIO_IHOSTAUDIO_FN_PARAMS_INIT);
    937987
    938988    /**
     
    942992     * @param   pInterface          Pointer to the interface structure containing the called function pointer.
    943993     */
    944     DECLR3CALLBACKMEMBER(void, pfnShutdown, (PPDMIHOSTAUDIO pInterface));
     994    DECLR3CALLBACKMEMBER(PDMAUDIO_IHOSTAUDIO_FN_RET_SHUTDOWN, pfnShutdown, PDMAUDIO_IHOSTAUDIO_FN_PARAMS_SHUTDOWN);
    945995
    946996    /**
     
    9511001     * @param   pBackendCfg         Pointer where to store the backend audio configuration to.
    9521002     */
    953     DECLR3CALLBACKMEMBER(int, pfnGetConfig, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pBackendCfg));
     1003    DECLR3CALLBACKMEMBER(PDMAUDIO_IHOSTAUDIO_FN_RET_GETCONFIG, pfnGetConfig, PDMAUDIO_IHOSTAUDIO_FN_PARAMS_GETCONFIG);
    9541004
    9551005    /**
     
    9601010     * @param   enmDir              Audio direction to get status for. Pass PDMAUDIODIR_ANY for overall status.
    9611011     */
    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.
    9661018     *
    9671019     * @returns VBox status code.
    9681020     * @param   pInterface          Pointer to the interface structure containing the called function pointer.
    9691021     * @param   pStream             Pointer to audio stream.
    970      * @param   pStreamCfg          Pointer to stream configuration.
    971      * @param   pcSamples           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);
    9741026
    9751027    /**
     
    9801032     * @param   pStream             Pointer to audio stream.
    9811033     */
    982     DECLR3CALLBACKMEMBER(int, pfnStreamDestroy, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream));
     1034    DECLR3CALLBACKMEMBER(PDMAUDIO_IHOSTAUDIO_FN_RET_STREAMDESTROY, pfnStreamDestroy, PDMAUDIO_IHOSTAUDIO_FN_PARAMS_STREAMDESTROY);
    9831035
    9841036    /**
     
    9901042     * @param   enmStreamCmd        The stream command to issue.
    9911043     */
    992     DECLR3CALLBACKMEMBER(int, pfnStreamControl, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd));
     1044    DECLR3CALLBACKMEMBER(PDMAUDIO_IHOSTAUDIO_FN_RET_STREAMCONTROL, pfnStreamControl, PDMAUDIO_IHOSTAUDIO_FN_PARAMS_STREAMCONTROL);
    9931045
    9941046    /**
    9951047     * Returns whether the specified audio direction in the backend is enabled or not.
    9961048     *
     1049     * @returns PDMAUDIOSTRMSTS
    9971050     * @param   pInterface          Pointer to the interface structure containing the called function pointer.
    9981051     * @param   enmDir              Audio direction to check status for.
    9991052     */
    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.
    10091057     *
    10101058     * @returns VBox status code.
    10111059     * @param   pInterface          Pointer to the interface structure containing the called function pointer.
    10121060     * @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.
    10191066     *
    10201067     * @returns VBox status code.
    10211068     * @param   pInterface          Pointer to the interface structure containing the called function pointer.
    10221069     * @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);
    10261087
    10271088} PDMIHOSTAUDIO;
    10281089
    10291090/** PDMIHOSTAUDIO interface ID. */
    1030 #define PDMIHOSTAUDIO_IID                           "96AC69D0-F301-42AC-8F1D-1E19BA808887"
     1091#define PDMIHOSTAUDIO_IID                           "C3B069D4-0543-474B-AE81-769B3E8F40DA"
    10311092
    10321093/** @} */
  • trunk/src/VBox/Devices/Audio/DrvAudio.cpp

    r63212 r63360  
    521521     */
    522522
     523    /* Make the acquired host configuration the requested host configuration by default. */
     524    PDMAUDIOSTREAMCFG CfgAcq;
     525    memcpy(&CfgAcq, pCfgHost, sizeof(PDMAUDIOSTREAMCFG));
     526
    523527    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 */);
    525530    if (RT_SUCCESS(rc))
    526531    {
     
    10281033            {
    10291034                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);
    10311037                if (RT_FAILURE(rc))
    10321038                {
     
    11351141                && (strmSts & PDMAUDIOSTRMSTS_FLAG_DATA_READABLE))
    11361142            {
    1137                 rc = pThis->pHostDrvAudio->pfnStreamCapture(pThis->pHostDrvAudio, pHstStream, &cSamplesCaptured);
     1143                rc = pThis->pHostDrvAudio->pfnStreamCapture(pThis->pHostDrvAudio, pHstStream, NULL /* pvBuf */, 0 /* cbBuf */,
     1144                                                            &cSamplesCaptured);
    11381145                if (RT_FAILURE(rc))
    11391146                {
  • trunk/src/VBox/Devices/Audio/DrvHostALSAAudio.cpp

    r63214 r63360  
    220220}
    221221
     222
    222223static int alsaALSAToAudioFmt(snd_pcm_format_t fmt,
    223224                              PDMAUDIOFMT *pFmt, PDMAUDIOENDIANNESS *pEndianness)
     
    295296    return VINF_SUCCESS;
    296297}
     298
    297299
    298300static int alsaGetSampleShift(snd_pcm_format_t fmt, unsigned *puShift)
     
    329331}
    330332
     333
    331334static int alsaStreamSetThreshold(snd_pcm_t *phPCM, snd_pcm_uframes_t threshold)
    332335{
     
    383386}
    384387
     388
    385389static int alsaStreamClose(snd_pcm_t **pphPCM)
    386390{
     
    404408}
    405409
     410
    406411#if 0 /* After Beta. */
    407412static int alsaSetHWParams(snd_pcm_t *phPCM, PALSAAUDIOSTREAMCFG pCfg)
     
    532537    return rc;
    533538}
     539
     540
    534541static int alsaSetSWParams(snd_pcm_t *phPCM, PALSAAUDIOCFG pCfg)
    535542{
     
    594601}
    595602#endif
     603
    596604
    597605static int alsaStreamOpen(bool fIn, PALSAAUDIOSTREAMCFG pCfgReq, PALSAAUDIOSTREAMCFG pCfgObt, snd_pcm_t **pphPCM)
     
    884892}
    885893
     894
    886895#ifdef DEBUG
    887896static void alsaDbgErrorHandler(const char *file, int line, const char *function,
     
    893902#endif
    894903
     904
    895905static int alsaStreamGetAvail(snd_pcm_t *phPCM, snd_pcm_sframes_t *pFramesAvail)
    896906{
     
    922932}
    923933
     934
    924935static int alsaStreamRecover(snd_pcm_t *phPCM)
    925936{
     
    936947}
    937948
     949
    938950static int alsaStreamResume(snd_pcm_t *phPCM)
    939951{
     
    950962}
    951963
     964
    952965static int drvHostALSAAudioStreamCtl(snd_pcm_t *phPCM, bool fPause)
    953966{
     
    975988}
    976989
    977 static DECLCALLBACK(int) drvHostALSAAudioInit(PPDMIHOSTAUDIO pInterface)
     990
     991/**
     992 * @interface_method_impl{PDMIHOSTAUDIO,pfnInit}
     993 */
     994PDMAUDIO_IHOSTAUDIO_EMIT_INIT(drvHostALSAAudio)
    978995{
    979996    NOREF(pInterface);
     
    9941011}
    9951012
    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 */
     1017PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCAPTURE(drvHostALSAAudio)
     1018{
     1019    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     1020    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
     1021    /* pcbRead is optional. */
    10011022
    10021023    PALSAAUDIOSTREAMIN pThisStream = (PALSAAUDIOSTREAMIN)pStream;
     
    10361057        if (!cAvail)
    10371058        {
    1038             if (pcSamplesCaptured)
    1039                 *pcSamplesCaptured = 0;
     1059            if (pcbRead)
     1060                *pcbRead = 0;
    10401061            return VINF_SUCCESS;
    10411062        }
     
    11341155                                        &cProcessed);
    11351156
    1136         if (pcSamplesCaptured)
    1137             *pcSamplesCaptured = cWrittenTotal;
     1157        if (pcbRead)
     1158            *pcbRead = cWrittenTotal;
    11381159
    11391160        LogFlowFunc(("cWrittenTotal=%RU32 (%RU32 processed), rc=%Rrc\n",
     
    11451166}
    11461167
    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 */
     1171PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(drvHostALSAAudio)
     1172{
     1173    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     1174    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
     1175    /* pcbWritten is optional. */
    11521176
    11531177    PALSAAUDIOSTREAMOUT pThisStream = (PALSAAUDIOSTREAMOUT)pStream;
     
    12551279            AudioMixBufFinish(&pStream->MixBuf, cReadTotal);
    12561280
    1257         if (pcSamplesPlayed)
    1258             *pcSamplesPlayed = cReadTotal;
     1281        if (pcbWritten)
     1282            *pcbWritten = cReadTotal;
    12591283
    12601284        LogFlowFunc(("cReadTotal=%RU32 (%RU32 bytes), rc=%Rrc\n",
     
    12661290}
    12671291
     1292
    12681293static int alsaDestroyStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
    12691294{
     
    12841309}
    12851310
     1311
    12861312static int alsaDestroyStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
    12871313{
     
    13021328}
    13031329
     1330
    13041331static 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{
    13121334    PALSAAUDIOSTREAMOUT pThisStream = (PALSAAUDIOSTREAMOUT)pStream;
     1335
    13131336    snd_pcm_t *phPCM = NULL;
    13141337
     
    13181341    {
    13191342        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;
    13231346        req.period_size = s_ALSAConf.period_size_out;
    13241347        req.buffer_size = s_ALSAConf.buffer_size_out;
     
    13351358            break;
    13361359
    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);
    13441368        if (RT_FAILURE(rc))
    13451369            break;
    13461370
    13471371        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! */
    13491373        AssertBreakStmt(cbBuf, rc = VERR_INVALID_PARAMETER);
    13501374        pThisStream->pvBuf = RTMemAlloc(cbBuf);
     
    13521376        {
    13531377            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));
    13551379            rc = VERR_NO_MEMORY;
    13561380            break;
    13571381        }
    13581382
    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;
    13641385    }
    13651386    while (0);
     
    13721393}
    13731394
     1395
    13741396static 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{
    13811399    int rc;
    13821400
     
    13871405    {
    13881406        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;
    13921410        req.period_size = s_ALSAConf.period_size_in;
    13931411        req.buffer_size = s_ALSAConf.buffer_size_in;
     
    14041422            break;
    14051423
    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);
    14131432        if (RT_FAILURE(rc))
    14141433            break;
    14151434
    14161435        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! */
    14181437        AssertBreakStmt(cbBuf, rc = VERR_INVALID_PARAMETER);
    14191438        pThisStream->pvBuf = RTMemAlloc(cbBuf);
     
    14211440        {
    14221441            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));
    14241443            rc = VERR_NO_MEMORY;
    14251444            break;
    14261445        }
    14271446
    1428         pThisStream->cbBuf       = cbBuf;
    1429         pThisStream->phPCM       = phPCM;
    1430 
    1431         if (pcSamples)
    1432             *pcSamples = obt.samples;
     1447        pThisStream->cbBuf = cbBuf;
     1448        pThisStream->phPCM = phPCM;
    14331449    }
    14341450    while (0);
     
    14401456    return rc;
    14411457}
     1458
    14421459
    14431460static int alsaControlStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream,
     
    14721489}
    14731490
     1491
    14741492static int alsaControlStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream,
    14751493                                PDMAUDIOSTREAMCMD enmStreamCmd)
     
    15031521}
    15041522
    1505 static DECLCALLBACK(int) drvHostALSAAudioGetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pCfg)
     1523
     1524/**
     1525 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetConfig}
     1526 */
     1527PDMAUDIO_IHOSTAUDIO_EMIT_GETCONFIG(drvHostALSAAudio)
    15061528{
    15071529    NOREF(pInterface);
    1508     AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
    1509 
    1510     pCfg->cbStreamIn  = sizeof(ALSAAUDIOSTREAMIN);
    1511     pCfg->cbStreamOut = sizeof(ALSAAUDIOSTREAMOUT);
    1512 
    1513     pCfg->cSources    = 0;
    1514     pCfg->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;
    15151537
    15161538    /* Enumerate sound devices. */
     
    15371559            {
    15381560                if (!RTStrICmp("input", pszIOID))
    1539                     pCfg->cSources++;
     1561                    pBackendCfg->cSources++;
    15401562                else if (!RTStrICmp("output", pszIOID))
    1541                     pCfg->cSinks++;
     1563                    pBackendCfg->cSinks++;
    15421564            }
    15431565            else /* NULL means bidirectional, input + output. */
    15441566            {
    1545                 pCfg->cSources++;
    1546                 pCfg->cSinks++;
     1567                pBackendCfg->cSources++;
     1568                pBackendCfg->cSinks++;
    15471569            }
    15481570
     
    15631585        }
    15641586
    1565         LogRel2(("ALSA: Found %RU8 host playback devices\n",  pCfg->cSinks));
    1566         LogRel2(("ALSA: Found %RU8 host capturing devices\n", pCfg->cSources));
     1587        LogRel2(("ALSA: Found %RU8 host playback devices\n",  pBackendCfg->cSinks));
     1588        LogRel2(("ALSA: Found %RU8 host capturing devices\n", pBackendCfg->cSources));
    15671589
    15681590        snd_device_name_free_hint((void **)pszHints);
     
    15731595
    15741596    /* ALSA allows exactly one input and one output used at a time for the selected device(s). */
    1575     pCfg->cMaxStreamsIn  = 1;
    1576     pCfg->cMaxStreamsOut = 1;
     1597    pBackendCfg->cMaxStreamsIn  = 1;
     1598    pBackendCfg->cMaxStreamsOut = 1;
    15771599
    15781600    return VINF_SUCCESS;
    15791601}
    15801602
    1581 static DECLCALLBACK(void) drvHostALSAAudioShutdown(PPDMIHOSTAUDIO pInterface)
     1603
     1604/**
     1605 * @interface_method_impl{PDMIHOSTAUDIO,pfnShutdown}
     1606 */
     1607PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(drvHostALSAAudio)
    15821608{
    15831609    NOREF(pInterface);
    15841610}
    15851611
    1586 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvHostALSAAudioGetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir)
     1612
     1613/**
     1614 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus}
     1615 */
     1616PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(drvHostALSAAudio)
    15871617{
    15881618    RT_NOREF(enmDir);
     
    15921622}
    15931623
    1594 static DECLCALLBACK(int) drvHostALSAAudioStreamCreate(PPDMIHOSTAUDIO pInterface,
    1595                                                       PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples)
     1624
     1625/**
     1626 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate}
     1627 */
     1628PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCREATE(drvHostALSAAudio)
    15961629{
    15971630    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    15981631    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    1599     AssertPtrReturn(pCfg,       VERR_INVALID_POINTER);
     1632    AssertPtrReturn(pCfgReq,    VERR_INVALID_POINTER);
     1633    AssertPtrReturn(pCfgAcq,    VERR_INVALID_POINTER);
    16001634
    16011635    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);
    16041638    else
    1605         rc = alsaCreateStreamOut(pInterface, pStream, pCfg, pcSamples);
     1639        rc = alsaCreateStreamOut(pInterface, pStream, pCfgReq, pCfgAcq);
    16061640
    16071641    LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc));
     
    16091643}
    16101644
    1611 static DECLCALLBACK(int) drvHostALSAAudioStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     1645
     1646/**
     1647 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
     1648 */
     1649PDMAUDIO_IHOSTAUDIO_EMIT_STREAMDESTROY(drvHostALSAAudio)
    16121650{
    16131651    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    16231661}
    16241662
    1625 static DECLCALLBACK(int) drvHostALSAAudioStreamControl(PPDMIHOSTAUDIO pInterface,
    1626                                                        PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
     1663
     1664/**
     1665 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl}
     1666 */
     1667PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCONTROL(drvHostALSAAudio)
    16271668{
    16281669    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    16401681}
    16411682
    1642 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostALSAAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     1683
     1684/**
     1685 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus}
     1686 */
     1687PDMAUDIO_IHOSTAUDIO_EMIT_STREAMGETSTATUS(drvHostALSAAudio)
    16431688{
    16441689    NOREF(pInterface);
     
    16691714}
    16701715
    1671 static DECLCALLBACK(int) drvHostALSAAudioStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     1716
     1717/**
     1718 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamIterate}
     1719 */
     1720PDMAUDIO_IHOSTAUDIO_EMIT_STREAMITERATE(drvHostALSAAudio)
    16721721{
    16731722    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    16791728    return VINF_SUCCESS;
    16801729}
     1730
    16811731
    16821732/**
     
    16921742    return NULL;
    16931743}
     1744
    16941745
    16951746/**
     
    17161767    return VINF_SUCCESS;
    17171768}
     1769
    17181770
    17191771/**
  • trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp

    r62337 r63360  
    388388
    389389
    390 static int coreAudioInitIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, uint32_t *pcSamples);
    391 static int coreAudioInitOut(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, uint32_t *pcSamples);
     390static int coreAudioInitIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq);
     391static int coreAudioInitOut(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq);
    392392static int coreAudioControlStreamIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd);
    393393static 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);
     394static int coreAudioCreateStreamIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq);
     395static int coreAudioCreateStreamOut(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq);
    396396static int coreAudioDestroyStreamIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream);
    397397static int coreAudioDestroyStreamOut(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream);
     
    10931093
    10941094/** @todo Eventually split up this function, as this already is huge! */
    1095 static int coreAudioInitIn(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, uint32_t *pcSamples)
    1096 {
     1095static 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
    10971103    int rc = VINF_SUCCESS;
    10981104
     
    14851491        LogFunc(("cSamples=%RU32\n", cSamples));
    14861492
    1487         if (pcSamples)
    1488             *pcSamples = cSamples;
     1493        if (pCfgAcq)
     1494            pCfgAcq->cSamples = cSamples;
    14891495    }
    14901496    else
     
    15081514
    15091515/** @todo Eventually split up this function, as this already is huge! */
    1510 static int coreAudioInitOut(PDRVHOSTCOREAUDIO pThis, PPDMAUDIOSTREAM pStream, uint32_t *pcSamples)
    1511 {
     1516static 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
    15121524    int rc = VINF_SUCCESS;
    15131525
     
    17881800        LogFunc(("cSamples=%RU32\n", cSamples));
    17891801
    1790         if (pcSamples)
    1791             *pcSamples = cSamples;
     1802        if (pCfgAcq)
     1803            pCfgAcq->cSamples = cSamples;
    17921804    }
    17931805    else
     
    18951907static DECLCALLBACK(int) drvHostCoreAudioInit(PPDMIHOSTAUDIO pInterface)
    18961908{
    1897     NOREF(pInterface);
     1909    RT_NOREF(pInterface);
    18981910
    18991911    LogFlowFuncEnter();
     
    19031915
    19041916static 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
    19071923    PPDMDRVINS pDrvIns      = PDMIBASE_2_PDMDRV(pInterface);
    19081924    PDRVHOSTCOREAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTCOREAUDIO);
     
    19161932    if (ASMAtomicReadU32(&pStreamIn->status) != CA_STATUS_INIT)
    19171933    {
    1918         if (pcSamplesCaptured)
    1919             *pcSamplesCaptured = 0;
     1934        if (pcbRead)
     1935            *pcbRead = 0;
    19201936        return VINF_SUCCESS;
    19211937    }
     
    19952011            LogFlowFunc(("%RU32 samples captured\n", cCaptured));
    19962012
    1997         if (pcSamplesCaptured)
    1998             *pcSamplesCaptured = cCaptured;
     2013        if (pcbRead)
     2014            *pcbRead = cCaptured;
    19992015    }
    20002016
     
    20052021}
    20062022
    2007 static DECLCALLBACK(int) drvHostCoreAudioStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream,
    2008                                                     uint32_t *pcSamplesPlayed)
    2009 {
     2023PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(drvHostCoreAudio)
     2024{
     2025    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     2026    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
     2027    /* pcbWritten is optional. */
     2028
    20102029    PPDMDRVINS pDrvIns      = PDMIBASE_2_PDMDRV(pInterface);
    20112030    PDRVHOSTCOREAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTCOREAUDIO);
     
    20182037    if (!cLive) /* Not live samples to play? Bail out. */
    20192038    {
    2020         if (pcSamplesPlayed)
    2021             *pcSamplesPlayed = 0;
     2039        if (pcbWritten)
     2040            *pcbWritten = 0;
    20222041        return VINF_SUCCESS;
    20232042    }
     
    20742093        Log3Func(("cReadTotal=%RU32 (%RU32 bytes)\n", cReadTotal, cbReadTotal));
    20752094
    2076         if (pcSamplesPlayed)
    2077             *pcSamplesPlayed = cReadTotal;
     2095        if (pcbWritten)
     2096            *pcbWritten = cReadTotal;
    20782097    }
    20792098
     
    24492468
    24502469static 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
    24532477    PCOREAUDIOSTREAMIN pStreamIn = (PCOREAUDIOSTREAMIN)pStream;
    24542478
    2455     LogFlowFunc(("enmRecSource=%RU32\n", pCfg->DestSource.Source));
     2479    LogFlowFunc(("enmRecSource=%RU32\n", pCfgReq->DestSource.Source));
    24562480
    24572481    pStreamIn->deviceID            = kAudioDeviceUnknown;
     
    24712495    bool fDeviceByUser = false; /* Do we use a device which was set by the user? */
    24722496
    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);
    24752510    if (RT_SUCCESS(rc))
    24762511    {
    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            }
    24852545            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        }
    25272548    }
    25282549
     
    25322553
    25332554static 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
    25372562    PCOREAUDIOSTREAMOUT pStreamOut = (PCOREAUDIOSTREAMOUT)pStream;
    25382563
     
    25532578    bool fDeviceByUser = false; /* Do we use a device which was set by the user? */
    25542579
    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);
    25572595    if (RT_SUCCESS(rc))
    25582596    {
    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            }
    25692610            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        }
    26072629    }
    26082630
     
    26112633}
    26122634
    2613 static DECLCALLBACK(int) drvHostCoreAudioGetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pCfg)
    2614 {
    2615     AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    2616     AssertPtrReturn(pCfg,      VERR_INVALID_POINTER);
     2635PDMAUDIO_IHOSTAUDIO_EMIT_GETCONFIG(drvHostCoreAudio)
     2636{
     2637    AssertPtrReturn(pInterface,  VERR_INVALID_POINTER);
     2638    AssertPtrReturn(pBackendCfg, VERR_INVALID_POINTER);
    26172639
    26182640    PPDMDRVINS        pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
    26192641    PDRVHOSTCOREAUDIO pThis   = PDMINS_2_DATA(pDrvIns, PDRVHOSTCOREAUDIO);
    26202642
    2621     return coreAudioUpdateStatusInternalEx(pThis, pCfg, 0 /* fEnum */);
    2622 }
    2623 
    2624 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvHostCoreAudioGetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir)
     2643    return coreAudioUpdateStatusInternalEx(pThis, pBackendCfg, 0 /* fEnum */);
     2644}
     2645
     2646PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(drvHostCoreAudio)
    26252647{
    26262648    AssertPtrReturn(pInterface, PDMAUDIOBACKENDSTS_UNKNOWN);
     
    26292651}
    26302652
    2631 static DECLCALLBACK(int) drvHostCoreAudioStreamCreate(PPDMIHOSTAUDIO pInterface,
    2632                                                        PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples)
     2653PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCREATE(drvHostCoreAudio)
    26332654{
    26342655    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    26352656    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    2636     AssertPtrReturn(pCfg,       VERR_INVALID_POINTER);
     2657    AssertPtrReturn(pCfgReq,    VERR_INVALID_POINTER);
     2658    AssertPtrReturn(pCfgAcq,    VERR_INVALID_POINTER);
    26372659
    26382660    PPDMDRVINS        pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
     
    26402662
    26412663    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);
    26442666    else
    2645         rc = coreAudioCreateStreamOut(pThis, pStream, pCfg, pcSamples);
     2667        rc = coreAudioCreateStreamOut(pThis, pStream, pCfgReq, pCfgAcq);
    26462668
    26472669    LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc));
     
    26492671}
    26502672
    2651 static DECLCALLBACK(int) drvHostCoreAudioStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     2673PDMAUDIO_IHOSTAUDIO_EMIT_STREAMDESTROY(drvHostCoreAudio)
    26522674{
    26532675    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    26662688}
    26672689
    2668 static DECLCALLBACK(int) drvHostCoreAudioStreamControl(PPDMIHOSTAUDIO pInterface,
    2669                                                        PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
     2690PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCONTROL(drvHostCoreAudio)
    26702691{
    26712692    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    26862707}
    26872708
    2688 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostCoreAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
    2689 {
    2690     NOREF(pInterface);
     2709PDMAUDIO_IHOSTAUDIO_EMIT_STREAMGETSTATUS(drvHostCoreAudio)
     2710{
     2711    RT_NOREF(pInterface);
    26912712    AssertPtrReturn(pStream, VERR_INVALID_POINTER);
    26922713
     
    27212742}
    27222743
    2723 static DECLCALLBACK(int) drvHostCoreAudioStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     2744PDMAUDIO_IHOSTAUDIO_EMIT_STREAMITERATE(drvHostCoreAudio)
    27242745{
    27252746    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    27302751}
    27312752
    2732 static DECLCALLBACK(void) drvHostCoreAudioShutdown(PPDMIHOSTAUDIO pInterface)
    2733 {
    2734     NOREF(pInterface);
     2753PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(drvHostCoreAudio)
     2754{
     2755    RT_NOREF(pInterface);
    27352756}
    27362757
     
    27462767}
    27472768
    2748  /* Construct a DirectSound Audio driver instance.
     2769/* Construct a DirectSound Audio driver instance.
    27492770 *
    27502771 * @copydoc FNPDMDRVCONSTRUCT
  • trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp

    r62979 r63360  
    217217}
    218218
     219
    219220static int dsoundWaveFmtFromCfg(PPDMAUDIOSTREAMCFG pCfg, PWAVEFORMATEX pFmt)
    220221{
     
    259260    return VINF_SUCCESS;
    260261}
     262
    261263
    262264static int dsoundGetPosOut(PDRVHOSTDSOUND   pThis,
     
    305307}
    306308
     309
    307310static char *dsoundGUIDToUtf8StrA(LPCGUID pGUID)
    308311{
     
    323326    return RTStrDup("{Default device}");
    324327}
     328
    325329
    326330/**
     
    347351}
    348352
     353
    349354static HRESULT directSoundPlayRestore(PDRVHOSTDSOUND pThis, LPDIRECTSOUNDBUFFER8 pDSB)
    350355{
     
    356361}
    357362
     363
    358364static HRESULT directSoundPlayUnlock(PDRVHOSTDSOUND pThis, LPDIRECTSOUNDBUFFER8 pDSB,
    359365                                     PVOID pv1, PVOID pv2,
     
    367373}
    368374
     375
    369376static HRESULT directSoundCaptureUnlock(LPDIRECTSOUNDCAPTUREBUFFER8 pDSCB,
    370377                                        PVOID pv1, PVOID pv2,
     
    376383    return hr;
    377384}
     385
    378386
    379387static HRESULT directSoundPlayLock(PDRVHOSTDSOUND pThis,
     
    413421}
    414422
     423
    415424static HRESULT directSoundCaptureLock(LPDIRECTSOUNDCAPTUREBUFFER8 pDSCB, PPDMPCMPROPS pProps,
    416425                                      DWORD dwOffset, DWORD dwBytes,
     
    463472}
    464473
     474
    465475static HRESULT directSoundPlayInterfaceCreate(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMOUT pDSoundStream)
    466476{
     
    501511    return hr;
    502512}
     513
    503514
    504515static HRESULT directSoundPlayClose(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMOUT pDSoundStream)
     
    543554    return hr;
    544555}
     556
    545557
    546558static HRESULT directSoundPlayOpen(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMOUT pDSoundStream)
     
    727739}
    728740
     741
    729742static void dsoundPlayClearSamples(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMOUT pDSoundStream)
    730743{
     
    753766}
    754767
     768
    755769static HRESULT directSoundPlayGetStatus(PDRVHOSTDSOUND pThis, LPDIRECTSOUNDBUFFER8 pDSB, DWORD *pdwStatus)
    756770{
     
    786800}
    787801
     802
    788803static HRESULT directSoundPlayStop(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMOUT pDSoundStream)
    789804{
     
    823838    return hr;
    824839}
     840
    825841
    826842static HRESULT directSoundPlayStart(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMOUT pDSoundStream)
     
    941957}
    942958
     959
    943960static void directSoundCaptureInterfaceRelease(PDSOUNDSTREAMIN pDSoundStream)
    944961{
     
    950967    }
    951968}
     969
    952970
    953971static HRESULT directSoundCaptureInterfaceCreate(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMIN pDSoundStream)
     
    9841002}
    9851003
     1004
    9861005static HRESULT directSoundCaptureClose(PDSOUNDSTREAMIN pDSoundStream)
    9871006{
     
    10101029    return hr;
    10111030}
     1031
    10121032
    10131033static HRESULT directSoundCaptureOpen(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMIN pDSoundStream)
     
    11431163}
    11441164
     1165
    11451166static HRESULT directSoundCaptureStop(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMIN pDSoundStream)
    11461167{
     
    11691190    return hr;
    11701191}
     1192
    11711193
    11721194static HRESULT directSoundCaptureStart(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMIN pDSoundStream)
     
    12131235}
    12141236
     1237
    12151238static int dsoundDevAdd(PRTLISTANCHOR pList, LPGUID pGUID, LPCWSTR pwszDescription, PDSOUNDDEV *ppDev)
    12161239{
     
    12361259}
    12371260
     1261
    12381262static void dsoundDeviceRemove(PDSOUNDDEV pDev)
    12391263{
     
    12481272    }
    12491273}
     1274
    12501275
    12511276static void dsoundLogDevice(const char *pszType, LPGUID pGUID, LPCWSTR pwszDescription, LPCWSTR pwszModule)
     
    12571282}
    12581283
     1284
    12591285static BOOL CALLBACK dsoundDevicesEnumCbPlayback(LPGUID pGUID, LPCWSTR pwszDescription, LPCWSTR pwszModule, PVOID lpContext)
    12601286{
     
    12821308}
    12831309
     1310
    12841311static BOOL CALLBACK dsoundDevicesEnumCbCapture(LPGUID pGUID, LPCWSTR pwszDescription, LPCWSTR pwszModule, PVOID lpContext)
    12851312{
     
    13031330    return TRUE;
    13041331}
     1332
    13051333
    13061334/**
     
    13581386}
    13591387
     1388
    13601389/**
    13611390 * Updates this host driver's internal status, according to the global, overall input/output
     
    14061435}
    14071436
     1437
    14081438static void dsoundUpdateStatusInternal(PDRVHOSTDSOUND pThis)
    14091439{
     
    14111441}
    14121442
    1413 static int dsoundCreateStreamOut(PDRVHOSTDSOUND pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples)
    1414 {
    1415     LogFlowFunc(("pStream=%p, pCfg=%p\n", pStream, pCfg));
     1443
     1444static int dsoundCreateStreamOut(PDRVHOSTDSOUND pThis, PPDMAUDIOSTREAM pStream,
     1445                                 PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
     1446{
     1447    LogFlowFunc(("pStream=%p, pCfg=%p\n", pStream, pCfgReq));
    14161448    PDSOUNDSTREAMOUT pDSoundStream = (PDSOUNDSTREAMOUT)pStream;
    14171449
    1418     pDSoundStream->streamCfg = *pCfg;
     1450    pDSoundStream->streamCfg = *pCfgReq;
    14191451    pDSoundStream->streamCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS;
    14201452
     
    14281460        pDSoundStream->cMaxSamplesInBuffer = 0;
    14291461
    1430         if (pcSamples)
    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! */
    14321464
    14331465        /* Try to open playback in case the device is already there. */
     
    14971529 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay}
    14981530 */
    1499 static DECLCALLBACK(int) drvHostDSoundStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesPlayed)
     1531PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(drvHostDSound)
    15001532{
    15011533    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    15021534    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    1503     /* pcSamplesPlayed is optional. */
    1504 
    1505     PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);
     1535    /* pcbRead is optional. */
     1536
     1537    PDRVHOSTDSOUND   pThis        = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);
    15061538    PDSOUNDSTREAMOUT pDSoundStream = (PDSOUNDSTREAMOUT)pStream;
    15071539
     
    16341666    if (RT_FAILURE(rc))
    16351667        dsoundUpdateStatusInternal(pThis);
    1636     else if (pcSamplesPlayed)
    1637         *pcSamplesPlayed = cReadTotal;
     1668    else if (pcbRead)
     1669        *pcbRead = cReadTotal;
    16381670
    16391671    LogFlowFuncLeaveRC(rc);
    16401672    return rc;
    16411673}
     1674
    16421675
    16431676static int dsoundDestroyStreamOut(PDRVHOSTDSOUND pThis, PPDMAUDIOSTREAM pStream)
     
    16561689}
    16571690
    1658 static int dsoundCreateStreamIn(PDRVHOSTDSOUND pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples)
     1691static int dsoundCreateStreamIn(PDRVHOSTDSOUND pThis, PPDMAUDIOSTREAM pStream,
     1692                                PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
    16591693{
    16601694    PDSOUNDSTREAMIN pDSoundStream = (PDSOUNDSTREAMIN)pStream;
    16611695
    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));
    16651699
    16661700    /** @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! */
    16681702    if (RT_SUCCESS(rc))
    16691703    {
     
    16731707        pDSoundStream->pDSC                = NULL;
    16741708        pDSoundStream->pDSCB               = NULL;
    1675         pDSoundStream->enmRecSource        = pCfg->DestSource.Source;
     1709        pDSoundStream->enmRecSource        = pCfgReq->DestSource.Source;
    16761710        pDSoundStream->hrLastCapture       = S_OK;
    16771711
    1678         if (pcSamples)
    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! */
    16801714
    16811715        /* 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?? */
    16831717    }
    16841718    else
     
    17461780 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture}
    17471781 */
    1748 static DECLCALLBACK(int) drvHostDSoundStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream,
    1749                                                     uint32_t *pcSamplesCaptured)
     1782PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCAPTURE(drvHostDSound)
    17501783{
    17511784    PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);
     
    18611894    if (RT_FAILURE(rc))
    18621895        dsoundUpdateStatusInternal(pThis);
    1863     else if (pcSamplesCaptured)
    1864         *pcSamplesCaptured = cSamplesProcessed;
     1896    else if (pcbWritten)
     1897        *pcbWritten = cSamplesProcessed;
    18651898
    18661899    LogFlowFuncLeaveRC(rc);
     
    18851918 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetConfig}
    18861919 */
    1887 static DECLCALLBACK(int) drvHostDSoundGetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pCfg)
    1888 {
    1889     AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    1890     AssertPtrReturn(pCfg,      VERR_INVALID_POINTER);
     1920PDMAUDIO_IHOSTAUDIO_EMIT_GETCONFIG(drvHostDSound)
     1921{
     1922    AssertPtrReturn(pInterface,  VERR_INVALID_POINTER);
     1923    AssertPtrReturn(pBackendCfg, VERR_INVALID_POINTER);
    18911924
    18921925    PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);
    18931926
    1894     dsoundUpdateStatusInternalEx(pThis, pCfg, 0 /* fEnum */);
     1927    dsoundUpdateStatusInternalEx(pThis, pBackendCfg, 0 /* fEnum */);
    18951928
    18961929    return VINF_SUCCESS;
     
    20122045 * @interface_method_impl{PDMIHOSTAUDIO,pfnShutdown}
    20132046 */
    2014 static DECLCALLBACK(void) drvHostDSoundShutdown(PPDMIHOSTAUDIO pInterface)
     2047PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(drvHostDSound)
    20152048{
    20162049    PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);
     
    20442077 * @interface_method_impl{PDMIHOSTAUDIO,pfnInit}
    20452078 */
    2046 static DECLCALLBACK(int) drvHostDSoundInit(PPDMIHOSTAUDIO pInterface)
     2079PDMAUDIO_IHOSTAUDIO_EMIT_INIT(drvHostDSound)
    20472080{
    20482081    PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);
     
    21392172 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus}
    21402173 */
    2141 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvHostDSoundGetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir)
     2174PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(drvHostDSound)
    21422175{
    21432176    RT_NOREF(enmDir);
     
    21512184 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate}
    21522185 */
    2153 static DECLCALLBACK(int)
    2154 drvHostDSoundStreamCreate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples)
    2155 {
    2156     AssertPtrReturn(pInterface,    VERR_INVALID_POINTER);
    2157     AssertPtrReturn(pStream,       VERR_INVALID_POINTER);
    2158     AssertPtrReturn(pCfg,          VERR_INVALID_POINTER);
    2159     AssertPtrNullReturn(pcSamples, VERR_INVALID_POINTER);
     2186PDMAUDIO_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
    21602193    PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);
    21612194
    21622195    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);
    21652198    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
    21692201    return rc;
    21702202}
     
    21742206 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
    21752207 */
    2176 static DECLCALLBACK(int) drvHostDSoundStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     2208PDMAUDIO_IHOSTAUDIO_EMIT_STREAMDESTROY(drvHostDSound)
    21772209{
    21782210    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    21792211    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
     2212
    21802213    PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);
    21812214
     
    21932226 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl}
    21942227 */
    2195 static DECLCALLBACK(int)
    2196 drvHostDSoundStreamControl(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
     2228PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCONTROL(drvHostDSound)
    21972229{
    21982230    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    21992231    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
     2232
    22002233    PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);
    22012234
     
    22152248 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
    22162249 */
    2217 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostDSoundStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     2250PDMAUDIO_IHOSTAUDIO_EMIT_STREAMGETSTATUS(drvHostDSound)
    22182251{
    22192252    AssertPtrReturn(pInterface, PDMAUDIOSTRMSTS_FLAG_NONE);
     
    22542287 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamIterate}
    22552288 */
    2256 static DECLCALLBACK(int) drvHostDSoundStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     2289PDMAUDIO_IHOSTAUDIO_EMIT_STREAMITERATE(drvHostDSound)
    22572290{
    22582291    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    23682401    return VINF_SUCCESS;
    23692402}
     2403
    23702404
    23712405/**
  • trunk/src/VBox/Devices/Audio/DrvHostDebugAudio.cpp

    r62973 r63360  
    7272
    7373
    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 */
     77PDMAUDIO_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);
    8184
    8285    /* 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 */
     99PDMAUDIO_IHOSTAUDIO_EMIT_INIT(drvHostDebugAudio)
    93100{
    94101    NOREF(pInterface);
     
    98105}
    99106
     107
     108/**
     109 * @interface_method_impl{PDMIHOSTAUDIO,pfnShutdown}
     110 */
     111PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(drvHostDebugAudio)
     112{
     113    NOREF(pInterface);
     114}
     115
     116
     117/**
     118 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus}
     119 */
     120PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(drvHostDebugAudio)
     121{
     122    RT_NOREF(enmDir);
     123    AssertPtrReturn(pInterface, PDMAUDIOBACKENDSTS_UNKNOWN);
     124
     125    return PDMAUDIOBACKENDSTS_RUNNING;
     126}
     127
     128
    100129static int debugCreateStreamIn(PPDMIHOSTAUDIO pInterface,
    101                                PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples)
     130                               PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
    102131{
    103132    NOREF(pInterface);
    104133
    105134    /* Just adopt the wanted stream configuration. */
    106     int rc = DrvAudioHlpStreamCfgToProps(pCfg, &pStream->Props);
     135    int rc = DrvAudioHlpStreamCfgToProps(pCfgReq, &pStream->Props);
    107136    if (RT_SUCCESS(rc))
    108137    {
    109         if (pcSamples)
    110             *pcSamples = _1K;
     138        if (pCfgAcq)
     139            pCfgAcq->cSamples = _1K;
    111140    }
    112141
     
    115144}
    116145
     146
    117147static int debugCreateStreamOut(PPDMIHOSTAUDIO pInterface,
    118                                 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg,
    119                                 uint32_t *pcSamples)
     148                                PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
    120149{
    121150    NOREF(pInterface);
     
    125154    /* Just adopt the wanted stream configuration. */
    126155    PDMPCMPROPS Props;
    127     int rc = DrvAudioHlpStreamCfgToProps(pCfg, &Props);
     156    int rc = DrvAudioHlpStreamCfgToProps(pCfgReq, &Props);
    128157    if (RT_SUCCESS(rc))
    129158    {
     
    152181    if (RT_SUCCESS(rc))
    153182    {
    154         if (pcSamples)
    155             *pcSamples = pDbgStream->Out.cMaxSamplesInPlayBuffer;
     183        if (pCfgAcq)
     184            pCfgAcq->cSamples = pDbgStream->Out.cMaxSamplesInPlayBuffer;
    156185    }
    157186
     
    160189}
    161190
    162 static DECLCALLBACK(int) drvHostDebugAudioStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream,
    163                                                      uint32_t *pcSamplesPlayed)
     191
     192/**
     193 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate}
     194 */
     195PDMAUDIO_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 */
     215PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(drvHostDebugAudio)
    164216{
    165217    PDRVHOSTDEBUGAUDIO pDrv       = RT_FROM_MEMBER(pInterface, DRVHOSTDEBUGAUDIO, IHostAudio);
     
    215267
    216268        cSamplesPlayed += cSamplesRead;
    217     };
     269    }
    218270
    219271    /* Remember when samples were consumed. */
    220272    pDbgStream->Out.tsLastPlayed = u64TicksNow;
    221273
    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 */
     284PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCAPTURE(drvHostDebugAudio)
    230285{
    231286    RT_NOREF(pInterface, pStream);
    232287
    233288    /* 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
    239295
    240296static int debugDestroyStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     
    244300    return VINF_SUCCESS;
    245301}
     302
    246303
    247304static int debugDestroyStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     
    270327}
    271328
    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     else
    291         rc = debugCreateStreamOut(pInterface, pStream, pCfg, pcSamples);
    292 
    293     LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc));
    294     return rc;
    295 }
    296329
    297330static DECLCALLBACK(int) drvHostDebugAudioStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     
    338371}
    339372
     373
    340374/**
    341375 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
     
    351385}
    352386
    353 static DECLCALLBACK(void) drvHostDebugAudioShutdown(PPDMIHOSTAUDIO pInterface)
    354 {
    355     NOREF(pInterface);
    356 }
    357387
    358388/**
  • trunk/src/VBox/Devices/Audio/DrvHostNullAudio.cpp

    r62970 r63360  
    9393 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetConfig}
    9494 */
    95 static DECLCALLBACK(int) drvHostNullAudioGetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pCfg)
     95PDMAUDIO_IHOSTAUDIO_EMIT_GETCONFIG(drvHostNullAudio)
    9696{
    9797    NOREF(pInterface);
    98     AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
    99 
    100     pCfg->cbStreamOut    = sizeof(NULLAUDIOSTREAMOUT);
    101     pCfg->cbStreamIn     = sizeof(NULLAUDIOSTREAMIN);
     98    AssertPtrReturn(pBackendCfg, VERR_INVALID_POINTER);
     99
     100    pBackendCfg->cbStreamOut    = sizeof(NULLAUDIOSTREAMOUT);
     101    pBackendCfg->cbStreamIn     = sizeof(NULLAUDIOSTREAMIN);
    102102
    103103    /* The NULL backend has exactly one input source and one output sink. */
    104     pCfg->cSources       = 1;
    105     pCfg->cSinks         = 1;
    106 
    107     pCfg->cMaxStreamsOut = 1; /* Output */
    108     pCfg->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. */
    109109
    110110    return VINF_SUCCESS;
     
    115115 * @interface_method_impl{PDMIHOSTAUDIO,pfnInit}
    116116 */
    117 static DECLCALLBACK(int) drvHostNullAudioInit(PPDMIHOSTAUDIO pInterface)
     117PDMAUDIO_IHOSTAUDIO_EMIT_INIT(drvHostNullAudio)
    118118{
    119119    NOREF(pInterface);
     
    125125
    126126/**
     127 * @interface_method_impl{PDMIHOSTAUDIO,pfnShutdown}
     128 */
     129PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(drvHostNullAudio)
     130{
     131    RT_NOREF(pInterface);
     132}
     133
     134
     135/**
     136 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus}
     137 */
     138PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(drvHostNullAudio)
     139{
     140    RT_NOREF(enmDir);
     141    AssertPtrReturn(pInterface, PDMAUDIOBACKENDSTS_UNKNOWN);
     142
     143    return PDMAUDIOBACKENDSTS_RUNNING;
     144}
     145
     146
     147/**
    127148 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay}
    128149 */
    129 static DECLCALLBACK(int) drvHostNullAudioStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesPlayed)
     150PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(drvHostNullAudio)
    130151{
    131152    PDRVHOSTNULLAUDIO   pDrv        = RT_FROM_MEMBER(pInterface, DRVHOSTNULLAUDIO, IHostAudio);
     
    159180    AudioMixBufFinish(&pStream->MixBuf, cSamplesToRead);
    160181
    161     if (pcSamplesPlayed)
    162         *pcSamplesPlayed = cSamplesToRead;
     182    if (pcbWritten)
     183        *pcbWritten = cSamplesToRead;
    163184
    164185    return VINF_SUCCESS;
     
    169190 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture}
    170191 */
    171 static DECLCALLBACK(int)
    172 drvHostNullAudioStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesCaptured)
     192PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCAPTURE(drvHostNullAudio)
    173193{
    174194    RT_NOREF(pInterface, pStream);
    175195
    176196    /* 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
     204static int nullCreateStreamIn(PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
    197205{
    198206    /* Just adopt the wanted stream configuration. */
    199     int rc = DrvAudioHlpStreamCfgToProps(pCfg, &pStream->Props);
     207    int rc = DrvAudioHlpStreamCfgToProps(pCfgReq, &pStream->Props);
    200208    if (RT_SUCCESS(rc))
    201209    {
    202         if (pcSamples)
    203             *pcSamples = _1K;
     210        if (pCfgAcq)
     211            pCfgAcq->cSamples = _1K;
    204212    }
    205213
     
    209217
    210218
    211 static int nullCreateStreamOut(PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples)
     219static int nullCreateStreamOut(PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
    212220{
    213221    /* Just adopt the wanted stream configuration. */
    214     int rc = DrvAudioHlpStreamCfgToProps(pCfg, &pStream->Props);
     222    int rc = DrvAudioHlpStreamCfgToProps(pCfgReq, &pStream->Props);
    215223    if (RT_SUCCESS(rc))
    216224    {
    217225        PNULLAUDIOSTREAMOUT pNullStream = RT_FROM_MEMBER(pStream, NULLAUDIOSTREAMOUT, Stream);
     226
    218227        pNullStream->u64TicksLast  = 0;
    219228        pNullStream->cMaxSamplesInPlayBuffer = _1K;
     229
    220230        pNullStream->pbPlayBuffer = (uint8_t *)RTMemAlloc(_1K << pStream->Props.cShift);
    221231        if (pNullStream->pbPlayBuffer)
    222232        {
    223             if (pcSamples)
    224                 *pcSamples = pNullStream->cMaxSamplesInPlayBuffer;
     233            if (pCfgAcq)
     234                pCfgAcq->cSamples = pNullStream->cMaxSamplesInPlayBuffer;
    225235        }
    226236        else
     
    236246 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate}
    237247 */
    238 static DECLCALLBACK(int)
    239 drvHostNullAudioStreamCreate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples)
     248PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCREATE(drvHostNullAudio)
    240249{
    241250    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    242251    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    243     AssertPtrReturn(pCfg,       VERR_INVALID_POINTER);
     252    AssertPtrReturn(pCfgReq,    VERR_INVALID_POINTER);
    244253
    245254    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);
    248257    else
    249         rc = nullCreateStreamOut(pStream, pCfg, pcSamples);
     258        rc = nullCreateStreamOut(pStream, pCfgReq, pCfgAcq);
    250259
    251260    LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc));
     
    279288 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
    280289 */
    281 static DECLCALLBACK(int) drvHostNullAudioStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     290PDMAUDIO_IHOSTAUDIO_EMIT_STREAMDESTROY(drvHostNullAudio)
    282291{
    283292    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    297306 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl}
    298307 */
    299 static DECLCALLBACK(int)
    300 drvHostNullAudioStreamControl(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
     308PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCONTROL(drvHostNullAudio)
    301309{
    302310    RT_NOREF(enmStreamCmd);
     
    313321 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
    314322 */
    315 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostNullAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     323PDMAUDIO_IHOSTAUDIO_EMIT_STREAMGETSTATUS(drvHostNullAudio)
    316324{
    317325    RT_NOREF(pInterface, pStream);
     
    324332 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamIterate}
    325333 */
    326 static DECLCALLBACK(int) drvHostNullAudioStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     334PDMAUDIO_IHOSTAUDIO_EMIT_STREAMITERATE(drvHostNullAudio)
    327335{
    328336    NOREF(pInterface);
     
    330338
    331339    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);
    341340}
    342341
     
    382381    return VINF_SUCCESS;
    383382}
     383
    384384
    385385/**
  • trunk/src/VBox/Devices/Audio/DrvHostOSSAudio.cpp

    r63212 r63360  
    149149}
    150150
     151
    151152static uint32_t lsbindex(uint32_t u)
    152153{
    153154    return popcount ((u&-u)-1);
    154155}
     156
    155157
    156158static int ossAudioFmtToOSS(PDMAUDIOFMT fmt)
     
    177179    return AFMT_U8;
    178180}
     181
    179182
    180183static int ossOSSToAudioFmt(int fmt, PDMAUDIOFMT *pFmt, PDMAUDIOENDIANNESS *pENDIANNESS)
     
    226229}
    227230
     231
    228232static int ossStreamClose(int *phFile)
    229233{
     
    246250}
    247251
     252
    248253static int ossStreamOpen(const char *pszDev, int fOpen, POSSAUDIOSTREAMCFG pReq, POSSAUDIOSTREAMCFG pObt, int *phFile)
    249254{
    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 
    255255    int rc;
    256256
     
    336336}
    337337
    338 static int ossControlStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream,
    339                               PDMAUDIOSTREAMCMD enmStreamCmd)
    340 {
    341     NOREF(pInterface);
    342     NOREF(pStream);
    343     NOREF(enmStreamCmd);
     338
     339static int ossControlStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
     340{
    344341
    345342    /** @todo Nothing to do here right now!? */
     
    348345}
    349346
    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
     348static int ossControlStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
     349{
     350    POSSAUDIOSTREAMOUT pStreamOut = (POSSAUDIOSTREAMOUT)pStream;
    357351
    358352#ifdef RT_OS_L4
    359353    return VINF_SUCCESS;
    360354#else
    361     if (!pThisStream->fMemMapped)
     355    if (!pStreamOut->fMemMapped)
    362356        return VINF_SUCCESS;
    363357#endif
     
    370364        case PDMAUDIOSTREAMCMD_RESUME:
    371365        {
    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));
    374368
    375369            mask = PCM_ENABLE_OUTPUT;
    376             if (ioctl(pThisStream->hFile, SNDCTL_DSP_SETTRIGGER, &mask) < 0)
     370            if (ioctl(pStreamOut->hFile, SNDCTL_DSP_SETTRIGGER, &mask) < 0)
    377371            {
    378372                LogRel(("OSS: Failed to enable output stream: %s\n", strerror(errno)));
     
    387381        {
    388382            mask = 0;
    389             if (ioctl(pThisStream->hFile, SNDCTL_DSP_SETTRIGGER, &mask) < 0)
     383            if (ioctl(pStreamOut->hFile, SNDCTL_DSP_SETTRIGGER, &mask) < 0)
    390384            {
    391385                LogRel(("OSS: Failed to disable output stream: %s\n", strerror(errno)));
     
    406400}
    407401
    408 static DECLCALLBACK(int) drvHostOSSAudioInit(PPDMIHOSTAUDIO pInterface)
    409 {
    410     NOREF(pInterface);
     402
     403/**
     404 * @interface_method_impl{PDMIHOSTAUDIO,pfnInit}
     405 */
     406PDMAUDIO_IHOSTAUDIO_EMIT_INIT(drvHostOSSAudio)
     407{
     408    RT_NOREF(pInterface);
    411409
    412410    LogFlowFuncEnter();
     
    415413}
    416414
    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 */
     419PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCAPTURE(drvHostOSSAudio)
     420{
     421    RT_NOREF(pInterface);
    421422    AssertPtrReturn(pStream, VERR_INVALID_POINTER);
    422423
     
    494495            rc = AudioMixBufMixToParent(&pStream->MixBuf, cWrittenTotal, &cProcessed);
    495496
    496         if (pcSamplesCaptured)
    497             *pcSamplesCaptured = cWrittenTotal;
     497        if (pcbRead)
     498            *pcbRead = cWrittenTotal;
    498499
    499500        LogFlowFunc(("cWrittenTotal=%RU32 (%RU32 processed), rc=%Rrc\n",
     
    505506}
    506507
     508
    507509static int ossDestroyStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
    508510{
    509     NOREF(pInterface);
    510     AssertPtrReturn(pStream, VERR_INVALID_POINTER);
    511 
    512511    POSSAUDIOSTREAMIN pStrm = (POSSAUDIOSTREAMIN)pStream;
    513512
     
    529528}
    530529
     530
    531531static int ossDestroyStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
    532532{
    533     NOREF(pInterface);
    534     AssertPtrReturn(pStream, VERR_INVALID_POINTER);
    535 
    536533    POSSAUDIOSTREAMOUT pStrm = (POSSAUDIOSTREAMOUT)pStream;
    537534
     
    578575}
    579576
    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 */
     581PDMAUDIO_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;
    589590
    590591    int hFile = open("/dev/dsp", O_WRONLY | O_NONBLOCK, 0);
     
    619620                    cDev = ossInfo.numaudios;
    620621
    621                 pCfg->cSources        = cDev;
    622                 pCfg->cSinks          = cDev;
    623 
    624                 pCfg->cMaxStreamsIn   = UINT32_MAX;
    625                 pCfg->cMaxStreamsOut  = UINT32_MAX;
     622                pBackendCfg->cSources        = cDev;
     623                pBackendCfg->cSinks          = cDev;
     624
     625                pBackendCfg->cMaxStreamsIn   = UINT32_MAX;
     626                pBackendCfg->cMaxStreamsOut  = UINT32_MAX;
    626627            }
    627628            else
     
    630631                /* Since we cannot query anything, assume that we have at least
    631632                 * one input and one output if we found "/dev/dsp" or "/dev/mixer". */
    632                 pCfg->cSources        = 1;
    633                 pCfg->cSinks          = 1;
    634 
    635                 pCfg->cMaxStreamsIn   = UINT32_MAX;
    636                 pCfg->cMaxStreamsOut  = UINT32_MAX;
     633                pBackendCfg->cSources        = 1;
     634                pBackendCfg->cSinks          = 1;
     635
     636                pBackendCfg->cMaxStreamsIn   = UINT32_MAX;
     637                pBackendCfg->cMaxStreamsOut  = UINT32_MAX;
    637638#ifdef VBOX_WITH_AUDIO_OSS_SYSINFO
    638639            }
     
    648649}
    649650
     651
    650652static 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);
    657656    POSSAUDIOSTREAMIN pStrm = (POSSAUDIOSTREAMIN)pStream;
    658657
     
    665664
    666665        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;
    670669        reqStream.cFragments     = s_OSSConf.nfrags;
    671670        reqStream.cbFragmentSize = s_OSSConf.fragsize;
     
    674673        if (RT_SUCCESS(rc))
    675674        {
    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);
    688682            if (RT_SUCCESS(rc))
    689683            {
    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;
    692691                if (!cSamples)
    693692                    rc = VERR_INVALID_PARAMETER;
    694693            }
    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            }
    717715        }
    718716
     
    726724}
    727725
     726
    728727static 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);
    736731    POSSAUDIOSTREAMOUT pStrm = (POSSAUDIOSTREAMOUT)pStream;
    737732
     
    744739
    745740        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;
    749744        reqStream.cFragments     = s_OSSConf.nfrags;
    750745        reqStream.cbFragmentSize = s_OSSConf.fragsize;
    751746
     747        PDMPCMPROPS Props;
     748        RT_ZERO(Props);
     749
    752750        rc = ossStreamOpen(s_OSSConf.devpath_out, O_WRONLY | O_NONBLOCK, &reqStream, &obtStream, &hFile);
    753751        if (RT_SUCCESS(rc))
    754752        {
    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);
    767759            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            }
    770769        }
    771770
     
    774773            pStrm->fMemMapped = false;
    775774
    776             size_t cbSamples =  cSamples << pStream->Props.cShift;
     775            size_t cbSamples =  cSamples << Props.cShift;
    777776            Assert(cbSamples);
    778777
     
    839838            }
    840839#endif
    841             if (pcSamples)
    842                 *pcSamples = cSamples;
     840            pCfgAcq->cSamples = cSamples;
    843841        }
    844842
     
    852850}
    853851
    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 */
     856PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(drvHostOSSAudio)
     857{
     858    RT_NOREF(pInterface);
    857859    AssertPtrReturn(pStream, VERR_INVALID_POINTER);
    858860
     
    865867    do
    866868    {
    867         size_t cbBuf = AudioMixBufSizeBytes(&pStream->MixBuf);
     869        size_t cbBufSize = AudioMixBufSizeBytes(&pStream->MixBuf);
    868870
    869871        uint32_t cLive = AudioMixBufLive(&pStream->MixBuf);
     
    891893                cbData = cntinfo.ptr - pStrm->old_optr;
    892894            else
    893                 cbData = cbBuf + cntinfo.ptr - pStrm->old_optr;
     895                cbData = cbBufSize + cntinfo.ptr - pStrm->old_optr;
    894896            Assert(cbData);
    895897
     
    909911            }
    910912
    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;
    915917                /* Keep going. */
    916918            }
     
    918920            if (abinfo.bytes < 0)
    919921            {
    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));
    921923                rc = VERR_INVALID_PARAMETER;
    922924                break;
     
    967969            AudioMixBufFinish(&pStream->MixBuf, cReadTotal);
    968970
    969         if (pcSamplesPlayed)
    970             *pcSamplesPlayed = cReadTotal;
     971        if (pcbWritten)
     972            *pcbWritten = cReadTotal;
    971973
    972974        LogFlowFunc(("cReadTotal=%RU32 (%RU32 bytes), rc=%Rrc\n", cReadTotal, cbReadTotal, rc));
     
    977979}
    978980
    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 */
     985PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(drvHostOSSAudio)
     986{
     987    RT_NOREF(pInterface);
     988}
     989
     990
     991/**
     992 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus}
     993 */
     994PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(drvHostOSSAudio)
    985995{
    986996    AssertPtrReturn(pInterface, PDMAUDIOBACKENDSTS_UNKNOWN);
     
    9901000}
    9911001
    992 static DECLCALLBACK(int) drvHostOSSAudioStreamCreate(PPDMIHOSTAUDIO pInterface,
    993                                                      PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples)
     1002
     1003/**
     1004 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate}
     1005 */
     1006PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCREATE(drvHostOSSAudio)
    9941007{
    9951008    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    9961009    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    997     AssertPtrReturn(pCfg,       VERR_INVALID_POINTER);
     1010    AssertPtrReturn(pCfgReq,    VERR_INVALID_POINTER);
     1011    AssertPtrReturn(pCfgAcq,    VERR_INVALID_POINTER);
    9981012
    9991013    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);
    10021016    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
    10061019    return rc;
    10071020}
    10081021
    1009 static DECLCALLBACK(int) drvHostOSSAudioStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     1022
     1023/**
     1024 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
     1025 */
     1026PDMAUDIO_IHOSTAUDIO_EMIT_STREAMDESTROY(drvHostOSSAudio)
    10101027{
    10111028    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    10211038}
    10221039
    1023 static DECLCALLBACK(int) drvHostOSSAudioStreamControl(PPDMIHOSTAUDIO pInterface,
    1024                                                       PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
     1040
     1041/**
     1042 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl}
     1043 */
     1044PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCONTROL(drvHostOSSAudio)
    10251045{
    10261046    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    10381058}
    10391059
    1040 static DECLCALLBACK(int) drvHostOSSAudioStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     1060
     1061/**
     1062 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamIterate}
     1063 */
     1064PDMAUDIO_IHOSTAUDIO_EMIT_STREAMITERATE(drvHostOSSAudio)
    10411065{
    10421066    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    10491073}
    10501074
    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 */
     1079PDMAUDIO_IHOSTAUDIO_EMIT_STREAMGETSTATUS(drvHostOSSAudio)
     1080{
     1081    RT_NOREF(pInterface);
     1082    RT_NOREF(pStream);
    10551083
    10561084    PDMAUDIOSTRMSTS strmSts =   PDMAUDIOSTRMSTS_FLAG_INITIALIZED
     
    10631091    return strmSts;
    10641092}
     1093
    10651094/**
    10661095 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
     
    10681097static DECLCALLBACK(void *) drvHostOSSAudioQueryInterface(PPDMIBASE pInterface, const char *pszIID)
    10691098{
    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
    10721102    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
    10731103    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHOSTAUDIO, &pThis->IHostAudio);
  • trunk/src/VBox/Devices/Audio/DrvHostPulseAudio.cpp

    r63214 r63360  
    167167static void paStreamCbSuccess(pa_stream *pStream, int fSuccess, void *pvContext);
    168168
     169
     170
    169171/**
    170172 * Signal the main loop to abort. Just signalling isn't sufficient as the
     
    179181    pa_threaded_mainloop_signal(pThis->pMainLoop, 0);
    180182}
     183
    181184
    182185static pa_sample_format_t paFmtToPulse(PDMAUDIOFMT fmt)
     
    202205}
    203206
     207
    204208static int paPulseToFmt(pa_sample_format_t pulsefmt,
    205209                        PDMAUDIOFMT *pFmt, PDMAUDIOENDIANNESS *pEndianness)
     
    244248}
    245249
     250
    246251/**
    247252 * Synchronously wait until an operation completed.
     
    277282}
    278283
     284
    279285static int paWaitFor(PDRVHOSTPULSEAUDIO pThis, pa_operation *pOP)
    280286{
    281287    return paWaitForEx(pThis, pOP, 10 * 1000 /* 10s timeout */);
    282288}
     289
    283290
    284291/**
     
    309316}
    310317
     318
    311319/**
    312320 * Callback called when our pa_stream_drain operation was completed.
     
    334342    }
    335343}
     344
    336345
    337346/**
     
    358367}
    359368
     369
    360370static void paStreamCbSuccess(pa_stream *pStream, int fSuccess, void *pvUser)
    361371{
     
    372382        paError(pStrm->pDrv, "Failed to finish stream operation");
    373383}
     384
    374385
    375386static int paStreamOpen(PDRVHOSTPULSEAUDIO pThis, bool fIn, const char *pszName,
     
    508519}
    509520
    510 static DECLCALLBACK(int) drvHostPulseAudioInit(PPDMIHOSTAUDIO pInterface)
     521
     522/**
     523 * @interface_method_impl{PDMIHOSTAUDIO,pfnInit}
     524 */
     525PDMAUDIO_IHOSTAUDIO_EMIT_INIT(drvHostPulseAudio)
    511526{
    512527    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    616631}
    617632
     633
    618634static 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{
    626637    PDRVHOSTPULSEAUDIO pThis = PDMIHOSTAUDIO_2_DRVHOSTPULSEAUDIO(pInterface);
    627638    PPULSEAUDIOSTREAM  pStrm = (PPULSEAUDIOSTREAM)pStream;
     
    631642    pStrm->pDrainOp            = NULL;
    632643
    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;
    636647
    637648    /* Note that setting maxlength to -1 does not work on PulseAudio servers
     
    648659        return rc;
    649660
    650     PDMAUDIOSTREAMCFG streamCfg;
    651661    rc = paPulseToFmt(pStrm->SampleSpec.format,
    652                       &streamCfg.enmFormat, &streamCfg.enmEndianness);
     662                      &pCfgAcq->enmFormat, &pCfgAcq->enmEndianness);
    653663    if (RT_FAILURE(rc))
    654664    {
     
    657667    }
    658668
    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);
    663673    if (RT_SUCCESS(rc))
    664674    {
     
    672682                pStrm->cbPCMBuf = cbBuf;
    673683
    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! */
    677685
    678686                /* Save pointer to driver instance. */
    679687                pStrm->pDrv = pThis;
    680 
    681                 LogFunc(("cbBuf=%RU32, cSamples=%RU32\n", cbBuf, cSamples));
    682688            }
    683689            else
     
    692698}
    693699
     700
    694701static 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{
    702704    PDRVHOSTPULSEAUDIO pThis = PDMIHOSTAUDIO_2_DRVHOSTPULSEAUDIO(pInterface);
    703705    PPULSEAUDIOSTREAM  pStrm = (PPULSEAUDIOSTREAM)pStream;
    704706
    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;
    708710
    709711    /* XXX check these values */
     
    718720        return rc;
    719721
    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);
    723724    if (RT_FAILURE(rc))
    724725    {
     
    727728    }
    728729
    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);
    733734    if (RT_SUCCESS(rc))
    734735    {
    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! */
    740738
    741739        /* Save pointer to driver instance. */
    742740        pStrm->pDrv       = pThis;
    743741        pStrm->pu8PeekBuf = NULL;
    744 
    745         if (pcSamples)
    746             *pcSamples = cSamples;
    747742    }
    748743
     
    751746}
    752747
    753 static DECLCALLBACK(int) drvHostPulseAudioStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream,
    754                                                         uint32_t *pcSamplesCaptured)
     748
     749/**
     750 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture}
     751 */
     752PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCAPTURE(drvHostPulseAudio)
    755753{
    756754    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    757755    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    758     /* pcSamplesPlayed is optional. */
     756    /* pcbRead is optional. */
    759757
    760758    PDRVHOSTPULSEAUDIO pThis = PDMIHOSTAUDIO_2_DRVHOSTPULSEAUDIO(pInterface);
     
    780778    if (!cbAvail) /* No data? Bail out. */
    781779    {
    782         if (pcSamplesCaptured)
    783             *pcSamplesCaptured = 0;
     780        if (pcbRead)
     781            *pcbRead = 0;
    784782        return VINF_SUCCESS;
    785783    }
     
    861859            rc = AudioMixBufMixToParent(&pStream->MixBuf, cWrittenTotal,
    862860                                        &cProcessed);*/
    863 
    864         if (pcSamplesCaptured)
    865             *pcSamplesCaptured = cWrittenTotal;
     861        if (pcbRead)
     862            *pcbRead = cWrittenTotal;
    866863
    867864        LogFlowFunc(("cWrittenTotal=%RU32 (%RU32 processed), rc=%Rrc\n",
     
    873870}
    874871
    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 */
     876PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(drvHostPulseAudio)
     877{
     878    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     879    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
     880    /* pcbWritten is optional. */
    881881
    882882    PDRVHOSTPULSEAUDIO pThis     = PDMIHOSTAUDIO_2_DRVHOSTPULSEAUDIO(pInterface);
     
    890890    {
    891891        LogFlowFunc(("No live samples, skipping\n"));
    892         if (pcSamplesPlayed)
    893             *pcSamplesPlayed = 0;
     892        if (pcbWritten)
     893            *pcbWritten = 0;
    894894        return VINF_SUCCESS;
    895895    }
     
    949949            AudioMixBufFinish(&pStream->MixBuf, cReadTotal);
    950950
    951         if (pcSamplesPlayed)
    952             *pcSamplesPlayed = cReadTotal;
     951        if (pcbWritten)
     952            *pcbWritten = cReadTotal;
    953953
    954954        LogFlowFunc(("cReadTotal=%RU32 (%RU32 bytes), rc=%Rrc\n", cReadTotal, cbReadTotal, rc));
     
    959959}
    960960
     961
    961962/** @todo Implement va handling. */
    962963static int paError(PDRVHOSTPULSEAUDIO pThis, const char *szMsg)
     
    974975    return VERR_GENERAL_FAILURE;
    975976}
     977
    976978
    977979static void paEnumSinkCb(pa_context *pCtx, const pa_sink_info *pInfo, int eol, void *pvUserData)
     
    995997}
    996998
     999
    9971000static void paEnumSourceCb(pa_context *pCtx, const pa_source_info *pInfo, int eol, void *pvUserData)
    9981001{
     
    10151018}
    10161019
     1020
    10171021static void paEnumServerCb(pa_context *pCtx, const pa_server_info *pInfo, void *pvUserData)
    10181022{
     
    10401044    pa_threaded_mainloop_signal(pThis->pMainLoop, 0);
    10411045}
     1046
    10421047
    10431048static int paEnumerate(PDRVHOSTPULSEAUDIO pThis, PPDMAUDIOBACKENDCFG pCfg, uint32_t fEnum)
     
    11341139}
    11351140
     1141
    11361142static int paDestroyStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
    11371143{
     
    11581164    return VINF_SUCCESS;
    11591165}
     1166
    11601167
    11611168static int paDestroyStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     
    11971204    return VINF_SUCCESS;
    11981205}
     1206
    11991207
    12001208static int paControlStreamOut(PPDMIHOSTAUDIO pInterface,
     
    12611269}
    12621270
     1271
    12631272static int paControlStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream,
    12641273                             PDMAUDIOSTREAMCMD enmStreamCmd)
     
    13091318}
    13101319
    1311 static DECLCALLBACK(void) drvHostPulseAudioShutdown(PPDMIHOSTAUDIO pInterface)
     1320
     1321/**
     1322 * @interface_method_impl{PDMIHOSTAUDIO,pfnShutdown}
     1323 */
     1324PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(drvHostPulseAudio)
    13121325{
    13131326    AssertPtrReturnVoid(pInterface);
     
    13361349}
    13371350
    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 */
     1355PDMAUDIO_IHOSTAUDIO_EMIT_GETCONFIG(drvHostPulseAudio)
     1356{
     1357    AssertPtrReturn(pInterface,  VERR_INVALID_POINTER);
     1358    AssertPtrReturn(pBackendCfg, VERR_INVALID_POINTER);
    13421359
    13431360    PDRVHOSTPULSEAUDIO pThis = PDMIHOSTAUDIO_2_DRVHOSTPULSEAUDIO(pInterface);
    13441361
    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 */
     1369PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(drvHostPulseAudio)
    13491370{
    13501371    RT_NOREF(enmDir);
     
    13541375}
    13551376
    1356 static DECLCALLBACK(int) drvHostPulseAudioStreamCreate(PPDMIHOSTAUDIO pInterface,
    1357                                                        PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples)
     1377
     1378/**
     1379 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate}
     1380 */
     1381PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCREATE(drvHostPulseAudio)
    13581382{
    13591383    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    13601384    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    1361     AssertPtrReturn(pCfg,       VERR_INVALID_POINTER);
     1385    AssertPtrReturn(pCfgReq,    VERR_INVALID_POINTER);
     1386    AssertPtrReturn(pCfgAcq,    VERR_INVALID_POINTER);
    13621387
    13631388    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);
    13661391    else if (pStream->enmDir == PDMAUDIODIR_OUT)
    1367         rc = paCreateStreamOut(pInterface, pStream, pCfg, pcSamples);
     1392        rc = paCreateStreamOut(pInterface, pStream, pCfgReq, pCfgAcq);
    13681393    else
    13691394        AssertFailedReturn(VERR_NOT_IMPLEMENTED);
    13701395
    1371     LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc));
    13721396    return rc;
    13731397}
    13741398
    1375 static DECLCALLBACK(int) drvHostPulseAudioStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     1399
     1400/**
     1401 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
     1402 */
     1403PDMAUDIO_IHOSTAUDIO_EMIT_STREAMDESTROY(drvHostPulseAudio)
    13761404{
    13771405    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    13781406    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    1379 
    1380     LogFlowFunc(("%s\n", pStream->szName));
    13811407
    13821408    int rc;
     
    13881414        AssertFailedReturn(VERR_NOT_IMPLEMENTED);
    13891415
    1390     LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc));
    13911416    return rc;
    13921417}
    13931418
    1394 static DECLCALLBACK(int) drvHostPulseAudioStreamControl(PPDMIHOSTAUDIO pInterface,
    1395                                                         PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
     1419
     1420/**
     1421 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl}
     1422 */
     1423PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCONTROL(drvHostPulseAudio)
    13961424{
    13971425    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    14081436        AssertFailedReturn(VERR_NOT_IMPLEMENTED);
    14091437
    1410     LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc));
    14111438    return rc;
    14121439}
    14131440
    1414 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostPulseAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     1441
     1442/**
     1443 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
     1444 */
     1445PDMAUDIO_IHOSTAUDIO_EMIT_STREAMGETSTATUS(drvHostPulseAudio)
    14151446{
    14161447    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    14491480}
    14501481
    1451 static DECLCALLBACK(int) drvHostPulseAudioStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     1482
     1483/**
     1484 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetConfig}
     1485 */
     1486PDMAUDIO_IHOSTAUDIO_EMIT_STREAMITERATE(drvHostPulseAudio)
    14521487{
    14531488    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    14541489    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
     1490
    14551491    LogFlowFuncEnter();
    14561492
     
    14581494    return VINF_SUCCESS;
    14591495}
     1496
    14601497
    14611498/**
  • trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp

    r63244 r63360  
    8585
    8686
     87
    8788static 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);
    9397    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
    101106
    102107static 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);
    110116    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
    118125
    119126static int vrdeControlStreamOut(PPDMIHOSTAUDIO pInterface,
     
    133140    return VINF_SUCCESS;
    134141}
     142
    135143
    136144static int vrdeControlStreamIn(PPDMIHOSTAUDIO pInterface,
     
    174182}
    175183
    176 static DECLCALLBACK(int) drvAudioVRDEInit(PPDMIHOSTAUDIO pInterface)
     184
     185/**
     186 * @interface_method_impl{PDMIHOSTAUDIO,pfnInit}
     187 */
     188PDMAUDIO_IHOSTAUDIO_EMIT_INIT(drvAudioVRDE)
    177189{
    178190    RT_NOREF(pInterface);
     
    182194}
    183195
    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 */
     200PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCAPTURE(drvAudioVRDE)
    198201{
    199202    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);
    206207    PVRDESTREAMIN pVRDEStrmIn = (PVRDESTREAMIN)pStream;
    207     AssertPtrReturn(pVRDEStrmIn, VERR_INVALID_POINTER);
    208208
    209209    /** @todo Use CritSect! */
     
    222222    if (RT_SUCCESS(rc))
    223223    {
    224         *pcSamplesCaptured = cProcessed;
    225 
    226224        Assert(pVRDEStrmIn->cSamplesCaptured >= cProcessed);
    227225        pVRDEStrmIn->cSamplesCaptured -= cProcessed;
     226
     227        if (pcbRead)
     228            *pcbRead = cProcessed;
    228229    }
    229230
     
    232233}
    233234
    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 */
     239PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(drvAudioVRDE)
    247240{
    248241    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    249242    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);
    255246    PVRDESTREAMOUT pVRDEStrmOut = (PVRDESTREAMOUT)pStream;
    256     AssertPtrReturn(pVRDEStrmOut, VERR_INVALID_POINTER);
    257247
    258248    uint32_t cLive = AudioMixBufLive(&pStream->MixBuf);
     
    316306     * VRDP server actually did process those.
    317307     */
    318     if (pcSamplesPlayed)
    319         *pcSamplesPlayed = cReadTotal;
     308    if (pcbWritten)
     309        *pcbWritten = cReadTotal;
    320310
    321311    LogFlowFunc(("cReadTotal=%RU32, rc=%Rrc\n", cReadTotal, rc));
    322312    return rc;
    323313}
     314
    324315
    325316static int vrdeDestroyStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     
    335326}
    336327
     328
    337329static int vrdeDestroyStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
    338330{
     
    344336}
    345337
    346 static DECLCALLBACK(int) drvAudioVRDEGetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pCfg)
     338
     339/**
     340 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetConfig}
     341 */
     342PDMAUDIO_IHOSTAUDIO_EMIT_GETCONFIG(drvAudioVRDE)
    347343{
    348344    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 */
     361PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(drvAudioVRDE)
    362362{
    363363    PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
     
    368368}
    369369
    370 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvAudioVRDEGetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir)
     370
     371/**
     372 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus}
     373 */
     374PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(drvAudioVRDE)
    371375{
    372376    RT_NOREF(enmDir);
     
    376380}
    377381
    378 static DECLCALLBACK(int) drvAudioVRDEStreamCreate(PPDMIHOSTAUDIO pInterface,
    379                                                   PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples)
     382
     383/**
     384 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate}
     385 */
     386PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCREATE(drvAudioVRDE)
    380387{
    381388    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    382389    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    383     AssertPtrReturn(pCfg,       VERR_INVALID_POINTER);
     390    AssertPtrReturn(pCfgReq,    VERR_INVALID_POINTER);
     391    AssertPtrReturn(pCfgAcq,    VERR_INVALID_POINTER);
    384392
    385393    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);
    388396    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
    392399    return rc;
    393400}
    394401
    395 static DECLCALLBACK(int) drvAudioVRDEStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     402
     403/**
     404 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
     405 */
     406PDMAUDIO_IHOSTAUDIO_EMIT_STREAMDESTROY(drvAudioVRDE)
    396407{
    397408    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    407418}
    408419
    409 static DECLCALLBACK(int) drvAudioVRDEStreamControl(PPDMIHOSTAUDIO pInterface,
    410                                                    PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
     420
     421/**
     422 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl}
     423 */
     424PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCONTROL(drvAudioVRDE)
    411425{
    412426    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    424438}
    425439
    426 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvAudioVRDEStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     440
     441/**
     442 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
     443 */
     444PDMAUDIO_IHOSTAUDIO_EMIT_STREAMGETSTATUS(drvAudioVRDE)
    427445{
    428446    NOREF(pInterface);
     
    433451}
    434452
    435 static DECLCALLBACK(int) drvAudioVRDEStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     453
     454/**
     455 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamIterate}
     456 */
     457PDMAUDIO_IHOSTAUDIO_EMIT_STREAMITERATE(drvAudioVRDE)
    436458{
    437459    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    443465    return VINF_SUCCESS;
    444466}
     467
    445468
    446469/**
     
    457480}
    458481
     482
    459483AudioVRDE::AudioVRDE(Console *pConsole)
    460484    : mpDrv(NULL),
     
    462486{
    463487}
     488
    464489
    465490AudioVRDE::~AudioVRDE(void)
     
    472497}
    473498
     499
    474500int AudioVRDE::onVRDEControl(bool fEnable, uint32_t uFlags)
    475501{
     
    484510    return VINF_SUCCESS; /* Never veto. */
    485511}
     512
    486513
    487514/**
     
    515542}
    516543
     544
    517545int AudioVRDE::onVRDEInputData(void *pvContext, const void *pvData, uint32_t cbData)
    518546{
     
    535563}
    536564
     565
    537566int AudioVRDE::onVRDEInputEnd(void *pvContext)
    538567{
     
    541570    return VINF_SUCCESS;
    542571}
     572
    543573
    544574int AudioVRDE::onVRDEInputIntercept(bool fEnabled)
     
    547577    return VINF_SUCCESS; /* Never veto. */
    548578}
     579
    549580
    550581/**
     
    557588{
    558589    RT_NOREF(fFlags);
     590
    559591    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
    560592    PDRVAUDIOVRDE pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIOVRDE);
     593
    561594    AssertPtrReturn(pDrvIns, VERR_INVALID_POINTER);
    562595    AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette