DvppSourceManager.cpp
1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "DvppSourceManager.h"
#include "dvpp_headers.h"
#include "depend_headers.h"
using namespace std;
DvppSourceManager::~DvppSourceManager()
{
for(auto iter = ctxMap.begin(); iter != ctxMap.end(); iter++){
aclError ret = aclrtDestroyContext(iter->second);
if(ret != ACL_ERROR_NONE){
LOG_ERROR("aclrtDestroyContext failed !");
continue;
}
}
ctxMap.clear();
channelMap.clear();
// aclFinalize();
}
int DvppSourceManager::getChannel(int devId){
// channel 最大值暂定为32, 华为没有接口获取最大channel,只有文档说明
for(int iChannel = 0; iChannel < 32; iChannel++){
string channelKey = "channel_" + to_string(devId) + "_" + to_string(iChannel) ;
auto it = channelMap.find(channelKey);
if(it == channelMap.end()){
channelMap[channelKey] = iChannel;
return iChannel;
}
}
return -1;
}
void DvppSourceManager::releaseChannel(int devId, int iChannel){
string channelKey = "channel_" + to_string(devId) + "_" + to_string(iChannel) ;
auto it = channelMap.find(channelKey);
if(it != channelMap.end()){
channelMap.erase(channelKey);
}
}