VirtualBox

Changeset 89226 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
May 21, 2021 3:02:10 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144569
Message:

Audio/ValKit: Initial support for the audio test execution service (ATS) to support playing test tones. bugref:10008

Location:
trunk/src/VBox/Devices/Audio
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/AudioTestService.cpp

    r89225 r89226  
    536536        return atsReplyInvalidState(pThis, pClient, pPktHdr);
    537537
     538    if (!pThis->Callbacks.pfnTonePlay)
     539        return atsReplyRC(pThis, pClient, pPktHdr, VERR_NOT_SUPPORTED, "Playing tones not supported");
     540
     541    PATSPKTREQTONEPLAY pReq = (PATSPKTREQTONEPLAY)pPktHdr;
     542    rc = pThis->Callbacks.pfnTonePlay(pThis->Callbacks.pvUser, &pReq->StreamCfg, &pReq->ToneParms);
     543
     544    int rc2 = atsReplyAck(pThis, pClient, pPktHdr);
     545    if (RT_SUCCESS(rc))
     546        rc = rc2;
     547
    538548    return rc;
    539549}
     
    564574    else if (atsIsSameOpcode(pPktHdr, ATSPKT_OPCODE_BYE))
    565575        rc = atsDoBye(pThis, pClient, pPktHdr);
    566     /* Gadget API. */
     576    /* Audio testing: */
    567577    else if (atsIsSameOpcode(pPktHdr, ATSPKT_OPCODE_TONE_PLAY))
    568578        rc = atsDoTonePlay(pThis, pClient, pPktHdr);
     
    762772 * @param   pThis               The ATS instance.
    763773 *  */
    764 int AudioTestSvcInit(PATSSERVER pThis)
    765 {
     774int AudioTestSvcInit(PATSSERVER pThis, PCATSCALLBACKS pCallbacks)
     775{
     776    memcpy(&pThis->Callbacks, pCallbacks, sizeof(ATSCALLBACKS));
     777
    766778    pThis->fStarted   = false;
    767779    pThis->fTerminate = false;
  • trunk/src/VBox/Devices/Audio/AudioTestService.h

    r89225 r89226  
    2626
    2727/**
     28 * Structure for keeping an Audio Test Server (ATS) callback table.
     29 */
     30typedef struct ATSCALLBACKS
     31{
     32    /**
     33     * Plays a test tone.
     34     *
     35     * @returns VBox status code.
     36     * @param   pvUser          User-supplied pointer to context data. Optional.
     37     * @param   pStreamCfg      Audio stream configuration to use for stream to play tone on.
     38     * @param   pToneParms      Tone parameters to use for playback.
     39     */
     40    DECLR3CALLBACKMEMBER(int, pfnTonePlay, (void const *pvUser, PPDMAUDIOSTREAMCFG pStreamCfg, PAUDIOTESTTONEPARMS pToneParms));
     41    /** Pointer to opaque user-provided context data. */
     42    void const *pvUser;
     43} ATSCALLBACKS;
     44/** Pointer to a const ATS callbacks table. */
     45typedef const struct ATSCALLBACKS *PCATSCALLBACKS;
     46
     47/**
    2848 * Structure for keeping an Audio Test Server (ATS) instance.
    2949 */
     
    3252    /** The selected transport layer. */
    3353    PCATSTRANSPORT       pTransport;
     54    /** The callbacks table. */
     55    ATSCALLBACKS         Callbacks;
    3456    /** Whether server is in started state or not. */
    3557    bool volatile        fStarted;
     
    5577
    5678
    57 int AudioTestSvcInit(PATSSERVER pThis);
     79int AudioTestSvcInit(PATSSERVER pThis, PCATSCALLBACKS pCallbacks);
    5880int AudioTestSvcDestroy(PATSSERVER pThis);
    5981int AudioTestSvcStart(PATSSERVER pThis);
  • trunk/src/VBox/Devices/Audio/AudioTestServiceClient.cpp

    r89215 r89226  
    227227}
    228228
     229int AudioTestSvcClientTonePlay(PATSCLIENT pClient, PPDMAUDIOSTREAMCFG pStreamCfg, PAUDIOTESTTONEPARMS pToneParms)
     230{
     231    ATSPKTREQTONEPLAY Req;
     232
     233    memcpy(&Req.StreamCfg, pStreamCfg, sizeof(PDMAUDIOSTREAMCFG));
     234    memcpy(&Req.ToneParms, pToneParms, sizeof(AUDIOTESTTONEPARMS));
     235
     236    audioTestSvcClientReqHdrInit(&Req.Hdr, sizeof(Req), ATSPKT_OPCODE_TONE_PLAY, 0);
     237
     238    int rc = audioTestSvcClientSendMsg(pClient, &Req, sizeof(Req), NULL, 0);
     239    if (RT_SUCCESS(rc))
     240        rc = audioTestSvcClientRecvAck(pClient);
     241
     242    return rc;
     243}
     244
    229245int AudioTestSvcClientClose(PATSCLIENT pClient)
    230246{
  • trunk/src/VBox/Devices/Audio/AudioTestServiceClient.h

    r89215 r89226  
    3131
    3232int AudioTestSvcClientConnect(PATSCLIENT pClient, const char *pszAddr);
     33int AudioTestSvcClientTonePlay(PATSCLIENT pClient, PPDMAUDIOSTREAMCFG pStreamCfg, PAUDIOTESTTONEPARMS pToneParms);
    3334int AudioTestSvcClientClose(PATSCLIENT pClient);
    3435
  • trunk/src/VBox/Devices/Audio/AudioTestServiceProtocol.h

    r89215 r89226  
    130130    /** Embedded packet header. */
    131131    ATSPKTHDR          Hdr;
    132     AUDIOTESTTONEPARMS Parms;
    133     uint8_t            au8Padding[8];
     132    /** Stream configuration to use for playing the tone.
     133     *  Note: Depending on the actual implementation this configuration might or might not be available / supported. */
     134    PDMAUDIOSTREAMCFG  StreamCfg;
     135    /** Test tone parameters for playback. */
     136    AUDIOTESTTONEPARMS ToneParms;
    134137} ATSPKTREQTONEPLAY;
    135138AssertCompileSizeAlignment(ATSPKTREQTONEPLAY, ATSPKT_ALIGNMENT);
Note: See TracChangeset for help on using the changeset viewer.

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