Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8a4394f8 authored by Mikhail Naganov's avatar Mikhail Naganov Committed by Gerrit Code Review
Browse files

Merge "audio: Fix remote submix configuration and 'prepareToClose'" into main

parents 43d4e6fd 2ebe3906
Loading
Loading
Loading
Loading
+9 −9
Original line number Original line Diff line number Diff line
@@ -302,8 +302,9 @@ std::unique_ptr<Configuration> getPrimaryConfiguration() {
//   2. The canonical r_submix configuration only lists 'STEREO' and '48000',
//   2. The canonical r_submix configuration only lists 'STEREO' and '48000',
//      however the framework attempts to open streams for other sample rates
//      however the framework attempts to open streams for other sample rates
//      as well. The legacy r_submix implementation allowed that, but libaudiohal@aidl
//      as well. The legacy r_submix implementation allowed that, but libaudiohal@aidl
//      will not find a mix port to use. Because of that, list all channel
//      will not find a mix port to use. Because of that, list all sample rates that
//      masks and sample rates that the legacy implementation allowed.
//      the legacy implementation allowed (note that mono was not allowed, the framework
//      is expected to upmix mono tracks into stereo if needed).
//   3. The legacy implementation had a hard limit on the number of routes (10),
//   3. The legacy implementation had a hard limit on the number of routes (10),
//      and this is checked indirectly by AudioPlaybackCaptureTest#testPlaybackCaptureDoS
//      and this is checked indirectly by AudioPlaybackCaptureTest#testPlaybackCaptureDoS
//      CTS test. Instead of hardcoding the number of routes, we can use
//      CTS test. Instead of hardcoding the number of routes, we can use
@@ -331,9 +332,8 @@ std::unique_ptr<Configuration> getPrimaryConfiguration() {
std::unique_ptr<Configuration> getRSubmixConfiguration() {
std::unique_ptr<Configuration> getRSubmixConfiguration() {
    static const Configuration configuration = []() {
    static const Configuration configuration = []() {
        Configuration c;
        Configuration c;
        const std::vector<AudioProfile> standardPcmAudioProfiles{
        const std::vector<AudioProfile> remoteSubmixPcmAudioProfiles{
                createProfile(PcmType::INT_16_BIT,
                createProfile(PcmType::INT_16_BIT, {AudioChannelLayout::LAYOUT_STEREO},
                              {AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO},
                              {8000, 11025, 16000, 32000, 44100, 48000})};
                              {8000, 11025, 16000, 32000, 44100, 48000})};


        // Device ports
        // Device ports
@@ -343,25 +343,25 @@ std::unique_ptr<Configuration> getRSubmixConfiguration() {
                           createDeviceExt(AudioDeviceType::OUT_SUBMIX, 0,
                           createDeviceExt(AudioDeviceType::OUT_SUBMIX, 0,
                                           AudioDeviceDescription::CONNECTION_VIRTUAL));
                                           AudioDeviceDescription::CONNECTION_VIRTUAL));
        c.ports.push_back(rsubmixOutDevice);
        c.ports.push_back(rsubmixOutDevice);
        c.connectedProfiles[rsubmixOutDevice.id] = standardPcmAudioProfiles;
        c.connectedProfiles[rsubmixOutDevice.id] = remoteSubmixPcmAudioProfiles;


        AudioPort rsubmixInDevice =
        AudioPort rsubmixInDevice =
                createPort(c.nextPortId++, "Remote Submix In", 0, true,
                createPort(c.nextPortId++, "Remote Submix In", 0, true,
                           createDeviceExt(AudioDeviceType::IN_SUBMIX, 0,
                           createDeviceExt(AudioDeviceType::IN_SUBMIX, 0,
                                           AudioDeviceDescription::CONNECTION_VIRTUAL));
                                           AudioDeviceDescription::CONNECTION_VIRTUAL));
        c.ports.push_back(rsubmixInDevice);
        c.ports.push_back(rsubmixInDevice);
        c.connectedProfiles[rsubmixInDevice.id] = standardPcmAudioProfiles;
        c.connectedProfiles[rsubmixInDevice.id] = remoteSubmixPcmAudioProfiles;


        // Mix ports
        // Mix ports


        AudioPort rsubmixOutMix =
        AudioPort rsubmixOutMix =
                createPort(c.nextPortId++, "r_submix output", 0, false, createPortMixExt(20, 10));
                createPort(c.nextPortId++, "r_submix output", 0, false, createPortMixExt(20, 10));
        rsubmixOutMix.profiles = standardPcmAudioProfiles;
        rsubmixOutMix.profiles = remoteSubmixPcmAudioProfiles;
        c.ports.push_back(rsubmixOutMix);
        c.ports.push_back(rsubmixOutMix);


        AudioPort rsubmixInMix =
        AudioPort rsubmixInMix =
                createPort(c.nextPortId++, "r_submix input", 0, true, createPortMixExt(20, 10));
                createPort(c.nextPortId++, "r_submix input", 0, true, createPortMixExt(20, 10));
        rsubmixInMix.profiles = standardPcmAudioProfiles;
        rsubmixInMix.profiles = remoteSubmixPcmAudioProfiles;
        c.ports.push_back(rsubmixInMix);
        c.ports.push_back(rsubmixInMix);


        c.routes.push_back(createRoute({rsubmixOutMix}, rsubmixOutDevice));
        c.routes.push_back(createRoute({rsubmixOutMix}, rsubmixOutDevice));
+2 −0
Original line number Original line Diff line number Diff line
@@ -131,6 +131,8 @@ ndk::ScopedAStatus StreamRemoteSubmix::prepareToClose() {
            LOG(DEBUG) << __func__ << ": shutting down MonoPipe sink";
            LOG(DEBUG) << __func__ << ": shutting down MonoPipe sink";


            sink->shutdown(true);
            sink->shutdown(true);
            // The client already considers this stream as closed, release the output end.
            route->closeStream(mIsInput);
        } else {
        } else {
            LOG(DEBUG) << __func__ << ": stream already closed.";
            LOG(DEBUG) << __func__ << ": stream already closed.";
            ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
            ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);