Permalink
Browse files

fix some formatting

  • Loading branch information...
rdp committed Sep 20, 2012
1 parent 8e897b0 commit 8d11cf9a6280ee15f2ffcc8334d6383eb85f687d
Showing with 25 additions and 24 deletions.
  1. +1 −1 source_code/acam/acam.vcxproj.user
  2. +18 −18 source_code/acam/directshow_stuff.cpp
  3. +6 −5 source_code/acam/loopback-capture.cpp
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <LocalDebuggerCommand>c:\installs\ffmpeg-20120816-git-f0896a6-win32-static\bin\ffmpeg.exe</LocalDebuggerCommand>
+ <LocalDebuggerCommand>C:\installs\ffmpeg-20120903-git-5d55830-win32-static\ffmpeg-20120903-git-5d55830-win32-static\bin\ffmpeg.exe</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments> -f dshow -i audio=virtual-audio-capturer -y yo.mp3</LocalDebuggerCommandArguments>
</PropertyGroup>
@@ -160,28 +160,28 @@ HRESULT CVCamStream::SetMediaType(const CMediaType *pmt)
}
HRESULT setupPwfex(WAVEFORMATEX *pwfex, AM_MEDIA_TYPE *pmt) {
- // TODO match more than just htz...maybe that's all we need? :)
- pwfex->wFormatTag = WAVE_FORMAT_PCM;
- pwfex->cbSize = 0; // apparently should be zero if using WAVE_FORMAT_PCM http://msdn.microsoft.com/en-us/library/ff538799(VS.85).aspx
- pwfex->nChannels = getChannels(); // 1 for mono, 2 for stereo..
- pwfex->nSamplesPerSec = getHtzRate();
- pwfex->wBitsPerSample = 16; // 16 bit sound
- pwfex->nBlockAlign = (WORD)((pwfex->wBitsPerSample * pwfex->nChannels) / BITS_PER_BYTE);
- pwfex->nAvgBytesPerSec = pwfex->nSamplesPerSec * pwfex->nBlockAlign; // it can't calculate this itself? huh?
+ // TODO match more than just htz...maybe that's all we need? :)
+ pwfex->wFormatTag = WAVE_FORMAT_PCM;
+ pwfex->cbSize = 0; // apparently should be zero if using WAVE_FORMAT_PCM http://msdn.microsoft.com/en-us/library/ff538799(VS.85).aspx
+ pwfex->nChannels = getChannels(); // 1 for mono, 2 for stereo..
+ pwfex->nSamplesPerSec = getHtzRate();
+ pwfex->wBitsPerSample = 16; // 16 bit sound
+ pwfex->nBlockAlign = (WORD)((pwfex->wBitsPerSample * pwfex->nChannels) / BITS_PER_BYTE);
+ pwfex->nAvgBytesPerSec = pwfex->nSamplesPerSec * pwfex->nBlockAlign; // it can't calculate this itself? huh?
- // copy this info into the pmt
- return ::CreateAudioMediaType(pwfex, pmt, FALSE /* dont allocate more memory */);
+ // copy this info into the pmt
+ return ::CreateAudioMediaType(pwfex, pmt, FALSE /* dont allocate more memory */);
}
HRESULT CVCamStream::setAsNormal(CMediaType *pmt) {
- WAVEFORMATEX *pwfex;
- pwfex = (WAVEFORMATEX *) pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
- ZeroMemory(pwfex, sizeof(WAVEFORMATEX));
- if(NULL == pwfex)
- {
- return E_OUTOFMEMORY;
- }
- return setupPwfex(pwfex, pmt);
+ WAVEFORMATEX *pwfex;
+ pwfex = (WAVEFORMATEX *) pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
+ ZeroMemory(pwfex, sizeof(WAVEFORMATEX));
+ if(NULL == pwfex)
+ {
+ return E_OUTOFMEMORY;
+ }
+ return setupPwfex(pwfex, pmt);
}
// GetMediaType
@@ -140,7 +140,7 @@ HRESULT LoopbackCaptureSetup()
// get the default device format (incoming...)
WAVEFORMATEX *pwfx; // incoming wave...
// apparently propogated by GetMixFormat...
- hr = pAudioClient->GetMixFormat(&pwfx);
+ hr = pAudioClient->GetMixFormat(&pwfx); // we free pwfx
if (FAILED(hr)) {
ShowOutput("IAudioClient::GetMixFormat failed: hr = 0x%08x\n", hr);
CoTaskMemFree(pwfx);
@@ -161,7 +161,7 @@ HRESULT LoopbackCaptureSetup()
pwfx->nAvgBytesPerSec = pwfx->nBlockAlign * pwfx->nSamplesPerSec;
break;
- case WAVE_FORMAT_EXTENSIBLE:
+ case WAVE_FORMAT_EXTENSIBLE: // 65534
{
// naked scope for case-local variable
PWAVEFORMATEXTENSIBLE pEx = reinterpret_cast<PWAVEFORMATEXTENSIBLE>(pwfx);
@@ -324,8 +324,9 @@ BYTE *captureData;
// activate an IAudioCaptureClient
hr = pAudioClient->GetService(
__uuidof(IAudioCaptureClient),
- (void**)&pAudioCaptureClient // CARE INSTANTIATION
+ (void**)&pAudioCaptureClient
);
+
if (FAILED(hr)) {
ShowOutput("IAudioClient::GetService(IAudioCaptureClient) failed: hr 0x%08x\n", hr);
pAudioClient->Release();
@@ -370,9 +371,9 @@ BYTE *captureData;
return HRESULT_FROM_WIN32(dwErr);
} else {
// we...shouldn't need this...maybe?
- // seems to make no difference...
+ // seems to make no difference anyway, and probably won't hurt...
hr = SetThreadPriority(m_hThread, THREAD_PRIORITY_TIME_CRITICAL);
- if (FAILED(hr)) { // of course we always want to be a high prio thread, right? [we don't use much cpu...]
+ if (FAILED(hr)) {
return hr;
}
}

0 comments on commit 8d11cf9

Please sign in to comment.