VirtualBox

Changeset 59434 in vbox


Ignore:
Timestamp:
Jan 22, 2016 8:42:22 AM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
105172
Message:

Audio/DrvHostCoreAudio.cpp: Fixed recording for older OS X hosts.

File:
1 edited

Legend:

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

    r59433 r59434  
    265265    /** Host stream out. */
    266266    PDMAUDIOHSTSTRMOUT          streamOut;
    267     /* Stream description which is default on the device */
     267    /** Stream description which is default on the device. */
    268268    AudioStreamBasicDescription deviceFormat;
    269     /* Stream description which is selected for using by VBox */
     269    /** Stream description which is selected for using with VBox. */
    270270    AudioStreamBasicDescription streamFormat;
    271     /* The audio device ID of the currently used device */
     271    /** The audio device ID of the currently used device. */
    272272    AudioDeviceID               deviceID;
    273     /* The AudioUnit used */
     273    /** The AudioUnit being used. */
    274274    AudioUnit                   audioUnit;
    275     /* A ring buffer for transferring data to the playback thread. */
     275    /** A ring buffer for transferring data to the playback thread. */
    276276    PRTCIRCBUF                  pBuf;
    277     /* Initialization status tracker. Used when some of the device parameters
    278      * or the device itself is changed during the runtime. */
     277    /** Initialization status tracker. Used when some of the device parameters
     278     *  or the device itself is changed during the runtime. */
    279279    volatile uint32_t           status;
    280280    /** Flag whether the "default device changed" listener was registered. */
     
    286286    /** Host stream in. */
    287287    PDMAUDIOHSTSTRMIN           streamIn;
    288     /* Stream description which is default on the device */
     288    /** Stream description which is default on the device. */
    289289    AudioStreamBasicDescription deviceFormat;
    290     /* Stream description which is selected for using by VBox */
     290    /** Stream description which is selected for using with VBox. */
    291291    AudioStreamBasicDescription streamFormat;
    292     /* The audio device ID of the currently used device */
     292    /** The audio device ID of the currently used device. */
    293293    AudioDeviceID               deviceID;
    294     /* The AudioUnit used */
     294    /** The AudioUnit used. */
    295295    AudioUnit                   audioUnit;
    296     /* The audio converter if necessary */
     296    /** The audio converter if necessary. */
    297297    AudioConverterRef           converter;
    298     /* A temporary position value used in the caConverterCallback function */
    299     uint32_t                    rpos;
    300     /* The ratio between the device & the stream sample rate */
     298    /** Native buffer used for render the audio data in the recording thread. */
     299    AudioBufferList             bufferList;
     300    /** Reading offset for the bufferList's buffer. */
     301    uint32_t                    offBufferRead;
     302    /** The ratio between the device & the stream sample rate. */
    301303    Float64                     sampleRatio;
    302     /* An extra buffer used for render the audio data in the recording thread */
    303     AudioBufferList             bufferList;
    304     /* A ring buffer for transferring data from the recording thread */
     304    /** A ring buffer for transferring data from the recording thread. */
    305305    PRTCIRCBUF                  pBuf;
    306     /* Initialization status tracker. Used when some of the device parameters
    307      * or the device itself is changed during the runtime. */
     306    /** Initialization status tracker. Used when some of the device parameters
     307     *  or the device itself is changed during the runtime. */
    308308    volatile uint32_t           status;
    309309    /** Flag whether the "default device changed" listener was registered. */
     
    487487
    488488    /* Use the lower one of the packets to process & the available packets in the buffer. */
    489     Assert(pBufferList->mBuffers[0].mDataByteSize >= pStreamIn->rpos);
     489    Assert(pBufferList->mBuffers[0].mDataByteSize >= pStreamIn->offBufferRead);
    490490    UInt32 cSize = RT_MIN(*pcPackets * pStreamIn->deviceFormat.mBytesPerPacket,
    491                           pBufferList->mBuffers[0].mDataByteSize - pStreamIn->rpos);
     491                          pBufferList->mBuffers[0].mDataByteSize - pStreamIn->offBufferRead);
    492492
    493493    /* Set the new size on output, so the caller know what we have processed. */
     
    510510        pBufData->mBuffers[0].mNumberChannels = pBufferList->mBuffers[0].mNumberChannels;
    511511        pBufData->mBuffers[0].mDataByteSize   = cSize;
    512         pBufData->mBuffers[0].mData           = (uint8_t *)pBufferList->mBuffers[0].mData + pStreamIn->rpos;
    513 
    514         pStreamIn->rpos += cSize;
     512        pBufData->mBuffers[0].mData           = (uint8_t *)pBufferList->mBuffers[0].mData + pStreamIn->offBufferRead;
     513
     514        pStreamIn->offBufferRead += cSize;
    515515
    516516        err = noErr;
     
    571571            tmpList.mNumberBuffers = 1;
    572572            tmpList.mBuffers[0].mNumberChannels = pStreamIn->streamFormat.mChannelsPerFrame;
     573
     574            /* Set the read position to zero. */
     575            pStreamIn->offBufferRead = 0;
    573576
    574577            /* Iterate as long as data is available. */
     
    18091812                RTCircBufDestroy(pStreamIn->pBuf);
    18101813
    1811                 pStreamIn->audioUnit   = NULL;
    1812                 pStreamIn->deviceID    = kAudioDeviceUnknown;
    1813                 pStreamIn->pBuf        = NULL;
    1814                 pStreamIn->sampleRatio = 1;
    1815                 pStreamIn->rpos        = 0;
     1814                pStreamIn->audioUnit     = NULL;
     1815                pStreamIn->deviceID      = kAudioDeviceUnknown;
     1816                pStreamIn->pBuf          = NULL;
     1817                pStreamIn->sampleRatio   = 1;
     1818                pStreamIn->offBufferRead = 0;
    18161819
    18171820                ASMAtomicXchgU32(&pStreamIn->status, CA_STATUS_UNINIT);
     
    19351938    ASMAtomicXchgU32(&pStreamIn->status, CA_STATUS_UNINIT);
    19361939
    1937     pStreamIn->audioUnit   = NULL;
    1938     pStreamIn->deviceID    = kAudioDeviceUnknown;
    1939     pStreamIn->converter   = NULL;
    1940     pStreamIn->sampleRatio = 1;
    1941     pStreamIn->rpos        = 0;
     1940    pStreamIn->audioUnit     = NULL;
     1941    pStreamIn->deviceID      = kAudioDeviceUnknown;
     1942    pStreamIn->converter     = NULL;
     1943    pStreamIn->sampleRatio   = 1;
     1944    pStreamIn->offBufferRead = 0;
    19421945
    19431946    bool fDeviceByUser = false;
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