VOID CSoundRecDlg::StartRecording() { MMRESULT mRes; SetStatus("Recording..."); try { OpenDevice(); PrepareBuffers(); mRes=waveInStart(m_hWaveIn); if(mRes!=0) { StoreError(mRes,FALSE,"File: %s ,Line Number:%d",__FILE__,__LINE__); throw m_csErrorText; } while(m_bRun) { SleepEx(100,FALSE); } } catch(PCHAR pErrorMsg) { AfxMessageBox(pErrorMsg); } CloseDevice(); CloseHandle(m_hThread); m_hThread=NULL; SetStatus("Recording stopped..."); }
void StoreImpl::Save(const char *filename) const { Util::ScopedLock lock(m_pimpl->operationsCS); XML::CXML xml(WebWatchTag); xml << *m_pimpl->rootGroup; xml << m_pimpl->siteListSettings; XML::CXML *xmlWindowPlacement = xml.CreateChild(WindowPlacementTag); ConvertWindowPlacementToXML(m_pimpl->wp, *xmlWindowPlacement); ASSERT(m_pimpl->muSettings.get()); xml << *m_pimpl->muSettings; ASSERT(m_pimpl->checkSettings.get()); xml << *m_pimpl->checkSettings; xml << m_pimpl->siteGroupsTreeSettings; ASSERT(m_pimpl->generalSettings.get()); xml << *m_pimpl->generalSettings; // Make a per-save backup of configuration file if (IsFileExistent(filename)) { MakeBackup(filename, perSave, AfxGetApp()->GetMainWnd()->GetSafeHwnd()); } if (xml.SaveAs(filename) == false) throw StoreError(FormatCantSaveError(filename)); }
UINT CSoundRecDlg::FillDevices() { CComboBox *pBox=(CComboBox*)GetDlgItem(IDC_DEVICES); UINT nDevices,nC1; WAVEINCAPS stWIC={0}; MMRESULT mRes; pBox->ResetContent(); nDevices=waveInGetNumDevs(); for(nC1=0;nC1<nDevices;++nC1) { ZeroMemory(&stWIC,sizeof(WAVEINCAPS)); mRes=waveInGetDevCaps(nC1,&stWIC,sizeof(WAVEINCAPS)); if(mRes==0) pBox->AddString(stWIC.szPname); else StoreError(mRes,TRUE,"File: %s ,Line Number:%d",__FILE__,__LINE__); } if(pBox->GetCount()) { pBox->SetCurSel(0); OnCbnSelchangeDevices(); } return nDevices; }
void StatementObject::GetTypeInfo(int dataType) { if (!m_hstmt) { NPN_SetException(this, "Statement isn't initialized"); return; } NPError rc = Close(); if (rc != NPERR_NO_ERROR) return; SQLRETURN code = SQLGetTypeInfo(m_hstmt, dataType); if (!SQL_SUCCEEDED(code) && code != SQL_NO_DATA) { StoreError(SQL_HANDLE_STMT, m_hstmt); return; } SQLSMALLINT cols; if (SQL_SUCCEEDED(SQLNumResultCols(m_hstmt, &cols))) m_columnCount = cols; SQLLEN rcnt; if (SQL_SUCCEEDED(SQLRowCount(m_hstmt, &rcnt))) m_rowCount = rcnt; }
NPError StatementObject::MoreResults(bool *retval) { if (!m_hstmt) { NPN_SetException(this, "Statement isn't initialized"); return NPERR_GENERIC_ERROR; } SQLRETURN rc = SQLMoreResults(m_hstmt); if (SQL_SUCCEEDED(rc)) { SQLSMALLINT cols; if (SQL_SUCCEEDED(SQLNumResultCols(m_hstmt, &cols))) m_columnCount = cols; if (m_columnCount > 0) *retval = true; else *retval = false; return NPERR_NO_ERROR; } else if (rc == SQL_NO_DATA) { *retval = false; return NPERR_NO_ERROR; } else { StoreError(SQL_HANDLE_STMT, m_hstmt); return NPERR_GENERIC_ERROR; } }
void CSoundRecDlg::OnCbnSelchangeDevices() { CComboBox *pDevices=(CComboBox*)GetDlgItem(IDC_DEVICES); CComboBox *pFormats=(CComboBox*)GetDlgItem(IDC_FORMATS); int nSel; WAVEINCAPS stWIC={0}; MMRESULT mRes; SetStatus("Querying device informations..."); pFormats->ResetContent(); nSel=pDevices->GetCurSel(); if(nSel!=-1) { ZeroMemory(&stWIC,sizeof(WAVEINCAPS)); mRes=waveInGetDevCaps(nSel,&stWIC,sizeof(WAVEINCAPS)); if(mRes==0) { if(WAVE_FORMAT_1M08==(stWIC.dwFormats&WAVE_FORMAT_1M08)) pFormats->SetItemData(pFormats->AddString("11.025 kHz, mono, 8-bit"),WAVE_FORMAT_1M08); if(WAVE_FORMAT_1M16==(stWIC.dwFormats&WAVE_FORMAT_1M16)) pFormats->SetItemData(pFormats->AddString("11.025 kHz, mono, 16-bit"),WAVE_FORMAT_1M16); if(WAVE_FORMAT_1S08==(stWIC.dwFormats&WAVE_FORMAT_1S08)) pFormats->SetItemData(pFormats->AddString("11.025 kHz, stereo, 8-bit"),WAVE_FORMAT_1S08); if(WAVE_FORMAT_1S16==(stWIC.dwFormats&WAVE_FORMAT_1S16)) pFormats->SetItemData(pFormats->AddString("11.025 kHz, stereo, 16-bit"),WAVE_FORMAT_1S16); if(WAVE_FORMAT_2M08==(stWIC.dwFormats&WAVE_FORMAT_2M08)) pFormats->SetItemData(pFormats->AddString("22.05 kHz, mono, 8-bit"),WAVE_FORMAT_2M08); if(WAVE_FORMAT_2M16==(stWIC.dwFormats&WAVE_FORMAT_2M16)) pFormats->SetItemData(pFormats->AddString("22.05 kHz, mono, 16-bit"),WAVE_FORMAT_2M16); if(WAVE_FORMAT_2S08==(stWIC.dwFormats&WAVE_FORMAT_2S08)) pFormats->SetItemData(pFormats->AddString("22.05 kHz, stereo, 8-bit"),WAVE_FORMAT_2S08); if(WAVE_FORMAT_2S16==(stWIC.dwFormats&WAVE_FORMAT_2S16)) pFormats->SetItemData(pFormats->AddString("22.05 kHz, stereo, 16-bit"),WAVE_FORMAT_2S16); if(WAVE_FORMAT_4M08==(stWIC.dwFormats&WAVE_FORMAT_4M08)) pFormats->SetItemData(pFormats->AddString("44.1 kHz, mono, 8-bit"),WAVE_FORMAT_4M08); if(WAVE_FORMAT_4M16==(stWIC.dwFormats&WAVE_FORMAT_4M16)) pFormats->SetItemData(pFormats->AddString("44.1 kHz, mono, 16-bit"),WAVE_FORMAT_4M16); if(WAVE_FORMAT_4S08==(stWIC.dwFormats&WAVE_FORMAT_4S08)) pFormats->SetItemData(pFormats->AddString("44.1 kHz, stereo, 8-bit"),WAVE_FORMAT_4S08); if(WAVE_FORMAT_4S16==(stWIC.dwFormats&WAVE_FORMAT_4S16)) pFormats->SetItemData(pFormats->AddString("44.1 kHz, stereo, 16-bit"),WAVE_FORMAT_4S16); if(WAVE_FORMAT_96M08==(stWIC.dwFormats&WAVE_FORMAT_96M08)) pFormats->SetItemData(pFormats->AddString("96 kHz, mono, 8-bit"),WAVE_FORMAT_96M08); if(WAVE_FORMAT_96S08==(stWIC.dwFormats&WAVE_FORMAT_96S08)) pFormats->SetItemData(pFormats->AddString("96 kHz, stereo, 8-bit"),WAVE_FORMAT_96S08); if(WAVE_FORMAT_96M16==(stWIC.dwFormats&WAVE_FORMAT_96M16)) pFormats->SetItemData(pFormats->AddString("96 kHz, mono, 16-bit"),WAVE_FORMAT_96M16); if(WAVE_FORMAT_96S16==(stWIC.dwFormats&WAVE_FORMAT_96S16)) pFormats->SetItemData(pFormats->AddString("96 kHz, stereo, 16-bit"),WAVE_FORMAT_96S16); if(pFormats->GetCount()) pFormats->SetCurSel(0); } else StoreError(mRes,TRUE,"File: %s ,Line Number:%d",__FILE__,__LINE__); } SetStatus("Waiting to start..."); }
void StoreImpl::SetDefaultSiteGroupsTreeSettings() { Util::ScopedLock lock(m_pimpl->operationsCS); try { CSiteGroupsTree::GetDefaultSettings(m_pimpl->siteGroupsTreeSettings); } catch (std::exception & ex) { throw StoreError(ex.what()); } }
void StatementObject::GetForeignKeys(const NPVariant *arg0, const NPVariant *arg1, const NPVariant *arg2, const NPVariant *arg3, const NPVariant *arg4, const NPVariant *arg5) { NPString *pcat = NULL; NPString *psch = NULL; NPString *ptbl = NULL; NPString *fcat = NULL; NPString *fsch = NULL; NPString *ftbl = NULL; if (NPVARIANT_IS_STRING(*arg0)) pcat = (NPString*)&NPVARIANT_TO_STRING(*arg0); if (NPVARIANT_IS_STRING(*arg1)) psch = (NPString*)&NPVARIANT_TO_STRING(*arg1); if (NPVARIANT_IS_STRING(*arg2)) ptbl = (NPString*)&NPVARIANT_TO_STRING(*arg2); if (NPVARIANT_IS_STRING(*arg3)) fcat = (NPString*)&NPVARIANT_TO_STRING(*arg3); if (NPVARIANT_IS_STRING(*arg4)) fsch = (NPString*)&NPVARIANT_TO_STRING(*arg4); if (NPVARIANT_IS_STRING(*arg5)) ftbl = (NPString*)&NPVARIANT_TO_STRING(*arg5); if (!m_hstmt) { NPN_SetException(this, "Statement isn't initialized"); return; } NPError rc = Close(); if (rc != NPERR_NO_ERROR) return; SQLRETURN code = SQLForeignKeysW(m_hstmt, (pcat?nsWString(pcat).Data():NULL), (pcat?SQL_NTS:0), (psch?nsWString(psch).Data():NULL), (psch?SQL_NTS:0), (ptbl?nsWString(ptbl).Data():NULL), (ptbl?SQL_NTS:0), (fcat?nsWString(fcat).Data():NULL), (fcat?SQL_NTS:0), (fsch?nsWString(fsch).Data():NULL), (fsch?SQL_NTS:0), (ftbl?nsWString(ftbl).Data():NULL), (ftbl?SQL_NTS:0)); if (!SQL_SUCCEEDED(code) && code != SQL_NO_DATA) { StoreError(SQL_HANDLE_STMT, m_hstmt); return; } SQLSMALLINT cols; if (SQL_SUCCEEDED(SQLNumResultCols(m_hstmt, &cols))) m_columnCount = cols; SQLLEN rcnt; if (SQL_SUCCEEDED(SQLRowCount(m_hstmt, &rcnt))) m_rowCount = rcnt; }
SiteItemGroup & StoreImpl::ImportGroup(SiteItemGroup & group, const char *filename) { Util::ScopedLock lock(m_pimpl->operationsCS); XML::CXML xml; if (xml.Load(filename, WebWatchTag) == false) throw StoreError(FormatCantImportGroupError(filename)); if (strcmp(xml.GetParamText("Type"), GroupExportTag) != 0) throw StoreError(FormatNoGroupExportInfoError(filename)); XML::CXML *xmlGroup = xml.FindFirstChild(SiteItemGroup::GetXMLName()); if (xmlGroup == 0) throw StoreError(FormatNoSiteGroupsError(filename)); SiteItemGroup *newGroup = new SiteItemGroup(*xmlGroup); group.AddGroup(*newGroup); return *newGroup; }
void StoreImpl::ExportGroup(const SiteItemGroup & group, const char *filename) const { Util::ScopedLock lock(m_pimpl->operationsCS); XML::CXML xml(WebWatchTag); xml.SetParam("Type", GroupExportTag); xml << group; if (xml.SaveAs(filename) == false) throw StoreError(FormatCantExportGroupError(filename)); }
void StoreImpl::Load(const char *filename) { Util::ScopedLock lock(m_pimpl->operationsCS); XML::CXML root; if (root.Load(filename, WebWatchTag) == false) throw StoreError(FormatCantLoadError(filename)); if (XML::CXML *xml = root.FindFirstChild(SiteItemGroup::GetXMLName())) { m_pimpl->rootGroup.reset(new SiteItemGroup(*xml)); if (m_pimpl->rootGroup->GetSiteCount() != 0) { MessageBox(0, FormatRootGroupHasSitesWarning().c_str(), "Warning", MB_OK | MB_ICONEXCLAMATION); m_pimpl->rootGroup->DeleteAllSites(); } } else { m_pimpl->rootGroup.reset(new SiteItemGroup(DefaultRootGroupName)); } if (XML::CXML *xml = root.FindFirstChild(CSiteList::GetXMLName())) m_pimpl->siteListSettings = *xml; else SetDefaultSiteListSettings(); if (XML::CXML *xml = root.FindFirstChild(WindowPlacementTag)) ConvertXMLToWindowPlacement(*xml, m_pimpl->wp); else SetDefaultWindowPlacement(); if (XML::CXML *xml = root.FindFirstChild(MUSettings::GetXMLName())) m_pimpl->muSettings.reset(new MUSettings(*xml)); else SetDefaultMUSettings(); if (XML::CXML *xml = root.FindFirstChild(CheckSettings::GetXMLName())) m_pimpl->checkSettings.reset(new CheckSettings(*xml)); else SetDefaultCheckSettings(); if (XML::CXML *xml = root.FindFirstChild(CSiteGroupsTree::GetXMLName())) m_pimpl->siteGroupsTreeSettings = *xml; else SetDefaultSiteGroupsTreeSettings(); if (XML::CXML *xml = root.FindFirstChild(GeneralSettings::GetXMLName())) m_pimpl->generalSettings.reset(new GeneralSettings(*xml)); else SetDefaultGeneralSettings(); }
VOID CSoundRecDlg::CloseDevice() { MMRESULT mRes=0; if(m_hWaveIn) { UnPrepareBuffers(); mRes=waveInClose(m_hWaveIn); } if(m_hOPFile) { mRes=mmioAscend(m_hOPFile, &m_stckOut, 0); if(mRes!=MMSYSERR_NOERROR) { StoreError(mRes,FALSE,"File: %s ,Line Number:%d",__FILE__,__LINE__); } mRes=mmioAscend(m_hOPFile, &m_stckOutRIFF, 0); if(mRes!=MMSYSERR_NOERROR) { StoreError(mRes,FALSE,"File: %s ,Line Number:%d",__FILE__,__LINE__); } mmioClose(m_hOPFile,0); m_hOPFile=NULL; } m_hWaveIn=NULL; // Close FAAC encoder int nRet = faacEncClose(m_hAACEncoder); m_hAACEncoder = 0; if (m_pbAACBuffer) delete[] m_pbAACBuffer; m_pbAACBuffer = NULL; if (m_fpAACOutput) fclose(m_fpAACOutput); m_fpAACOutput = NULL; }
VOID CSoundRecDlg::PrepareBuffers() { MMRESULT mRes=0; int nT1=0; for(nT1=0;nT1<MAX_BUFFERS;++nT1) { m_stWHDR[nT1].lpData=(LPSTR)HeapAlloc(GetProcessHeap(),8,m_stWFEX.nAvgBytesPerSec); m_stWHDR[nT1].dwBufferLength=m_stWFEX.nAvgBytesPerSec; m_stWHDR[nT1].dwUser=nT1; mRes=waveInPrepareHeader(m_hWaveIn,&m_stWHDR[nT1],sizeof(WAVEHDR)); if(mRes!=0) { StoreError(mRes,FALSE,"File: %s ,Line Number:%d",__FILE__,__LINE__); throw m_csErrorText; } mRes=waveInAddBuffer(m_hWaveIn,&m_stWHDR[nT1],sizeof(WAVEHDR)); if(mRes!=0) { StoreError(mRes,FALSE,"File: %s ,Line Number:%d",__FILE__,__LINE__); throw m_csErrorText; } } }
NPError StatementObject::CheckRC(SWORD fHandleType, SQLHANDLE handle, SQLRETURN rc) { m_errCode = 0; m_errState[0] = 0; m_errMessage[0] = 0; if (!SQL_SUCCEEDED(rc)) { StoreError(fHandleType, handle); return NPERR_GENERIC_ERROR; } else { return NPERR_NO_ERROR; } }
void StatementObject::GetProcedureColumns(const NPVariant *arg0, const NPVariant *arg1, const NPVariant *arg2, const NPVariant *arg3) { NPString *cat = NULL; NPString *sch = NULL; NPString *prc = NULL; NPString *col = NULL; if (NPVARIANT_IS_STRING(*arg0)) cat = (NPString*)&NPVARIANT_TO_STRING(*arg0); if (NPVARIANT_IS_STRING(*arg1)) sch = (NPString*)&NPVARIANT_TO_STRING(*arg1); if (NPVARIANT_IS_STRING(*arg2)) prc = (NPString*)&NPVARIANT_TO_STRING(*arg2); if (NPVARIANT_IS_STRING(*arg3)) col = (NPString*)&NPVARIANT_TO_STRING(*arg3); if (!m_hstmt) { NPN_SetException(this, "Statement isn't initialized"); return; } NPError rc = Close(); if (rc != NPERR_NO_ERROR) return; SQLRETURN code = SQLProcedureColumnsW(m_hstmt, (cat?nsWString(cat).Data():NULL), (cat?SQL_NTS:0), (sch?nsWString(sch).Data():NULL), (sch?SQL_NTS:0), (prc?nsWString(prc).Data():NULL), (prc?SQL_NTS:0), (col?nsWString(col).Data():NULL), (col?SQL_NTS:0)); if (!SQL_SUCCEEDED(code) && code != SQL_NO_DATA) { StoreError(SQL_HANDLE_STMT, m_hstmt); return; } SQLSMALLINT cols; if (SQL_SUCCEEDED(SQLNumResultCols(m_hstmt, &cols))) m_columnCount = cols; SQLLEN rcnt; if (SQL_SUCCEEDED(SQLRowCount(m_hstmt, &rcnt))) m_rowCount = rcnt; }
VOID CSoundRecDlg::ProcessHeader(WAVEHDR * pHdr) { MMRESULT mRes=0; TRACE("%d",pHdr->dwUser); if(WHDR_DONE==(WHDR_DONE &pHdr->dwFlags)) { ShowDebug(_T("CSoundRecDlg::ProcessHeader, pHdr->dwBytesRecorded=%d"), pHdr->dwBytesRecorded); unsigned long nInputSamples = pHdr->dwBytesRecorded / (m_stWFEX.wBitsPerSample / 8); ShowDebug(_T("CSoundRecDlg::ProcessHeader faacEncEncode nInputSamples=%d"), nInputSamples); long nLeftSamples = nInputSamples; BYTE* pData = (BYTE*)pHdr->lpData; while (nLeftSamples > 0) { int nBytesEncoded = faacEncEncode(m_hAACEncoder, (int*)pData, m_nMaxInputSamples, m_pbAACBuffer, m_nMaxOutputBytes); ShowDebug(_T("CSoundRecDlg::ProcessHeader faacEncEncode nBytesEncoded=%d"), nBytesEncoded); int nBytesWritten = fwrite(m_pbAACBuffer, 1, nBytesEncoded, m_fpAACOutput); ShowDebug(_T("CSoundRecDlg::ProcessHeader fwrite nBytesWritten=%d"), nBytesWritten); nLeftSamples -= m_nMaxInputSamples; pData += m_nMaxInputSamples; } mmioWrite(m_hOPFile,pHdr->lpData,pHdr->dwBytesRecorded); mRes=waveInAddBuffer(m_hWaveIn,pHdr,sizeof(WAVEHDR)); if(mRes!=0) StoreError(mRes,TRUE,"File: %s ,Line Number:%d",__FILE__,__LINE__); } }
//=============================================== NPError StatementObject::Fetch(bool *retval) { if (!m_hstmt) { NPN_SetException(this, "Statement isn't initialized"); return NPERR_GENERIC_ERROR; } SQLRETURN rc = SQLFetch(m_hstmt); if (SQL_SUCCEEDED(rc)) { *retval = true; return NPERR_NO_ERROR; } else if (rc == SQL_NO_DATA) { *retval = false; return NPERR_NO_ERROR; } else { StoreError(SQL_HANDLE_STMT, m_hstmt); return NPERR_GENERIC_ERROR; } }
NPError StatementObject::Execute(NPString *query) { if (!m_hstmt) { NPN_SetException(this, "Statement isn't initialized"); return NPERR_GENERIC_ERROR; } NPError rc = Close(); if (rc != NPERR_NO_ERROR) return rc; /**********/ int i = 0; VecODBCParams::iterator p; if (!m_params.empty()) { for(p = m_params.begin(); p < m_params.end(); p++) { nsODBCParam *val = *p; if (val == NULL) { return NPERR_GENERIC_ERROR; } i++; switch(val->mType) { case nsODBCParam::VTYPE_BOOL : { val->mInd = 0; rc = CheckStmtRC(SQLBindParameter(m_hstmt, i, SQL_PARAM_INPUT, SQL_C_BIT, SQL_BIT, sizeof(bool), 0, &(val->mVal.mBoolValue), 0, (SQLLEN *)&(val->mInd))); if (rc != NPERR_NO_ERROR) return rc; break; } case nsODBCParam::VTYPE_INT32 : { val->mInd = 0; rc = CheckStmtRC(SQLBindParameter(m_hstmt, i, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(int), 0, &(val->mVal.mInt32Value), 0, (SQLLEN *)&(val->mInd))); if (rc != NPERR_NO_ERROR) return rc; break; } case nsODBCParam::VTYPE_DOUBLE : { val->mInd = 0; rc = CheckStmtRC(SQLBindParameter(m_hstmt, i, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_DOUBLE, sizeof(double), 0, &(val->mVal.mDoubleValue), 0, (SQLLEN *)&(val->mInd))); if (rc != NPERR_NO_ERROR) return rc; break; } case nsODBCParam::VTYPE_STRING : { nsWString *v_str = val->mVal.mStringValue; val->mInd = SQL_NTS; rc = CheckStmtRC(SQLBindParameter(m_hstmt, i, SQL_PARAM_INPUT, SQL_C_WCHAR, (val->mIsLong?SQL_WLONGVARCHAR:SQL_WVARCHAR), v_str->Length(), 0, v_str->Data(), 0, (SQLLEN *)&(val->mInd))); if (rc != NPERR_NO_ERROR) return rc; break; } #if 0 case nsIDataType::VTYPE_ARRAY : { nsBinary *v_bin = val->mVal.mBinValue; val->mInd = v_bin->Length(); rv = CheckStmtRC(SQLBindParameter(m_hstmt, i, SQL_PARAM_INPUT, SQL_C_BINARY, (val->mIsLong?SQL_LONGVARBINARY:SQL_VARBINARY), v_bin->Length(), 0, v_bin->Data(), 0, (SQLINTEGER *)&(val->mInd))); if (rv != NS_OK) return rv; break; } #endif default: { val->mInd = SQL_NULL_DATA; rc = CheckStmtRC(SQLBindParameter(m_hstmt, i, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 0, 0, NULL, 0, (SQLLEN *)&(val->mInd))); if (rc != NPERR_NO_ERROR) return rc; break; } } } } /**********/ SQLRETURN code = SQLExecDirectW (m_hstmt, nsWString(query).Data(), SQL_NTS); if (!SQL_SUCCEEDED(code) && code != SQL_NO_DATA) { StoreError(SQL_HANDLE_STMT, m_hstmt); ClearParams(); return NPERR_GENERIC_ERROR; } SQLFreeStmt (m_hstmt, SQL_RESET_PARAMS); ClearParams(); SQLSMALLINT cols; if (SQL_SUCCEEDED(SQLNumResultCols(m_hstmt, &cols))) m_columnCount = cols; SQLLEN rcnt; if (SQL_SUCCEEDED(SQLRowCount(m_hstmt, &rcnt))) m_rowCount = rcnt; return NPERR_NO_ERROR; }
VOID CSoundRecDlg::OpenDevice() { int nT1=0; CString csT1; double dT1=0.0; MMRESULT mRes=0; CComboBox *pDevices=(CComboBox*)GetDlgItem(IDC_DEVICES); CComboBox *pFormats=(CComboBox*)GetDlgItem(IDC_FORMATS); nT1=pFormats->GetCurSel(); if(nT1==-1) throw ""; pFormats->GetLBText(nT1,csT1); sscanf((PCHAR)(LPCTSTR)csT1,"%lf",&dT1); dT1=dT1*1000; m_stWFEX.nSamplesPerSec=(int)dT1; csT1=csT1.Right(csT1.GetLength()-csT1.Find(',')-1); csT1.Trim(); if(csT1.Find("mono")!=-1) m_stWFEX.nChannels=1; if(csT1.Find("stereo")!=-1) m_stWFEX.nChannels=2; csT1=csT1.Right(csT1.GetLength()-csT1.Find(',')-1); csT1.Trim(); sscanf((PCHAR)(LPCTSTR)csT1,"%d",&m_stWFEX.wBitsPerSample); m_stWFEX.wFormatTag=WAVE_FORMAT_PCM; m_stWFEX.nBlockAlign=m_stWFEX.nChannels*m_stWFEX.wBitsPerSample/8; m_stWFEX.nAvgBytesPerSec=m_stWFEX.nSamplesPerSec*m_stWFEX.nBlockAlign; m_stWFEX.cbSize=sizeof(WAVEFORMATEX); mRes=waveInOpen(&m_hWaveIn,pDevices->GetCurSel(),&m_stWFEX,(DWORD_PTR)waveInProc,(DWORD_PTR)this,CALLBACK_FUNCTION); if(mRes!=MMSYSERR_NOERROR) { StoreError(mRes,FALSE,"File: %s ,Line Number:%d",__FILE__,__LINE__); throw m_csErrorText; } GetDlgItem(IDC_FILENAME)->GetWindowText(csT1); ZeroMemory(&m_stmmIF,sizeof(MMIOINFO)); DeleteFile((PCHAR)(LPCTSTR)csT1); m_hOPFile=mmioOpen((PCHAR)(LPCTSTR)csT1,&m_stmmIF,MMIO_WRITE | MMIO_CREATE); if(m_hOPFile==NULL) throw "Can not open file..."; ZeroMemory(&m_stckOutRIFF,sizeof(MMCKINFO)); m_stckOutRIFF.fccType = mmioFOURCC('W', 'A', 'V', 'E'); mRes=mmioCreateChunk(m_hOPFile, &m_stckOutRIFF, MMIO_CREATERIFF); if(mRes!=MMSYSERR_NOERROR) { StoreError(mRes,FALSE,"File: %s ,Line Number:%d",__FILE__,__LINE__); throw m_csErrorText; } ZeroMemory(&m_stckOut,sizeof(MMCKINFO)); m_stckOut.ckid = mmioFOURCC('f', 'm', 't', ' '); m_stckOut.cksize = sizeof(m_stWFEX); mRes=mmioCreateChunk(m_hOPFile, &m_stckOut, 0); if(mRes!=MMSYSERR_NOERROR) { StoreError(mRes,FALSE,"File: %s ,Line Number:%d",__FILE__,__LINE__); throw m_csErrorText; } nT1=mmioWrite(m_hOPFile, (HPSTR) &m_stWFEX, sizeof(m_stWFEX)); if(nT1!=sizeof(m_stWFEX)) { m_csErrorText.Format("Can not write Wave Header..File: %s ,Line Number:%d",__FILE__,__LINE__); throw m_csErrorText; } mRes=mmioAscend(m_hOPFile, &m_stckOut, 0); if(mRes!=MMSYSERR_NOERROR) { StoreError(mRes,FALSE,"File: %s ,Line Number:%d",__FILE__,__LINE__); throw m_csErrorText; } m_stckOut.ckid = mmioFOURCC('d', 'a', 't', 'a'); mRes=mmioCreateChunk(m_hOPFile, &m_stckOut, 0); if(mRes!=MMSYSERR_NOERROR) { StoreError(mRes,FALSE,"File: %s ,Line Number:%d",__FILE__,__LINE__); throw m_csErrorText; } // Open FAAC encoder m_hAACEncoder = faacEncOpen(m_stWFEX.nSamplesPerSec, m_stWFEX.nChannels, &m_nMaxInputSamples, &m_nMaxOutputBytes); ShowDebug(_T("CSoundRecDlg::faacEncOpen m_nMaxInputSamples=%d, m_nMaxOutputBytes=%d"), m_nMaxInputSamples, m_nMaxOutputBytes); if (m_hAACEncoder == NULL) { StoreError(mRes,FALSE,"File: %s ,Line Number:%d",__FILE__,__LINE__); throw m_csErrorText; } m_pbAACBuffer = new BYTE[m_nMaxOutputBytes]; if (m_pbAACBuffer == NULL) { return; } // Get current encoding configuration m_pAACConfiguration = faacEncGetCurrentConfiguration(m_hAACEncoder); // switch (m_stWFEX.wBitsPerSample) // { // case 16: // m_pAACConfiguration->inputFormat = FAAC_INPUT_16BIT; // break; // case 24: // m_pAACConfiguration->inputFormat = FAAC_INPUT_24BIT; // break; // case 32: // m_pAACConfiguration->inputFormat = FAAC_INPUT_32BIT; // break; // default: // m_pAACConfiguration->inputFormat = FAAC_INPUT_16BIT; // } m_pAACConfiguration->inputFormat = FAAC_INPUT_16BIT; // Set encoding configuration int nRet = faacEncSetConfiguration(m_hAACEncoder, m_pAACConfiguration); errno_t err = fopen_s(&m_fpAACOutput, "out.aac", "wb"); }