From 36802bd18b7b4e8c87fa019c7e3068bee330d174 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 20 Nov 2014 11:31:17 -0800 Subject: 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 to , which has better typechecking (hooray for not macros!). Bug: 18466763 Change-Id: I9561dcb2526578687819ff85421ba80d8e1a9694 --- cmds/stagefright/SineSource.h | 3 ++- include/media/ToneGenerator.h | 9 +++++---- media/libstagefright/OMXCodec.cpp | 8 ++++---- services/audioflinger/AudioMixer.h | 12 ++++++------ services/audioflinger/AudioResampler.h | 4 +++- services/audioflinger/AudioResamplerFirGen.h | 10 ++++++---- services/audioflinger/StateQueue.cpp | 2 +- services/camera/libcameraservice/api1/client2/Parameters.h | 6 ++++-- .../libcameraservice/device1/CameraHardwareInterface.h | 2 +- 9 files changed, 32 insertions(+), 24 deletions(-) diff --git a/cmds/stagefright/SineSource.h b/cmds/stagefright/SineSource.h index d772e0d..be05661 100644 --- a/cmds/stagefright/SineSource.h +++ b/cmds/stagefright/SineSource.h @@ -3,6 +3,7 @@ #define SINE_SOURCE_H_ #include +#include 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; diff --git a/include/media/ToneGenerator.h b/include/media/ToneGenerator.h index 98c4332..8406ed6 100644 --- a/include/media/ToneGenerator.h +++ b/include/media/ToneGenerator.h @@ -17,11 +17,12 @@ #ifndef ANDROID_TONEGENERATOR_H_ #define ANDROID_TONEGENERATOR_H_ -#include -#include -#include #include #include +#include +#include +#include +#include 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[]: diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp index a8806c8..d54f65d 100644 --- a/media/libstagefright/OMXCodec.cpp +++ b/media/libstagefright/OMXCodec.cpp @@ -100,10 +100,10 @@ static sp InstantiateSoftwareEncoder( #undef FACTORY_CREATE_ENCODER #undef FACTORY_REF -#define CODEC_LOGI(x, ...) ALOGI("[%s] "x, mComponentName, ##__VA_ARGS__) -#define CODEC_LOGV(x, ...) ALOGV("[%s] "x, mComponentName, ##__VA_ARGS__) -#define CODEC_LOGW(x, ...) ALOGW("[%s] "x, mComponentName, ##__VA_ARGS__) -#define CODEC_LOGE(x, ...) ALOGE("[%s] "x, mComponentName, ##__VA_ARGS__) +#define CODEC_LOGI(x, ...) ALOGI("[%s] " x, mComponentName, ##__VA_ARGS__) +#define CODEC_LOGV(x, ...) ALOGV("[%s] " x, mComponentName, ##__VA_ARGS__) +#define CODEC_LOGW(x, ...) ALOGW("[%s] " x, mComponentName, ##__VA_ARGS__) +#define CODEC_LOGE(x, ...) ALOGE("[%s] " x, mComponentName, ##__VA_ARGS__) struct OMXCodecObserver : public BnOMXObserver { OMXCodecObserver() { diff --git a/services/audioflinger/AudioMixer.h b/services/audioflinger/AudioMixer.h index 3b972bb..f4f142b 100644 --- a/services/audioflinger/AudioMixer.h +++ b/services/audioflinger/AudioMixer.h @@ -21,15 +21,15 @@ #include #include +#include +#include +#include +#include +#include #include -#include #include "AudioResampler.h" -#include -#include -#include - // 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 diff --git a/services/audioflinger/AudioResampler.h b/services/audioflinger/AudioResampler.h index cdc6d92..069d946 100644 --- a/services/audioflinger/AudioResampler.h +++ b/services/audioflinger/AudioResampler.h @@ -19,7 +19,9 @@ #include #include + #include +#include #include #include @@ -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); diff --git a/services/audioflinger/AudioResamplerFirGen.h b/services/audioflinger/AudioResamplerFirGen.h index d024b2f..f3718b6 100644 --- a/services/audioflinger/AudioResamplerFirGen.h +++ b/services/audioflinger/AudioResamplerFirGen.h @@ -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 struct I0Term { - static const double value = I0Term::value / (4. * N * N); + static const CONSTEXPR double value = I0Term::value / (4. * N * N); }; template <> struct I0Term<0> { - static const double value = 1.; + static const CONSTEXPR double value = 1.; }; template struct I0ATerm { - static const double value = I0ATerm::value * (2.*N-1.) * (2.*N-1.) / (8. * N); + static const CONSTEXPR double value = I0ATerm::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 diff --git a/services/audioflinger/StateQueue.cpp b/services/audioflinger/StateQueue.cpp index 40d7bcd..9d4188f 100644 --- a/services/audioflinger/StateQueue.cpp +++ b/services/audioflinger/StateQueue.cpp @@ -48,7 +48,7 @@ template StateQueue::StateQueue() : , mObserverDump(&mObserverDummyDump), mMutatorDump(&mMutatorDummyDump) #endif { - atomic_init(&mNext, 0); + atomic_init(&mNext, static_cast(0)); } template StateQueue::~StateQueue() diff --git a/services/camera/libcameraservice/api1/client2/Parameters.h b/services/camera/libcameraservice/api1/client2/Parameters.h index 815cc55..e4e9a92 100644 --- a/services/camera/libcameraservice/api1/client2/Parameters.h +++ b/services/camera/libcameraservice/api1/client2/Parameters.h @@ -19,11 +19,13 @@ #include +#include #include +#include #include #include #include -#include + #include #include #include @@ -187,7 +189,7 @@ struct Parameters { static const int MAX_INITIAL_PREVIEW_WIDTH = 1920; static const int MAX_INITIAL_PREVIEW_HEIGHT = 1080; // Aspect ratio tolerance - static const float ASPECT_RATIO_TOLERANCE = 0.001; + static const CONSTEXPR float ASPECT_RATIO_TOLERANCE = 0.001; // Full static camera info, object owned by someone else, such as // Camera2Device. diff --git a/services/camera/libcameraservice/device1/CameraHardwareInterface.h b/services/camera/libcameraservice/device1/CameraHardwareInterface.h index 6386838..1935c2b 100644 --- a/services/camera/libcameraservice/device1/CameraHardwareInterface.h +++ b/services/camera/libcameraservice/device1/CameraHardwareInterface.h @@ -588,7 +588,7 @@ private: #ifndef container_of #define container_of(ptr, type, member) ({ \ - const typeof(((type *) 0)->member) *__mptr = (ptr); \ + const __typeof__(((type *) 0)->member) *__mptr = (ptr); \ (type *) ((char *) __mptr - (char *)(&((type *)0)->member)); }) #endif -- cgit v1.1