示例#1
0
TBool DriverAlsa::Pimpl::TryProfile(Profile& aProfile, TUint aBitDepth,
                                    TUint aNumChannels, TUint aSampleRate,
                                    TUint aBufferUs)
{
    auto outputFormat = aProfile.GetFormat(aBitDepth);

    if (iDuplicateChannel)
    {
        // We are manually converting a mono input to stereo.
        // Configure the stream for stereo.
        aNumChannels *= 2;
    }

    auto err = snd_pcm_set_params(iHandle,
                                  outputFormat.first,
                                  SND_PCM_ACCESS_RW_INTERLEAVED,
                                  aNumChannels,
                                  aSampleRate,
                                  0,             // no soft-resample
                                  aBufferUs);
    return err == 0;
}