Tomasz Wiszkowski | 5f73a25 | 2017-09-22 11:29:30 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef HW_EMULATOR_CAMERA_EMULATED_CAMERA_COMMON_H |
| 18 | #define HW_EMULATOR_CAMERA_EMULATED_CAMERA_COMMON_H |
| 19 | |
| 20 | /* |
| 21 | * Contains common declarations that are used across the camera emulation. |
| 22 | */ |
| 23 | |
Tomasz Wiszkowski | 5f73a25 | 2017-09-22 11:29:30 -0700 | [diff] [blame] | 24 | #include <hardware/camera.h> |
Greg Hartman | ffd70fc | 2018-01-04 19:32:38 -0800 | [diff] [blame] | 25 | #include <linux/videodev2.h> |
Tomasz Wiszkowski | 5f73a25 | 2017-09-22 11:29:30 -0700 | [diff] [blame] | 26 | |
| 27 | /* A helper class that tracks a routine execution. |
| 28 | * Basically, it dumps an enry message in its constructor, and an exit message |
| 29 | * in its destructor. Use LOGRE() macro (declared bellow) to create instances |
| 30 | * of this class at the beginning of the tracked routines / methods. |
| 31 | */ |
| 32 | class HWERoutineTracker { |
Greg Hartman | ffd70fc | 2018-01-04 19:32:38 -0800 | [diff] [blame] | 33 | public: |
| 34 | /* Constructor that prints an "entry" trace message. */ |
| 35 | explicit HWERoutineTracker(const char* name) : mName(name) { |
| 36 | ALOGV("Entering %s", mName); |
| 37 | } |
Tomasz Wiszkowski | 5f73a25 | 2017-09-22 11:29:30 -0700 | [diff] [blame] | 38 | |
Greg Hartman | ffd70fc | 2018-01-04 19:32:38 -0800 | [diff] [blame] | 39 | /* Destructor that prints a "leave" trace message. */ |
| 40 | ~HWERoutineTracker() { ALOGV("Leaving %s", mName); } |
Tomasz Wiszkowski | 5f73a25 | 2017-09-22 11:29:30 -0700 | [diff] [blame] | 41 | |
Greg Hartman | ffd70fc | 2018-01-04 19:32:38 -0800 | [diff] [blame] | 42 | private: |
| 43 | /* Stores the routine name. */ |
| 44 | const char* mName; |
Tomasz Wiszkowski | 5f73a25 | 2017-09-22 11:29:30 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | /* Logs an execution of a routine / method. */ |
| 48 | #define LOGRE() HWERoutineTracker hwertracker_##__LINE__(__FUNCTION__) |
| 49 | |
| 50 | /* |
| 51 | * min / max macros |
| 52 | */ |
| 53 | |
Greg Hartman | ffd70fc | 2018-01-04 19:32:38 -0800 | [diff] [blame] | 54 | #define min(a, b) (((a) < (b)) ? (a) : (b)) |
| 55 | #define max(a, b) (((a) > (b)) ? (a) : (b)) |
Tomasz Wiszkowski | 5f73a25 | 2017-09-22 11:29:30 -0700 | [diff] [blame] | 56 | |
Greg Hartman | ffd70fc | 2018-01-04 19:32:38 -0800 | [diff] [blame] | 57 | #endif /* HW_EMULATOR_CAMERA_EMULATED_CAMERA_COMMON_H */ |