VirtualBox

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


Ignore:
Timestamp:
Dec 3, 2019 11:27:10 AM (5 years ago)
Author:
vboxsync
Message:

DevIchAc97: Cleanups. bugref:9218

File:
1 edited

Legend:

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

    r82340 r82343  
    143143/** @} */
    144144
    145 /* AC'97 uses 1.5dB steps, we use 0.375dB steps: 1 AC'97 step equals 4 PDM steps. */
     145/** AC'97 uses 1.5dB steps, we use 0.375dB steps: 1 AC'97 step equals 4 PDM steps. */
    146146#define AC97_DB_FACTOR                  4
    147147
     
    265265*   Structures and Typedefs                                                                                                      *
    266266*********************************************************************************************************************************/
     267/** The ICH AC'97 (Intel) controller. */
     268typedef struct AC97STATE *PAC97STATE;
    267269
    268270/**
     
    301303#ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO
    302304/**
    303  * Structure keeping the AC'97 stream's state for asynchronous I/O.
     305 * Asynchronous I/O state for an AC'97 stream.
    304306 */
    305307typedef struct AC97STREAMSTATEAIO
     
    318320    volatile bool           fEnabled;
    319321    bool                    afPadding[5];
    320 } AC97STREAMSTATEAIO, *PAC97STREAMSTATEAIO;
     322} AC97STREAMSTATEAIO;
     323/** Pointer to the async I/O state for an AC'97 stream. */
     324typedef AC97STREAMSTATEAIO *PAC97STREAMSTATEAIO;
    321325#endif
    322326
    323 /** The ICH AC'97 (Intel) controller. */
    324 typedef struct AC97STATE *PAC97STATE;
    325 
    326 /**
    327  * Structure for keeping the internal state of an AC'97 stream.
     327
     328/**
     329 * The internal state of an AC'97 stream.
    328330 */
    329331typedef struct AC97STREAMSTATE
     
    367369
    368370/**
    369  * Structure containing AC'97 stream debug stuff, configurable at runtime.
    370  */
    371 typedef struct AC97STREAMDBGINFORT
     371 * Runtime configurable debug stuff for an AC'97 stream.
     372 */
     373typedef struct AC97STREAMDEBUGRT
    372374{
    373375    /** Whether debugging is enabled or not. */
     
    382384     *  whereas for output streams this dumps data being read from the device DMA. */
    383385    R3PTRTYPE(PPDMAUDIOFILE) pFileDMA;
    384 } AC97STREAMDBGINFORT, *PAC97STREAMDBGINFORT;
    385 
    386 /**
    387  * Structure containing AC'97 stream debug information.
    388  */
    389 typedef struct AC97STREAMDBGINFO
    390 {
    391     /** Runtime debug info. */
    392     AC97STREAMDBGINFORT      Runtime;
    393 } AC97STREAMDBGINFO ,*PAC97STREAMDBGINFO;
    394 
    395 /**
    396  * Structure for an AC'97 stream.
     386} AC97STREAMDEBUGRT;
     387
     388/**
     389 * Debug stuff for an AC'97 stream.
     390 */
     391typedef struct AC97STREAMDEBUG
     392{
     393    /** Runtime debug stuff. */
     394    AC97STREAMDEBUGRT       Runtime;
     395} AC97STREAMDEBUG;
     396
     397/**
     398 * An AC'97 stream.
    397399 */
    398400typedef struct AC97STREAM
     
    410412    uint32_t              Padding1;
    411413#endif
    412     /** Debug information. */
    413     AC97STREAMDBGINFO     Dbg;
    414 } AC97STREAM, *PAC97STREAM;
     414    /** Debug stuff. */
     415    AC97STREAMDEBUG         Dbg;
     416} AC97STREAM;
    415417AssertCompileSizeAlignment(AC97STREAM, 8);
    416418/** Pointer to an AC'97 stream (registers + state). */
     
    420422#ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO
    421423/**
    422  * Structure for the async I/O thread context.
     424 * Asynchronous I/O thread context (arguments).
    423425 */
    424426typedef struct AC97STREAMTHREADCTX
     
    426428    PAC97STATE  pThis;
    427429    PAC97STREAM pStream;
    428 } AC97STREAMTHREADCTX, *PAC97STREAMTHREADCTX;
     430} AC97STREAMTHREADCTX;
     431/** Pointer to the context for an async I/O thread. */
     432typedef AC97STREAMTHREADCTX *PAC97STREAMTHREADCTX;
    429433#endif
    430434
    431435/**
    432  * Structure defining a (host backend) driver stream.
     436 * A driver stream (host backend).
     437 *
    433438 * Each driver has its own instances of audio mixer streams, which then
    434439 * can go into the same (or even different) audio mixer sinks.
     
    438443    /** Associated mixer stream handle. */
    439444    R3PTRTYPE(PAUDMIXSTREAM)           pMixStrm;
    440 } AC97DRIVERSTREAM, *PAC97DRIVERSTREAM;
    441 
    442 /**
    443  * Struct for maintaining a host backend driver.
     445} AC97DRIVERSTREAM;
     446/** Pointer to a driver stream. */
     447typedef AC97DRIVERSTREAM *PAC97DRIVERSTREAM;
     448
     449/**
     450 * A host backend driver (LUN).
    444451 */
    445452typedef struct AC97DRIVER
     
    468475    /** Driver stream for output. */
    469476    AC97DRIVERSTREAM                   Out;
    470 } AC97DRIVER, *PAC97DRIVER;
    471 
    472 typedef struct AC97STATEDBGINFO
     477} AC97DRIVER;
     478/** Pointer to a host backend driver (LUN). */
     479typedef AC97DRIVER *PAC97DRIVER;
     480
     481/**
     482 * Debug settings.
     483 */
     484typedef struct AC97STATEDEBUG
    473485{
    474486    /** Whether debugging is enabled or not. */
     
    476488    /** Path where to dump the debug output to.
    477489     *  Defaults to VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH. */
    478     char                               szOutPath[RTPATH_MAX + 1];
    479 } AC97STATEDBGINFO, *PAC97STATEDBGINFO;
    480 
    481 /**
    482  * Structure for maintaining an AC'97 device state.
     490    char                               szOutPath[RTPATH_MAX];
     491} AC97STATEDEBUG;
     492
     493
     494/**
     495 * The shared AC'97 device state.
    483496 */
    484497typedef struct AC97STATE
     
    524537    /** The base interface for LUN\#0. */
    525538    PDMIBASE                IBase;
    526     AC97STATEDBGINFO        Dbg;
     539    /** Debug settings. */
     540    AC97STATEDEBUG          Dbg;
    527541
    528542    /** PCI region \#0: NAM I/O ports. */
     
    540554} AC97STATE;
    541555AssertCompileMemberAlignment(AC97STATE, aStreams, 8);
    542 /** Pointer to a AC'97 state. */
    543 typedef AC97STATE *PAC97STATE;
     556
    544557
    545558/**
     
    633646
    634647# ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO
    635 static DECLCALLBACK(int)  ichac97R3StreamAsyncIOThread(RTTHREAD hThreadSelf, void *pvUser);
    636648static int                ichac97R3StreamAsyncIOCreate(PAC97STATE pThis, PAC97STREAM pStream);
    637649static int                ichac97R3StreamAsyncIODestroy(PAC97STATE pThis, PAC97STREAM pStream);
     
    952964            RTStrPrintf(szFile, sizeof(szFile), "ac97StreamReadSD%RU8", pStream->u8SD);
    953965
    954         char szPath[RTPATH_MAX + 1];
     966        char szPath[RTPATH_MAX];
    955967        int rc2 = DrvAudioHlpFileNameGet(szPath, sizeof(szPath), pThis->Dbg.szOutPath, szFile,
    956968                                         0 /* uInst */, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAGS_NONE);
     
    12071219    RTThreadUserSignal(hThreadSelf);
    12081220
     1221    /** @todo r=bird: What wasn't mentioned by the original author of this
     1222     *        code, is that pCtx is now invalid as it must be assumed to be out
     1223     *        of scope in the parent thread.  It is a 'ing stack object! */
     1224
    12091225    LogFunc(("[SD%RU8] Started\n", pStream->u8SD));
    12101226
     
    12691285            if (RT_SUCCESS(rc))
    12701286            {
     1287/** @todo r=bird: Why is Ctx on the stack?  There is no mention of this in
     1288 *        the thread structure.  Besides, you only wait 10seconds, if the
     1289 *        host is totally overloaded, it may go out of scope before the new
     1290 *        thread has finished with it and it will like crash and burn.
     1291 *
     1292 *        Also, there is RTThreadCreateF for giving threads complicated
     1293 *        names.
     1294 *
     1295 *        Why aren't this code using the PDM threads (PDMDevHlpThreadCreate)?
     1296 *        They would help you with managing stuff like VM suspending, resuming
     1297 *        and powering off.
     1298 *
     1299 *        Finally, just create the threads at construction time. */
    12711300                AC97STREAMTHREADCTX Ctx = { pThis, pStream };
     1301# error "Busted code! Do not pass a structure living on the parent stack to the poor thread!"
    12721302
    12731303                char szThreadName[64];
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