VirtualBox

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


Ignore:
Timestamp:
Jan 21, 2016 1:56:23 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
105163
Message:

Audio/DrvHostCoreAudio.cpp: Only set the output stream format for the input device.

File:
1 edited

Legend:

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

    r59378 r59428  
    6666 ******************************************************************************/
    6767
    68 #ifdef DEBUG
    6968static void drvHostCoreAudioPrintASBDesc(const char *pszDesc, const AudioStreamBasicDescription *pStreamDesc)
    7069{
    7170    char pszSampleRate[32];
    72     Log(("%s AudioStreamBasicDescription:\n", pszDesc));
    73     LogFlowFunc(("Format ID: %RU32 (%c%c%c%c)\n", pStreamDesc->mFormatID,
    74                  RT_BYTE4(pStreamDesc->mFormatID), RT_BYTE3(pStreamDesc->mFormatID),
    75                  RT_BYTE2(pStreamDesc->mFormatID), RT_BYTE1(pStreamDesc->mFormatID)));
    76     LogFlowFunc(("Flags: %RU32", pStreamDesc->mFormatFlags));
     71    LogRel2(("CoreAudio: %s description:\n", pszDesc));
     72    LogRel2(("CoreAudio: Format ID: %RU32 (%c%c%c%c)\n", pStreamDesc->mFormatID,
     73             RT_BYTE4(pStreamDesc->mFormatID), RT_BYTE3(pStreamDesc->mFormatID),
     74             RT_BYTE2(pStreamDesc->mFormatID), RT_BYTE1(pStreamDesc->mFormatID)));
     75    LogRel2(("CoreAudio: Flags: %RU32", pStreamDesc->mFormatFlags));
    7776    if (pStreamDesc->mFormatFlags & kAudioFormatFlagIsFloat)
    78         Log((" Float"));
     77        LogRel2((" Float"));
    7978    if (pStreamDesc->mFormatFlags & kAudioFormatFlagIsBigEndian)
    80         Log((" BigEndian"));
     79        LogRel2((" BigEndian"));
    8180    if (pStreamDesc->mFormatFlags & kAudioFormatFlagIsSignedInteger)
    82         Log((" SignedInteger"));
     81        LogRel2((" SignedInteger"));
    8382    if (pStreamDesc->mFormatFlags & kAudioFormatFlagIsPacked)
    84         Log((" Packed"));
     83        LogRel2((" Packed"));
    8584    if (pStreamDesc->mFormatFlags & kAudioFormatFlagIsAlignedHigh)
    86         Log((" AlignedHigh"));
     85        LogRel2((" AlignedHigh"));
    8786    if (pStreamDesc->mFormatFlags & kAudioFormatFlagIsNonInterleaved)
    88         Log((" NonInterleaved"));
     87        LogRel2((" NonInterleaved"));
    8988    if (pStreamDesc->mFormatFlags & kAudioFormatFlagIsNonMixable)
    90         Log((" NonMixable"));
     89        LogRel2((" NonMixable"));
    9190    if (pStreamDesc->mFormatFlags & kAudioFormatFlagsAreAllClear)
    92         Log((" AllClear"));
    93     Log(("\n"));
     91        LogRel2((" AllClear"));
     92    LogRel2(("\n"));
    9493    snprintf(pszSampleRate, 32, "%.2f", (float)pStreamDesc->mSampleRate); /** @todo r=andy Use RTStrPrint*. */
    95     LogFlowFunc(("SampleRate      : %s\n", pszSampleRate));
    96     LogFlowFunc(("ChannelsPerFrame: %RU32\n", pStreamDesc->mChannelsPerFrame));
    97     LogFlowFunc(("FramesPerPacket : %RU32\n", pStreamDesc->mFramesPerPacket));
    98     LogFlowFunc(("BitsPerChannel  : %RU32\n", pStreamDesc->mBitsPerChannel));
    99     LogFlowFunc(("BytesPerFrame   : %RU32\n", pStreamDesc->mBytesPerFrame));
    100     LogFlowFunc(("BytesPerPacket  : %RU32\n", pStreamDesc->mBytesPerPacket));
    101 }
    102 #endif /* DEBUG */
     94    LogRel2(("CoreAudio: SampleRate      : %s\n", pszSampleRate));
     95    LogRel2(("CoreAudio: ChannelsPerFrame: %RU32\n", pStreamDesc->mChannelsPerFrame));
     96    LogRel2(("CoreAudio: FramesPerPacket : %RU32\n", pStreamDesc->mFramesPerPacket));
     97    LogRel2(("CoreAudio: BitsPerChannel  : %RU32\n", pStreamDesc->mBitsPerChannel));
     98    LogRel2(("CoreAudio: BytesPerFrame   : %RU32\n", pStreamDesc->mBytesPerFrame));
     99    LogRel2(("CoreAudio: BytesPerPacket  : %RU32\n", pStreamDesc->mBytesPerPacket));
     100}
    103101
    104102static void drvHostCoreAudioPCMInfoToASBDesc(PDMPCMPROPS *pPcmProperties, AudioStreamBasicDescription *pStreamDesc)
     
    807805    }
    808806
    809     /* Switch the I/O mode for input to off. This is important, as this is a pure input stream. */
     807    /* Switch the I/O mode for output to off. This is important, as this is a pure input stream. */
    810808    uFlag = 0;
    811809    err = AudioUnitSetProperty(pStreamIn->audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output,
     
    856854    drvHostCoreAudioPCMInfoToASBDesc(&pStreamIn->streamIn.Props, &pStreamIn->streamFormat);
    857855
    858 #ifdef DEBUG
    859856    drvHostCoreAudioPrintASBDesc("CoreAudio: Input device", &pStreamIn->deviceFormat);
    860857    drvHostCoreAudioPrintASBDesc("CoreAudio: Input stream", &pStreamIn->streamFormat);
    861 #endif /* DEBUG */
    862858
    863859    /* If the frequency of the device is different from the requested one we
     
    866862        || pStreamIn->deviceFormat.mChannelsPerFrame != pStreamIn->streamFormat.mChannelsPerFrame)
    867863    {
     864        LogRel(("CoreAudio: Input converter is active\n"));
     865
    868866        err = AudioConverterNew(&pStreamIn->deviceFormat, &pStreamIn->streamFormat, &pStreamIn->converter);
    869867        if (RT_UNLIKELY(err != noErr))
    870868        {
    871             LogRel(("CoreAudio: Failed to create the audio converte(%RI32). Input Format=%d, Output Foramt=%d\n",
    872                      err, pStreamIn->deviceFormat, pStreamIn->streamFormat));
     869            LogRel(("CoreAudio: Failed to create the audio converter (%RI32)\n", err));
    873870            return VERR_AUDIO_BACKEND_INIT_FAILED;
    874871        }
     
    889886            if (err != noErr)
    890887            {
    891                 LogRel(("CoreAudio: Failed to set channel mapping for the audio input converter (%RI32)\n", err));
     888                LogRel(("CoreAudio: Failed to set channel mapping (mono -> stereo) for the audio input converter (%RI32)\n", err));
    892889                return VERR_AUDIO_BACKEND_INIT_FAILED;
    893890            }
    894         }
    895 
    896         /* Set the new input format description for the stream. */
    897         err = AudioUnitSetProperty(pStreamIn->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input,
    898                                    1, &pStreamIn->streamFormat, sizeof(pStreamIn->streamFormat));
    899         if (err != noErr)
    900         {
    901             LogRel(("CoreAudio: Failed to set input format for input stream (%RI32)\n", err));
    902             return VERR_AUDIO_BACKEND_INIT_FAILED;
    903891        }
    904892#if 0
     
    910898            LogRel(("CoreAudio: Failed to set input audio converter quality to the maximum (%RI32)\n", err));
    911899#endif
    912         LogRel(("CoreAudio: Input converter is active\n"));
    913     }
    914     else
    915     {
    916         /* Set the new output format description for the stream. */
    917         err = AudioUnitSetProperty(pStreamIn->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output,
    918                                    1, &pStreamIn->streamFormat, sizeof(pStreamIn->streamFormat));
    919         if (err != noErr)
    920         {
    921             LogRel(("CoreAudio: Failed to set output format for input stream (%RI32)\n", err));
    922             return VERR_AUDIO_BACKEND_INIT_FAILED; /** @todo Fudge! */
    923         }
     900    }
     901
     902
     903    /* Set the new output format description for the input stream. */
     904    err = AudioUnitSetProperty(pStreamIn->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output,
     905                               1, &pStreamIn->streamFormat, sizeof(pStreamIn->streamFormat));
     906    if (err != noErr)
     907    {
     908        LogRel(("CoreAudio: Failed to set output format for input stream (%RI32)\n", err));
     909        return VERR_AUDIO_BACKEND_INIT_FAILED; /** @todo Fudge! */
    924910    }
    925911
     
    11961182    drvHostCoreAudioPCMInfoToASBDesc(&pStreamOut->streamOut.Props, &pStreamOut->streamFormat);
    11971183
    1198 #ifdef DEBUG
    11991184    drvHostCoreAudioPrintASBDesc("CoreAudio: Output device", &pStreamOut->deviceFormat);
    12001185    drvHostCoreAudioPrintASBDesc("CoreAudio: Output format", &pStreamOut->streamFormat);
    1201 #endif /* DEBUG */
    12021186
    12031187    /* Set the new output format description for the stream. */
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