VolumeShaper: Clean up constructors
Explicit only for single argument constructors
Test: instrumented ducking, CTS
Bug: 37536598
Change-Id: I78776f500513a40c8daf7af78cbaec4b153e9ea2
diff --git a/include/media/VolumeShaper.h b/include/media/VolumeShaper.h
index 4f6cbdc..4ddb8d3 100644
--- a/include/media/VolumeShaper.h
+++ b/include/media/VolumeShaper.h
@@ -95,7 +95,7 @@
, mId(-1) {
}
- Configuration(const Configuration &configuration)
+ explicit Configuration(const Configuration &configuration)
: Interpolator<S, T>(*static_cast<const Interpolator<S, T> *>(&configuration))
, mType(configuration.mType)
, mOptionFlags(configuration.mOptionFlags)
@@ -236,6 +236,7 @@
clampVolume();
}
+ // The parcel layout must match VolumeShaper.java
status_t writeToParcel(Parcel *parcel) const {
if (parcel == nullptr) return BAD_VALUE;
return parcel->writeInt32((int32_t)mType)
@@ -300,15 +301,19 @@
: Operation(FLAG_NONE, -1 /* replaceId */) {
}
- explicit Operation(Flag flags, int replaceId)
+ Operation(Flag flags, int replaceId)
: Operation(flags, replaceId, std::numeric_limits<S>::quiet_NaN() /* xOffset */) {
}
- Operation(const Operation &operation)
+ explicit Operation(const Operation &operation)
: Operation(operation.mFlags, operation.mReplaceId, operation.mXOffset) {
}
- explicit Operation(Flag flags, int replaceId, S xOffset)
+ explicit Operation(const sp<Operation> &operation)
+ : Operation(*operation.get()) {
+ }
+
+ Operation(Flag flags, int replaceId, S xOffset)
: mFlags(flags)
, mReplaceId(replaceId)
, mXOffset(xOffset) {
@@ -375,7 +380,7 @@
// must match with VolumeShaper.java in frameworks/base
class State : public RefBase {
public:
- explicit State(T volume, S xOffset)
+ State(T volume, S xOffset)
: mVolume(volume)
, mXOffset(xOffset) {
}
@@ -480,7 +485,7 @@
// TODO: Since we pass configuration and operation as shared pointers
// there is a potential risk that the caller may modify these after
// delivery. Currently, we don't require copies made here.
- explicit VolumeShaper(
+ VolumeShaper(
const sp<VolumeShaper::Configuration> &configuration,
const sp<VolumeShaper::Operation> &operation)
: mConfiguration(configuration) // we do not make a copy
@@ -793,7 +798,7 @@
void reset() {
AutoMutex _l(mLock);
mVolumeShapers.clear();
- mLastFrame = -1;
+ mLastFrame = 0;
// keep mVolumeShaperIdCounter as is.
}
@@ -835,7 +840,7 @@
mutable Mutex mLock;
double mSampleRate; // in samples (frames) per second
- int64_t mLastFrame; // logging purpose only
+ int64_t mLastFrame; // logging purpose only, 0 on start
int32_t mVolumeShaperIdCounter; // a counter to return a unique volume shaper id.
std::pair<T /* volume */, bool /* active */> mLastVolume;
std::list<VolumeShaper> mVolumeShapers; // list provides stable iterators on erase