Permalink
Browse files

0.3.7 release

  • Loading branch information...
rdp committed Aug 21, 2012
1 parent 6d27c61 commit dca5b20cb18b54478a15a1faccee71f69fb6b9a1
View
@@ -1,3 +1,7 @@
+0.3.7
+
+make compatible with FMLE now [hopefully]
+
0.3.6
hopefully fix ffmpeg complaining like:
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
@@ -18,11 +18,7 @@
#include "common.h"
#include <assert.h>
-HRESULT LoopbackCaptureTakeFromBuffer(BYTE pBuf[], int iSize, WAVEFORMATEX* ifNotNullThenJustSetTypeOnly, LONG* sizeWrote);
-
-#define BITS_PER_BYTE 8
-
-extern CCritSec m_cSharedState;
+//extern CCritSec m_cSharedState;
// This class is exported from the acam.dll
class ACAM_API Cacam {
@@ -129,9 +125,9 @@ class CVCamStream : public CSourceStream, public IAMStreamConfig, public IKsProp
CRefTime m_rtPreviousSampleEndTime;
- // IAMBufferNEgotiation -- never gets called...
- HRESULT STDMETHODCALLTYPE SuggestAllocatorProperties( /* [in] */ const ALLOCATOR_PROPERTIES *pprop) {return NULL;/*TODO*/}
- HRESULT STDMETHODCALLTYPE GetAllocatorProperties( ALLOCATOR_PROPERTIES *pprop) {return NULL;/*TODO*/}
+ // IAMBufferNegotiation -- never gets called...
+ HRESULT STDMETHODCALLTYPE SuggestAllocatorProperties( /* [in] */ const ALLOCATOR_PROPERTIES *pprop);
+ HRESULT STDMETHODCALLTYPE GetAllocatorProperties( ALLOCATOR_PROPERTIES *pprop);
// IAMFilterMiscFlags -- never gets called...
ULONG STDMETHODCALLTYPE GetMiscFlags() { return AM_FILTER_MISC_FLAGS_IS_SOURCE; }
@@ -1,10 +1,14 @@
#define SECOND_FRACTIONS_TO_GRAB 16
-// awfuls...
+// dangerous macros!
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
extern bool bFirstPacket;
void ShowOutput(const char *str, ...);
HRESULT set_config_string_setting(LPCTSTR szValueName, wchar_t *szToThis );
int getHtzRate();
+
+HRESULT LoopbackCaptureTakeFromBuffer(BYTE pBuf[], int iSize, WAVEFORMATEX* ifNotNullThenJustSetTypeOnly, LONG* sizeWrote);
+
+#define BITS_PER_BYTE 8
@@ -12,13 +12,15 @@ CCritSec m_cSharedState;
HRESULT CVCamStream::FillBuffer(IMediaSample *pms)
{
// I don't expect these...the parent controls this/us and doesn't call us when it is stopped I guess, so we should always be active...
- assert(m_pParent->IsActive());
- assert(!m_pParent->IsStopped());
+ ShowOutput("requested audio frame");
+ //assert(m_pParent->IsActive()); // one of these can cause freezing on "stop button" in FME
+ //assert(!m_pParent->IsStopped());
CheckPointer(pms,E_POINTER);
BYTE *pData;
HRESULT hr = pms->GetPointer(&pData);
if (FAILED(hr)) {
+ ShowOutput("fail 1");
assert(false);
return hr;
}
@@ -29,14 +31,15 @@ HRESULT CVCamStream::FillBuffer(IMediaSample *pms)
if(FAILED(hr)) {
// this one can return false during shutdown, so it's actually ok to just return from here...
// assert(false);
+ ShowOutput("shutdown 1");
return hr;
}
CAutoLock cAutoLockShared(&m_cSharedState); // for the bFirstPacket boolean control, except there's probably still some odd race conditions er other...
hr = pms->SetActualDataLength(totalWrote);
if(FAILED(hr)) {
- assert(false);
+ assert(false);
return hr;
}
@@ -46,10 +49,10 @@ HRESULT CVCamStream::FillBuffer(IMediaSample *pms)
CRefTime sampleTimeUsed = (REFERENCE_TIME)(UNITS * pms->GetActualDataLength()) /
(REFERENCE_TIME)pwfexCurrent->nAvgBytesPerSec;
CRefTime rtStart;
- if(bFirstPacket) { // bFirstPacket or true here...true seemed to help that one guy...
+ if(bFirstPacket) { // either have bFirstPacket or true here...true seemed to help that one guy...
m_pParent->StreamTime(rtStart); // gets current graph ref time [now] as its "start", as normal "capture" devices would, just in case that's better...
if(bFirstPacket)
- ShowOutput("retrieving a first packet");
+ ShowOutput("got an audio first packet");
} else {
// since there hasn't been discontinuity, I think we should be safe to tell it
// that this packet starts where the previous packet ended off
@@ -115,7 +118,7 @@ HRESULT CVCamStream::FillBuffer(IMediaSample *pms)
assert(false);
return hr;
}
-
+ ShowOutput("sent audio frame");
bFirstPacket = false;
return NOERROR;
@@ -123,11 +123,13 @@ HRESULT STDMETHODCALLTYPE CVCamStream::SetMaxStreamOffset(REFERENCE_TIME) {
HRESULT CVCamStream::QueryInterface(REFIID riid, void **ppv)
{
- // Standard OLE stuff
+ // Standard OLE stuff...allow it to query for our interfaces that we implement...
if(riid == _uuidof(IAMStreamConfig))
*ppv = (IAMStreamConfig*)this;
else if(riid == _uuidof(IKsPropertySet))
*ppv = (IKsPropertySet*)this;
+ else if(riid == _uuidof(IAMBufferNegotiation))
+ *ppv = (IAMBufferNegotiation*)this;
else
return CSourceStream::QueryInterface(riid, ppv);
@@ -153,8 +155,6 @@ HRESULT CVCamStream::SetMediaType(const CMediaType *pmt)
return hr;
}
-#define DECLARE_PTR(type, ptr, expr) type* ptr = (type*)(expr);
-
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;
@@ -208,7 +208,6 @@ HRESULT CVCamStream::CheckMediaType(const CMediaType *pMediaType)
if(*pMediaType != m_mt) {
return E_INVALIDARG;
}
-
return S_OK;
} // CheckMediaType
@@ -337,7 +336,14 @@ HRESULT CVCamStream::OnThreadCreate()
HRESULT STDMETHODCALLTYPE CVCamStream::SetFormat(AM_MEDIA_TYPE *pmt)
{
// this is them saying you "must" use this type from now on...unless pmt is NULL that "means" reset...LODO handle it someday...
- assert(pmt);
+ if(!pmt) {
+ return S_OK; // *sure* we reset..yeah...sure we did...
+ }
+
+ if(CheckMediaType((CMediaType *) pmt) != S_OK) {
+ return E_FAIL; // just in case :P [FME...]
+ }
+
m_mt = *pmt;
IPin* pin;
@@ -378,8 +384,6 @@ HRESULT STDMETHODCALLTYPE CVCamStream::GetStreamCaps(int iIndex, AM_MEDIA_TYPE *
if (*ppMediaType == NULL) return E_OUTOFMEMORY;
DECLARE_PTR(WAVEFORMATEX, pAudioFormat, (*ppMediaType)->pbFormat);
-
-
AM_MEDIA_TYPE * pm = *ppMediaType;
@@ -393,8 +397,8 @@ HRESULT STDMETHODCALLTYPE CVCamStream::GetStreamCaps(int iIndex, AM_MEDIA_TYPE *
pASCC->MaximumChannels = pAudioFormat->nChannels;
pASCC->MinimumChannels = pAudioFormat->nChannels;
pASCC->ChannelsGranularity = 1; // doesn't matter
- pASCC->MaximumSampleFrequency = getHtzRate();
- pASCC->MinimumSampleFrequency = getHtzRate();
+ pASCC->MaximumSampleFrequency = pAudioFormat->nSamplesPerSec;
+ pASCC->MinimumSampleFrequency = pAudioFormat->nSamplesPerSec;
pASCC->SampleFrequencyGranularity = 11025; // doesn't matter
pASCC->MaximumBitsPerSample = pAudioFormat->wBitsPerSample;
pASCC->MinimumBitsPerSample = pAudioFormat->wBitsPerSample;
@@ -446,3 +450,22 @@ HRESULT CVCamStream::QuerySupported(REFGUID guidPropSet, DWORD dwPropID, DWORD *
return S_OK;
}
+extern long pBufLocalSize;
+extern long pBufOriginalSize;
+
+HRESULT STDMETHODCALLTYPE CVCamStream::SuggestAllocatorProperties( /* [in] */ const ALLOCATOR_PROPERTIES *pprop) {
+ // maybe we shouldn't even care though...I mean like seriously...only make it bigger never smaller?
+
+ int requested = pprop->cbBuffer;
+ if(pprop->cBuffers > 0)
+ requested *= pprop->cBuffers;
+ requested += pprop->cbPrefix;
+
+ if(requested <= pBufOriginalSize) {
+ pBufLocalSize = requested;
+ return S_OK;
+ } else {
+ return E_FAIL;
+ }
+}
+HRESULT STDMETHODCALLTYPE CVCamStream::GetAllocatorProperties( ALLOCATOR_PROPERTIES *pprop) {return NULL;}
@@ -26,10 +26,11 @@ UINT32 pnFrames;
CCritSec csMyLock; // shared critical section. Starts not locked...
-int shouldStop = 0;
+int shouldStop = true;
BYTE pBufLocal[1024*1024]; // 1MB is quite awhile I think...
-long pBufLocalSize = 1024*1024; // TODO needed?
+long pBufOriginalSize = 1024*1024;
+long pBufLocalSize = 1024*1024; // used for buffer size negotiation method.
long pBufLocalCurrentEndLocation = 0;
long expectedMaxBufferSize = 0;
@@ -92,6 +93,7 @@ int getHtzRate() {
// we only call this once...per hit of the play button :)
HRESULT LoopbackCaptureSetup()
{
+ assert(shouldStop); // duplicate starts would be odd...
shouldStop = false; // allow graphs to restart, if they so desire...
pnFrames = 0;
bool bInt16 = true; // makes it actually work, for some reason...LODO
@@ -369,15 +371,7 @@ BYTE *captureData;
HRESULT propagateBufferOnce();
-static DWORD WINAPI propagateBufferForever(LPVOID pv) {
- while(!shouldStop) {
- HRESULT hr = propagateBufferOnce();
- if(FAILED(hr)) {
- return hr;
- }
- }
- return S_OK;
-}
+
extern CCritSec m_cSharedState;
@@ -531,7 +525,7 @@ HRESULT propagateBufferOnce() {
return hr;
} // while !got anything && should continue loop
- return E_UNEXPECTED;
+ return S_OK; // stop was called...
}
@@ -582,3 +576,15 @@ void outputStats() {
wsprintf(output, L"total reads %d total blips %d total overflows %d", totalSuccessFullyread , totalBlips, totalOverflows);
set_config_string_setting(L"last_output", output);
}
+
+// called via reflection :)
+static DWORD WINAPI propagateBufferForever(LPVOID pv) {
+ int a = 3;
+ while(!shouldStop) {
+ HRESULT hr = propagateBufferOnce();
+ if(FAILED(hr)) {
+ return hr;
+ }
+ }
+ return S_OK;
+}
Binary file not shown.

0 comments on commit dca5b20

Please sign in to comment.