DWORD CPlayer::OvPlayerThread() { while (TRUE) { // 停止フラグのチェック if (m_fStop) return RET_STOP; // 出力バッファの確保 if (!m_pOutHdr || m_cbOutBufLeft < OVD_PCMBUF_LEN) { if (m_pOutHdr) { OutputBuffer(m_pOutHdr, m_cbOutBuf - m_cbOutBufLeft); m_cbOutBufLeft = 0; m_pOutHdr = NULL; } if (m_fSuppress) return RET_EOF; m_pOutHdr = m_Output.GetBuffer(); m_cbOutBufLeft = m_cbOutBuf; if (m_fSeek) continue; } int nRet, nOutput; { // Critical Sectionのセット CAutoLock lock(&m_csecThread); if (m_fSeek) { if (m_Status == MAP_STATUS_PLAY) m_fPlay = TRUE; m_Reverb.Reset(); m_Echo.Reset(); m_BassBoost.Reset(); m_3DChorus.Reset(); m_Output.Reset(); m_fSeek = FALSE; m_pOutHdr = NULL; continue; } // デコード nRet = ovd_read(m_hOvd, (LPBYTE)m_pOutHdr->lpData + (m_cbOutBuf - m_cbOutBufLeft) , m_cbOutBufLeft, &nOutput); // プリアンプ Preamp((LPBYTE)m_pOutHdr->lpData + (m_cbOutBuf - m_cbOutBufLeft), nOutput); m_cbOutBufLeft -= nOutput; } switch (nRet) { case OVD_FATAL_ERR: case OVD_ERR: return RET_ERROR; case OVD_EOF: return RET_EOF; } } }
// Preset Load bool SweepSettings::Load(QSettings &s) { mode = (OperationalMode)(s.value("Mode", (int)Mode()).toInt()); start = s.value("Sweep/Start", Start().Val()).toDouble(); stop = s.value("Sweep/Stop", Stop().Val()).toDouble(); center = s.value("Sweep/Center", Center().Val()).toDouble(); span = s.value("Sweep/Span", Span().Val()).toDouble(); step = s.value("Sweep/Step", Step().Val()).toDouble(); rbw = s.value("Sweep/RBW", RBW().Val()).toDouble(); vbw = s.value("Sweep/VBW", VBW().Val()).toDouble(); auto_rbw = s.value("Sweep/AutoRBW", AutoRBW()).toBool(); auto_vbw = s.value("Sweep/AutoVBW", AutoVBW()).toBool(); native_rbw = s.value("Sweep/NativeRBW", NativeRBW()).toBool(); refLevel.Load(s, "Sweep/RefLevel"); div = s.value("Sweep/Division", Div()).toDouble(); attenuation = s.value("Sweep/Attenuation", Atten()).toInt(); gain = s.value("Sweep/Gain", Gain()).toInt(); preamp = s.value("Sweep/Preamp", Preamp()).toInt(); sweepTime = s.value("Sweep/SweepTime", SweepTime().Val()).toDouble(); processingUnits = s.value("Sweep/ProcessingUnits", ProcessingUnits()).toInt(); detector = s.value("Sweep/Detector", Detector()).toInt(); rejection = s.value("Sweep/Rejection", Rejection()).toBool(); tgSweepSize = s.value("Sweep/TgSweepSize", tgSweepSize).toInt(); tgHighRangeSweep = s.value("Sweep/TgHighRangeSweep", tgHighRangeSweep).toBool(); tgPassiveDevice = s.value("Sweep/TgPassiveDevice", tgPassiveDevice).toBool(); UpdateProgram(); return true; }
DWORD CPlayer::WavPlayerThread() { BOOL fFlush = FALSE; if (m_pwfxSrc->wFormatTag == WAVE_FORMAT_PCM) { // PCM DWORD cbInBuf, cbRead; while (TRUE) { // 停止フラグのチェック if (m_fStop) return RET_STOP; if (!m_pOutHdr) m_pOutHdr = m_Output.GetBuffer(); { // Critical Sectionのセット CAutoLock lock(&m_csecThread); if (m_fSeek) { if (m_Status == MAP_STATUS_PLAY) m_fPlay = TRUE; m_Reverb.Reset(); m_Echo.Reset(); m_BassBoost.Reset(); m_3DChorus.Reset(); m_Output.Reset(); m_fSeek = FALSE; m_pOutHdr = NULL; continue; } // 読み込み cbRead = min(m_dwDataSize - m_dwCurrentSize, m_cbOutBuf); if (!m_Reader.Read((LPBYTE)m_pOutHdr->lpData, cbRead, &cbInBuf) || !cbInBuf) { if (GetLastError() != ERROR_SUCCESS) return RET_ERROR; fFlush = TRUE; } Preamp((LPBYTE)m_pOutHdr->lpData, cbInBuf); m_dwCurrentSize += cbInBuf; } if (fFlush) return RET_EOF; OutputBuffer(m_pOutHdr, cbInBuf); m_cbOutBufLeft = 0; m_pOutHdr = NULL; if (m_dwCurrentSize >= m_dwDataSize) return RET_EOF; if (m_fSuppress) return RET_EOF; } } else { // PCM 以外 // デコード開始 BYTE bRead[WAV_FILE_BUFF_LEN]; DWORD cbInBuf, cbRead; while (TRUE) { // 停止フラグのチェック if (m_fStop) return RET_STOP; // 出力バッファの確保 if (m_pOutHdr) { OutputBuffer(m_pOutHdr, m_cbOutBuf - m_cbOutBufLeft); m_cbOutBufLeft = 0; m_pOutHdr = NULL; } if (m_fSuppress) return RET_EOF; m_pOutHdr = m_Output.GetBuffer(); m_cbOutBufLeft = m_cbOutBuf; { // Critical Sectionのセット CAutoLock lock(&m_csecThread); if (m_fSeek) { if (m_Status == MAP_STATUS_PLAY) m_fPlay = TRUE; m_Reverb.Reset(); m_Echo.Reset(); m_BassBoost.Reset(); m_Output.Reset(); m_fSeek = FALSE; m_pOutHdr = NULL; acmStreamReset(m_hAcm, 0); continue; } acmStreamSize(m_hAcm, m_cbOutBufLeft, &cbRead, ACM_STREAMSIZEF_DESTINATION); // 読み込み cbRead = min(m_dwDataSize - m_dwCurrentSize, cbRead); cbRead = min(WAV_FILE_BUFF_LEN, cbRead); if (!m_Reader.Read(bRead, cbRead, &cbInBuf) || !cbInBuf) { if (GetLastError() != ERROR_SUCCESS) return RET_ERROR; fFlush = TRUE; } m_dwCurrentSize += cbInBuf; } if (fFlush) return RET_EOF; // ヘッダの確保 ACMSTREAMHEADER ash; memset(&ash, 0, sizeof(ash)); ash.cbStruct = sizeof(ash); //構造体のサイズ ash.pbSrc = bRead; ash.cbSrcLength = cbInBuf; ash.pbDst = (LPBYTE)m_pOutHdr->lpData + (m_cbOutBuf - m_cbOutBufLeft); ash.cbDstLength = m_cbOutBufLeft; if (acmStreamPrepareHeader(m_hAcm, &ash, 0)) break; // 変換 if (acmStreamConvert(m_hAcm, &ash, 0)) break; Preamp((LPBYTE)m_pOutHdr->lpData + (m_cbOutBuf - m_cbOutBufLeft), ash.cbDstLengthUsed); m_cbOutBufLeft -= ash.cbDstLengthUsed; // 後処理 if (acmStreamUnprepareHeader(m_hAcm, &ash, 0)) break; if (m_dwCurrentSize >= m_dwDataSize) return RET_EOF; } return RET_ERROR; } }