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

Commit 9ee0540d authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

Remove last references to hardware/audio.h

DeviceHalInterface transitioned to "capabilities" model
(similar to the one already used by streams, e.g. 'supportsDrain').
No direct checking of the HAL version is needed.

AudioPolicy uses its own version read from the configuration,
and these values never checked against the actual HAL version,
thus it does not need versions and macroses from hardware/*.

Test: make & run on N6P
Change-Id: Ic4a56bfa19a9a61edac2b9f9a163fd8f63a0ff87
parent e7e8d636
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -33,9 +33,6 @@ class DeviceHalInterface : public RefBase
    // Sets the value of 'devices' to a bitmask of 1 or more values of audio_devices_t.
    virtual status_t getSupportedDevices(uint32_t *devices) = 0;

    // Get the hardware module version.
    virtual status_t getVersion(uint32_t *version) = 0;

    // Check to see if the audio hardware interface has been initialized.
    virtual status_t initCheck() = 0;

@@ -88,6 +85,9 @@ class DeviceHalInterface : public RefBase
            audio_source_t source,
            sp<StreamInHalInterface> *inStream) = 0;

    // Returns whether createAudioPatch and releaseAudioPatch operations are supported.
    virtual status_t supportsAudioPatches(bool *supportsPatches) = 0;

    // Creates an audio patch between several source and sink ports.
    virtual status_t createAudioPatch(
            unsigned int num_sources,
+20 −8
Original line number Diff line number Diff line
@@ -40,11 +40,6 @@ status_t DeviceHalLocal::getSupportedDevices(uint32_t *devices) {
    return OK;
}

status_t DeviceHalLocal::getVersion(uint32_t *version) {
    *version = mDev->common.version;
    return OK;
}

status_t DeviceHalLocal::initCheck() {
    return mDev->init_check(mDev);
}
@@ -139,17 +134,31 @@ status_t DeviceHalLocal::openInputStream(
    return openResult;
}

status_t DeviceHalLocal::supportsAudioPatches(bool *supportsPatches) {
    *supportsPatches = version() >= AUDIO_DEVICE_API_VERSION_3_0;
    return OK;
}

status_t DeviceHalLocal::createAudioPatch(
        unsigned int num_sources,
        const struct audio_port_config *sources,
        unsigned int num_sinks,
        const struct audio_port_config *sinks,
        audio_patch_handle_t *patch) {
    return mDev->create_audio_patch(mDev, num_sources, sources, num_sinks, sinks, patch);
    if (version() >= AUDIO_DEVICE_API_VERSION_3_0) {
        return mDev->create_audio_patch(
                mDev, num_sources, sources, num_sinks, sinks, patch);
    } else {
        return INVALID_OPERATION;
    }
}

status_t DeviceHalLocal::releaseAudioPatch(audio_patch_handle_t patch) {
    if (version() >= AUDIO_DEVICE_API_VERSION_3_0) {
        return mDev->release_audio_patch(mDev, patch);
    } else {
        return INVALID_OPERATION;
    }
}

status_t DeviceHalLocal::getAudioPort(struct audio_port *port) {
@@ -157,7 +166,10 @@ status_t DeviceHalLocal::getAudioPort(struct audio_port *port) {
}

status_t DeviceHalLocal::setAudioPortConfig(const struct audio_port_config *config) {
    if (version() >= AUDIO_DEVICE_API_VERSION_3_0)
        return mDev->set_audio_port_config(mDev, config);
    else
        return INVALID_OPERATION;
}

status_t DeviceHalLocal::dump(int fd) {
+5 −3
Original line number Diff line number Diff line
@@ -28,9 +28,6 @@ class DeviceHalLocal : public DeviceHalInterface
    // Sets the value of 'devices' to a bitmask of 1 or more values of audio_devices_t.
    virtual status_t getSupportedDevices(uint32_t *devices);

    // Get the hardware module version.
    virtual status_t getVersion(uint32_t *version);

    // Check to see if the audio hardware interface has been initialized.
    virtual status_t initCheck();

@@ -83,6 +80,9 @@ class DeviceHalLocal : public DeviceHalInterface
            audio_source_t source,
            sp<StreamInHalInterface> *inStream);

    // Returns whether createAudioPatch and releaseAudioPatch operations are supported.
    virtual status_t supportsAudioPatches(bool *supportsPatches);

    // Creates an audio patch between several source and sink ports.
    virtual status_t createAudioPatch(
            unsigned int num_sources,
@@ -115,6 +115,8 @@ class DeviceHalLocal : public DeviceHalInterface

    // The destructor automatically closes the device.
    virtual ~DeviceHalLocal();

    uint32_t version() const { return mDev->common.version; }
};

} // namespace android
+0 −2
Original line number Diff line number Diff line
@@ -67,8 +67,6 @@
#include <mediautils/BatteryNotifier.h>
#include <private/android_filesystem_config.h>

#include <hardware/audio.h>  // for AUDIO_HARDWARE_MODULE_...

// ----------------------------------------------------------------------------

// Note: the following macro is used for extremely verbose logging message.  In
+4 −4
Original line number Diff line number Diff line
@@ -93,10 +93,10 @@ status_t AudioHwDevice::openOutputStream(
    return status;
}

uint32_t AudioHwDevice::version() const
{
    uint32_t result;
    return mHwDevice->getVersion(&result) == OK ? result : 0;
bool AudioHwDevice::supportsAudioPatches() const {
    bool result;
    return mHwDevice->supportsAudioPatches(&result) == OK ? result : false;
}


}; // namespace android
Loading