VirtualBox

Changeset 61706 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Jun 15, 2016 9:59:40 AM (9 years ago)
Author:
vboxsync
Message:

Audio/DrvHostCoreAudio.cpp: Implemented device state changed listener, fixed a warning, logging changes.

File:
1 edited

Legend:

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

    r61698 r61706  
    123123
    124124    /* First try to set the new frame buffer size. */
    125     OSStatus err = AudioObjectSetPropertyData(deviceID, &propAdr, NULL, 0, sizeof(cReqSize), &cReqSize);
     125    OSStatus err = AudioObjectSetPropertyData(deviceID, &propAdr, 0, NULL, sizeof(cReqSize), &cReqSize);
    126126
    127127    /* Check if it really was set. */
     
    262262static const OSStatus caConverterEOFDErr = 0x656F6664; /* 'eofd' */
    263263
     264/* Prototypes needed for COREAUDIOSTREAMCBCTX. */
     265struct COREAUDIOSTREAMIN;
     266typedef struct COREAUDIOSTREAMIN *PCOREAUDIOSTREAMIN;
     267struct COREAUDIOSTREAMOUT;
     268typedef struct COREAUDIOSTREAMOUT *PCOREAUDIOSTREAMOUT;
     269
     270/**
     271 * Simple structure for maintaining a stream's callback context.
     272 ** @todo Remove this as soon as we have unified input/output streams in this backend.
     273 */
     274typedef struct COREAUDIOSTREAMCBCTX
     275{
     276    /** The stream's direction. */
     277    PDMAUDIODIR             enmDir;
     278    union
     279    {
     280        /** Pointer to self, if it's an input stream. */
     281        PCOREAUDIOSTREAMIN  pIn;
     282        /** Pointer to self, if it's an output stream. */
     283        PCOREAUDIOSTREAMOUT pOut;
     284    };
     285} COREAUDIOSTREAMCBCTX, *PCOREAUDIOSTREAMCBCTX;
     286
     287/** @todo Unify COREAUDIOSTREAMOUT / COREAUDIOSTREAMIN. */
    264288typedef struct COREAUDIOSTREAMOUT
    265289{
     
    282306    /** Flag whether the "default device changed" listener was registered. */
    283307    bool                        fDefDevChgListReg;
     308    /** Flag whether the "device state changed" listener was registered. */
     309    bool                        fDevStateChgListReg;
     310    /** Callback context for this stream for handing this stream in to
     311     *  a CoreAudio callback.
     312     ** @todo Remove this as soon as we have unified input/output streams in this backend. */
     313    COREAUDIOSTREAMCBCTX        cbCtx;
    284314} COREAUDIOSTREAMOUT, *PCOREAUDIOSTREAMOUT;
    285315
     
    312342    /** Flag whether the "default device changed" listener was registered. */
    313343    bool                        fDefDevChgListReg;
     344    /** Flag whether the "device state changed" listener was registered. */
     345    bool                        fDevStateChgListReg;
     346    /** Callback context for this stream for handing this stream in to
     347     *  a CoreAudio callback.
     348     ** @todo Remove this as soon as we have unified input/output streams in this backend. */
     349    COREAUDIOSTREAMCBCTX        cbCtx;
    314350} COREAUDIOSTREAMIN, *PCOREAUDIOSTREAMIN;
    315351
     
    327363static int coreAudioDestroyStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream);
    328364
    329 /* Callback for getting notified when the default input/output device has been changed. */
     365static DECLCALLBACK(OSStatus) drvHostCoreAudioDeviceStateChanged(AudioObjectID propertyID,
     366                                                                 UInt32 nAddresses,
     367                                                                 const AudioObjectPropertyAddress properties[],
     368                                                                 void *pvUser)
     369{
     370    PCOREAUDIOSTREAMCBCTX pCbCtx = (PCOREAUDIOSTREAMCBCTX)pvUser;
     371
     372    LogFlowFunc(("propertyID=%u nAddresses=%u pvUser=%p\n", propertyID, nAddresses, pvUser));
     373
     374    UInt32 uAlive = 1;
     375    UInt32 uSize  = sizeof(UInt32);
     376
     377    AudioObjectPropertyAddress propAdr = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal,
     378                                           kAudioObjectPropertyElementMaster };
     379
     380    AudioDeviceID deviceID = pCbCtx->enmDir == PDMAUDIODIR_IN
     381                           ? pCbCtx->pIn->deviceID : pCbCtx->pOut->deviceID;
     382
     383    OSStatus err = AudioObjectGetPropertyData(deviceID, &propAdr, 0, NULL, &uSize, &uAlive);
     384
     385    bool fIsDead = false;
     386
     387    if (err == kAudioHardwareBadDeviceError)
     388        fIsDead = true; /* Unplugged. */
     389    else if ((err == kAudioHardwareNoError) && (!RT_BOOL(uAlive)))
     390        fIsDead = true; /* Something else happened. */
     391
     392    if (fIsDead)
     393    {
     394        switch (pCbCtx->enmDir)
     395        {
     396            case PDMAUDIODIR_IN:
     397            {
     398                PCOREAUDIOSTREAMIN pStreamIn = pCbCtx->pIn;
     399
     400                /* We move the reinitialization to the next output event.
     401                 * This make sure this thread isn't blocked and the
     402                 * reinitialization is done when necessary only. */
     403                ASMAtomicXchgU32(&pStreamIn->status, CA_STATUS_REINIT);
     404
     405                LogRel(("CoreAudio: Capturing device stopped functioning\n"));
     406                break;
     407            }
     408
     409            case PDMAUDIODIR_OUT:
     410            {
     411                PCOREAUDIOSTREAMOUT pStreamOut = pCbCtx->pOut;
     412
     413                /* We move the reinitialization to the next output event.
     414                 * This make sure this thread isn't blocked and the
     415                 * reinitialization is done when necessary only. */
     416                ASMAtomicXchgU32(&pStreamOut->status, CA_STATUS_REINIT);
     417
     418                LogRel(("CoreAudio: Playback device stopped functioning\n"));
     419                break;
     420            }
     421
     422            default:
     423                AssertMsgFailed(("Not implemented\n"));
     424                break;
     425        }
     426    }
     427
     428    return noErr;
     429}
     430
     431/* Callback for getting notified when the default recording/playback device has been changed. */
    330432static DECLCALLBACK(OSStatus) coreAudioDefaultDeviceChanged(AudioObjectID propertyID,
    331433                                                            UInt32 nAddresses,
     
    357459                    if (pStreamIn->deviceID != uResp)
    358460                    {
    359                         LogRel(("CoreAudio: Default input device has changed\n"));
     461                        LogRel(("CoreAudio: Default recording device has changed\n"));
    360462
    361463                        /* We move the reinitialization to the next input event.
     
    385487                    if (pStreamOut->deviceID != uResp)
    386488                    {
    387                         LogRel(("CoreAudio: Default output device has changed\n"));
     489                        LogRel(("CoreAudio: Default playback device has changed\n"));
    388490
    389491                        /* We move the reinitialization to the next input event.
     
    722824    if (pStreamIn->deviceID == kAudioDeviceUnknown)
    723825    {
    724         /* Fetch the default audio input device currently in use. */
     826        /* Fetch the default audio recording device currently in use. */
    725827        AudioObjectPropertyAddress propAdr = { kAudioHardwarePropertyDefaultInputDevice,
    726828                                               kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
     
    729831        if (err != noErr)
    730832        {
    731             LogRel(("CoreAudio: Unable to determine default input device (%RI32)\n", err));
     833            LogRel(("CoreAudio: Unable to determine default recording device (%RI32)\n", err));
    732834            return VERR_NOT_FOUND;
    733835        }
     
    735837
    736838    /*
    737      * Try to get the name of the input device and log it. It's not fatal if it fails.
     839     * Try to get the name of the recording device and log it. It's not fatal if it fails.
    738840     */
    739841    CFStringRef strTemp;
     
    761863                {
    762864                    CFRelease(strTemp);
    763                     LogRel(("CoreAudio: Using input device: %s (UID: %s)\n", pszDevName, pszUID));
     865                    LogRel(("CoreAudio: Using recording device: %s (UID: %s)\n", pszDevName, pszUID));
    764866
    765867                    RTMemFree(pszUID);
     
    773875    {
    774876        /* This is not fatal, can happen for some Macs. */
    775         LogRel2(("CoreAudio: Unable to determine input device name (%RI32)\n", err));
     877        LogRel2(("CoreAudio: Unable to determine recording device name (%RI32)\n", err));
    776878    }
    777879
     
    784886    if (err != noErr)
    785887    {
    786         /* Can happen if no input device is available by default. Happens on some Macs,
     888        /* Can happen if no recording device is available by default. Happens on some Macs,
    787889         * so don't log this by default to not scare people. */
    788         LogRel2(("CoreAudio: Failed to determine frame buffer size of the audio input device (%RI32)\n", err));
     890        LogRel2(("CoreAudio: Failed to determine frame buffer size of the audio recording device (%RI32)\n", err));
    789891        return VERR_AUDIO_BACKEND_INIT_FAILED;
    790892    }
     
    794896    if (err != noErr)
    795897    {
    796         LogRel(("CoreAudio: Failed to set frame buffer size for the audio input device (%RI32)\n", err));
     898        LogRel(("CoreAudio: Failed to set frame buffer size for the audio recording device (%RI32)\n", err));
    797899        return VERR_AUDIO_BACKEND_INIT_FAILED;
    798900    }
     
    842944    }
    843945
    844     /* Set the default audio input device as the device for the new AudioUnit. */
     946    /* Set the default audio recording device as the device for the new AudioUnit. */
    845947    err = AudioUnitSetProperty(pStreamIn->audioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global,
    846948                               0, &pStreamIn->deviceID, sizeof(pStreamIn->deviceID));
     
    881983    coreAudioPCMInfoToASBDesc(&pStreamIn->Stream.Props, &pStreamIn->streamFormat);
    882984
    883     coreAudioPrintASBDesc("CoreAudio: Input device", &pStreamIn->deviceFormat);
     985    coreAudioPrintASBDesc("CoreAudio: recording device", &pStreamIn->deviceFormat);
    884986    coreAudioPrintASBDesc("CoreAudio: Input stream", &pStreamIn->streamFormat);
    885987
     
    9891091    if (err != noErr)
    9901092    {
    991         LogRel(("CoreAudio: Failed to get input device format (%RI32)\n", err));
     1093        LogRel(("CoreAudio: Failed to get recording device format (%RI32)\n", err));
    9921094        return VERR_AUDIO_BACKEND_INIT_FAILED;
    9931095    }
     
    10671169    if (RT_SUCCESS(rc))
    10681170    {
     1171        /* Set callback context. */
     1172        pStreamIn->cbCtx.enmDir = PDMAUDIODIR_IN;
     1173        pStreamIn->cbCtx.pIn    = pStreamIn;
     1174
    10691175        ASMAtomicXchgU32(&pStreamIn->status, CA_STATUS_INIT);
    10701176
     
    10991205    if (pStreamOut->deviceID == kAudioDeviceUnknown)
    11001206    {
    1101         /* Fetch the default audio input device currently in use. */
     1207        /* Fetch the default audio recording device currently in use. */
    11021208        AudioObjectPropertyAddress propAdr = { kAudioHardwarePropertyDefaultOutputDevice,
    11031209                                               kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
     
    11061212        if (err != noErr)
    11071213        {
    1108             LogRel(("CoreAudio: Unable to determine default output device (%RI32)\n", err));
     1214            LogRel(("CoreAudio: Unable to determine default playback device (%RI32)\n", err));
    11091215            return VERR_NOT_FOUND;
    11101216        }
     
    11121218
    11131219    /*
    1114      * Try to get the name of the output device and log it. It's not fatal if it fails.
     1220     * Try to get the name of the playback device and log it. It's not fatal if it fails.
    11151221     */
    11161222    CFStringRef strTemp;
     
    11381244                {
    11391245                    CFRelease(strTemp);
    1140                     LogRel(("CoreAudio: Using output device: %s (UID: %s)\n", pszDevName, pszUID));
     1246                    LogRel(("CoreAudio: Using playback device: %s (UID: %s)\n", pszDevName, pszUID));
    11411247
    11421248                    RTMemFree(pszUID);
     
    11481254    }
    11491255    else
    1150         LogRel(("CoreAudio: Unable to determine output device name (%RI32)\n", err));
     1256        LogRel(("CoreAudio: Unable to determine playback device name (%RI32)\n", err));
    11511257
    11521258    /* Get the default frames buffer size, so that we can setup our internal buffers. */
     
    11581264    if (err != noErr)
    11591265    {
    1160         LogRel(("CoreAudio: Failed to determine frame buffer size of the audio output device (%RI32)\n", err));
     1266        LogRel(("CoreAudio: Failed to determine frame buffer size of the audio playback device (%RI32)\n", err));
    11611267        return VERR_AUDIO_BACKEND_INIT_FAILED;
    11621268    }
     
    11661272    if (err != noErr)
    11671273    {
    1168         LogRel(("CoreAudio: Failed to set frame buffer size for the audio output device (%RI32)\n", err));
     1274        LogRel(("CoreAudio: Failed to set frame buffer size for the audio playback device (%RI32)\n", err));
    11691275        return VERR_AUDIO_BACKEND_INIT_FAILED;
    11701276    }
     
    12021308    }
    12031309
    1204     /* Set the default audio output device as the device for the new AudioUnit. */
     1310    /* Set the default audio playback device as the device for the new AudioUnit. */
    12051311    err = AudioUnitSetProperty(pStreamOut->audioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global,
    12061312                               0, &pStreamOut->deviceID, sizeof(pStreamOut->deviceID));
     
    12411347    coreAudioPCMInfoToASBDesc(&pStreamOut->Stream.Props, &pStreamOut->streamFormat);
    12421348
    1243     coreAudioPrintASBDesc("CoreAudio: Output device", &pStreamOut->deviceFormat);
     1349    coreAudioPrintASBDesc("CoreAudio: playback device", &pStreamOut->deviceFormat);
    12441350    coreAudioPrintASBDesc("CoreAudio: Output format", &pStreamOut->streamFormat);
    12451351
     
    13491455    if (RT_SUCCESS(rc))
    13501456    {
     1457        /* Set callback context. */
     1458        pStreamOut->cbCtx.enmDir = PDMAUDIODIR_OUT;
     1459        pStreamOut->cbCtx.pOut   = pStreamOut;
     1460
    13511461        ASMAtomicXchgU32(&pStreamOut->status, CA_STATUS_INIT);
    13521462
     
    18091919
    18101920        /*
    1811          * Unregister input device callbacks.
     1921         * Unregister recording device callbacks.
    18121922         */
    18131923        AudioObjectPropertyAddress propAdr = { kAudioDeviceProcessorOverload, kAudioObjectPropertyScopeGlobal,
     
    18181928        /* Not Fatal */
    18191929        if (RT_UNLIKELY(err != noErr))
    1820             LogRel(("CoreAudio: Failed to remove the processor overload listener (%RI32)\n", err));
     1930            LogRel(("CoreAudio: Failed to remove the recording processor overload listener (%RI32)\n", err));
    18211931#endif /* DEBUG */
    18221932
     
    18261936        /* Not Fatal */
    18271937        if (RT_UNLIKELY(err != noErr))
    1828             LogRel(("CoreAudio: Failed to remove the sample rate changed listener (%RI32)\n", err));
     1938            LogRel(("CoreAudio: Failed to remove the recording sample rate changed listener (%RI32)\n", err));
    18291939
    18301940        if (pStreamIn->fDefDevChgListReg)
     
    18381948            }
    18391949            else
    1840                 LogRel(("CoreAudio: [Output] Failed to remove the default input device changed listener (%RI32)\n", err));
     1950                LogRel(("CoreAudio: Failed to remove the default recording device changed listener (%RI32)\n", err));
     1951        }
     1952
     1953        if (pStreamIn->fDevStateChgListReg)
     1954        {
     1955            AudioObjectPropertyAddress propAdr2 = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal,
     1956                                                    kAudioObjectPropertyElementMaster };
     1957            err = AudioObjectRemovePropertyListener(pStreamIn->deviceID, &propAdr2,
     1958                                                    drvHostCoreAudioDeviceStateChanged, &pStreamIn->cbCtx);
     1959            if (RT_LIKELY(err == noErr))
     1960            {
     1961                pStreamIn->fDevStateChgListReg = false;
     1962            }
     1963            else
     1964                LogRel(("CoreAudio: Failed to remove the recording device state changed listener (%RI32)\n", err));
    18411965        }
    18421966
     
    18671991            else
    18681992            {
    1869                 LogRel(("CoreAudio: Failed to close the AudioUnit (%RI32)\n", err));
     1993                LogRel(("CoreAudio: Failed to close the recording unit (%RI32)\n", err));
    18701994                rc = VERR_GENERAL_FAILURE; /** @todo Fudge! */
    18711995            }
     
    18731997        else
    18741998        {
    1875             LogRel(("CoreAudio: Failed to uninitialize the AudioUnit (%RI32)\n", err));
     1999            LogRel(("CoreAudio: Failed to uninitialize the recording unit (%RI32)\n", err));
    18762000            rc = VERR_GENERAL_FAILURE; /** @todo Fudge! */
    18772001        }
     
    19202044        /* Not Fatal */
    19212045        if (RT_UNLIKELY(err != noErr))
    1922             LogRel(("CoreAudio: Failed to remove the processor overload listener (%RI32)\n", err));
     2046            LogRel(("CoreAudio: Failed to remove the playback processor overload listener (%RI32)\n", err));
    19232047#endif /* DEBUG */
    19242048
     
    19282052        /* Not Fatal */
    19292053        if (RT_UNLIKELY(err != noErr))
    1930             LogRel(("CoreAudio: Failed to remove the sample rate changed listener (%RI32)\n", err));
     2054            LogRel(("CoreAudio: Failed to remove the playback sample rate changed listener (%RI32)\n", err));
    19312055
    19322056        if (pStreamOut->fDefDevChgListReg)
     
    19422066            }
    19432067            else
    1944                 LogRel(("CoreAudio: [Output] Failed to remove the default playback device changed listener (%RI32)\n", err));
     2068                LogRel(("CoreAudio: Failed to remove the default playback device changed listener (%RI32)\n", err));
     2069        }
     2070
     2071        if (pStreamOut->fDevStateChgListReg)
     2072        {
     2073            AudioObjectPropertyAddress propAdr2 = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal,
     2074                                                    kAudioObjectPropertyElementMaster };
     2075            err = AudioObjectRemovePropertyListener(pStreamOut->deviceID, &propAdr2,
     2076                                                    drvHostCoreAudioDeviceStateChanged, &pStreamOut->cbCtx);
     2077            if (RT_LIKELY(err == noErr))
     2078            {
     2079                pStreamOut->fDevStateChgListReg = false;
     2080            }
     2081            else
     2082                LogRel(("CoreAudio: Failed to remove the playback device state changed listener (%RI32)\n", err));
    19452083        }
    19462084
     
    19622100            }
    19632101            else
    1964                 LogRel(("CoreAudio: Failed to close the AudioUnit (%RI32)\n", err));
     2102                LogRel(("CoreAudio: Failed to close the playback unit (%RI32)\n", err));
    19652103        }
    19662104        else
    1967             LogRel(("CoreAudio: Failed to uninitialize the AudioUnit (%RI32)\n", err));
     2105            LogRel(("CoreAudio: Failed to uninitialize the playback unit (%RI32)\n", err));
    19682106    }
    19692107    else
     
    19902128    pStreamIn->status                    = CA_STATUS_UNINIT;
    19912129    pStreamIn->fDefDevChgListReg         = false;
     2130    pStreamIn->fDevStateChgListReg       = false;
    19922131
    19932132    bool fDeviceByUser = false; /* Do we use a device which was set by the user? */
     
    20042143            /* Not fatal */
    20052144            if (pStreamIn->deviceID == kAudioDeviceUnknown)
    2006                 LogRel(("CoreAudio: Unable to find input device %s. Falling back to the default audio device. \n", DeviceUID.pszInputDeviceUID));
     2145                LogRel(("CoreAudio: Unable to find recording device %s. Falling back to the default audio device. \n", DeviceUID.pszInputDeviceUID));
    20072146            else
    20082147                fDeviceByUser = true;
     
    20142153    if (RT_SUCCESS(rc))
    20152154    {
     2155        OSStatus err;
     2156
    20162157        /* When the devices isn't forced by the user, we want default device change notifications. */
    20172158        if (!fDeviceByUser)
     
    20192160            AudioObjectPropertyAddress propAdr = { kAudioHardwarePropertyDefaultInputDevice, kAudioObjectPropertyScopeGlobal,
    20202161                                                   kAudioObjectPropertyElementMaster };
    2021             OSStatus err = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &propAdr,
    2022                                                           coreAudioDefaultDeviceChanged, (void *)pStreamIn);
     2162            err = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &propAdr,
     2163                                                 coreAudioDefaultDeviceChanged, (void *)pStreamIn);
    20232164            /* Not fatal. */
    20242165            if (RT_LIKELY(err == noErr))
     
    20272168            }
    20282169            else
    2029                 LogRel(("CoreAudio: Failed to add the default input device changed listener (%RI32)\n", err));
    2030         }
     2170                LogRel(("CoreAudio: Failed to add the default recording device changed listener (%RI32)\n", err));
     2171        }
     2172
     2173        /* Register callback for being notified if the device stops being alive. */
     2174        AudioObjectPropertyAddress propAdr = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal,
     2175                                               kAudioObjectPropertyElementMaster };
     2176        err = AudioObjectAddPropertyListener(pStreamIn->deviceID, &propAdr, drvHostCoreAudioDeviceStateChanged,
     2177                                             (void *)&pStreamIn->cbCtx);
     2178        /* Not fatal. */
     2179        if (RT_LIKELY(err == noErr))
     2180        {
     2181            pStreamIn->fDevStateChgListReg = true;
     2182        }
     2183        else
     2184            LogRel(("CoreAudio: Failed to add the recording device state changed listener (%RI32)\n", err));
    20312185    }
    20322186
     
    20482202    pStreamOut->status                    = CA_STATUS_UNINIT;
    20492203    pStreamOut->fDefDevChgListReg         = false;
     2204    pStreamOut->fDevStateChgListReg       = false;
    20502205
    20512206    bool fDeviceByUser = false; /* Do we use a device which was set by the user? */
     
    20642219            /* Not fatal */
    20652220            if (pStreamOut->audioDeviceId == kAudioDeviceUnknown)
    2066                 LogRel(("CoreAudio: Unable to find output device %s. Falling back to the default audio device. \n", DeviceUID.pszOutputDeviceUID));
     2221                LogRel(("CoreAudio: Unable to find playback device %s. Falling back to the default audio device. \n", DeviceUID.pszOutputDeviceUID));
    20672222            else
    20682223                fDeviceByUser = true;
     
    20742229    if (RT_SUCCESS(rc))
    20752230    {
     2231        OSStatus err;
     2232
    20762233        /* When the devices isn't forced by the user, we want default device change notifications. */
    20772234        if (!fDeviceByUser)
     
    20792236            AudioObjectPropertyAddress propAdr = { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal,
    20802237                                                   kAudioObjectPropertyElementMaster };
    2081             OSStatus err = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &propAdr,
    2082                                                           coreAudioDefaultDeviceChanged, (void *)pStreamOut);
     2238            err = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &propAdr,
     2239                                                 coreAudioDefaultDeviceChanged, (void *)pStreamOut);
    20832240            /* Not fatal. */
    20842241            if (RT_LIKELY(err == noErr))
     
    20872244            }
    20882245            else
    2089                 LogRel(("CoreAudio: Failed to add the default output device changed listener (%RI32)\n", err));
    2090         }
     2246                LogRel(("CoreAudio: Failed to add the default playback device changed listener (%RI32)\n", err));
     2247        }
     2248
     2249
     2250        /* Register callback for being notified if the device stops being alive. */
     2251        AudioObjectPropertyAddress propAdr = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal,
     2252                                               kAudioObjectPropertyElementMaster };
     2253        err = AudioObjectAddPropertyListener(pStreamOut->deviceID, &propAdr, drvHostCoreAudioDeviceStateChanged,
     2254                                             (void *)&pStreamOut->cbCtx);
     2255        /* Not fatal. */
     2256        if (RT_LIKELY(err == noErr))
     2257        {
     2258            pStreamOut->fDevStateChgListReg = true;
     2259        }
     2260        else
     2261            LogRel(("CoreAudio: Failed to add the playback device state changed listener (%RI32)\n", err));
    20912262    }
    20922263
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