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

Commit 36802bd1 authored by Dan Albert's avatar Dan Albert
Browse files

C++11 compatibility.

 * Fix string literal concatenation to not be interpreted as UD
   literals.
 * Add constexpr compatibility for non-integral static members.
 * Use __typeof__ instead of typeof (should become decltype once this
   actually becomes C++11).
 * Add an appropriate cast for atomic_uintptr_t, since moving to C++11
   means moving from <stdatomic.h> to <atomic>, which has better
   typechecking (hooray for not macros!).

Bug: 18466763
Change-Id: I9561dcb2526578687819ff85421ba80d8e1a9694
parent de14fae7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
#define SINE_SOURCE_H_

#include <media/stagefright/MediaSource.h>
#include <utils/Compat.h>

namespace android {

@@ -24,7 +25,7 @@ protected:

private:
    enum { kBufferSize = 8192 };
    static const double kFrequency = 500.0;
    static const CONSTEXPR double kFrequency = 500.0;

    bool mStarted;
    int32_t mSampleRate;
+5 −4
Original line number Diff line number Diff line
@@ -17,11 +17,12 @@
#ifndef ANDROID_TONEGENERATOR_H_
#define ANDROID_TONEGENERATOR_H_

#include <utils/RefBase.h>
#include <utils/KeyedVector.h>
#include <utils/threads.h>
#include <media/AudioSystem.h>
#include <media/AudioTrack.h>
#include <utils/Compat.h>
#include <utils/KeyedVector.h>
#include <utils/RefBase.h>
#include <utils/threads.h>

namespace android {

@@ -207,7 +208,7 @@ private:
    static const unsigned int TONEGEN_MAX_WAVES = 3;     // Maximun number of sine waves in a tone segment
    static const unsigned int TONEGEN_MAX_SEGMENTS = 12;  // Maximun number of segments in a tone descriptor
    static const unsigned int TONEGEN_INF = 0xFFFFFFFF;  // Represents infinite time duration
    static const float TONEGEN_GAIN = 0.9;  // Default gain passed to  WaveGenerator().
    static const CONSTEXPR float TONEGEN_GAIN = 0.9;  // Default gain passed to  WaveGenerator().

    // ToneDescriptor class contains all parameters needed to generate a tone:
    //    - The array waveFreq[]:
+6 −6
Original line number Diff line number Diff line
@@ -21,15 +21,15 @@
#include <stdint.h>
#include <sys/types.h>

#include <hardware/audio_effect.h>
#include <media/AudioBufferProvider.h>
#include <media/nbaio/NBLog.h>
#include <system/audio.h>
#include <utils/Compat.h>
#include <utils/threads.h>

#include <media/AudioBufferProvider.h>
#include "AudioResampler.h"

#include <hardware/audio_effect.h>
#include <system/audio.h>
#include <media/nbaio/NBLog.h>

// FIXME This is actually unity gain, which might not be max in future, expressed in U.12
#define MAX_GAIN_INT AudioMixer::UNITY_GAIN_INT

@@ -58,7 +58,7 @@ public:
    static const uint32_t MAX_NUM_CHANNELS_TO_DOWNMIX = AUDIO_CHANNEL_COUNT_MAX;

    static const uint16_t UNITY_GAIN_INT = 0x1000;
    static const float    UNITY_GAIN_FLOAT = 1.0f;
    static const CONSTEXPR float UNITY_GAIN_FLOAT = 1.0f;

    enum { // names

+3 −1
Original line number Diff line number Diff line
@@ -19,7 +19,9 @@

#include <stdint.h>
#include <sys/types.h>

#include <cutils/compiler.h>
#include <utils/Compat.h>

#include <media/AudioBufferProvider.h>
#include <system/audio.h>
@@ -47,7 +49,7 @@ public:
        DYN_HIGH_QUALITY=7,
    };

    static const float UNITY_GAIN_FLOAT = 1.0f;
    static const CONSTEXPR float UNITY_GAIN_FLOAT = 1.0f;

    static AudioResampler* create(audio_format_t format, int inChannelCount,
            int32_t sampleRate, src_quality quality=DEFAULT_QUALITY);
+6 −4
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
#ifndef ANDROID_AUDIO_RESAMPLER_FIR_GEN_H
#define ANDROID_AUDIO_RESAMPLER_FIR_GEN_H

#include "utils/Compat.h"

namespace android {

/*
@@ -187,22 +189,22 @@ static inline int64_t toint(double x, int64_t maxval) {

template <int N>
struct I0Term {
    static const double value = I0Term<N-1>::value / (4. * N * N);
    static const CONSTEXPR double value = I0Term<N-1>::value / (4. * N * N);
};

template <>
struct I0Term<0> {
    static const double value = 1.;
    static const CONSTEXPR double value = 1.;
};

template <int N>
struct I0ATerm {
    static const double value = I0ATerm<N-1>::value * (2.*N-1.) * (2.*N-1.) / (8. * N);
    static const CONSTEXPR double value = I0ATerm<N-1>::value * (2.*N-1.) * (2.*N-1.) / (8. * N);
};

template <>
struct I0ATerm<0> { // 1/sqrt(2*PI);
    static const double value = 0.398942280401432677939946059934381868475858631164934657665925;
    static const CONSTEXPR double value = 0.398942280401432677939946059934381868475858631164934657665925;
};

#if USE_HORNERS_METHOD
Loading