Skip to content

Commit

Permalink
ver. up - mod 7
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrolean committed Apr 13, 2022
1 parent 8e05567 commit 57b4cf5
Show file tree
Hide file tree
Showing 66 changed files with 627 additions and 512 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
*.~*
*.ec?
*.BAT
Thumbs.db

# VC++ files
.vs/
Expand Down
8 changes: 6 additions & 2 deletions BonDriver_PTx-ST.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ StreamingMethod=1
StartBuff=8
;PT1/2のバージョン(1か2) ※PT3では無効
PT1ver=2
;高精度割込みタイマーを有効にしてストリームの転送効率を高めるかどうか[1/0]
UseHRTimer=0
;PT3を優先して検出するかどうか[1/0] ※x付き(BonDriver_PTx)以外は無効
;0=PT1/2を優先、1=PT3を優先
xFirstPT3=1
Expand All @@ -41,9 +43,11 @@ xCompactService=1
; 周波数調整に費やす最大時間(ms)
MAXDUR_FREQ=1000
; TMCC取得に費やす最大時間(ms)
MAXDUR_TMCC=1500
MAXDUR_TMCC=1000
; TMCC(S側)取得に費やす最大時間(ms)
MAXDUR_TMCC_S=500
; TSID設定に費やす最大時間(ms)
MAXDUR_TSID=3000
MAXDUR_TSID=1000


;既定のチャンネル情報
Expand Down
Binary file modified BonDriver_PTx/BonDriver_PTx.rc
Binary file not shown.
8 changes: 5 additions & 3 deletions BonDriver_PTx/BonTuner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ CBonTuner::CBonTuner()
PathFileExists((m_strDirPath+L"PT3Ctrl.exe").c_str()) ;
m_bXSparePTw = bypassPTw==0 ? FALSE:
PathFileExists((m_strDirPath+L"PTwCtrl.exe").c_str()) ;

parse_fname(L"PTx");

}else if(m_iPT==2) { // pt2wdm Tuner
Expand Down Expand Up @@ -175,6 +176,7 @@ CBonTuner::CBonTuner()
m_dwSetChDelay = GetPrivateProfileIntW(L"SET", L"SetChDelay", 0, strIni.c_str());
m_dwRetryDur = GetPrivateProfileIntW(L"SET", L"RetryDur", 3000, strIni.c_str());
m_dwStartBuff = GetPrivateProfileIntW(L"SET", L"StartBuff", 8, strIni.c_str());
SetHRSleepMode(GetPrivateProfileIntW(L"SET", L"UseHRTimer", 0, strIni.c_str()));

wstring strChSet;

Expand Down Expand Up @@ -769,7 +771,7 @@ const BOOL CBonTuner::SetChannel(const DWORD dwSpace, const DWORD dwChannel)
}

if (m_dwSetChDelay)
Sleep(m_dwSetChDelay);
HRSleep(m_dwSetChDelay);

PurgeTsStream();

Expand Down Expand Up @@ -841,7 +843,7 @@ UINT WINAPI CBonTuner::RecvThreadPipeIOProc(LPVOID pParam)
}
}else{
if(!pSys->m_hasStream) pSys->PurgeTsStream();
::Sleep(5);
HRSleep(5);
}
}

Expand Down Expand Up @@ -1057,7 +1059,7 @@ const BOOL CBonTuner::TransponderSetCurID(const DWORD dwID)
}

if (m_dwSetChDelay)
Sleep(m_dwSetChDelay);
HRSleep(m_dwSetChDelay);

PurgeTsStream();

Expand Down
1 change: 0 additions & 1 deletion BonDriver_PTx/ParseChSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ BOOL CParseChSet::Parse1Line(string parseLine, TP_DATA* tpInfo )
return TRUE;
}

// MARK: BOOL CParseChSet::Parse1Line(string parseLine, CH_DATA* chInfo )
BOOL CParseChSet::Parse1Line(string parseLine, CH_DATA* chInfo )
{
auto ParseData=[](string strBuff, DWORD lastVal) -> DWORD {
Expand Down
2 changes: 1 addition & 1 deletion Common/BaseIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ UINT CBaseIO::MemStreamingThreadProcMain(DWORD dwID)
tx(Buff(dwID), MemStreamer(dwID));

if (obj!=nullptr||!m_fDataCarry[dwID])
Sleep(MemStreamer(dwID) ? 10 : CmdWait);
HRSleep(MemStreamer(dwID) ? 10 : CmdWait);
}

return 0;
Expand Down
1 change: 0 additions & 1 deletion Common/PTCtrlMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ void CPTCtrlMain::CmdCloseTuner(CMD_STREAM* pCmdParam, CMD_STREAM* pResParam)
}

//CMD_SET_CH SetChannel
// MARK : void CPTCtrlMain::CmdSetCh(CMD_STREAM* pCmdParam, CMD_STREAM* pResParam)
void CPTCtrlMain::CmdSetCh(CMD_STREAM* pCmdParam, CMD_STREAM* pResParam)
{
int iID;
Expand Down
2 changes: 1 addition & 1 deletion Common/PTManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class IPTManager
BOOL m_bMemStreaming;

DWORD m_dwMaxDurFREQ;
DWORD m_dwMaxDurTMCC;
DWORD m_dwMaxDurTMCC, m_dwMaxDurTMCC_S;
DWORD m_dwMaxDurTSID;

virtual void FreeSDK() {}
Expand Down
102 changes: 53 additions & 49 deletions Common/PTxManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ CPTxManager::CPTxManager(void)
}
m_bMemStreaming = GetPrivateProfileInt(L"SET", L"StreamingMethod", 0, strIni.c_str());

SetHRSleepMode(GetPrivateProfileInt(L"SET", L"UseHRTimer", 0, strIni.c_str()));

m_dwMaxDurFREQ = GetPrivateProfileInt(L"SET", L"MAXDUR_FREQ", 1000, strIni.c_str() ); //周波数調整に費やす最大時間(msec)
m_dwMaxDurTMCC = GetPrivateProfileInt(L"SET", L"MAXDUR_TMCC", 1500, strIni.c_str() ); //TMCC取得に費やす最大時間(msec)
m_dwMaxDurTSID = GetPrivateProfileInt(L"SET", L"MAXDUR_TSID", 3000, strIni.c_str() ); //TSID設定に費やす最大時間(msec)
m_dwMaxDurTMCC = GetPrivateProfileInt(L"SET", L"MAXDUR_TMCC", 1000, strIni.c_str() ); //TMCC取得に費やす最大時間(msec)
m_dwMaxDurTMCC_S = GetPrivateProfileInt(L"SET", L"MAXDUR_TMCC_S", m_dwMaxDurTMCC, strIni.c_str() ); //TMCC(S側)取得に費やす最大時間(msec)
m_dwMaxDurTSID = GetPrivateProfileInt(L"SET", L"MAXDUR_TSID", 1000, strIni.c_str() ); //TSID設定に費やす最大時間(msec)
}

BOOL CPTxManager::LoadSDK()
Expand Down Expand Up @@ -323,18 +326,32 @@ BOOL CPTxManager::SetFreq(int iID, unsigned long ulCh)
sint32 offset = (ulCh >> 16) & 0xffff;
if (offset >= 32768) offset -= 65536;

status enStatus;
status enStatus = PT::STATUS_GENERAL_ERROR ;
for (DWORD t=0,s=dur(); t<m_dwMaxDurFREQ; t=dur(s)) {
if(t) HRSleep(enStatus==PT::STATUS_OK?10:40);
if( enStatus!=PT::STATUS_OK )
#if PT_VER==1 || PT_VER==2
enStatus = m_EnumDev[iDevID]->pcDevice->SetFrequency(iTuner, enISDB, ch, offset);
enStatus = m_EnumDev[iDevID]->pcDevice->SetFrequency(iTuner, enISDB, ch, offset);
#elif PT_VER==3
enStatus = m_EnumDev[iDevID]->pcDevice->SetFrequency(enISDB, iTuner, ch, offset);
enStatus = m_EnumDev[iDevID]->pcDevice->SetFrequency(enISDB, iTuner, ch, offset);
#endif

if( enStatus != PT::STATUS_OK ) {
return FALSE ;
if( enStatus == PT::STATUS_OK ) {
uint32 cur_ch ;
sint32 cur_offset ;
status enCurStatus ;
#if PT_VER==1 || PT_VER==2
enCurStatus = m_EnumDev[iDevID]->pcDevice->GetFrequency(iTuner, enISDB, &cur_ch, &cur_offset);
#elif PT_VER==3
enCurStatus = m_EnumDev[iDevID]->pcDevice->GetFrequency(enISDB, iTuner, &cur_ch, &cur_offset);
#endif
if(enCurStatus == PT::STATUS_OK) {
if(cur_ch==ch && cur_offset==offset)
return TRUE ;
}
}
}

return TRUE ;
return FALSE ;
}

BOOL CPTxManager::GetIdListS(int iID, PTTSIDLIST* pPtTSIDList)
Expand All @@ -353,9 +370,8 @@ BOOL CPTxManager::GetIdListS(int iID, PTTSIDLIST* pPtTSIDList)
return FALSE ;
}

for(uint32 i=0;i<8;i++) {
pPtTSIDList->dwId[i] = (DWORD) tmcc.Id[i] ;
}
PDWORD pdwId = &pPtTSIDList->dwId[0];
std::copy(&tmcc.Id[0], &tmcc.Id[8], pdwId);

return TRUE ;
}
Expand Down Expand Up @@ -391,23 +407,21 @@ BOOL CPTxManager::SetIdS(int iID, DWORD dwTSID)
}

DWORD dwGetID=0xffff;
Sleep(50);
for (DWORD t=0,s=dur(),n=0; t<m_dwMaxDurTSID ; t=dur(s)) {
status enStatus = m_EnumDev[iDevID]->pcDevice->SetIdS(iTuner, dwTSID);
if( enStatus == PT::STATUS_OK ) { if(++n>=2) break ; }
Sleep(50);
}
Sleep(10);
BOOL bRes = FALSE ;

status enStatus = PT::STATUS_GENERAL_ERROR ;
for (DWORD t=0,s=dur(); t<m_dwMaxDurTSID && dwTSID != dwGetID ; t=dur(s)) {
if(GetIdS(iID, &dwGetID)) bRes=TRUE;
Sleep(10);
if(t) HRSleep(enStatus==PT::STATUS_OK?10:40);
if( enStatus != PT::STATUS_OK )
enStatus = m_EnumDev[iDevID]->pcDevice->SetIdS(iTuner, dwTSID);
if( enStatus == PT::STATUS_OK ) {
if(GetIdS(iID, &dwGetID)) bRes=TRUE;
}
}
return bRes && (dwTSID==dwGetID) ? TRUE : FALSE ;

return (dwTSID==dwGetID) ? bRes : FALSE ;
}

// MARK : BOOL CPTxManager::SetCh(int iID, unsigned long ulCh, DWORD dwTSID, BOOL &hasStream)
BOOL CPTxManager::SetCh(int iID, unsigned long ulCh, DWORD dwTSID, BOOL &hasStream)
{
uint32 ch = ulCh & 0xffff;
Expand All @@ -430,27 +444,17 @@ BOOL CPTxManager::SetCh(int iID, unsigned long ulCh, DWORD dwTSID, BOOL &hasStre
}

BOOL bRes=FALSE;
for (DWORD t=0,s=dur(),n=0; t<m_dwMaxDurFREQ; t=dur(s)) {

bRes = SetFreq(iID, ulCh);
if( bRes ) {
if(++n>=2) {
_OutputDebugString(L"CPT%dManager::SetFreq: Device::SetFrequency: ISDB:%d tuner:%d ch:%d\n",PT_VER,enISDB,iTuner,ch);
break ;
}
}
Sleep(50);
}

if( !bRes ) {
bRes = SetFreq(iID, ulCh);
if( bRes ) {
_OutputDebugString(L"CPT%dManager::SetFreq: Device::SetFrequency: ISDB:%d tuner:%d ch:%d\n",PT_VER,enISDB,iTuner,ch);
}else {
_OutputDebugString(L"CPT%dManager::SetFreq: Device::SetFrequency failure!\n",PT_VER) ;
break ;
}

if( enISDB == PT::Device::ISDB_S ){
bool checkOnly = (dwTSID&~7UL)!=0 ,checkFinished=false ;
Sleep(50);
for (DWORD t=0,s=dur(); t<m_dwMaxDurTMCC; t=dur(s)) {
for (DWORD t=0,s=dur(); !checkFinished && t<m_dwMaxDurTMCC_S; t=dur(s)) {
PTTSIDLIST PtTSIDList = {0};
bRes = GetIdListS(iID, &PtTSIDList);
if (bRes) {
Expand All @@ -466,37 +470,37 @@ BOOL CPTxManager::SetCh(int iID, unsigned long ulCh, DWORD dwTSID, BOOL &hasStre
//dwTSIDに0~7が指定された場合は、TSIDをチューナーから取得して
//下位3ビットと一致するものに書き換える
// mod by 2020 LVhJPic0JSk5LiQ1ITskKVk9UGBg
dwTSID = id ;
dwTSID = id ; checkFinished = true ;
_OutputDebugString(L"CPT%dManager::SetCh: replaced TSID=%d\n",PT_VER,id) ;
break;
}
}
}
}
Sleep(50);
HRSleep(0,500);
}else
HRSleep(10);
}
if(checkOnly&&!checkFinished) {
if(!checkFinished) {
_OutputDebugString(L"CPT%dManager::SetCh: TSID:%04x was not found on TMCC!\n",PT_VER,dwTSID) ;
break;
}
if(dwTSID&~7UL) {
else {
if(!SetIdS(iID, dwTSID)) {
_OutputDebugString(L"CPT%dManager::SetCh: SetIdS failure!\n",PT_VER) ;
break;
}
hasStream = TRUE ;
}
}else {
Sleep(50);
for (DWORD t=0,s=dur(); t<m_dwMaxDurTMCC; t=dur(s)) {
PT::Device::TmccT tmcc;
ZeroMemory(&tmcc,sizeof(tmcc));
//std::fill_n(tmcc.Id,8,0xffff) ;
if(t) HRSleep(40);
status enStatus = m_EnumDev[iDevID]->pcDevice->GetTmccT(iTuner, &tmcc);
if (enStatus == PT::STATUS_OK) {
hasStream = TRUE ; break;
}
Sleep(50);
}
}

Expand Down Expand Up @@ -642,7 +646,7 @@ int CPTxManager::OpenTuner2(BOOL bSate, int iTunerID)
OutputDebugStringA(log);
// PT::STATUS_DEVICE_IS_ALREADY_OPEN_ERRORの場合は考慮しない
m_EnumDev[iDevID]->pcDevice->Close();
Sleep(10); // 保険
HRSleep(10); // 保険
}
if( enStatus != PT::STATUS_OK ){
m_EnumDev[iDevID]->pcDevice->Delete();
Expand All @@ -660,7 +664,7 @@ int CPTxManager::OpenTuner2(BOOL bSate, int iTunerID)
OutputDebugStringA(log);
return -1;
}
Sleep(20);
HRSleep(20);
enStatus = m_EnumDev[iDevID]->pcDevice->SetTunerPowerReset(PT::Device::TUNER_POWER_ON_RESET_DISABLE);
if( enStatus != PT::STATUS_OK ){
m_EnumDev[iDevID]->pcDevice->Close();
Expand All @@ -670,7 +674,7 @@ int CPTxManager::OpenTuner2(BOOL bSate, int iTunerID)
OutputDebugStringA(log);
return -1;
}
Sleep(1);
HRSleep(1);
for( uint32 i=0; i<2; i++ ){
enStatus = m_EnumDev[iDevID]->pcDevice->InitTuner(i);
if( enStatus != PT::STATUS_OK ){
Expand Down Expand Up @@ -746,7 +750,7 @@ int CPTxManager::OpenTuner2(BOOL bSate, int iTunerID)
m_EnumDev[iDevID]->bUseT1 = TRUE;
}
#if PT_VER==1 || PT_VER==2
Sleep(10); // PT1/2のT側はこの後の選局までが早すぎるとエラーになる場合があるので
HRSleep(10); // PT1/2のT側はこの後の選局までが早すぎるとエラーになる場合があるので
#endif
}else{
if( iTuner == 0 ){
Expand Down
20 changes: 6 additions & 14 deletions Common/PoolBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,8 @@ class pool_objects {
template<class T>
class pool_buffer_object {
struct ref_t {
ref_t(): data_(nullptr), ref_cnt_(1), size_(0), grew_(0) {}
ref_t(): data_(nullptr), size_(0), grew_(0) {}
~ref_t() { free(); }
void addref() {ref_cnt_++;}
bool release() {
if(!--ref_cnt_) {
return true ;
}
return false;
}
void free() {
if(data_!=nullptr) {
delete [] data_ ;
Expand Down Expand Up @@ -196,24 +189,23 @@ class pool_buffer_object {
T* data_;
size_t size_;
size_t grew_;
size_t ref_cnt_;
};
ref_t* ref_;
public:
pool_buffer_object() { ref_ = new ref_t() ; }
pool_buffer_object(const pool_buffer_object &obj)
{ ref_ = obj.ref_; ref_->addref(); }
pool_buffer_object(pool_buffer_object &&obj)
{ ref_ = obj.ref_; obj.ref_ = nullptr; }
~pool_buffer_object()
{ if(ref_->release()) delete ref_; }
{ if(ref_!=nullptr) delete ref_; }
void free() { ref_->free(); }
bool resize(size_t new_size) { return ref_->resize(new_size); }
bool growup(size_t capa_size) { return ref_->growup(capa_size); }
T* data() { return ref_->data(); }
size_t size() const { return ref_->size(); }
size_t capacity() const { return ref_->capacity(); }
T& operator[](size_t index) { return (*ref_)[index] ; }
pool_buffer_object& operator =(const pool_buffer_object &obj)
{ if(ref_->release()) delete ref_; ref_=obj.ref_; ref_->addref(); return *this; }
pool_buffer_object& operator =(pool_buffer_object &&obj)
{ if(ref_!=nullptr) delete ref_; ref_=obj.ref_; obj.ref_=nullptr; return *this; }
};

// pool_buffer
Expand Down
2 changes: 1 addition & 1 deletion Common/SharedMem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ DWORD CSharedCmdOperator::WaitForCmd(DWORD timeout)
for(DWORD s=e ; dur(s,e)<=timeout ; e = dur()) {
HANDLE event = OpenEvent(EVENT_ALL_ACCESS,FALSE,NamListen.c_str());
if(event&&event!=INVALID_HANDLE_VALUE) { hListen=event; break; }
Sleep(10);
HRSleep(10);
}
if(!hListen) {
res = WAIT_TIMEOUT;
Expand Down
Loading

0 comments on commit 57b4cf5

Please sign in to comment.