| 187 | } |
| 188 | |
| 189 | static void* callbackThread(void *args) { |
| 190 | pdbg("callbackThread run pid:%d tid:%d", getpid(), gettid()); |
| 191 | ManufacturerCoder *coder = reinterpret_cast<ManufacturerCoder *>(args); |
| 192 | while (1) { |
| 193 | IHardCoderDataCallback *callback = coder->callback; |
| 194 | amc::DataCallback dataCallback = coder->cbQueue.pop(); |
| 195 | int type = dataCallback.type(); |
| 196 | |
| 197 | if (type == 1) { |
| 198 | std::list<int> cbl = coder->systemEventCallbackList; |
| 199 | if (cbl.empty()) { |
| 200 | pdbg("systemEventCallbackList is empty size:%d continue", TOINT(cbl.size())); |
| 201 | continue; |
| 202 | } |
| 203 | std::list<int>::iterator it; |
| 204 | for (it = cbl.begin(); it != cbl.end(); ++it) { |
| 205 | int len = dataCallback.ByteSize(); |
| 206 | uint8_t body[len] ; |
| 207 | dataCallback.SerializeToArray(body,len); |
| 208 | callback->onCallback(*it, FUNC_REG_SYSTEM_EVENT_CALLBACK, 0, 0, 0, 0 , body, len); |
| 209 | pdbg("system event callback done for succ uid:%d", *it); |
| 210 | } |
| 211 | |
| 212 | } else if (type == 2) { |
| 213 | std::list<int> cbl = coder->anrCallbackUidList; |
| 214 | if (cbl.empty()) { |
| 215 | pdbg("anrCallbackUidList is empty size:%d continue", TOINT(cbl.size())); |
| 216 | continue; |
| 217 | } |
| 218 | std::list<int>::iterator it; |
| 219 | for (it = cbl.begin(); it != cbl.end(); ++it) { |
| 220 | int len = dataCallback.ByteSize(); |
| 221 | uint8_t body[len]; |
| 222 | dataCallback.SerializeToArray(body, len); |
| 223 | callback->onCallback(*it, FUNC_REG_ANR_CALLBACK, 0, 0, 0, 0, body, len); |
| 224 | pdbg("anr callback done for succ uid:%d", *it); |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | pwrn("callbackThread loop QUIT now."); |
| 229 | return NULL; |
| 230 | } |
| 231 | |
| 232 | //for test system event |
| 233 | static void* testSystemEvent(void *args) { |