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

Commit 9aab1380 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

Spatializer speaker capabilities queried from effect

Bug: 377582613
Flag: android.media.audio.spatializer_capabilities
Test: adb shell dumpsys audio | grep "Spatial audio" -A 7
Change-Id: Ic000fcb8f98f80afa140155653173e41ce3db5f5
parent e3cfe878
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -163,4 +163,11 @@ interface ISpatializer {
     * Gets the io handle of the output stream the spatializer is connected to.
     */
     int getOutput();

     /**
      * Returns a list of channel masks that represent the widest channel masks the spatializer
      * is capable of rendering with individual channel positions.
      * Note that each channel mask is in the native format.
      */
      int[] getSpatializedChannelMasks();
}
+38 −0
Original line number Diff line number Diff line
@@ -413,6 +413,29 @@ status_t Spatializer::loadEngineConfiguration(sp<EffectHalInterface> effect) {
        return BAD_VALUE;
    }

    std::vector<audio_channel_mask_t> spatializedChannelMasks;
    status = getHalParameter<true>(effect, SPATIALIZER_PARAM_SPATIALIZED_CHANNEL_MASKS,
                                   &spatializedChannelMasks);
    if (status != NO_ERROR) {
        ALOGW("%s: cannot get SPATIALIZER_PARAM_SPATIALIZED_CHANNEL_MASKS", __func__);
        return status;
    }
    if (spatializedChannelMasks.empty()) {
        ALOGW("%s: SPATIALIZER_PARAM_SPATIALIZED_CHANNEL_MASKS reports empty", __func__);
        return BAD_VALUE;
    }
    for (const audio_channel_mask_t spatializedMask : spatializedChannelMasks) {
        // spatialized masks must be contained in the supported input masks
        if (std::find(mChannelMasks.begin(), mChannelMasks.end(), spatializedMask)
                != mChannelMasks.end()) {
            mSpatializedChannelMasks.emplace_back(spatializedMask);
        } else {
            ALOGE("%s: spatialized mask %#x not in list reported by PARAM_SUPPORTED_CHANNEL_MASKS",
                  __func__, spatializedMask);
            return BAD_VALUE;
        }
    }

    if (com::android::media::audio::dsa_over_bt_le_audio()
            && mSupportsHeadTracking) {
        mHeadtrackingConnectionMode = HeadTracking::ConnectionMode::FRAMEWORK_PROCESSED;
@@ -474,6 +497,17 @@ audio_config_base_t Spatializer::getAudioInConfig() const {
    return config;
}

Status Spatializer::getSpatializedChannelMasks(std::vector<int>* masks) {
        audio_utils::lock_guard lock(mMutex);
        ALOGV("%s", __func__);
        if (masks == nullptr) {
            return binderStatusFromStatusT(BAD_VALUE);
        }
        masks->insert(masks->end(), mSpatializedChannelMasks.begin(),
                      mSpatializedChannelMasks.end());
        return Status::ok();
    }

status_t Spatializer::registerCallback(
        const sp<media::INativeSpatializerCallback>& callback) {
    audio_utils::lock_guard lock(mMutex);
@@ -1254,6 +1288,10 @@ std::string Spatializer::toString(unsigned level) const {
    for (auto& mask : mChannelMasks) {
        base::StringAppendF(&ss, "%s", audio_channel_out_mask_to_string(mask));
    }
    base::StringAppendF(&ss, "%smSpatializedChannelMasks: ", prefixSpace.c_str());
    for (auto& mask : mSpatializedChannelMasks) {
        base::StringAppendF(&ss, "%s", audio_channel_out_mask_to_string(mask));
    }
    base::StringAppendF(&ss, "\n%smSupportsHeadTracking: %s\n", prefixSpace.c_str(),
                        mSupportsHeadTracking ? "true" : "false");
    // 2. Settings (Output, tracks)
+2 −0
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ class Spatializer : public media::BnSpatializer,
    binder::Status setParameter(int key, const std::vector<unsigned char>& value) override;
    binder::Status getParameter(int key, std::vector<unsigned char> *value) override;
    binder::Status getOutput(int *output);
    binder::Status getSpatializedChannelMasks(std::vector<int>* masks) override;

    /** IBinder::DeathRecipient. Listen to the death of the INativeSpatializerCallback. */
    virtual void binderDied(const wp<IBinder>& who);
@@ -536,6 +537,7 @@ private:
    std::vector<media::audio::common::HeadTracking::Mode> mHeadTrackingModes;
    std::vector<media::audio::common::Spatialization::Mode> mSpatializationModes;
    std::vector<audio_channel_mask_t> mChannelMasks;
    std::vector<audio_channel_mask_t> mSpatializedChannelMasks;
    bool mSupportsHeadTracking;

    /** List of supported head tracking connection modes reported by the spatializer.