2 * Copyright (C) 2019, The LineageOS Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
24 #include <condition_variable>
28 #include <hardware/camera.h>
29 #include <hardware/camera2.h>
31 #define CB_TYPE_NONE 0
32 #define CB_TYPE_NOTIFY 1
33 #define CB_TYPE_DATA 2
35 struct WorkerMessage
{
36 /* Worker callback type */
41 const camera_memory_t
*data
;
43 camera_frame_metadata_t
*metadata
;
50 camera_notify_callback NewUserNotifyCb
;
51 camera_data_callback NewUserDataCb
;
56 class CallbackWorkerThread
{
58 CallbackWorkerThread();
59 ~CallbackWorkerThread();
61 /* Creates our worker, returns true on success */
64 /* Exits the worker thread */
67 /* Sends a new callback to our worker thread */
68 void AddCallback(const WorkerMessage
* data
);
70 /* Sets the callback function pointers for our worker to call */
71 void SetCallbacks(const CallbackData
* data
);
73 /* Clears the worker message queue */
74 void ClearCallbacks(void);
77 CallbackWorkerThread(const CallbackWorkerThread
&);
78 CallbackWorkerThread
& operator=(const CallbackWorkerThread
&);
80 long long GetTimestamp();
82 /* Entry point for the worker thread */
85 std::thread
* m_thread
;
86 std::queue
<ThreadMsg
*> m_queue
;
88 std::condition_variable m_cv
;