VirtualBox

Changeset 68919 in vbox


Ignore:
Timestamp:
Sep 28, 2017 8:57:08 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
118183
Message:

Audio/SB16: Implemented support for attaching + detaching drivers on runtime.

File:
1 edited

Legend:

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

    r68468 r68919  
    7373static const char e3[] = "COPYRIGHT (C) CREATIVE TECHNOLOGY LTD, 1992.";
    7474
    75 typedef struct SB16OUTPUTSTREAM
    76 {
    77     /** PCM output stream. */
     75/**
     76 * Structure defining a (host backend) driver stream.
     77 * Each driver has its own instances of audio mixer streams, which then
     78 * can go into the same (or even different) audio mixer sinks.
     79 */
     80typedef struct SB16DRIVERSTREAM
     81{
     82    /** Associated PDM audio stream. */
    7883    R3PTRTYPE(PPDMAUDIOSTREAM)         pStream;
    79 } SB16OUTPUTSTREAM, *PSB16OUTPUTSTREAM;
     84    /** The stream's current configuration. */
     85} SB16DRIVERSTREAM, *PSB16DRIVERSTREAM;
    8086
    8187/**
     
    102108    R3PTRTYPE(PPDMIAUDIOCONNECTOR)     pConnector;
    103109    /** Stream for output. */
    104     SB16OUTPUTSTREAM                   Out;
     110    SB16DRIVERSTREAM                   Out;
    105111} SB16DRIVER, *PSB16DRIVER;
     112
     113/**
     114 * Structure for a SB16 stream.
     115 */
     116typedef struct SB16STREAM
     117{
     118    /** The stream's current configuration. */
     119    PDMAUDIOSTREAMCFG                  Cfg;
     120} SB16STREAM, *PSB16STREAM;
    106121
    107122typedef struct SB16STATE
     
    183198    /** The base interface for LUN\#0. */
    184199    PDMIBASE                       IBase;
     200    /** Output stream. */
     201    SB16STREAM                     Out;
    185202
    186203    /* mixer state */
     
    189206} SB16STATE, *PSB16STATE;
    190207
     208static int sb16CreateDrvStream(PSB16STATE pThis, PPDMAUDIOSTREAMCFG pCfg, PSB16DRIVER pDrv);
     209static void sb16DestroyDrvStream(PSB16STATE pThis, PSB16DRIVER pDrv);
    191210static int sb16OpenOut(PSB16STATE pThis, PPDMAUDIOSTREAMCFG pCfg);
    192211static void sb16CloseOut(PSB16STATE pThis);
     
    204223 *
    205224 * @returns VBox status code.
    206  * @param   pDevIns     The device instance.
    207  * @param   pDrv        Driver to (re-)use for (re-)attaching to.
    208  *                      If NULL is specified, a new driver will be created and appended
    209  *                      to the driver list.
     225 * @param   pThis       SB16 state.
    210226 * @param   uLUN        The logical unit which is being detached.
    211227 * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
     228 * @param   ppDrv       Attached driver instance on success. Optional.
    212229 */
    213 static int sb16AttachInternal(PPDMDEVINS pDevIns, PSB16DRIVER pDrv, unsigned uLUN, uint32_t fFlags)
     230static int sb16AttachInternal(PSB16STATE pThis, unsigned uLUN, uint32_t fFlags, PSB16DRIVER *ppDrv)
    214231{
    215232    RT_NOREF(fFlags);
    216     PSB16STATE pThis = PDMINS_2_DATA(pDevIns, PSB16STATE);
    217233
    218234    /*
     
    224240
    225241    PPDMIBASE pDrvBase;
    226     int rc = PDMDevHlpDriverAttach(pDevIns, uLUN,
     242    int rc = PDMDevHlpDriverAttach(pThis->pDevInsR3, uLUN,
    227243                                   &pThis->IBase, &pDrvBase, pszDesc);
    228244    if (RT_SUCCESS(rc))
    229245    {
    230         if (pDrv == NULL)
    231             pDrv = (PSB16DRIVER)RTMemAllocZ(sizeof(SB16DRIVER));
     246        PSB16DRIVER pDrv = (PSB16DRIVER)RTMemAllocZ(sizeof(SB16DRIVER));
    232247        if (pDrv)
    233248        {
     
    253268                pDrv->fAttached = true;
    254269            }
     270
     271            if (ppDrv)
     272                *ppDrv = pDrv;
    255273        }
    256274        else
     
    258276    }
    259277    else if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
    260     {
    261278        LogFunc(("No attached driver for LUN #%u\n", uLUN));
    262     }
    263     else if (RT_FAILURE(rc))
    264         AssertMsgFailed(("Failed to attach SB16 LUN #%u (\"%s\"), rc=%Rrc\n",
    265                         uLUN, pszDesc, rc));
    266279
    267280    if (RT_FAILURE(rc))
     
    277290
    278291/**
    279  * Attach command.
     292 * Detach command, internal version.
    280293 *
    281  * This is called to let the device attach to a driver for a specified LUN
    282  * during runtime. This is not called during VM construction, the device
    283  * constructor has to attach to all the available drivers.
     294 * This is called to let the device detach from a driver for a specified LUN
     295 * during runtime.
    284296 *
    285297 * @returns VBox status code.
    286  * @param   pDevIns     The device instance.
    287  * @param   uLUN        The logical unit which is being detached.
     298 * @param   pThis       SB16 state.
     299 * @param   pDrv        Driver to detach device from.
    288300 * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
    289301 */
     302static int sb16DetachInternal(PSB16STATE pThis, PSB16DRIVER pDrv, uint32_t fFlags)
     303{
     304    RT_NOREF(fFlags);
     305
     306    sb16DestroyDrvStream(pThis, pDrv);
     307
     308    RTListNodeRemove(&pDrv->Node);
     309
     310    LogFunc(("uLUN=%u, fFlags=0x%x\n", pDrv->uLUN, fFlags));
     311    return VINF_SUCCESS;
     312}
     313
     314/**
     315 * @interface_method_impl{PDMDEVREG,pfnAttach}
     316 */
    290317static DECLCALLBACK(int) sb16Attach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags)
    291318{
    292     return sb16AttachInternal(pDevIns, NULL /* pDrv */, uLUN, fFlags);
    293 }
    294 
     319    PSB16STATE pThis = PDMINS_2_DATA(pDevIns, PSB16STATE);
     320
     321    LogFunc(("uLUN=%u, fFlags=0x%x\n", uLUN, fFlags));
     322
     323    PSB16DRIVER pDrv;
     324    int rc2 = sb16AttachInternal(pThis, uLUN, fFlags, &pDrv);
     325    if (RT_SUCCESS(rc2))
     326        rc2 = sb16CreateDrvStream(pThis, &pThis->Out.Cfg, pDrv);
     327
     328    return VINF_SUCCESS;
     329}
     330
     331/**
     332 * @interface_method_impl{PDMDEVREG,pfnDetach}
     333 */
    295334static DECLCALLBACK(void) sb16Detach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags)
    296335{
    297     RT_NOREF(pDevIns, uLUN, fFlags);
    298     LogFunc(("iLUN=%u, fFlags=0x%x\n", uLUN, fFlags));
     336    PSB16STATE pThis = PDMINS_2_DATA(pDevIns, PSB16STATE);
     337
     338    LogFunc(("uLUN=%u, fFlags=0x%x\n", uLUN, fFlags));
     339
     340    PSB16DRIVER pDrv, pDrvNext;
     341    RTListForEachSafe(&pThis->lstDrv, pDrv, pDrvNext, SB16DRIVER, Node)
     342    {
     343        if (pDrv->uLUN == uLUN)
     344        {
     345            int rc2 = sb16DetachInternal(pThis, pDrv, fFlags);
     346            if (RT_SUCCESS(rc2))
     347            {
     348                RTMemFree(pDrv);
     349                pDrv = NULL;
     350            }
     351
     352            break;
     353        }
     354    }
    299355}
    300356
    301357/**
    302  * Re-attach.
     358 * Re-attaches (replaces) a driver with a new driver.
    303359 *
    304360 * @returns VBox status code.
     
    308364 *                      to the driver list.
    309365 * @param   uLUN        The logical unit which is being re-detached.
    310  * @param   pszDriver   Driver name.
     366 * @param   pszDriver   New driver name to attach.
    311367 */
    312368static int sb16Reattach(PSB16STATE pThis, PSB16DRIVER pDrv, uint8_t uLUN, const char *pszDriver)
     
    314370    AssertPtrReturn(pThis,     VERR_INVALID_POINTER);
    315371    AssertPtrReturn(pszDriver, VERR_INVALID_POINTER);
     372
     373    int rc;
     374
     375    if (pDrv)
     376    {
     377        rc = sb16DetachInternal(pThis, pDrv, 0 /* fFlags */);
     378        if (RT_SUCCESS(rc))
     379            rc = PDMDevHlpDriverDetach(pThis->pDevInsR3, PDMIBASE_2_PDMDRV(pDrv->pDrvBase), 0 /* fFlags */);
     380
     381        if (RT_FAILURE(rc))
     382            return rc;
     383
     384        pDrv = NULL;
     385    }
    316386
    317387    PVM pVM = PDMDevHlpGetVM(pThis->pDevInsR3);
     
    325395    {
    326396        /* Re-use the driver instance so detach it before. */
    327         int rc = PDMDevHlpDriverDetach(pThis->pDevInsR3, PDMIBASE_2_PDMDRV(pDrv->pDrvBase), 0 /* fFlags */);
     397        rc = PDMDevHlpDriverDetach(pThis->pDevInsR3, PDMIBASE_2_PDMDRV(pDrv->pDrvBase), 0 /* fFlags */);
    328398        if (RT_FAILURE(rc))
    329399            return rc;
     
    332402#define RC_CHECK() if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; }
    333403
    334     int rc = VINF_SUCCESS;
    335404    do
    336405    {
     
    350419
    351420    if (RT_SUCCESS(rc))
    352         rc = sb16AttachInternal(pThis->pDevInsR3, pDrv, uLUN, 0 /* fFlags */);
     421        rc = sb16AttachInternal(pThis, uLUN, 0 /* fFlags */, NULL /* ppDrv */);
    353422
    354423    LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, uLUN, pszDriver, rc));
     
    477546    if (pThis->freq > 0)
    478547    {
    479         PDMAUDIOSTREAMCFG streamCfg;
    480         RT_ZERO(streamCfg);
    481 
    482         streamCfg.enmDir          = PDMAUDIODIR_OUT;
    483         streamCfg.DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT;
    484         streamCfg.enmLayout       = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
    485 
    486         streamCfg.Props.uHz       = pThis->freq;
    487         streamCfg.Props.cChannels = 1 << pThis->fmt_stereo;
    488         streamCfg.Props.cBits     = pThis->fmt_bits;
    489         streamCfg.Props.fSigned   = RT_BOOL(pThis->fmt_signed);
    490         streamCfg.Props.cShift    = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(streamCfg.Props.cBits, streamCfg.Props.cChannels);
    491 
    492         int rc = sb16OpenOut(pThis, &streamCfg);
     548        /* At the moment we only have one stream, the output stream. */
     549        PPDMAUDIOSTREAMCFG pCfg = &pThis->Out.Cfg;
     550
     551        pCfg->enmDir          = PDMAUDIODIR_OUT;
     552        pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT;
     553        pCfg->enmLayout       = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
     554
     555        pCfg->Props.uHz       = pThis->freq;
     556        pCfg->Props.cChannels = 1 << pThis->fmt_stereo;
     557        pCfg->Props.cBits     = pThis->fmt_bits;
     558        pCfg->Props.fSigned   = RT_BOOL(pThis->fmt_signed);
     559        pCfg->Props.cShift    = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels);
     560
     561        RTStrPrintf(pCfg->szName, sizeof(pCfg->szName), "Output");
     562
     563        sb16CloseOut(pThis);
     564
     565        int rc = sb16OpenOut(pThis, pCfg);
    493566        AssertRC(rc);
    494567    }
     
    619692    if (pThis->freq)
    620693    {
    621         PDMAUDIOSTREAMCFG streamCfg;
    622         RT_ZERO(streamCfg);
    623 
    624         streamCfg.enmDir          = PDMAUDIODIR_OUT;
    625         streamCfg.DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT;
    626         streamCfg.enmLayout       = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
    627 
    628         streamCfg.Props.uHz       = pThis->freq;
    629         streamCfg.Props.cChannels = 1 << pThis->fmt_stereo;
    630         streamCfg.Props.cBits     = pThis->fmt_bits;
    631         streamCfg.Props.fSigned   = RT_BOOL(pThis->fmt_signed);
    632         streamCfg.Props.cShift    = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(streamCfg.Props.cBits, streamCfg.Props.cChannels);
    633 
    634         int rc = sb16OpenOut(pThis, &streamCfg);
     694        /* At the moment we only have one stream, the output stream. */
     695        PPDMAUDIOSTREAMCFG pCfg = &pThis->Out.Cfg;
     696
     697        pCfg->enmDir          = PDMAUDIODIR_OUT;
     698        pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT;
     699        pCfg->enmLayout       = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
     700
     701        pCfg->Props.uHz       = pThis->freq;
     702        pCfg->Props.cChannels = 1 << pThis->fmt_stereo;
     703        pCfg->Props.cBits     = pThis->fmt_bits;
     704        pCfg->Props.fSigned   = RT_BOOL(pThis->fmt_signed);
     705        pCfg->Props.cShift    = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels);
     706
     707        RTStrPrintf(pCfg->szName, sizeof(pCfg->szName), "Output");
     708
     709        sb16CloseOut(pThis);
     710
     711        int rc = sb16OpenOut(pThis, pCfg);
    635712        AssertRC(rc);
    636713    }
     
    11561233    pThis->fmt_stereo = 0;
    11571234
    1158     PDMAUDIOSTREAMCFG streamCfg;
    1159     RT_ZERO(streamCfg);
    1160 
    1161     streamCfg.enmDir          = PDMAUDIODIR_OUT;
    1162     streamCfg.DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT;
    1163     streamCfg.enmLayout       = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
    1164 
    1165     streamCfg.Props.uHz       = pThis->freq;
    1166     streamCfg.Props.cChannels = 1; /* Mono */
    1167     streamCfg.Props.cBits     = 8;
    1168     streamCfg.Props.fSigned   = false;
    1169     streamCfg.Props.cShift    = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(streamCfg.Props.cBits, streamCfg.Props.cChannels);
    1170 
    1171     int rc2 = sb16OpenOut(pThis, &streamCfg);
     1235    /* At the moment we only have one stream, the output stream. */
     1236    PPDMAUDIOSTREAMCFG pCfg = &pThis->Out.Cfg;
     1237
     1238    pCfg->enmDir          = PDMAUDIODIR_OUT;
     1239    pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT;
     1240    pCfg->enmLayout       = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
     1241
     1242    pCfg->Props.uHz       = pThis->freq;
     1243    pCfg->Props.cChannels = 1; /* Mono */
     1244    pCfg->Props.cBits     = 8;
     1245    pCfg->Props.fSigned   = false;
     1246    pCfg->Props.cShift    = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels);
     1247
     1248    RTStrPrintf(pCfg->szName, sizeof(pCfg->szName), "Output");
     1249
     1250    sb16CloseOut(pThis);
     1251
     1252    int rc2 = sb16OpenOut(pThis, pCfg);
    11721253    AssertRC(rc2);
    11731254}
     
    20532134        if (pThis->freq)
    20542135        {
    2055             PDMAUDIOSTREAMCFG streamCfg;
    2056             RT_ZERO(streamCfg);
    2057 
    2058             streamCfg.enmDir          = PDMAUDIODIR_OUT;
    2059             streamCfg.DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT;
    2060             streamCfg.enmLayout       = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
    2061 
    2062             streamCfg.Props.uHz       = pThis->freq;
    2063             streamCfg.Props.cChannels = 1 << pThis->fmt_stereo;
    2064             streamCfg.Props.cBits     = pThis->fmt_bits;
    2065             streamCfg.Props.fSigned   = RT_BOOL(pThis->fmt_signed);
    2066             streamCfg.Props.cShift    = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(streamCfg.Props.cBits, streamCfg.Props.cChannels);
    2067 
    2068             int rc = sb16OpenOut(pThis, &streamCfg);
     2136            /* At the moment we only have one stream, the output stream. */
     2137            PPDMAUDIOSTREAMCFG pCfg = &pThis->Out.Cfg;
     2138
     2139            pCfg->enmDir          = PDMAUDIODIR_OUT;
     2140            pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT;
     2141            pCfg->enmLayout       = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
     2142
     2143            pCfg->Props.uHz       = pThis->freq;
     2144            pCfg->Props.cChannels = 1 << pThis->fmt_stereo;
     2145            pCfg->Props.cBits     = pThis->fmt_bits;
     2146            pCfg->Props.fSigned   = RT_BOOL(pThis->fmt_signed);
     2147            pCfg->Props.cShift    = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels);
     2148
     2149            RTStrPrintf(pCfg->szName, sizeof(pCfg->szName), "Output");
     2150
     2151            sb16CloseOut(pThis);
     2152
     2153            int rc = sb16OpenOut(pThis, pCfg);
    20692154            AssertRC(rc);
    20702155        }
     
    21482233}
    21492234
     2235/**
     2236 * Creates a PDM audio stream for a specific driver.
     2237 *
     2238 * @returns IPRT status code.
     2239 * @param   pThis               SB16 state.
     2240 * @param   pCfg                Stream configuration to use.
     2241 * @param   pDrv                Driver stream to create PDM stream for.
     2242 */
     2243static int sb16CreateDrvStream(PSB16STATE pThis, PPDMAUDIOSTREAMCFG pCfg, PSB16DRIVER pDrv)
     2244{
     2245    RT_NOREF(pThis);
     2246
     2247    AssertReturn(pCfg->enmDir == PDMAUDIODIR_OUT, VERR_INVALID_PARAMETER);
     2248    Assert(DrvAudioHlpStreamCfgIsValid(pCfg));
     2249
     2250    PPDMAUDIOSTREAMCFG pCfgHost = DrvAudioHlpStreamCfgDup(pCfg);
     2251    if (!pCfgHost)
     2252        return VERR_NO_MEMORY;
     2253
     2254    if (!RTStrPrintf(pCfgHost->szName, sizeof(pCfgHost->szName), "%s", pCfg->szName))
     2255    {
     2256        RTMemFree(pCfgHost);
     2257        return VERR_BUFFER_OVERFLOW;
     2258    }
     2259
     2260    LogFunc(("[LUN#%RU8] %s\n", pDrv->uLUN, pCfgHost->szName));
     2261
     2262    AssertMsg(pDrv->Out.pStream == NULL, ("[LUN#%RU8] Driver stream already present when it must not\n", pDrv->uLUN));
     2263
     2264    int rc = pDrv->pConnector->pfnStreamCreate(pDrv->pConnector, pCfgHost, pCfg /* pCfgGuest */, &pDrv->Out.pStream);
     2265    if (RT_SUCCESS(rc))
     2266    {
     2267        pDrv->pConnector->pfnStreamRetain(pDrv->pConnector, pDrv->Out.pStream);
     2268        LogFlowFunc(("LUN#%RU8: Created output \"%s\", rc=%Rrc\n", pDrv->uLUN, pCfg->szName, rc));
     2269    }
     2270
     2271    if (pCfgHost)
     2272    {
     2273        RTMemFree(pCfgHost);
     2274        pCfgHost = NULL;
     2275    }
     2276
     2277    return rc;
     2278}
     2279
     2280/**
     2281 * Destroys a PDM audio stream of a specific driver.
     2282 *
     2283 * @param   pThis               SB16 state.
     2284 * @param   pDrv                Driver stream to destroy PDM stream for.
     2285 */
     2286static void sb16DestroyDrvStream(PSB16STATE pThis, PSB16DRIVER pDrv)
     2287{
     2288    AssertPtrReturnVoid(pThis);
     2289    AssertPtrReturnVoid(pDrv);
     2290
     2291    if (pDrv->Out.pStream)
     2292    {
     2293        pDrv->pConnector->pfnStreamRelease(pDrv->pConnector, pDrv->Out.pStream);
     2294
     2295        int rc2 = pDrv->pConnector->pfnStreamDestroy(pDrv->pConnector, pDrv->Out.pStream);
     2296        if (RT_SUCCESS(rc2))
     2297            pDrv->Out.pStream = NULL;
     2298    }
     2299}
     2300
    21502301static int sb16OpenOut(PSB16STATE pThis, PPDMAUDIOSTREAMCFG pCfg)
    21512302{
     
    21552306    LogFlowFuncEnter();
    21562307
    2157     AssertReturn(pCfg->enmDir == PDMAUDIODIR_OUT, VERR_INVALID_PARAMETER);
    2158     Assert(DrvAudioHlpStreamCfgIsValid(pCfg));
    2159 
    2160     /* Set a default audio format for the host. */
    2161     PDMAUDIOSTREAMCFG CfgHost;
    2162     RT_ZERO(CfgHost);
    2163 
    2164     CfgHost.enmDir          = PDMAUDIODIR_OUT;
    2165     CfgHost.DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT;
    2166     CfgHost.enmLayout       = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
    2167 
    2168     CfgHost.Props.uHz       = pCfg->Props.uHz;
    2169     CfgHost.Props.cChannels = pCfg->Props.cChannels;
    2170     CfgHost.Props.cBits     = pCfg->Props.cBits;
    2171     CfgHost.Props.fSigned   = pCfg->Props.fSigned;
    2172     CfgHost.Props.cShift    = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(CfgHost.Props.cBits, CfgHost.Props.cChannels);
    2173 
    2174     RTStrPrintf(CfgHost.szName, sizeof(CfgHost.szName), "Output");
    2175 
    2176     uint8_t uLUN = 0;
     2308    if (!DrvAudioHlpStreamCfgIsValid(pCfg))
     2309        return VERR_INVALID_PARAMETER;
    21772310
    21782311    int rc = VINF_SUCCESS;
     
    21812314    RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node)
    21822315    {
    2183         if (!RTStrPrintf(pCfg->szName, sizeof(pCfg->szName), "%s", CfgHost.szName))
    2184         {
    2185             rc = VERR_BUFFER_OVERFLOW;
    2186             break;
    2187         }
    2188 
    2189         int rc2;
    2190 
    2191         if (pDrv->Out.pStream)
    2192         {
    2193             pDrv->pConnector->pfnStreamRelease(pDrv->pConnector, pDrv->Out.pStream);
    2194 
    2195             rc2 = pDrv->pConnector->pfnStreamDestroy(pDrv->pConnector, pDrv->Out.pStream);
    2196             if (RT_SUCCESS(rc2))
    2197                 pDrv->Out.pStream = NULL;
    2198         }
    2199         else
    2200             rc2 = VINF_SUCCESS;
    2201 
    2202         if (RT_SUCCESS(rc2))
    2203         {
    2204             rc2 = pDrv->pConnector->pfnStreamCreate(pDrv->pConnector, &CfgHost, pCfg, &pDrv->Out.pStream);
    2205             if (RT_SUCCESS(rc2))
    2206                 pDrv->pConnector->pfnStreamRetain(pDrv->pConnector, pDrv->Out.pStream);
    2207         }
    2208 
    2209         LogFlowFunc(("LUN#%RU8: Created output \"%s\", rc=%Rrc\n", pDrv->uLUN, pCfg->szName, rc2));
    2210 
    2211         uLUN++;
     2316        int rc2 = sb16CreateDrvStream(pThis, pCfg, pDrv);
     2317        if (RT_SUCCESS(rc))
     2318            rc = rc2;
    22122319    }
    22132320
     
    22242331    PSB16DRIVER pDrv;
    22252332    RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node)
    2226     {
    2227         int rc2 = pDrv->pConnector->pfnStreamControl(pDrv->pConnector, pDrv->Out.pStream, PDMAUDIOSTREAMCMD_DISABLE);
    2228         AssertRC(rc2);
    2229     }
     2333        sb16DestroyDrvStream(pThis, pDrv);
    22302334
    22312335    LogFlowFuncLeave();
     
    24452549    {
    24462550        LogFunc(("Trying to attach driver for LUN #%RU8 ...\n", uLUN));
    2447         rc = sb16AttachInternal(pDevIns, NULL /* pDrv */, uLUN, 0 /* fFlags */);
     2551        rc = sb16AttachInternal(pThis, uLUN, 0 /* fFlags */, NULL /* ppDrv */);
    24482552        if (RT_FAILURE(rc))
    24492553        {
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