Merge "Revert "audiohal: Get rid of multiple inheritance in IDevice implementation"" into oc-dev am: ed84acb9ff
am: 62ce08c3a2
Change-Id: I101943359421f8a4652fba2c53a45517f34ab23c
This commit is contained in:
commit
11397b8339
3 changed files with 32 additions and 73 deletions
|
@ -26,7 +26,6 @@
|
|||
#include "Conversions.h"
|
||||
#include "Device.h"
|
||||
#include "HidlUtils.h"
|
||||
#include "ParametersUtil.h"
|
||||
#include "StreamIn.h"
|
||||
#include "StreamOut.h"
|
||||
|
||||
|
@ -36,28 +35,9 @@ namespace audio {
|
|||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
namespace {
|
||||
|
||||
class ParametersUtilImpl : public ParametersUtil {
|
||||
public:
|
||||
ParametersUtilImpl(audio_hw_device_t* device) : mDevice{device} {}
|
||||
|
||||
char* halGetParameters(const char* keys) override {
|
||||
return mDevice->get_parameters(mDevice, keys);
|
||||
}
|
||||
|
||||
int halSetParameters(const char* keysAndValues) override {
|
||||
return mDevice->set_parameters(mDevice, keysAndValues);
|
||||
}
|
||||
|
||||
private:
|
||||
audio_hw_device_t* mDevice;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
Device::Device(audio_hw_device_t* device)
|
||||
: mDevice{device}, mParameters{new ParametersUtilImpl(mDevice)} {}
|
||||
: mDevice(device) {
|
||||
}
|
||||
|
||||
Device::~Device() {
|
||||
int status = audio_hw_device_close(mDevice);
|
||||
|
@ -87,28 +67,12 @@ void Device::closeOutputStream(audio_stream_out_t* stream) {
|
|||
mDevice->close_output_stream(mDevice, stream);
|
||||
}
|
||||
|
||||
Result Device::getParam(const char* name, bool* value) {
|
||||
return mParameters->getParam(name, value);
|
||||
char* Device::halGetParameters(const char* keys) {
|
||||
return mDevice->get_parameters(mDevice, keys);
|
||||
}
|
||||
|
||||
Result Device::getParam(const char* name, int* value) {
|
||||
return mParameters->getParam(name, value);
|
||||
}
|
||||
|
||||
Result Device::getParam(const char* name, String8* value) {
|
||||
return mParameters->getParam(name, value);
|
||||
}
|
||||
|
||||
Result Device::setParam(const char* name, bool value) {
|
||||
return mParameters->setParam(name, value);
|
||||
}
|
||||
|
||||
Result Device::setParam(const char* name, int value) {
|
||||
return mParameters->setParam(name, value);
|
||||
}
|
||||
|
||||
Result Device::setParam(const char* name, const char* value) {
|
||||
return mParameters->setParam(name, value);
|
||||
int Device::halSetParameters(const char* keysAndValues) {
|
||||
return mDevice->set_parameters(mDevice, keysAndValues);
|
||||
}
|
||||
|
||||
// Methods from ::android::hardware::audio::V2_0::IDevice follow.
|
||||
|
@ -310,22 +274,21 @@ Return<Result> Device::setAudioPortConfig(const AudioPortConfig& config) {
|
|||
|
||||
Return<AudioHwSync> Device::getHwAvSync() {
|
||||
int halHwAvSync;
|
||||
Result retval =
|
||||
mParameters->getParam(AudioParameter::keyHwAvSync, &halHwAvSync);
|
||||
Result retval = getParam(AudioParameter::keyHwAvSync, &halHwAvSync);
|
||||
return retval == Result::OK ? halHwAvSync : AUDIO_HW_SYNC_INVALID;
|
||||
}
|
||||
|
||||
Return<Result> Device::setScreenState(bool turnedOn) {
|
||||
return mParameters->setParam(AudioParameter::keyScreenState, turnedOn);
|
||||
return setParam(AudioParameter::keyScreenState, turnedOn);
|
||||
}
|
||||
|
||||
Return<void> Device::getParameters(const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) {
|
||||
mParameters->getParametersImpl(keys, _hidl_cb);
|
||||
getParametersImpl(keys, _hidl_cb);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<Result> Device::setParameters(const hidl_vec<ParameterValue>& parameters) {
|
||||
return mParameters->setParametersImpl(parameters);
|
||||
return setParametersImpl(parameters);
|
||||
}
|
||||
|
||||
Return<void> Device::debugDump(const hidl_handle& fd) {
|
||||
|
|
|
@ -27,14 +27,14 @@
|
|||
|
||||
#include <hidl/MQDescriptor.h>
|
||||
|
||||
#include "ParametersUtil.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
class ParametersUtil;
|
||||
|
||||
using ::android::hardware::audio::common::V2_0::AudioConfig;
|
||||
using ::android::hardware::audio::common::V2_0::AudioHwSync;
|
||||
using ::android::hardware::audio::common::V2_0::AudioInputFlag;
|
||||
|
@ -55,7 +55,7 @@ using ::android::hardware::hidl_vec;
|
|||
using ::android::hardware::hidl_string;
|
||||
using ::android::sp;
|
||||
|
||||
struct Device : public IDevice {
|
||||
struct Device : public IDevice, public ParametersUtil {
|
||||
explicit Device(audio_hw_device_t* device);
|
||||
|
||||
// Methods from ::android::hardware::audio::V2_0::IDevice follow.
|
||||
|
@ -101,19 +101,16 @@ struct Device : public IDevice {
|
|||
void closeInputStream(audio_stream_in_t* stream);
|
||||
void closeOutputStream(audio_stream_out_t* stream);
|
||||
audio_hw_device_t* device() const { return mDevice; }
|
||||
Result getParam(const char* name, bool* value);
|
||||
Result getParam(const char* name, int* value);
|
||||
Result getParam(const char* name, String8* value);
|
||||
Result setParam(const char* name, bool value);
|
||||
Result setParam(const char* name, int value);
|
||||
Result setParam(const char* name, const char* value);
|
||||
|
||||
private:
|
||||
audio_hw_device_t *mDevice;
|
||||
std::unique_ptr<ParametersUtil> mParameters;
|
||||
|
||||
virtual ~Device();
|
||||
|
||||
// Methods from ParametersUtil.
|
||||
char* halGetParameters(const char* keys) override;
|
||||
int halSetParameters(const char* keysAndValues) override;
|
||||
|
||||
uint32_t version() const { return mDevice->common.version; }
|
||||
};
|
||||
|
||||
|
|
|
@ -37,15 +37,12 @@ using ::android::hardware::hidl_vec;
|
|||
|
||||
class ParametersUtil {
|
||||
public:
|
||||
virtual ~ParametersUtil() = default;
|
||||
Result getParam(const char* name, bool* value);
|
||||
Result getParam(const char* name, int* value);
|
||||
Result getParam(const char* name, String8* value);
|
||||
void getParametersImpl(
|
||||
const hidl_vec<hidl_string>& keys,
|
||||
std::function<void(Result retval,
|
||||
const hidl_vec<ParameterValue>& parameters)>
|
||||
cb);
|
||||
std::function<void(Result retval, const hidl_vec<ParameterValue>& parameters)> cb);
|
||||
std::unique_ptr<AudioParameter> getParams(const AudioParameter& keys);
|
||||
Result setParam(const char* name, bool value);
|
||||
Result setParam(const char* name, int value);
|
||||
|
@ -54,6 +51,8 @@ class ParametersUtil {
|
|||
Result setParams(const AudioParameter& param);
|
||||
|
||||
protected:
|
||||
virtual ~ParametersUtil() {}
|
||||
|
||||
virtual char* halGetParameters(const char* keys) = 0;
|
||||
virtual int halSetParameters(const char* keysAndValues) = 0;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue