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

Commit 65025406 authored by Chih-Hung Hsieh's avatar Chih-Hung Hsieh
Browse files

Trigger error only when a template is instantiated.

Clang compiler will check defintions and trigger undefined template
error of 'android::CompileTimeAssert<false>' even when MixMul is not
instantiated. Avoid such parse time error but trigger link error when the
generic MixMul template is used.

Change-Id: I84ef60a69fbfbeefc93b5654e4bdd54f9d530867
parent a04c05ab
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -52,15 +52,12 @@ struct is_same<T, T> // partial specialization
 *
 * For high precision audio, only the <TO, TI, TV> = <float, float, float>
 * needs to be accelerated. This is perhaps the easiest form to do quickly as well.
 *
 * A generic version is NOT defined to catch any mistake of using it.
 */

template <typename TO, typename TI, typename TV>
inline TO MixMul(TI value, TV volume) {
    COMPILE_TIME_ASSERT_FUNCTION_SCOPE(false);
    // should not be here :-).
    // To avoid mistakes, this template is always specialized.
    return value * volume;
}
TO MixMul(TI value, TV volume);

template <>
inline int32_t MixMul<int32_t, int16_t, int16_t>(int16_t value, int16_t volume) {