void CAudioFormatDlg::OnOK() { m_cFmt.m_sCaptureDevice = GetCurrentCaptureDevice(); m_cFmt.m_sCompressor = GetCurrentCompressor(); m_cFmt.m_iCurrentCompression = GetCurrentCompression(); WAVEFORMATEX *pCurrentFormat = GetCurrentFormat(); if(pCurrentFormat) { m_cFmt.m_iFormatTag = pCurrentFormat->wFormatTag; m_cFmt.m_iNumChannels = pCurrentFormat->nChannels; m_cFmt.m_iSamplesPerSeconds = pCurrentFormat->nSamplesPerSec; m_cFmt.m_iAvgBytesPerSec = pCurrentFormat->nAvgBytesPerSec; m_cFmt.m_iBlockAlign = pCurrentFormat->nBlockAlign; m_cFmt.m_iBitsPerSample = pCurrentFormat->wBitsPerSample; m_cFmt.m_iCbSize = pCurrentFormat->cbSize; /* // just copy the value of m_iRecordAudio from current config // just not to overwrite it when new values // are copied from m_cFmt */ m_cFmt.m_iRecordAudio = cAudioFormat.m_iRecordAudio; } CDialog::OnOK(); }
void CAudioFormatDlg::UpdateCompressFormatInterface() { WAVEFORMATEX *pCurrentFormat = GetCurrentFormat(); if(pCurrentFormat) { CString sData = GetManufacturerFromFormatTag(pCurrentFormat->wFormatTag); sData.Format("%d", pCurrentFormat->wBitsPerSample); m_ctrlEditBitsPerSample.SetWindowTextA(sData); sData.Format("%d (%s)", pCurrentFormat->nChannels , pCurrentFormat->nChannels == 1 ? "mono" : "stereo"); m_ctrlEditChannels.SetWindowTextA(sData); sData.Format("%d", pCurrentFormat->nSamplesPerSec); m_ctrlSamplesPerSec.SetWindowTextA(sData); sData.Format("%d", pCurrentFormat->nAvgBytesPerSec); m_ctrlAvgBytesPerSec.SetWindowTextA(sData); } else { m_ctrlEditBitsPerSample.SetWindowTextA(""); m_ctrlEditChannels.SetWindowTextA(""); m_ctrlSamplesPerSec.SetWindowTextA(""); m_ctrlAvgBytesPerSec.SetWindowTextA(""); } }
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // GetPropertyData() //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- void FormatList::GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data) const { Float64* rates; AudioValueRange* rateRanges; UInt32 theNumberRates; UInt32 theNumberRateRanges; UInt32 theIndex; CMFormatDescriptionRef format = NULL; switch (address.mSelector) { case kCMIOStreamPropertyFormatDescription: ThrowIf(dataSize != sizeof(CMFormatDescriptionRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyFormatDescription"); if (NULL != GetCurrentFormat()) CFRetain(GetCurrentFormat()); *static_cast<CMFormatDescriptionRef*>(data) = GetCurrentFormat(); dataUsed = sizeof(CMFormatDescriptionRef); break; case kCMIOStreamPropertyFormatDescriptions: ThrowIf(dataSize != sizeof(CFArrayRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyFormatDescriptions"); *static_cast<CFArrayRef*>(data) = CFArrayCreateCopy(NULL, mDescriptions.GetCFArray()); dataUsed = sizeof(CFArrayRef); break; case kCMIOStreamPropertyStillImage: ThrowIf(dataSize != sizeof(CMSampleBufferRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyStillImage"); ThrowIf(qualifierDataSize != sizeof(CMFormatDescriptionRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong qualifier data size for kCMIOStreamPropertyStillImage"); *static_cast<CMSampleBufferRef*>(data) = GetStillImage(*static_cast<CMFormatDescriptionRef*>(const_cast<void*>(qualifierData))); dataUsed = sizeof(CMFormatDescriptionRef); break; case kCMIOStreamPropertyStillImageFormatDescriptions: ThrowIf(dataSize != sizeof(CFArrayRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyStillImageFormatDescriptions"); *static_cast<CFArrayRef*>(data) = CFArrayCreateCopy(NULL, mStillImageDescriptions.GetCFArray()); dataUsed = sizeof(CFArrayRef); break; case kCMIOStreamPropertyFrameRate: ThrowIf(dataSize != sizeof(Float64), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyFrameRate"); *(static_cast<Float64*>(data)) = GetCurrentFrameRate(); dataUsed = sizeof(Float64); break; case kCMIOStreamPropertyFrameRates: ThrowIf(qualifierDataSize != 0 and qualifierDataSize != sizeof(CMFormatDescriptionRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong qualifier data size for kCMIOStreamPropertyFrameRates"); format = (0 == qualifierDataSize) ? mCurrentFormat.Get() : *static_cast<CMFormatDescriptionRef*>(const_cast<void*>(qualifierData)); theNumberRates = std::min((UInt32)(dataSize / sizeof(Float64)), GetNumberFrameRates(format)); rates = static_cast<Float64*>(data); for(theIndex = 0; theIndex < theNumberRates; ++theIndex) { rates[theIndex] = GetFrameRateByIndex(format, theIndex); } dataUsed = theNumberRates * sizeof(Float64); break; case kCMIOStreamPropertyMinimumFrameRate: ThrowIf(dataSize != sizeof(Float64), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyMinimumFrameRate"); *(static_cast<Float64*>(data)) = GetMinimumFrameRate(); dataUsed = sizeof(Float64); break; case kCMIOStreamPropertyFrameRateRanges: ThrowIf(qualifierDataSize != 0 and qualifierDataSize != sizeof(CMFormatDescriptionRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong qualifier data size for kCMIOStreamPropertyFrameRateRanges"); format = (0 == qualifierDataSize) ? mCurrentFormat.Get() : *static_cast<CMFormatDescriptionRef*>(const_cast<void*>(qualifierData)); theNumberRateRanges = std::min((UInt32)(dataSize / sizeof(AudioValueRange)), GetNumberFrameRateRanges(format)); rateRanges = static_cast<AudioValueRange*>(data); for(theIndex = 0; theIndex < theNumberRateRanges; ++theIndex) { rateRanges[theIndex] = GetFrameRateRangeByIndex(format, theIndex); } dataUsed = theNumberRateRanges * sizeof(AudioValueRange); break; case kCMIOStreamPropertyPreferredFormatDescription: ThrowIf(dataSize != sizeof(CMFormatDescriptionRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyPreferredFormatDescription"); if (NULL != GetPreferredFormat()) CFRetain(GetPreferredFormat()); *static_cast<CMFormatDescriptionRef*>(data) = GetPreferredFormat(); dataUsed = sizeof(CMFormatDescriptionRef); break; case kCMIOStreamPropertyPreferredFrameRate: ThrowIf(dataSize != sizeof(Float64), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyPreferredFrameRate"); *(static_cast<Float64*>(data)) = GetPreferredFrameRate(); dataUsed = sizeof(Float64); break; }; }