diff options
author | tetsuo55 <tetsuo55@users.sourceforge.net> | 2010-04-09 01:14:58 +0400 |
---|---|---|
committer | tetsuo55 <tetsuo55@users.sourceforge.net> | 2010-04-09 01:14:58 +0400 |
commit | a9b7bf3fb3e1334d8defd05ca4cfae870b4912e5 (patch) | |
tree | 2dab453d94d5e003379a6cc895eceb84c80e23ec /src/filters/reader | |
parent | aafd49a91f7c2fa9c7103971c16fa6e1b29e8bfd (diff) |
astyle formatting cleanup to make the sourcecode more accessible
switch used: astyle --style=ansi --min-conditional-indent=0 --pad=oper --unpad=paren
http://astyle.sourceforge.net/
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1783 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/reader')
24 files changed, 1657 insertions, 1459 deletions
diff --git a/src/filters/reader/CDDAReader/CDDAReader.cpp b/src/filters/reader/CDDAReader/CDDAReader.cpp index 193451274..3f83ec737 100644 --- a/src/filters/reader/CDDAReader/CDDAReader.cpp +++ b/src/filters/reader/CDDAReader/CDDAReader.cpp @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -31,55 +31,55 @@ const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
{
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_WAVE},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_WAVE},
};
const AMOVIESETUP_PIN sudOpPin[] =
{
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut},
};
const AMOVIESETUP_FILTER sudFilter[] =
{
- {&__uuidof(CCDDAReader), L"MPC - CDDA Reader", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CCDDAReader), L"MPC - CDDA Reader", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] =
{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CCDDAReader>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CCDDAReader>, NULL, &sudFilter[0]}
};
int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
- if(GetVersion()&0x80000000)
- {
- ::MessageBox(NULL, _T("Sorry, this will only run on Windows NT based operating system."), _T("CDDA Reader"), MB_OK);
- return E_NOTIMPL;
- }
+ if(GetVersion() & 0x80000000)
+ {
+ ::MessageBox(NULL, _T("Sorry, this will only run on Windows NT based operating system."), _T("CDDA Reader"), MB_OK);
+ return E_NOTIMPL;
+ }
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"),
- _T("0"), _T("0,4,,52494646,8,4,,43444441")); // "RIFFxxxxCDDA"
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"),
+ _T("0"), _T("0,4,,52494646,8,4,,43444441")); // "RIFFxxxxCDDA"
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"),
- _T("Source Filter"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"),
+ _T("Source Filter"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"));
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".cda"),
- _T("Source Filter"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"));
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".cda"),
+ _T("Source Filter"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"));
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".cda"));
+ DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".cda"));
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -93,15 +93,15 @@ CFilterApp theApp; //
CCDDAReader::CCDDAReader(IUnknown* pUnk, HRESULT* phr)
- : CAsyncReader(NAME("CCDDAReader"), pUnk, &m_stream, phr, __uuidof(this))
+ : CAsyncReader(NAME("CCDDAReader"), pUnk, &m_stream, phr, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) *phr = S_OK;
- if(GetVersion()&0x80000000)
- {
- if(phr) *phr = E_NOTIMPL;
- return;
- }
+ if(GetVersion() & 0x80000000)
+ {
+ if(phr) *phr = E_NOTIMPL;
+ return;
+ }
}
CCDDAReader::~CCDDAReader()
@@ -112,310 +112,355 @@ STDMETHODIMP CCDDAReader::NonDelegatingQueryInterface(REFIID riid, void** ppv) {
CheckPointer(ppv, E_POINTER);
- return
- QI(IFileSourceFilter)
- QI2(IAMMediaContent)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IFileSourceFilter)
+ QI2(IAMMediaContent)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IFileSourceFilter
-STDMETHODIMP CCDDAReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
+STDMETHODIMP CCDDAReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(!m_stream.Load(pszFileName))
- return E_FAIL;
+ if(!m_stream.Load(pszFileName))
+ return E_FAIL;
- m_fn = pszFileName;
+ m_fn = pszFileName;
- CMediaType mt;
- mt.majortype = MEDIATYPE_Stream;
- mt.subtype = MEDIASUBTYPE_WAVE;
- m_mt = mt;
+ CMediaType mt;
+ mt.majortype = MEDIATYPE_Stream;
+ mt.subtype = MEDIASUBTYPE_WAVE;
+ m_mt = mt;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CCDDAReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- CheckPointer(ppszFileName, E_POINTER);
-
- if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR))))
- return E_OUTOFMEMORY;
+ CheckPointer(ppszFileName, E_POINTER);
- wcscpy(*ppszFileName, m_fn);
+ if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR))))
+ return E_OUTOFMEMORY;
- return S_OK;
+ wcscpy(*ppszFileName, m_fn);
+
+ return S_OK;
}
// IAMMediaContent
-STDMETHODIMP CCDDAReader::GetTypeInfoCount(UINT* pctinfo) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr) {return E_NOTIMPL;}
+STDMETHODIMP CCDDAReader::GetTypeInfoCount(UINT* pctinfo)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr)
+{
+ return E_NOTIMPL;
+}
STDMETHODIMP CCDDAReader::get_AuthorName(BSTR* pbstrAuthorName)
{
- CheckPointer(pbstrAuthorName, E_POINTER);
- CString str = m_stream.m_trackArtist;
- if(str.IsEmpty()) str = m_stream.m_discArtist;
- *pbstrAuthorName = str.AllocSysString();
- return S_OK;
+ CheckPointer(pbstrAuthorName, E_POINTER);
+ CString str = m_stream.m_trackArtist;
+ if(str.IsEmpty()) str = m_stream.m_discArtist;
+ *pbstrAuthorName = str.AllocSysString();
+ return S_OK;
}
STDMETHODIMP CCDDAReader::get_Title(BSTR* pbstrTitle)
{
- CheckPointer(pbstrTitle, E_POINTER);
- CString str = m_stream.m_trackTitle;
- if(str.IsEmpty()) str = m_stream.m_discTitle;
- *pbstrTitle = str.AllocSysString();
- return S_OK;
-}
-
-STDMETHODIMP CCDDAReader::get_Rating(BSTR* pbstrRating) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_Description(BSTR* pbstrDescription) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_Copyright(BSTR* pbstrCopyright) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_BaseURL(BSTR* pbstrBaseURL) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_LogoURL(BSTR* pbstrLogoURL) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_LogoIconURL(BSTR* pbstrLogoURL) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_WatermarkURL(BSTR* pbstrWatermarkURL) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_MoreInfoURL(BSTR* pbstrMoreInfoURL) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_MoreInfoBannerImage(BSTR* pbstrMoreInfoBannerImage) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_MoreInfoBannerURL(BSTR* pbstrMoreInfoBannerURL) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_MoreInfoText(BSTR* pbstrMoreInfoText) {return E_NOTIMPL;}
+ CheckPointer(pbstrTitle, E_POINTER);
+ CString str = m_stream.m_trackTitle;
+ if(str.IsEmpty()) str = m_stream.m_discTitle;
+ *pbstrTitle = str.AllocSysString();
+ return S_OK;
+}
+
+STDMETHODIMP CCDDAReader::get_Rating(BSTR* pbstrRating)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_Description(BSTR* pbstrDescription)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_Copyright(BSTR* pbstrCopyright)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_BaseURL(BSTR* pbstrBaseURL)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_LogoURL(BSTR* pbstrLogoURL)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_LogoIconURL(BSTR* pbstrLogoURL)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_WatermarkURL(BSTR* pbstrWatermarkURL)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_MoreInfoURL(BSTR* pbstrMoreInfoURL)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_MoreInfoBannerImage(BSTR* pbstrMoreInfoBannerImage)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_MoreInfoBannerURL(BSTR* pbstrMoreInfoBannerURL)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_MoreInfoText(BSTR* pbstrMoreInfoText)
+{
+ return E_NOTIMPL;
+}
// CCDDAStream
CCDDAStream::CCDDAStream()
{
- m_hDrive = INVALID_HANDLE_VALUE;
-
- m_llPosition = m_llLength = 0;
-
- memset(&m_TOC, 0, sizeof(m_TOC));
- m_nStartSector = m_nStopSector = 0;
-
- memset(&m_header, 0, sizeof(m_header));
- m_header.riff.hdr.chunkID = RIFFID;
- m_header.riff.WAVE = WAVEID;
- m_header.frm.hdr.chunkID = FormatID;
- m_header.frm.hdr.chunkSize = sizeof(m_header.frm.pcm);
- m_header.frm.pcm.wf.wFormatTag = WAVE_FORMAT_PCM;
- m_header.frm.pcm.wf.nSamplesPerSec = 44100;
- m_header.frm.pcm.wf.nChannels = 2;
- m_header.frm.pcm.wBitsPerSample = 16;
- m_header.frm.pcm.wf.nBlockAlign = m_header.frm.pcm.wf.nChannels * m_header.frm.pcm.wBitsPerSample / 8;
- m_header.frm.pcm.wf.nAvgBytesPerSec = m_header.frm.pcm.wf.nSamplesPerSec * m_header.frm.pcm.wf.nBlockAlign;
- m_header.data.hdr.chunkID = DataID;
+ m_hDrive = INVALID_HANDLE_VALUE;
+
+ m_llPosition = m_llLength = 0;
+
+ memset(&m_TOC, 0, sizeof(m_TOC));
+ m_nStartSector = m_nStopSector = 0;
+
+ memset(&m_header, 0, sizeof(m_header));
+ m_header.riff.hdr.chunkID = RIFFID;
+ m_header.riff.WAVE = WAVEID;
+ m_header.frm.hdr.chunkID = FormatID;
+ m_header.frm.hdr.chunkSize = sizeof(m_header.frm.pcm);
+ m_header.frm.pcm.wf.wFormatTag = WAVE_FORMAT_PCM;
+ m_header.frm.pcm.wf.nSamplesPerSec = 44100;
+ m_header.frm.pcm.wf.nChannels = 2;
+ m_header.frm.pcm.wBitsPerSample = 16;
+ m_header.frm.pcm.wf.nBlockAlign = m_header.frm.pcm.wf.nChannels * m_header.frm.pcm.wBitsPerSample / 8;
+ m_header.frm.pcm.wf.nAvgBytesPerSec = m_header.frm.pcm.wf.nSamplesPerSec * m_header.frm.pcm.wf.nBlockAlign;
+ m_header.data.hdr.chunkID = DataID;
}
CCDDAStream::~CCDDAStream()
{
- if(m_hDrive != INVALID_HANDLE_VALUE)
- {
- CloseHandle(m_hDrive);
- m_hDrive = INVALID_HANDLE_VALUE;
- }
+ if(m_hDrive != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(m_hDrive);
+ m_hDrive = INVALID_HANDLE_VALUE;
+ }
}
bool CCDDAStream::Load(const WCHAR* fnw)
{
- CString path(fnw);
-
- int iDriveLetter = path.Find(_T(":\\"))-1;
- int iTrackIndex = CString(path).MakeLower().Find(_T(".cda"))-1;
- if(iDriveLetter < 0 || iTrackIndex <= iDriveLetter)
- return(false);
-
- CString drive = CString(_T("\\\\.\\")) + path[iDriveLetter] + _T(":");
- while(iTrackIndex > 0 && _istdigit(path[iTrackIndex-1])) iTrackIndex--;
- if(1 != _stscanf(path.Mid(iTrackIndex), _T("%d"), &iTrackIndex))
- return(false);
-
- if(m_hDrive != INVALID_HANDLE_VALUE)
- {
- CloseHandle(m_hDrive);
- m_hDrive = INVALID_HANDLE_VALUE;
- }
-
- m_hDrive = CreateFile(drive, GENERIC_READ, FILE_SHARE_READ, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, (HANDLE)NULL);
- if(m_hDrive == INVALID_HANDLE_VALUE)
- {
- return(false);
- }
-
- DWORD BytesReturned;
- if(!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC, NULL, 0, &m_TOC, sizeof(m_TOC), &BytesReturned, 0)
- || !(m_TOC.FirstTrack <= iTrackIndex && iTrackIndex <= m_TOC.LastTrack))
- {
- CloseHandle(m_hDrive);
- m_hDrive = INVALID_HANDLE_VALUE;
- return(false);
- }
-
- // MMC-3 Draft Revision 10g: Table 222 – Q Sub-channel control field
- m_TOC.TrackData[iTrackIndex-1].Control &= 5;
- if(!(m_TOC.TrackData[iTrackIndex-1].Control == 0 || m_TOC.TrackData[iTrackIndex-1].Control == 1))
- {
- CloseHandle(m_hDrive);
- m_hDrive = INVALID_HANDLE_VALUE;
- return(false);
- }
-
- if(m_TOC.TrackData[iTrackIndex-1].Control&8)
- m_header.frm.pcm.wf.nChannels = 4;
-
- m_nStartSector = MSF2UINT(m_TOC.TrackData[iTrackIndex-1].Address) - 150;//MSF2UINT(m_TOC.TrackData[0].Address);
- m_nStopSector = MSF2UINT(m_TOC.TrackData[iTrackIndex].Address) - 150;//MSF2UINT(m_TOC.TrackData[0].Address);
-
- m_llLength = (m_nStopSector-m_nStartSector)*RAW_SECTOR_SIZE;
-
- m_header.riff.hdr.chunkSize = (long)(m_llLength + sizeof(m_header) - 8);
- m_header.data.hdr.chunkSize = (long)(m_llLength);
-
- do
- {
- CDROM_READ_TOC_EX TOCEx;
- memset(&TOCEx, 0, sizeof(TOCEx));
- TOCEx.Format = CDROM_READ_TOC_EX_FORMAT_CDTEXT;
- TOCEx.SessionTrack = iTrackIndex;
- WORD size = 0;
- ASSERT(MINIMUM_CDROM_READ_TOC_EX_SIZE == sizeof(size));
- if(!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC_EX, &TOCEx, sizeof(TOCEx), &size, sizeof(size), &BytesReturned, 0))
- break;
-
- size = ((size>>8)|(size<<8)) + sizeof(size);
-
- CAutoVectorPtr<BYTE> pCDTextData;
- pCDTextData.Allocate(size);
- memset(pCDTextData, 0, size);
-
- if(!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC_EX, &TOCEx, sizeof(TOCEx), pCDTextData, size, &BytesReturned, 0))
- break;
-
- size = (WORD)(BytesReturned - sizeof(CDROM_TOC_CD_TEXT_DATA));
- CDROM_TOC_CD_TEXT_DATA_BLOCK* pDesc = ((CDROM_TOC_CD_TEXT_DATA*)(BYTE*)pCDTextData)->Descriptors;
-
- CStringArray str[16];
- for(int i = 0; i < 16; i++) str[i].SetSize(1+m_TOC.LastTrack);
- CString last;
-
- for(int i = 0; size >= sizeof(CDROM_TOC_CD_TEXT_DATA_BLOCK); i++, size -= sizeof(CDROM_TOC_CD_TEXT_DATA_BLOCK), pDesc++)
- {
- if(pDesc->TrackNumber > m_TOC.LastTrack)
- continue;
-
- const int lenU = countof(pDesc->Text);
- const int lenW = countof(pDesc->WText);
-
- CString text = !pDesc->Unicode
- ? CString(CStringA((CHAR*)pDesc->Text, lenU))
- : CString(CStringW((WCHAR*)pDesc->WText, lenW));
-
- int tlen = text.GetLength();
- CString tmp = (tlen < 12-1)
- ? (!pDesc->Unicode
- ? CString(CStringA((CHAR*)pDesc->Text+tlen+1, lenU-(tlen+1)))
- : CString(CStringW((WCHAR*)pDesc->WText+tlen+1, lenW-(tlen+1))))
- : _T("");
-
- if((pDesc->PackType -= 0x80) >= 0x10)
- continue;
-
- if(pDesc->CharacterPosition == 0)
- {
- str[pDesc->PackType][pDesc->TrackNumber] = text;
- }
- else if(pDesc->CharacterPosition <= 0xf)
- {
- if(pDesc->CharacterPosition < 0xf && last.GetLength() > 0)
- {
- str[pDesc->PackType][pDesc->TrackNumber] = last + text;
- }
- else
- {
- str[pDesc->PackType][pDesc->TrackNumber] += text;
- }
- }
-
- last = tmp;
- }
-
- m_discTitle = str[0][0];
- m_trackTitle = str[0][iTrackIndex];
- m_discArtist = str[1][0];
- m_trackArtist = str[1][iTrackIndex];
- }
- while(0);
-
-
- return(true);
+ CString path(fnw);
+
+ int iDriveLetter = path.Find(_T(":\\")) - 1;
+ int iTrackIndex = CString(path).MakeLower().Find(_T(".cda")) - 1;
+ if(iDriveLetter < 0 || iTrackIndex <= iDriveLetter)
+ return(false);
+
+ CString drive = CString(_T("\\\\.\\")) + path[iDriveLetter] + _T(":");
+ while(iTrackIndex > 0 && _istdigit(path[iTrackIndex-1])) iTrackIndex--;
+ if(1 != _stscanf(path.Mid(iTrackIndex), _T("%d"), &iTrackIndex))
+ return(false);
+
+ if(m_hDrive != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(m_hDrive);
+ m_hDrive = INVALID_HANDLE_VALUE;
+ }
+
+ m_hDrive = CreateFile(drive, GENERIC_READ, FILE_SHARE_READ, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN, (HANDLE)NULL);
+ if(m_hDrive == INVALID_HANDLE_VALUE)
+ {
+ return(false);
+ }
+
+ DWORD BytesReturned;
+ if(!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC, NULL, 0, &m_TOC, sizeof(m_TOC), &BytesReturned, 0)
+ || !(m_TOC.FirstTrack <= iTrackIndex && iTrackIndex <= m_TOC.LastTrack))
+ {
+ CloseHandle(m_hDrive);
+ m_hDrive = INVALID_HANDLE_VALUE;
+ return(false);
+ }
+
+ // MMC-3 Draft Revision 10g: Table 222 – Q Sub-channel control field
+ m_TOC.TrackData[iTrackIndex-1].Control &= 5;
+ if(!(m_TOC.TrackData[iTrackIndex-1].Control == 0 || m_TOC.TrackData[iTrackIndex-1].Control == 1))
+ {
+ CloseHandle(m_hDrive);
+ m_hDrive = INVALID_HANDLE_VALUE;
+ return(false);
+ }
+
+ if(m_TOC.TrackData[iTrackIndex-1].Control & 8)
+ m_header.frm.pcm.wf.nChannels = 4;
+
+ m_nStartSector = MSF2UINT(m_TOC.TrackData[iTrackIndex-1].Address) - 150;//MSF2UINT(m_TOC.TrackData[0].Address);
+ m_nStopSector = MSF2UINT(m_TOC.TrackData[iTrackIndex].Address) - 150;//MSF2UINT(m_TOC.TrackData[0].Address);
+
+ m_llLength = (m_nStopSector - m_nStartSector) * RAW_SECTOR_SIZE;
+
+ m_header.riff.hdr.chunkSize = (long)(m_llLength + sizeof(m_header) - 8);
+ m_header.data.hdr.chunkSize = (long)(m_llLength);
+
+ do
+ {
+ CDROM_READ_TOC_EX TOCEx;
+ memset(&TOCEx, 0, sizeof(TOCEx));
+ TOCEx.Format = CDROM_READ_TOC_EX_FORMAT_CDTEXT;
+ TOCEx.SessionTrack = iTrackIndex;
+ WORD size = 0;
+ ASSERT(MINIMUM_CDROM_READ_TOC_EX_SIZE == sizeof(size));
+ if(!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC_EX, &TOCEx, sizeof(TOCEx), &size, sizeof(size), &BytesReturned, 0))
+ break;
+
+ size = ((size >> 8) | (size << 8)) + sizeof(size);
+
+ CAutoVectorPtr<BYTE> pCDTextData;
+ pCDTextData.Allocate(size);
+ memset(pCDTextData, 0, size);
+
+ if(!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC_EX, &TOCEx, sizeof(TOCEx), pCDTextData, size, &BytesReturned, 0))
+ break;
+
+ size = (WORD)(BytesReturned - sizeof(CDROM_TOC_CD_TEXT_DATA));
+ CDROM_TOC_CD_TEXT_DATA_BLOCK* pDesc = ((CDROM_TOC_CD_TEXT_DATA*)(BYTE*)pCDTextData)->Descriptors;
+
+ CStringArray str[16];
+ for(int i = 0; i < 16; i++) str[i].SetSize(1 + m_TOC.LastTrack);
+ CString last;
+
+ for(int i = 0; size >= sizeof(CDROM_TOC_CD_TEXT_DATA_BLOCK); i++, size -= sizeof(CDROM_TOC_CD_TEXT_DATA_BLOCK), pDesc++)
+ {
+ if(pDesc->TrackNumber > m_TOC.LastTrack)
+ continue;
+
+ const int lenU = countof(pDesc->Text);
+ const int lenW = countof(pDesc->WText);
+
+ CString text = !pDesc->Unicode
+ ? CString(CStringA((CHAR*)pDesc->Text, lenU))
+ : CString(CStringW((WCHAR*)pDesc->WText, lenW));
+
+ int tlen = text.GetLength();
+ CString tmp = (tlen < 12 - 1)
+ ? (!pDesc->Unicode
+ ? CString(CStringA((CHAR*)pDesc->Text + tlen + 1, lenU - (tlen + 1)))
+ : CString(CStringW((WCHAR*)pDesc->WText + tlen + 1, lenW - (tlen + 1))))
+ : _T("");
+
+ if((pDesc->PackType -= 0x80) >= 0x10)
+ continue;
+
+ if(pDesc->CharacterPosition == 0)
+ {
+ str[pDesc->PackType][pDesc->TrackNumber] = text;
+ }
+ else if(pDesc->CharacterPosition <= 0xf)
+ {
+ if(pDesc->CharacterPosition < 0xf && last.GetLength() > 0)
+ {
+ str[pDesc->PackType][pDesc->TrackNumber] = last + text;
+ }
+ else
+ {
+ str[pDesc->PackType][pDesc->TrackNumber] += text;
+ }
+ }
+
+ last = tmp;
+ }
+
+ m_discTitle = str[0][0];
+ m_trackTitle = str[0][iTrackIndex];
+ m_discArtist = str[1][0];
+ m_trackArtist = str[1][iTrackIndex];
+ }
+ while(0);
+
+
+ return(true);
}
HRESULT CCDDAStream::SetPointer(LONGLONG llPos)
{
- if(llPos < 0 || llPos > m_llLength) return S_FALSE;
- m_llPosition = llPos;
- return S_OK;
+ if(llPos < 0 || llPos > m_llLength) return S_FALSE;
+ m_llPosition = llPos;
+ return S_OK;
}
HRESULT CCDDAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead)
{
- CAutoLock lck(&m_csLock);
-
- BYTE buff[RAW_SECTOR_SIZE];
-
- PBYTE pbBufferOrg = pbBuffer;
- LONGLONG pos = m_llPosition;
- size_t len = (size_t)dwBytesToRead;
-
- if(pos < sizeof(m_header) && len > 0)
- {
- size_t l = (size_t)min(len, sizeof(m_header) - pos);
- memcpy(pbBuffer, &((BYTE*)&m_header)[pos], l);
- pbBuffer += l;
- pos += l;
- len -= l;
- }
-
- pos -= sizeof(m_header);
-
- while(pos >= 0 && pos < m_llLength && len > 0)
- {
- RAW_READ_INFO rawreadinfo;
- rawreadinfo.SectorCount = 1;
- rawreadinfo.TrackMode = CDDA;
-
- UINT sector = m_nStartSector + int(pos/RAW_SECTOR_SIZE);
- __int64 offset = pos%RAW_SECTOR_SIZE;
-
- rawreadinfo.DiskOffset.QuadPart = sector*2048;
- DWORD BytesReturned = 0;
- BOOL b = DeviceIoControl(
- m_hDrive, IOCTL_CDROM_RAW_READ,
- &rawreadinfo, sizeof(rawreadinfo),
- buff, RAW_SECTOR_SIZE,
- &BytesReturned, 0);
-
- size_t l = (size_t)min(min(len, RAW_SECTOR_SIZE - offset), m_llLength - pos);
- memcpy(pbBuffer, &buff[offset], l);
-
- pbBuffer += l;
- pos += l;
- len -= l;
- }
-
- if(pdwBytesRead) *pdwBytesRead = pbBuffer - pbBufferOrg;
- m_llPosition += pbBuffer - pbBufferOrg;
-
- return S_OK;
+ CAutoLock lck(&m_csLock);
+
+ BYTE buff[RAW_SECTOR_SIZE];
+
+ PBYTE pbBufferOrg = pbBuffer;
+ LONGLONG pos = m_llPosition;
+ size_t len = (size_t)dwBytesToRead;
+
+ if(pos < sizeof(m_header) && len > 0)
+ {
+ size_t l = (size_t)min(len, sizeof(m_header) - pos);
+ memcpy(pbBuffer, &((BYTE*)&m_header)[pos], l);
+ pbBuffer += l;
+ pos += l;
+ len -= l;
+ }
+
+ pos -= sizeof(m_header);
+
+ while(pos >= 0 && pos < m_llLength && len > 0)
+ {
+ RAW_READ_INFO rawreadinfo;
+ rawreadinfo.SectorCount = 1;
+ rawreadinfo.TrackMode = CDDA;
+
+ UINT sector = m_nStartSector + int(pos / RAW_SECTOR_SIZE);
+ __int64 offset = pos % RAW_SECTOR_SIZE;
+
+ rawreadinfo.DiskOffset.QuadPart = sector * 2048;
+ DWORD BytesReturned = 0;
+ BOOL b = DeviceIoControl(
+ m_hDrive, IOCTL_CDROM_RAW_READ,
+ &rawreadinfo, sizeof(rawreadinfo),
+ buff, RAW_SECTOR_SIZE,
+ &BytesReturned, 0);
+
+ size_t l = (size_t)min(min(len, RAW_SECTOR_SIZE - offset), m_llLength - pos);
+ memcpy(pbBuffer, &buff[offset], l);
+
+ pbBuffer += l;
+ pos += l;
+ len -= l;
+ }
+
+ if(pdwBytesRead) *pdwBytesRead = pbBuffer - pbBufferOrg;
+ m_llPosition += pbBuffer - pbBufferOrg;
+
+ return S_OK;
}
LONGLONG CCDDAStream::Size(LONGLONG* pSizeAvailable)
{
- LONGLONG size = sizeof(m_header) + m_llLength;
- if(pSizeAvailable) *pSizeAvailable = size;
+ LONGLONG size = sizeof(m_header) + m_llLength;
+ if(pSizeAvailable) *pSizeAvailable = size;
return size;
}
diff --git a/src/filters/reader/CDDAReader/CDDAReader.h b/src/filters/reader/CDDAReader/CDDAReader.h index d3ac17c0a..15019e76d 100644 --- a/src/filters/reader/CDDAReader/CDDAReader.h +++ b/src/filters/reader/CDDAReader/CDDAReader.h @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -28,77 +28,97 @@ #include "../asyncreader/asyncio.h"
#include "../asyncreader/asyncrdr.h"
-typedef struct {UINT chunkID; long chunkSize;} ChunkHeader;
+typedef struct
+{
+ UINT chunkID;
+ long chunkSize;
+} ChunkHeader;
-#define RIFFID 'FFIR'
-#define WAVEID 'EVAW'
-typedef struct {ChunkHeader hdr; UINT WAVE;} RIFFChunk;
+#define RIFFID 'FFIR'
+#define WAVEID 'EVAW'
+typedef struct
+{
+ ChunkHeader hdr;
+ UINT WAVE;
+} RIFFChunk;
-#define FormatID ' tmf'
-typedef struct {ChunkHeader hdr; PCMWAVEFORMAT pcm;} FormatChunk;
+#define FormatID ' tmf'
+typedef struct
+{
+ ChunkHeader hdr;
+ PCMWAVEFORMAT pcm;
+} FormatChunk;
#define DataID 'atad'
-typedef struct {ChunkHeader hdr;} DataChunk;
+typedef struct
+{
+ ChunkHeader hdr;
+} DataChunk;
-typedef struct {RIFFChunk riff; FormatChunk frm; DataChunk data;} WAVEChunck;
+typedef struct
+{
+ RIFFChunk riff;
+ FormatChunk frm;
+ DataChunk data;
+} WAVEChunck;
class CCDDAStream : public CAsyncStream
{
private:
CCritSec m_csLock;
- LONGLONG m_llPosition, m_llLength;
+ LONGLONG m_llPosition, m_llLength;
- HANDLE m_hDrive;
- CDROM_TOC m_TOC;
- UINT m_nFirstSector, m_nStartSector, m_nStopSector;
+ HANDLE m_hDrive;
+ CDROM_TOC m_TOC;
+ UINT m_nFirstSector, m_nStartSector, m_nStopSector;
- WAVEChunck m_header;
+ WAVEChunck m_header;
public:
- CCDDAStream();
- virtual ~CCDDAStream();
+ CCDDAStream();
+ virtual ~CCDDAStream();
- CString m_discTitle, m_trackTitle;
- CString m_discArtist, m_trackArtist;
+ CString m_discTitle, m_trackTitle;
+ CString m_discArtist, m_trackArtist;
- bool Load(const WCHAR* fnw);
+ bool Load(const WCHAR* fnw);
- // overrides
+ // overrides
HRESULT SetPointer(LONGLONG llPos);
HRESULT Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead);
LONGLONG Size(LONGLONG* pSizeAvailable);
DWORD Alignment();
void Lock();
- void Unlock();
+ void Unlock();
};
[uuid("54A35221-2C8D-4a31-A5DF-6D809847E393")]
-class CCDDAReader
- : public CAsyncReader
- , public IFileSourceFilter
- , public IAMMediaContent
+class CCDDAReader
+ : public CAsyncReader
+ , public IFileSourceFilter
+ , public IAMMediaContent
{
CCDDAStream m_stream;
- CStringW m_fn;
+ CStringW m_fn;
public:
CCDDAReader(IUnknown* pUnk, HRESULT* phr);
- ~CCDDAReader();
+ ~CCDDAReader();
- DECLARE_IUNKNOWN;
+ DECLARE_IUNKNOWN;
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IFileSourceFilter
+ // IFileSourceFilter
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
- // IAMMediaContent
+ // IAMMediaContent
STDMETHODIMP GetTypeInfoCount(UINT* pctinfo);
- STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo);
- STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid);
+ STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo);
+ STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid);
STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr);
STDMETHODIMP get_AuthorName(BSTR* pbstrAuthorName);
diff --git a/src/filters/reader/CDDAReader/resource.h b/src/filters/reader/CDDAReader/resource.h index 0d07f7b10..0bc7c47f7 100644 --- a/src/filters/reader/CDDAReader/resource.h +++ b/src/filters/reader/CDDAReader/resource.h @@ -3,7 +3,7 @@ // Used by cddareader.rc
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
diff --git a/src/filters/reader/CDDAReader/stdafx.cpp b/src/filters/reader/CDDAReader/stdafx.cpp index d431dab84..c330f87bd 100644 --- a/src/filters/reader/CDDAReader/stdafx.cpp +++ b/src/filters/reader/CDDAReader/stdafx.cpp @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/reader/CDDAReader/stdafx.h b/src/filters/reader/CDDAReader/stdafx.h index c35359c38..a9f666228 100644 --- a/src/filters/reader/CDDAReader/stdafx.h +++ b/src/filters/reader/CDDAReader/stdafx.h @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/reader/CDXAReader/CDXAReader.cpp b/src/filters/reader/CDXAReader/CDXAReader.cpp index 9d9e5e854..4ed1dbfa7 100644 --- a/src/filters/reader/CDXAReader/CDXAReader.cpp +++ b/src/filters/reader/CDXAReader/CDXAReader.cpp @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -28,83 +28,83 @@ /////////
-static DWORD EDC_crctable[256] =
+static DWORD EDC_crctable[256] =
{
- 0x00000000l, 0x90910101l, 0x91210201l, 0x01b00300l,
- 0x92410401l, 0x02d00500l, 0x03600600l, 0x93f10701l,
- 0x94810801l, 0x04100900l, 0x05a00a00l, 0x95310b01l,
- 0x06c00c00l, 0x96510d01l, 0x97e10e01l, 0x07700f00l,
- 0x99011001l, 0x09901100l, 0x08201200l, 0x98b11301l,
- 0x0b401400l, 0x9bd11501l, 0x9a611601l, 0x0af01700l,
- 0x0d801800l, 0x9d111901l, 0x9ca11a01l, 0x0c301b00l,
- 0x9fc11c01l, 0x0f501d00l, 0x0ee01e00l, 0x9e711f01l,
- 0x82012001l, 0x12902100l, 0x13202200l, 0x83b12301l,
- 0x10402400l, 0x80d12501l, 0x81612601l, 0x11f02700l,
- 0x16802800l, 0x86112901l, 0x87a12a01l, 0x17302b00l,
- 0x84c12c01l, 0x14502d00l, 0x15e02e00l, 0x85712f01l,
- 0x1b003000l, 0x8b913101l, 0x8a213201l, 0x1ab03300l,
- 0x89413401l, 0x19d03500l, 0x18603600l, 0x88f13701l,
- 0x8f813801l, 0x1f103900l, 0x1ea03a00l, 0x8e313b01l,
- 0x1dc03c00l, 0x8d513d01l, 0x8ce13e01l, 0x1c703f00l,
- 0xb4014001l, 0x24904100l, 0x25204200l, 0xb5b14301l,
- 0x26404400l, 0xb6d14501l, 0xb7614601l, 0x27f04700l,
- 0x20804800l, 0xb0114901l, 0xb1a14a01l, 0x21304b00l,
- 0xb2c14c01l, 0x22504d00l, 0x23e04e00l, 0xb3714f01l,
- 0x2d005000l, 0xbd915101l, 0xbc215201l, 0x2cb05300l,
- 0xbf415401l, 0x2fd05500l, 0x2e605600l, 0xbef15701l,
- 0xb9815801l, 0x29105900l, 0x28a05a00l, 0xb8315b01l,
- 0x2bc05c00l, 0xbb515d01l, 0xbae15e01l, 0x2a705f00l,
- 0x36006000l, 0xa6916101l, 0xa7216201l, 0x37b06300l,
- 0xa4416401l, 0x34d06500l, 0x35606600l, 0xa5f16701l,
- 0xa2816801l, 0x32106900l, 0x33a06a00l, 0xa3316b01l,
- 0x30c06c00l, 0xa0516d01l, 0xa1e16e01l, 0x31706f00l,
- 0xaf017001l, 0x3f907100l, 0x3e207200l, 0xaeb17301l,
- 0x3d407400l, 0xadd17501l, 0xac617601l, 0x3cf07700l,
- 0x3b807800l, 0xab117901l, 0xaaa17a01l, 0x3a307b00l,
- 0xa9c17c01l, 0x39507d00l, 0x38e07e00l, 0xa8717f01l,
- 0xd8018001l, 0x48908100l, 0x49208200l, 0xd9b18301l,
- 0x4a408400l, 0xdad18501l, 0xdb618601l, 0x4bf08700l,
- 0x4c808800l, 0xdc118901l, 0xdda18a01l, 0x4d308b00l,
- 0xdec18c01l, 0x4e508d00l, 0x4fe08e00l, 0xdf718f01l,
- 0x41009000l, 0xd1919101l, 0xd0219201l, 0x40b09300l,
- 0xd3419401l, 0x43d09500l, 0x42609600l, 0xd2f19701l,
- 0xd5819801l, 0x45109900l, 0x44a09a00l, 0xd4319b01l,
- 0x47c09c00l, 0xd7519d01l, 0xd6e19e01l, 0x46709f00l,
- 0x5a00a000l, 0xca91a101l, 0xcb21a201l, 0x5bb0a300l,
- 0xc841a401l, 0x58d0a500l, 0x5960a600l, 0xc9f1a701l,
- 0xce81a801l, 0x5e10a900l, 0x5fa0aa00l, 0xcf31ab01l,
- 0x5cc0ac00l, 0xcc51ad01l, 0xcde1ae01l, 0x5d70af00l,
- 0xc301b001l, 0x5390b100l, 0x5220b200l, 0xc2b1b301l,
- 0x5140b400l, 0xc1d1b501l, 0xc061b601l, 0x50f0b700l,
- 0x5780b800l, 0xc711b901l, 0xc6a1ba01l, 0x5630bb00l,
- 0xc5c1bc01l, 0x5550bd00l, 0x54e0be00l, 0xc471bf01l,
- 0x6c00c000l, 0xfc91c101l, 0xfd21c201l, 0x6db0c300l,
- 0xfe41c401l, 0x6ed0c500l, 0x6f60c600l, 0xfff1c701l,
- 0xf881c801l, 0x6810c900l, 0x69a0ca00l, 0xf931cb01l,
- 0x6ac0cc00l, 0xfa51cd01l, 0xfbe1ce01l, 0x6b70cf00l,
- 0xf501d001l, 0x6590d100l, 0x6420d200l, 0xf4b1d301l,
- 0x6740d400l, 0xf7d1d501l, 0xf661d601l, 0x66f0d700l,
- 0x6180d800l, 0xf111d901l, 0xf0a1da01l, 0x6030db00l,
- 0xf3c1dc01l, 0x6350dd00l, 0x62e0de00l, 0xf271df01l,
- 0xee01e001l, 0x7e90e100l, 0x7f20e200l, 0xefb1e301l,
- 0x7c40e400l, 0xecd1e501l, 0xed61e601l, 0x7df0e700l,
- 0x7a80e800l, 0xea11e901l, 0xeba1ea01l, 0x7b30eb00l,
- 0xe8c1ec01l, 0x7850ed00l, 0x79e0ee00l, 0xe971ef01l,
- 0x7700f000l, 0xe791f101l, 0xe621f201l, 0x76b0f300l,
- 0xe541f401l, 0x75d0f500l, 0x7460f600l, 0xe4f1f701l,
- 0xe381f801l, 0x7310f900l, 0x72a0fa00l, 0xe231fb01l,
- 0x71c0fc00l, 0xe151fd01l, 0xe0e1fe01l, 0x7070ff00l
+ 0x00000000l, 0x90910101l, 0x91210201l, 0x01b00300l,
+ 0x92410401l, 0x02d00500l, 0x03600600l, 0x93f10701l,
+ 0x94810801l, 0x04100900l, 0x05a00a00l, 0x95310b01l,
+ 0x06c00c00l, 0x96510d01l, 0x97e10e01l, 0x07700f00l,
+ 0x99011001l, 0x09901100l, 0x08201200l, 0x98b11301l,
+ 0x0b401400l, 0x9bd11501l, 0x9a611601l, 0x0af01700l,
+ 0x0d801800l, 0x9d111901l, 0x9ca11a01l, 0x0c301b00l,
+ 0x9fc11c01l, 0x0f501d00l, 0x0ee01e00l, 0x9e711f01l,
+ 0x82012001l, 0x12902100l, 0x13202200l, 0x83b12301l,
+ 0x10402400l, 0x80d12501l, 0x81612601l, 0x11f02700l,
+ 0x16802800l, 0x86112901l, 0x87a12a01l, 0x17302b00l,
+ 0x84c12c01l, 0x14502d00l, 0x15e02e00l, 0x85712f01l,
+ 0x1b003000l, 0x8b913101l, 0x8a213201l, 0x1ab03300l,
+ 0x89413401l, 0x19d03500l, 0x18603600l, 0x88f13701l,
+ 0x8f813801l, 0x1f103900l, 0x1ea03a00l, 0x8e313b01l,
+ 0x1dc03c00l, 0x8d513d01l, 0x8ce13e01l, 0x1c703f00l,
+ 0xb4014001l, 0x24904100l, 0x25204200l, 0xb5b14301l,
+ 0x26404400l, 0xb6d14501l, 0xb7614601l, 0x27f04700l,
+ 0x20804800l, 0xb0114901l, 0xb1a14a01l, 0x21304b00l,
+ 0xb2c14c01l, 0x22504d00l, 0x23e04e00l, 0xb3714f01l,
+ 0x2d005000l, 0xbd915101l, 0xbc215201l, 0x2cb05300l,
+ 0xbf415401l, 0x2fd05500l, 0x2e605600l, 0xbef15701l,
+ 0xb9815801l, 0x29105900l, 0x28a05a00l, 0xb8315b01l,
+ 0x2bc05c00l, 0xbb515d01l, 0xbae15e01l, 0x2a705f00l,
+ 0x36006000l, 0xa6916101l, 0xa7216201l, 0x37b06300l,
+ 0xa4416401l, 0x34d06500l, 0x35606600l, 0xa5f16701l,
+ 0xa2816801l, 0x32106900l, 0x33a06a00l, 0xa3316b01l,
+ 0x30c06c00l, 0xa0516d01l, 0xa1e16e01l, 0x31706f00l,
+ 0xaf017001l, 0x3f907100l, 0x3e207200l, 0xaeb17301l,
+ 0x3d407400l, 0xadd17501l, 0xac617601l, 0x3cf07700l,
+ 0x3b807800l, 0xab117901l, 0xaaa17a01l, 0x3a307b00l,
+ 0xa9c17c01l, 0x39507d00l, 0x38e07e00l, 0xa8717f01l,
+ 0xd8018001l, 0x48908100l, 0x49208200l, 0xd9b18301l,
+ 0x4a408400l, 0xdad18501l, 0xdb618601l, 0x4bf08700l,
+ 0x4c808800l, 0xdc118901l, 0xdda18a01l, 0x4d308b00l,
+ 0xdec18c01l, 0x4e508d00l, 0x4fe08e00l, 0xdf718f01l,
+ 0x41009000l, 0xd1919101l, 0xd0219201l, 0x40b09300l,
+ 0xd3419401l, 0x43d09500l, 0x42609600l, 0xd2f19701l,
+ 0xd5819801l, 0x45109900l, 0x44a09a00l, 0xd4319b01l,
+ 0x47c09c00l, 0xd7519d01l, 0xd6e19e01l, 0x46709f00l,
+ 0x5a00a000l, 0xca91a101l, 0xcb21a201l, 0x5bb0a300l,
+ 0xc841a401l, 0x58d0a500l, 0x5960a600l, 0xc9f1a701l,
+ 0xce81a801l, 0x5e10a900l, 0x5fa0aa00l, 0xcf31ab01l,
+ 0x5cc0ac00l, 0xcc51ad01l, 0xcde1ae01l, 0x5d70af00l,
+ 0xc301b001l, 0x5390b100l, 0x5220b200l, 0xc2b1b301l,
+ 0x5140b400l, 0xc1d1b501l, 0xc061b601l, 0x50f0b700l,
+ 0x5780b800l, 0xc711b901l, 0xc6a1ba01l, 0x5630bb00l,
+ 0xc5c1bc01l, 0x5550bd00l, 0x54e0be00l, 0xc471bf01l,
+ 0x6c00c000l, 0xfc91c101l, 0xfd21c201l, 0x6db0c300l,
+ 0xfe41c401l, 0x6ed0c500l, 0x6f60c600l, 0xfff1c701l,
+ 0xf881c801l, 0x6810c900l, 0x69a0ca00l, 0xf931cb01l,
+ 0x6ac0cc00l, 0xfa51cd01l, 0xfbe1ce01l, 0x6b70cf00l,
+ 0xf501d001l, 0x6590d100l, 0x6420d200l, 0xf4b1d301l,
+ 0x6740d400l, 0xf7d1d501l, 0xf661d601l, 0x66f0d700l,
+ 0x6180d800l, 0xf111d901l, 0xf0a1da01l, 0x6030db00l,
+ 0xf3c1dc01l, 0x6350dd00l, 0x62e0de00l, 0xf271df01l,
+ 0xee01e001l, 0x7e90e100l, 0x7f20e200l, 0xefb1e301l,
+ 0x7c40e400l, 0xecd1e501l, 0xed61e601l, 0x7df0e700l,
+ 0x7a80e800l, 0xea11e901l, 0xeba1ea01l, 0x7b30eb00l,
+ 0xe8c1ec01l, 0x7850ed00l, 0x79e0ee00l, 0xe971ef01l,
+ 0x7700f000l, 0xe791f101l, 0xe621f201l, 0x76b0f300l,
+ 0xe541f401l, 0x75d0f500l, 0x7460f600l, 0xe4f1f701l,
+ 0xe381f801l, 0x7310f900l, 0x72a0fa00l, 0xe231fb01l,
+ 0x71c0fc00l, 0xe151fd01l, 0xe0e1fe01l, 0x7070ff00l
};
static DWORD build_edc(const void* in, unsigned from, unsigned upto)
{
- const BYTE* p = (BYTE*)in + from;
- DWORD result = 0;
+ const BYTE* p = (BYTE*)in + from;
+ DWORD result = 0;
+
+ for(; from < upto; from++)
+ result = EDC_crctable[(result ^ *p++) & 0xffL] ^(result >> 8);
- for(; from < upto; from++)
- result = EDC_crctable[(result ^ *p++) & 0xffL] ^ (result >> 8);
-
- return result;
+ return result;
}
/////////
@@ -113,44 +113,44 @@ static DWORD build_edc(const void* in, unsigned from, unsigned upto) const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
{
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
};
const AMOVIESETUP_PIN sudOpPin[] =
{
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] =
{
- {&__uuidof(CCDXAReader), L"MPC - CDXA Reader", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CCDXAReader), L"MPC - CDXA Reader", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] =
{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CCDXAReader>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CCDXAReader>, NULL, &sudFilter[0]}
};
int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{D367878E-F3B8-4235-A968-F378EF1B9A44}"),
- _T("0"), _T("0,4,,52494646,8,4,,43445841")); // "RIFFxxxxCDXA"
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{D367878E-F3B8-4235-A968-F378EF1B9A44}"),
+ _T("0"), _T("0,4,,52494646,8,4,,43445841")); // "RIFFxxxxCDXA"
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{D367878E-F3B8-4235-A968-F378EF1B9A44}"),
- _T("Source Filter"), _T("{D367878E-F3B8-4235-A968-F378EF1B9A44}"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{D367878E-F3B8-4235-A968-F378EF1B9A44}"),
+ _T("Source Filter"), _T("{D367878E-F3B8-4235-A968-F378EF1B9A44}"));
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{D367878E-F3B8-4235-A968-F378EF1B9A44}"));
+ DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{D367878E-F3B8-4235-A968-F378EF1B9A44}"));
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -164,9 +164,9 @@ CFilterApp theApp; //
CCDXAReader::CCDXAReader(IUnknown* pUnk, HRESULT* phr)
- : CAsyncReader(NAME("CCDXAReader"), pUnk, &m_stream, phr, __uuidof(this))
+ : CAsyncReader(NAME("CCDXAReader"), pUnk, &m_stream, phr, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) *phr = S_OK;
}
CCDXAReader::~CCDXAReader()
@@ -175,174 +175,174 @@ CCDXAReader::~CCDXAReader() STDMETHODIMP CCDXAReader::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(IFileSourceFilter)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IFileSourceFilter)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
-STDMETHODIMP CCDXAReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE *pmt)
+STDMETHODIMP CCDXAReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE *pmt)
{
- CMediaType mt;
- m_mt = mt;
+ CMediaType mt;
+ m_mt = mt;
- if(!m_stream.Load(pszFileName))
- return E_FAIL;
+ if(!m_stream.Load(pszFileName))
+ return E_FAIL;
- m_fn = pszFileName;
+ m_fn = pszFileName;
- mt.majortype = MEDIATYPE_Stream;
- mt.subtype = m_stream.m_subtype;
- m_mt = mt;
+ mt.majortype = MEDIATYPE_Stream;
+ mt.subtype = m_stream.m_subtype;
+ m_mt = mt;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CCDXAReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if(!ppszFileName) return E_POINTER;
-
- if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR))))
- return E_OUTOFMEMORY;
+ if(!ppszFileName) return E_POINTER;
- wcscpy(*ppszFileName, m_fn);
+ if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR))))
+ return E_OUTOFMEMORY;
- return S_OK;
+ wcscpy(*ppszFileName, m_fn);
+
+ return S_OK;
}
// CCDXAStream
CCDXAStream::CCDXAStream()
{
- m_subtype = MEDIASUBTYPE_NULL;
-
- m_hFile = INVALID_HANDLE_VALUE;
+ m_subtype = MEDIASUBTYPE_NULL;
+
+ m_hFile = INVALID_HANDLE_VALUE;
- m_llPosition = m_llLength = 0;
- m_nFirstSector = 0;
- m_nBufferedSector = -1;
+ m_llPosition = m_llLength = 0;
+ m_nFirstSector = 0;
+ m_nBufferedSector = -1;
}
CCDXAStream::~CCDXAStream()
{
- if(m_hFile != INVALID_HANDLE_VALUE)
- {
- CloseHandle(m_hFile);
- m_hFile = INVALID_HANDLE_VALUE;
- }
+ if(m_hFile != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(m_hFile);
+ m_hFile = INVALID_HANDLE_VALUE;
+ }
}
bool CCDXAStream::Load(const WCHAR* fnw)
{
- if(m_hFile != INVALID_HANDLE_VALUE)
- {
- CloseHandle(m_hFile);
- m_hFile = INVALID_HANDLE_VALUE;
- }
-
- m_hFile = CreateFile(CString(fnw), GENERIC_READ, FILE_SHARE_READ, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, (HANDLE)NULL);
- if(m_hFile == INVALID_HANDLE_VALUE)
- {
- return(false);
- }
-
- BYTE hdr[RIFFCDXA_HEADER_SIZE];
- DWORD NumberOfBytesRead;
- if(!ReadFile(m_hFile, (LPVOID)hdr, RIFFCDXA_HEADER_SIZE, &NumberOfBytesRead, NULL)
- || *((DWORD*)&hdr[0]) != 'FFIR' || *((DWORD*)&hdr[8]) != 'AXDC'
- || *((DWORD*)&hdr[4]) != (*((DWORD*)&hdr[0x28])+0x24))
- {
- CloseHandle(m_hFile);
- m_hFile = INVALID_HANDLE_VALUE;
- return(false);
- }
-
- LARGE_INTEGER size = {0, 0};
- size.LowPart = (LONG)GetFileSize(m_hFile, (LPDWORD)&size.HighPart);
-
- m_llLength = int((size.QuadPart - RIFFCDXA_HEADER_SIZE) / RAW_SECTOR_SIZE) * RAW_DATA_SIZE;
-
- if(!LookForMediaSubType())
- {
- m_llPosition = m_llLength = 0;
- CloseHandle(m_hFile);
- m_hFile = INVALID_HANDLE_VALUE;
- return(false);
- }
-
- m_llPosition = 0;
-
- m_nBufferedSector = -1;
-
- return(true);
+ if(m_hFile != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(m_hFile);
+ m_hFile = INVALID_HANDLE_VALUE;
+ }
+
+ m_hFile = CreateFile(CString(fnw), GENERIC_READ, FILE_SHARE_READ, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN, (HANDLE)NULL);
+ if(m_hFile == INVALID_HANDLE_VALUE)
+ {
+ return(false);
+ }
+
+ BYTE hdr[RIFFCDXA_HEADER_SIZE];
+ DWORD NumberOfBytesRead;
+ if(!ReadFile(m_hFile, (LPVOID)hdr, RIFFCDXA_HEADER_SIZE, &NumberOfBytesRead, NULL)
+ || *((DWORD*)&hdr[0]) != 'FFIR' || *((DWORD*)&hdr[8]) != 'AXDC'
+ || *((DWORD*)&hdr[4]) != (*((DWORD*)&hdr[0x28]) + 0x24))
+ {
+ CloseHandle(m_hFile);
+ m_hFile = INVALID_HANDLE_VALUE;
+ return(false);
+ }
+
+ LARGE_INTEGER size = {0, 0};
+ size.LowPart = (LONG)GetFileSize(m_hFile, (LPDWORD)&size.HighPart);
+
+ m_llLength = int((size.QuadPart - RIFFCDXA_HEADER_SIZE) / RAW_SECTOR_SIZE) * RAW_DATA_SIZE;
+
+ if(!LookForMediaSubType())
+ {
+ m_llPosition = m_llLength = 0;
+ CloseHandle(m_hFile);
+ m_hFile = INVALID_HANDLE_VALUE;
+ return(false);
+ }
+
+ m_llPosition = 0;
+
+ m_nBufferedSector = -1;
+
+ return(true);
}
HRESULT CCDXAStream::SetPointer(LONGLONG llPos)
{
- return (llPos >= 0 && llPos < m_llLength) ? m_llPosition = llPos, S_OK : S_FALSE;
+ return (llPos >= 0 && llPos < m_llLength) ? m_llPosition = llPos, S_OK : S_FALSE;
}
HRESULT CCDXAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead)
{
- CAutoLock lck(&m_csLock);
+ CAutoLock lck(&m_csLock);
- PBYTE pbBufferOrg = pbBuffer;
- LONGLONG pos = m_llPosition;
+ PBYTE pbBufferOrg = pbBuffer;
+ LONGLONG pos = m_llPosition;
- while(pos >= 0 && pos < m_llLength && dwBytesToRead > 0)
- {
- UINT sector = m_nFirstSector + int(pos/RAW_DATA_SIZE);
- __int64 offset = pos%RAW_DATA_SIZE;
+ while(pos >= 0 && pos < m_llLength && dwBytesToRead > 0)
+ {
+ UINT sector = m_nFirstSector + int(pos / RAW_DATA_SIZE);
+ __int64 offset = pos % RAW_DATA_SIZE;
- if(m_nBufferedSector != sector)
- {
- LARGE_INTEGER FilePointer;
- FilePointer.QuadPart = RIFFCDXA_HEADER_SIZE + sector*RAW_SECTOR_SIZE;
- SetFilePointer(m_hFile, (LONG)FilePointer.LowPart, (PLONG)&FilePointer.HighPart, FILE_BEGIN);
+ if(m_nBufferedSector != sector)
+ {
+ LARGE_INTEGER FilePointer;
+ FilePointer.QuadPart = RIFFCDXA_HEADER_SIZE + sector * RAW_SECTOR_SIZE;
+ SetFilePointer(m_hFile, (LONG)FilePointer.LowPart, (PLONG)&FilePointer.HighPart, FILE_BEGIN);
- memset(m_sector, 0, sizeof(m_sector));
+ memset(m_sector, 0, sizeof(m_sector));
- DWORD NumberOfBytesRead = 0;
+ DWORD NumberOfBytesRead = 0;
- int nRetries = 3;
- while(nRetries--)
- {
- NumberOfBytesRead = 0;
- if(!ReadFile(m_hFile, m_sector, RAW_SECTOR_SIZE, &NumberOfBytesRead, NULL)
- || NumberOfBytesRead != RAW_SECTOR_SIZE)
- break;
+ int nRetries = 3;
+ while(nRetries--)
+ {
+ NumberOfBytesRead = 0;
+ if(!ReadFile(m_hFile, m_sector, RAW_SECTOR_SIZE, &NumberOfBytesRead, NULL)
+ || NumberOfBytesRead != RAW_SECTOR_SIZE)
+ break;
- if(*(DWORD*)&m_sector[RAW_SECTOR_SIZE-4] == 0) // no CRC? it happens...
- break;
+ if(*(DWORD*)&m_sector[RAW_SECTOR_SIZE-4] == 0) // no CRC? it happens...
+ break;
- if(build_edc(m_sector, RAW_SYNC_SIZE + RAW_HEADER_SIZE, RAW_SECTOR_SIZE) == 0)
- break;
+ if(build_edc(m_sector, RAW_SYNC_SIZE + RAW_HEADER_SIZE, RAW_SECTOR_SIZE) == 0)
+ break;
- TRACE(_T("CCDXAStream: CRC error at sector %d (fp=0x%I64x, retriesleft=%d)\n"), sector, FilePointer.QuadPart, nRetries);
- }
+ TRACE(_T("CCDXAStream: CRC error at sector %d (fp=0x%I64x, retriesleft=%d)\n"), sector, FilePointer.QuadPart, nRetries);
+ }
- m_nBufferedSector = sector;
- }
+ m_nBufferedSector = sector;
+ }
- DWORD l = min(min(dwBytesToRead, RAW_DATA_SIZE - offset), m_llLength - pos);
- memcpy(pbBuffer, &m_sector[RAW_SYNC_SIZE + RAW_HEADER_SIZE + RAW_SUBHEADER_SIZE + offset], l);
+ DWORD l = min(min(dwBytesToRead, RAW_DATA_SIZE - offset), m_llLength - pos);
+ memcpy(pbBuffer, &m_sector[RAW_SYNC_SIZE + RAW_HEADER_SIZE + RAW_SUBHEADER_SIZE + offset], l);
- pbBuffer += l;
- pos += l;
- dwBytesToRead -= l;
- }
+ pbBuffer += l;
+ pos += l;
+ dwBytesToRead -= l;
+ }
- if(pdwBytesRead) *pdwBytesRead = pbBuffer - pbBufferOrg;
- m_llPosition += pbBuffer - pbBufferOrg;
+ if(pdwBytesRead) *pdwBytesRead = pbBuffer - pbBufferOrg;
+ m_llPosition += pbBuffer - pbBufferOrg;
- if(dwBytesToRead != 0) return S_FALSE;
+ if(dwBytesToRead != 0) return S_FALSE;
- return S_OK;
+ return S_OK;
}
LONGLONG CCDXAStream::Size(LONGLONG* pSizeAvailable)
{
- if(pSizeAvailable) *pSizeAvailable = m_llLength;
+ if(pSizeAvailable) *pSizeAvailable = m_llLength;
return m_llLength;
}
@@ -365,172 +365,184 @@ void CCDXAStream::Unlock() bool CCDXAStream::LookForMediaSubType()
{
- BYTE buff[RAW_DATA_SIZE];
-
- m_subtype = MEDIASUBTYPE_NULL;
-
- m_llPosition = 0;
-
- for(int iSectorsRead = 0;
- Read(buff, RAW_DATA_SIZE, 1, NULL) == S_OK && iSectorsRead < 1000;
- iSectorsRead++)
- {
- if(*((DWORD*)&buff[0]) == 0xba010000)
- {
- m_llPosition = 0;
- m_llLength -= iSectorsRead*RAW_DATA_SIZE;
- m_nFirstSector = iSectorsRead;
-
- if((buff[4]&0xc4) == 0x44) m_subtype = MEDIASUBTYPE_MPEG2_PROGRAM;
- else if((buff[4]&0xf1) == 0x21) m_subtype = MEDIASUBTYPE_MPEG1System;
-
- return m_subtype != MEDIASUBTYPE_NULL;
- }
- else if(*((DWORD*)&buff[0]) == 'SggO')
- {
- m_llPosition = 0;
- m_llLength -= iSectorsRead*RAW_DATA_SIZE;
- m_nFirstSector = iSectorsRead;
-
- m_subtype = MEDIASUBTYPE_Ogg;
-
- return(true);
- }
- else if(*((DWORD*)&buff[0]) == 0xA3DF451A)
- {
- m_llPosition = 0;
- m_llLength -= iSectorsRead*RAW_DATA_SIZE;
- m_nFirstSector = iSectorsRead;
-
- m_subtype = MEDIASUBTYPE_Matroska;
-
- return(true);
- }
- else if(*((DWORD*)&buff[0]) == 'FMR.')
- {
- m_llPosition = 0;
- m_llLength -= iSectorsRead*RAW_DATA_SIZE;
- m_nFirstSector = iSectorsRead;
-
- m_subtype = MEDIASUBTYPE_RealMedia;
-
- return(true);
- }
- else if(*((DWORD*)&buff[0]) == 'FFIR' && *((DWORD*)&buff[8]) == ' IVA')
- {
- m_llPosition = 0;
- m_llLength = min(m_llLength, *((DWORD*)&buff[4])+8);
- m_nFirstSector = iSectorsRead;
-
- m_subtype = MEDIASUBTYPE_Avi;
-
- return(true);
- }
- else if(*((DWORD*)&buff[4]) == 'voom' || *((DWORD*)&buff[4]) == 'tadm'
- || *((DWORD*)&buff[4]) == 'pytf' && *((DWORD*)&buff[8]) == 'mosi' && *((DWORD*)&buff[16]) == '14pm')
- {
- m_llPosition = 0;
- m_llLength -= iSectorsRead*RAW_DATA_SIZE;
- m_nFirstSector = iSectorsRead;
-
- m_subtype = MEDIASUBTYPE_QTMovie;
-
- return(true);
- }
- }
-
- m_llPosition = 0;
-
- CRegKey majorkey;
- CString majortype = _T("\\Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}");
- if(ERROR_SUCCESS == majorkey.Open(HKEY_CLASSES_ROOT, majortype, KEY_READ))
- {
- TCHAR subtype[256+1];
- DWORD len = 256;
- for(int i = 0; ERROR_SUCCESS == majorkey.EnumKey(i, subtype, &len); i++, len = 256)
- {
- CRegKey subkey;
- if(ERROR_SUCCESS != subkey.Open(HKEY_CLASSES_ROOT, majortype + _T("\\") + subtype, KEY_READ))
- continue;
-
- for(int j = 0; true; j++)
- {
- TCHAR number[10];
- _stprintf(number, _T("%d"), j);
-
- TCHAR pattern[256+1];
- ULONG len = 256;
- if(ERROR_SUCCESS != subkey.QueryStringValue(number, pattern, &len))
- break;
-
- CString p = pattern;
- p += ',';
-
- __int64 offset = 0;
- DWORD cb = 0;
- CAtlArray<BYTE> mask, val;
-
- int nMatches = 0, nTries = 0;
-
- for(int k = 0, l; nTries >= 0 && (l = p.Find(',', k)) >= 0; k = l+1, nTries++)
- {
- CString s = p.Mid(k, l-k);
- TRACE(s + '\n');
-
- TCHAR* end = NULL;
-
- switch(nTries&3)
- {
- case 0: offset = _tcstol(s, &end, 10); break;
- case 1: cb = _tcstol(s, &end, 10); break;
- case 2: CStringToBin(s, mask); break;
- case 3: CStringToBin(s, val); break;
- default: nTries = -1; break;
- }
-
- if(nTries >= 0 && (nTries&3) == 3)
- {
- if(cb > 0 && val.GetCount() > 0 && cb == val.GetCount())
- {
- if(offset >= 0 && S_OK == SetPointer(offset)
- || S_OK == SetPointer(m_llLength + offset))
- {
- CAutoVectorPtr<BYTE> pData;
- if(pData.Allocate(cb))
- {
- DWORD BytesRead = 0;
- if(S_OK == Read(pData, cb, 1, &BytesRead) && cb == BytesRead)
- {
- if(mask.GetCount() < cb)
- {
- int i = mask.GetCount();
- mask.SetCount(cb);
- for(; i < cb; i++) mask[i] = 0xff;
- }
-
- for(int i = 0; i < cb; i++)
- pData[i] &= (BYTE)mask[i];
-
- if(memcmp(pData, val.GetData(), cb) == 0)
- nMatches++;
- }
- }
- }
-
- offset = 0; cb = 0;
- mask.RemoveAll(); val.RemoveAll();
- }
- }
- }
-
- if(nMatches > 0 && nMatches*4 == nTries)
- {
- m_subtype = GUIDFromCString(subtype);
- return S_OK;
- }
- }
- }
- }
-
- return(false);
+ BYTE buff[RAW_DATA_SIZE];
+
+ m_subtype = MEDIASUBTYPE_NULL;
+
+ m_llPosition = 0;
+
+ for(int iSectorsRead = 0;
+ Read(buff, RAW_DATA_SIZE, 1, NULL) == S_OK && iSectorsRead < 1000;
+ iSectorsRead++)
+ {
+ if(*((DWORD*)&buff[0]) == 0xba010000)
+ {
+ m_llPosition = 0;
+ m_llLength -= iSectorsRead * RAW_DATA_SIZE;
+ m_nFirstSector = iSectorsRead;
+
+ if((buff[4] & 0xc4) == 0x44) m_subtype = MEDIASUBTYPE_MPEG2_PROGRAM;
+ else if((buff[4] & 0xf1) == 0x21) m_subtype = MEDIASUBTYPE_MPEG1System;
+
+ return m_subtype != MEDIASUBTYPE_NULL;
+ }
+ else if(*((DWORD*)&buff[0]) == 'SggO')
+ {
+ m_llPosition = 0;
+ m_llLength -= iSectorsRead * RAW_DATA_SIZE;
+ m_nFirstSector = iSectorsRead;
+
+ m_subtype = MEDIASUBTYPE_Ogg;
+
+ return(true);
+ }
+ else if(*((DWORD*)&buff[0]) == 0xA3DF451A)
+ {
+ m_llPosition = 0;
+ m_llLength -= iSectorsRead * RAW_DATA_SIZE;
+ m_nFirstSector = iSectorsRead;
+
+ m_subtype = MEDIASUBTYPE_Matroska;
+
+ return(true);
+ }
+ else if(*((DWORD*)&buff[0]) == 'FMR.')
+ {
+ m_llPosition = 0;
+ m_llLength -= iSectorsRead * RAW_DATA_SIZE;
+ m_nFirstSector = iSectorsRead;
+
+ m_subtype = MEDIASUBTYPE_RealMedia;
+
+ return(true);
+ }
+ else if(*((DWORD*)&buff[0]) == 'FFIR' && *((DWORD*)&buff[8]) == ' IVA')
+ {
+ m_llPosition = 0;
+ m_llLength = min(m_llLength, *((DWORD*)&buff[4]) + 8);
+ m_nFirstSector = iSectorsRead;
+
+ m_subtype = MEDIASUBTYPE_Avi;
+
+ return(true);
+ }
+ else if(*((DWORD*)&buff[4]) == 'voom' || *((DWORD*)&buff[4]) == 'tadm'
+ || *((DWORD*)&buff[4]) == 'pytf' && *((DWORD*)&buff[8]) == 'mosi' && *((DWORD*)&buff[16]) == '14pm')
+ {
+ m_llPosition = 0;
+ m_llLength -= iSectorsRead * RAW_DATA_SIZE;
+ m_nFirstSector = iSectorsRead;
+
+ m_subtype = MEDIASUBTYPE_QTMovie;
+
+ return(true);
+ }
+ }
+
+ m_llPosition = 0;
+
+ CRegKey majorkey;
+ CString majortype = _T("\\Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}");
+ if(ERROR_SUCCESS == majorkey.Open(HKEY_CLASSES_ROOT, majortype, KEY_READ))
+ {
+ TCHAR subtype[256+1];
+ DWORD len = 256;
+ for(int i = 0; ERROR_SUCCESS == majorkey.EnumKey(i, subtype, &len); i++, len = 256)
+ {
+ CRegKey subkey;
+ if(ERROR_SUCCESS != subkey.Open(HKEY_CLASSES_ROOT, majortype + _T("\\") + subtype, KEY_READ))
+ continue;
+
+ for(int j = 0; true; j++)
+ {
+ TCHAR number[10];
+ _stprintf(number, _T("%d"), j);
+
+ TCHAR pattern[256+1];
+ ULONG len = 256;
+ if(ERROR_SUCCESS != subkey.QueryStringValue(number, pattern, &len))
+ break;
+
+ CString p = pattern;
+ p += ',';
+
+ __int64 offset = 0;
+ DWORD cb = 0;
+ CAtlArray<BYTE> mask, val;
+
+ int nMatches = 0, nTries = 0;
+
+ for(int k = 0, l; nTries >= 0 && (l = p.Find(',', k)) >= 0; k = l + 1, nTries++)
+ {
+ CString s = p.Mid(k, l - k);
+ TRACE(s + '\n');
+
+ TCHAR* end = NULL;
+
+ switch(nTries & 3)
+ {
+ case 0:
+ offset = _tcstol(s, &end, 10);
+ break;
+ case 1:
+ cb = _tcstol(s, &end, 10);
+ break;
+ case 2:
+ CStringToBin(s, mask);
+ break;
+ case 3:
+ CStringToBin(s, val);
+ break;
+ default:
+ nTries = -1;
+ break;
+ }
+
+ if(nTries >= 0 && (nTries & 3) == 3)
+ {
+ if(cb > 0 && val.GetCount() > 0 && cb == val.GetCount())
+ {
+ if(offset >= 0 && S_OK == SetPointer(offset)
+ || S_OK == SetPointer(m_llLength + offset))
+ {
+ CAutoVectorPtr<BYTE> pData;
+ if(pData.Allocate(cb))
+ {
+ DWORD BytesRead = 0;
+ if(S_OK == Read(pData, cb, 1, &BytesRead) && cb == BytesRead)
+ {
+ if(mask.GetCount() < cb)
+ {
+ int i = mask.GetCount();
+ mask.SetCount(cb);
+ for(; i < cb; i++) mask[i] = 0xff;
+ }
+
+ for(int i = 0; i < cb; i++)
+ pData[i] &= (BYTE)mask[i];
+
+ if(memcmp(pData, val.GetData(), cb) == 0)
+ nMatches++;
+ }
+ }
+ }
+
+ offset = 0;
+ cb = 0;
+ mask.RemoveAll();
+ val.RemoveAll();
+ }
+ }
+ }
+
+ if(nMatches > 0 && nMatches * 4 == nTries)
+ {
+ m_subtype = GUIDFromCString(subtype);
+ return S_OK;
+ }
+ }
+ }
+ }
+
+ return(false);
}
diff --git a/src/filters/reader/CDXAReader/CDXAReader.h b/src/filters/reader/CDXAReader/CDXAReader.h index 56a34be86..60f4babaa 100644 --- a/src/filters/reader/CDXAReader/CDXAReader.h +++ b/src/filters/reader/CDXAReader/CDXAReader.h @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -28,60 +28,60 @@ class CCDXAStream : public CAsyncStream
{
private:
- enum
- {
- RIFFCDXA_HEADER_SIZE = 44, // usually...
- RAW_SYNC_SIZE = 12, // 00 FF .. FF 00
- RAW_HEADER_SIZE = 4,
- RAW_SUBHEADER_SIZE = 8,
- RAW_DATA_SIZE = 2324,
- RAW_EDC_SIZE = 4,
- RAW_SECTOR_SIZE = 2352
- };
+ enum
+ {
+ RIFFCDXA_HEADER_SIZE = 44, // usually...
+ RAW_SYNC_SIZE = 12, // 00 FF .. FF 00
+ RAW_HEADER_SIZE = 4,
+ RAW_SUBHEADER_SIZE = 8,
+ RAW_DATA_SIZE = 2324,
+ RAW_EDC_SIZE = 4,
+ RAW_SECTOR_SIZE = 2352
+ };
CCritSec m_csLock;
- HANDLE m_hFile;
- LONGLONG m_llPosition, m_llLength;
- int m_nFirstSector;
+ HANDLE m_hFile;
+ LONGLONG m_llPosition, m_llLength;
+ int m_nFirstSector;
- int m_nBufferedSector;
- BYTE m_sector[RAW_SECTOR_SIZE];
+ int m_nBufferedSector;
+ BYTE m_sector[RAW_SECTOR_SIZE];
- bool LookForMediaSubType();
+ bool LookForMediaSubType();
public:
- CCDXAStream();
- virtual ~CCDXAStream();
+ CCDXAStream();
+ virtual ~CCDXAStream();
- bool Load(const WCHAR* fnw);
+ bool Load(const WCHAR* fnw);
HRESULT SetPointer(LONGLONG llPos);
HRESULT Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead);
LONGLONG Size(LONGLONG* pSizeAvailable);
DWORD Alignment();
void Lock();
- void Unlock();
+ void Unlock();
- GUID m_subtype;
+ GUID m_subtype;
};
[uuid("D367878E-F3B8-4235-A968-F378EF1B9A44")]
-class CCDXAReader
- : public CAsyncReader
- , public IFileSourceFilter
+class CCDXAReader
+ : public CAsyncReader
+ , public IFileSourceFilter
{
- CCDXAStream m_stream;
- CStringW m_fn;
+ CCDXAStream m_stream;
+ CStringW m_fn;
public:
CCDXAReader(IUnknown* pUnk, HRESULT* phr);
- ~CCDXAReader();
+ ~CCDXAReader();
DECLARE_IUNKNOWN
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IFileSourceFilter
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
+ // IFileSourceFilter
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
};
diff --git a/src/filters/reader/CDXAReader/resource.h b/src/filters/reader/CDXAReader/resource.h index 35951cffd..302231738 100644 --- a/src/filters/reader/CDXAReader/resource.h +++ b/src/filters/reader/CDXAReader/resource.h @@ -3,7 +3,7 @@ // Used by cdxareader.rc
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
diff --git a/src/filters/reader/CDXAReader/stdafx.cpp b/src/filters/reader/CDXAReader/stdafx.cpp index d5332bbe6..429feefb5 100644 --- a/src/filters/reader/CDXAReader/stdafx.cpp +++ b/src/filters/reader/CDXAReader/stdafx.cpp @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/reader/CDXAReader/stdafx.h b/src/filters/reader/CDXAReader/stdafx.h index c35359c38..a9f666228 100644 --- a/src/filters/reader/CDXAReader/stdafx.h +++ b/src/filters/reader/CDXAReader/stdafx.h @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/reader/UDPReader/UDPReader.cpp b/src/filters/reader/UDPReader/UDPReader.cpp index fbeb8426e..4afb4e830 100644 --- a/src/filters/reader/UDPReader/UDPReader.cpp +++ b/src/filters/reader/UDPReader/UDPReader.cpp @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -27,39 +27,39 @@ const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
{
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_PIN sudOpPin[] =
{
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] =
{
- {&__uuidof(CUDPReader), L"MPC - UDP Reader", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CUDPReader), L"MPC - UDP Reader", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] =
{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CUDPReader>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CUDPReader>, NULL, &sudFilter[0]}
};
int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
- SetRegKeyValue(_T("udp"), 0, _T("Source Filter"), CStringFromGUID(__uuidof(CUDPReader)));
- SetRegKeyValue(_T("tévé"), 0, _T("Source Filter"), CStringFromGUID(__uuidof(CUDPReader)));
+ SetRegKeyValue(_T("udp"), 0, _T("Source Filter"), CStringFromGUID(__uuidof(CUDPReader)));
+ SetRegKeyValue(_T("tévé"), 0, _T("Source Filter"), CStringFromGUID(__uuidof(CUDPReader)));
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- // TODO
+ // TODO
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -76,9 +76,9 @@ CFilterApp theApp; //
CUDPReader::CUDPReader(IUnknown* pUnk, HRESULT* phr)
- : CAsyncReader(NAME("CUDPReader"), pUnk, &m_stream, phr, __uuidof(this))
+ : CAsyncReader(NAME("CUDPReader"), pUnk, &m_stream, phr, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) *phr = S_OK;
}
CUDPReader::~CUDPReader()
@@ -89,208 +89,212 @@ STDMETHODIMP CUDPReader::NonDelegatingQueryInterface(REFIID riid, void** ppv) {
CheckPointer(ppv, E_POINTER);
- return
- QI(IFileSourceFilter)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IFileSourceFilter)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IFileSourceFilter
-STDMETHODIMP CUDPReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
+STDMETHODIMP CUDPReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(!m_stream.Load(pszFileName))
- return E_FAIL;
+ if(!m_stream.Load(pszFileName))
+ return E_FAIL;
- m_fn = pszFileName;
+ m_fn = pszFileName;
- CMediaType mt;
- mt.majortype = MEDIATYPE_Stream;
- mt.subtype = m_stream.GetSubType();
- m_mt = mt;
+ CMediaType mt;
+ mt.majortype = MEDIATYPE_Stream;
+ mt.subtype = m_stream.GetSubType();
+ m_mt = mt;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CUDPReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if(!ppszFileName) return E_POINTER;
-
- if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR))))
- return E_OUTOFMEMORY;
+ if(!ppszFileName) return E_POINTER;
+
+ if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR))))
+ return E_OUTOFMEMORY;
- wcscpy(*ppszFileName, m_fn);
+ wcscpy(*ppszFileName, m_fn);
- return S_OK;
+ return S_OK;
}
// CUDPStream
CUDPStream::CUDPStream()
{
- m_port = 0;
- m_socket = -1;
- m_subtype = MEDIASUBTYPE_NULL;
+ m_port = 0;
+ m_socket = -1;
+ m_subtype = MEDIASUBTYPE_NULL;
}
CUDPStream::~CUDPStream()
{
- Clear();
+ Clear();
}
void CUDPStream::Clear()
{
- if(m_socket >= 0) {closesocket(m_socket); m_socket = -1;}
- if(CAMThread::ThreadExists())
- {
- CAMThread::CallWorker(CMD_EXIT);
- CAMThread::Close();
- }
- while(!m_packets.IsEmpty()) delete m_packets.RemoveHead();
- m_pos = m_len = 0;
- m_drop = false;
+ if(m_socket >= 0)
+ {
+ closesocket(m_socket);
+ m_socket = -1;
+ }
+ if(CAMThread::ThreadExists())
+ {
+ CAMThread::CallWorker(CMD_EXIT);
+ CAMThread::Close();
+ }
+ while(!m_packets.IsEmpty()) delete m_packets.RemoveHead();
+ m_pos = m_len = 0;
+ m_drop = false;
}
void CUDPStream::Append(BYTE* buff, int len)
{
- CAutoLock cAutoLock(&m_csLock);
-
- if(m_packets.GetCount() > 1)
- {
- __int64 size = m_packets.GetTail()->m_end - m_packets.GetHead()->m_start;
-
- if(!m_drop && (m_pos >= BUFF_SIZE_FIRST && size >= BUFF_SIZE_FIRST || size >= 2*BUFF_SIZE_FIRST))
- {
- m_drop = true;
- TRACE(_T("DROP ON\n"));
- }
- else if(m_drop && size <= BUFF_SIZE_FIRST)
- {
- m_drop = false;
- TRACE(_T("DROP OFF\n"));
- }
-
- if(m_drop) return;
- }
-
- m_packets.AddTail(DNew packet_t(buff, m_len, m_len + len));
- m_len += len;
+ CAutoLock cAutoLock(&m_csLock);
+
+ if(m_packets.GetCount() > 1)
+ {
+ __int64 size = m_packets.GetTail()->m_end - m_packets.GetHead()->m_start;
+
+ if(!m_drop && (m_pos >= BUFF_SIZE_FIRST && size >= BUFF_SIZE_FIRST || size >= 2 * BUFF_SIZE_FIRST))
+ {
+ m_drop = true;
+ TRACE(_T("DROP ON\n"));
+ }
+ else if(m_drop && size <= BUFF_SIZE_FIRST)
+ {
+ m_drop = false;
+ TRACE(_T("DROP OFF\n"));
+ }
+
+ if(m_drop) return;
+ }
+
+ m_packets.AddTail(DNew packet_t(buff, m_len, m_len + len));
+ m_len += len;
}
bool CUDPStream::Load(const WCHAR* fnw)
{
- Clear();
+ Clear();
- CStringW url = CStringW(fnw);
+ CStringW url = CStringW(fnw);
#ifdef DEBUG
-// url = L"udp://:1234/";
-// url = L"udp://239.255.255.250:1234/{e436eb8e-524f-11ce-9f53-0020af0ba770}";
+// url = L"udp://:1234/";
+// url = L"udp://239.255.255.250:1234/{e436eb8e-524f-11ce-9f53-0020af0ba770}";
// url = L"udp://239.255.255.19:2345/";
#endif
- CAtlList<CStringW> sl;
- Explode(url, sl, ':');
- if(sl.GetCount() != 3) return false;
+ CAtlList<CStringW> sl;
+ Explode(url, sl, ':');
+ if(sl.GetCount() != 3) return false;
- CStringW protocol = sl.RemoveHead();
- // if(protocol != L"udp") return false;
+ CStringW protocol = sl.RemoveHead();
+ // if(protocol != L"udp") return false;
- m_ip = CString(sl.RemoveHead()).TrimLeft('/');
+ m_ip = CString(sl.RemoveHead()).TrimLeft('/');
- int port = _wtoi(Explode(sl.RemoveHead(), sl, '/', 2));
- if(port < 0 || port > 0xffff) return false;
- m_port = port;
+ int port = _wtoi(Explode(sl.RemoveHead(), sl, '/', 2));
+ if(port < 0 || port > 0xffff) return false;
+ m_port = port;
- if(sl.GetCount() != 2 || FAILED(GUIDFromCString(CString(sl.GetTail()), m_subtype)))
- m_subtype = MEDIASUBTYPE_NULL; // TODO: detect subtype
+ if(sl.GetCount() != 2 || FAILED(GUIDFromCString(CString(sl.GetTail()), m_subtype)))
+ m_subtype = MEDIASUBTYPE_NULL; // TODO: detect subtype
- CAMThread::Create();
- if(FAILED(CAMThread::CallWorker(CMD_RUN)))
- {
- Clear();
- return false;
- }
+ CAMThread::Create();
+ if(FAILED(CAMThread::CallWorker(CMD_RUN)))
+ {
+ Clear();
+ return false;
+ }
- clock_t start = clock();
- while(clock() - start < 3000 && m_len < 1000000)
- Sleep(100);
+ clock_t start = clock();
+ while(clock() - start < 3000 && m_len < 1000000)
+ Sleep(100);
- return true;
+ return true;
}
HRESULT CUDPStream::SetPointer(LONGLONG llPos)
{
- CAutoLock cAutoLock(&m_csLock);
+ CAutoLock cAutoLock(&m_csLock);
- if(m_packets.IsEmpty() && llPos != 0
- || !m_packets.IsEmpty() && llPos < m_packets.GetHead()->m_start
- || !m_packets.IsEmpty() && llPos > m_packets.GetTail()->m_end)
- {
- TRACE(_T("CUDPStream: SetPointer error\n"));
- return E_FAIL;
- }
+ if(m_packets.IsEmpty() && llPos != 0
+ || !m_packets.IsEmpty() && llPos < m_packets.GetHead()->m_start
+ || !m_packets.IsEmpty() && llPos > m_packets.GetTail()->m_end)
+ {
+ TRACE(_T("CUDPStream: SetPointer error\n"));
+ return E_FAIL;
+ }
- m_pos = llPos;
+ m_pos = llPos;
- return S_OK;
+ return S_OK;
}
HRESULT CUDPStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead)
{
- CAutoLock cAutoLock(&m_csLock);
-
- DWORD len = dwBytesToRead;
- BYTE* ptr = pbBuffer;
-
- while(len > 0 && !m_packets.IsEmpty())
- {
- POSITION pos = m_packets.GetHeadPosition();
- while(pos && len > 0)
- {
- packet_t* p = m_packets.GetNext(pos);
-
- if(p->m_start <= m_pos && m_pos < p->m_end)
- {
- int size;
-
- if(m_pos < p->m_start)
- {
- ASSERT(0);
- size = min(len, p->m_start - m_pos);
- memset(ptr, 0, size);
- }
- else
- {
- size = min(len, p->m_end - m_pos);
- memcpy(ptr, &p->m_buff[m_pos - p->m_start], size);
- }
-
- m_pos += size;
-
- ptr += size;
- len -= size;
- }
-
- if(p->m_end <= m_pos - 2048 && BUFF_SIZE_FIRST <= m_pos)
- {
- while(m_packets.GetHeadPosition() != pos)
- delete m_packets.RemoveHead();
- }
-
- }
- }
-
- if(pdwBytesRead)
- *pdwBytesRead = ptr - pbBuffer;
-
- return S_OK;
+ CAutoLock cAutoLock(&m_csLock);
+
+ DWORD len = dwBytesToRead;
+ BYTE* ptr = pbBuffer;
+
+ while(len > 0 && !m_packets.IsEmpty())
+ {
+ POSITION pos = m_packets.GetHeadPosition();
+ while(pos && len > 0)
+ {
+ packet_t* p = m_packets.GetNext(pos);
+
+ if(p->m_start <= m_pos && m_pos < p->m_end)
+ {
+ int size;
+
+ if(m_pos < p->m_start)
+ {
+ ASSERT(0);
+ size = min(len, p->m_start - m_pos);
+ memset(ptr, 0, size);
+ }
+ else
+ {
+ size = min(len, p->m_end - m_pos);
+ memcpy(ptr, &p->m_buff[m_pos - p->m_start], size);
+ }
+
+ m_pos += size;
+
+ ptr += size;
+ len -= size;
+ }
+
+ if(p->m_end <= m_pos - 2048 && BUFF_SIZE_FIRST <= m_pos)
+ {
+ while(m_packets.GetHeadPosition() != pos)
+ delete m_packets.RemoveHead();
+ }
+
+ }
+ }
+
+ if(pdwBytesRead)
+ *pdwBytesRead = ptr - pbBuffer;
+
+ return S_OK;
}
LONGLONG CUDPStream::Size(LONGLONG* pSizeAvailable)
{
- CAutoLock cAutoLock(&m_csLock);
- if(pSizeAvailable) *pSizeAvailable = m_len;
- return 0;
+ CAutoLock cAutoLock(&m_csLock);
+ if(pSizeAvailable) *pSizeAvailable = m_len;
+ return 0;
}
DWORD CUDPStream::Alignment()
@@ -310,138 +314,150 @@ void CUDPStream::Unlock() DWORD CUDPStream::ThreadProc()
{
- WSADATA wsaData;
- WSAStartup(MAKEWORD(2, 2), &wsaData);
-
- sockaddr_in addr;
- memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = htonl(INADDR_ANY);
- addr.sin_port = htons((u_short)m_port);
-
- ip_mreq imr;
- imr.imr_multiaddr.s_addr = inet_addr(CStringA(m_ip));
- imr.imr_interface.s_addr = INADDR_ANY;
-
- if((m_socket = socket(AF_INET, SOCK_DGRAM, 0)) >= 0)
- {
-/* u_long argp = 1;
- ioctlsocket(m_socket, FIONBIO, &argp);
-*/
- DWORD dw = TRUE;
- if(setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&dw, sizeof(dw)) < 0)
- {
- closesocket(m_socket);
- m_socket = -1;
- }
-
- if(bind(m_socket, (struct sockaddr*)&addr, sizeof(addr)) < 0)
- {
- closesocket(m_socket);
- m_socket = -1;
- }
-
- if(IN_MULTICAST(htonl(imr.imr_multiaddr.s_addr)))
- {
- int ret = setsockopt(m_socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char*)&imr, sizeof(imr));
- if(ret < 0) ret = ::WSAGetLastError();
- ret = ret;
- }
- }
-
- SetThreadPriority(m_hThread, THREAD_PRIORITY_TIME_CRITICAL);
-
- FILE* dump = NULL;
+ WSADATA wsaData;
+ WSAStartup(MAKEWORD(2, 2), &wsaData);
+
+ sockaddr_in addr;
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ addr.sin_port = htons((u_short)m_port);
+
+ ip_mreq imr;
+ imr.imr_multiaddr.s_addr = inet_addr(CStringA(m_ip));
+ imr.imr_interface.s_addr = INADDR_ANY;
+
+ if((m_socket = socket(AF_INET, SOCK_DGRAM, 0)) >= 0)
+ {
+ /* u_long argp = 1;
+ ioctlsocket(m_socket, FIONBIO, &argp);
+ */
+ DWORD dw = TRUE;
+ if(setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&dw, sizeof(dw)) < 0)
+ {
+ closesocket(m_socket);
+ m_socket = -1;
+ }
+
+ if(bind(m_socket, (struct sockaddr*)&addr, sizeof(addr)) < 0)
+ {
+ closesocket(m_socket);
+ m_socket = -1;
+ }
+
+ if(IN_MULTICAST(htonl(imr.imr_multiaddr.s_addr)))
+ {
+ int ret = setsockopt(m_socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char*)&imr, sizeof(imr));
+ if(ret < 0) ret = ::WSAGetLastError();
+ ret = ret;
+ }
+ }
+
+ SetThreadPriority(m_hThread, THREAD_PRIORITY_TIME_CRITICAL);
+
+ FILE* dump = NULL;
// dump = _tfopen(_T("c:\\udp.ts"), _T("wb"));
- FILE* log = NULL;
+ FILE* log = NULL;
// log = _tfopen(_T("c:\\udp.txt"), _T("wt"));
- while(1)
- {
- DWORD cmd = GetRequest();
-
- switch(cmd)
- {
- default:
- case CMD_EXIT:
- if(m_socket >= 0) {closesocket(m_socket); m_socket = -1;}
- WSACleanup();
- if(dump) fclose(dump);
- if(log) fclose(log);
- Reply(S_OK);
- return 0;
- case CMD_RUN:
- Reply(m_socket >= 0 ? S_OK : E_FAIL);
-
- {
- char buff[65536*2];
- int buffsize = 0;
-
- for(unsigned int i = 0; ; i++)
- {
- if(!(i&0xff))
- {
- if(CheckRequest(NULL))
- break;
- }
-
- int fromlen = sizeof(addr);
- int len = recvfrom(m_socket, &buff[buffsize], 65536, 0, (SOCKADDR*)&addr, &fromlen);
- if(len <= 0) {Sleep(1); continue;}
-
- if(log)
- {
- if(buffsize >= len && !memcmp(&buff[buffsize-len], &buff[buffsize], len))
- {
- DWORD pid = ((buff[buffsize+1]<<8)|buff[buffsize+2])&0x1fff;
- DWORD counter = buff[buffsize+3]&0xf;
- _ftprintf(log, _T("%04d %2d DUP\n"), pid, counter);
- }
- }
-
- buffsize += len;
-
- if(buffsize >= 65536 || m_len == 0)
- {
- if(dump)
- {
- fwrite(buff, buffsize, 1, dump);
- }
-
- if(log)
- {
- static BYTE pid2counter[0x2000];
- static bool init = false;
- if(!init) {memset(pid2counter, 0, sizeof(pid2counter)); init = true;}
-
- for(int i = 0; i < buffsize; i += 188)
- {
- DWORD pid = ((buff[i+1]<<8)|buff[i+2])&0x1fff;
- DWORD counter = buff[i+3]&0xf;
- if(pid2counter[pid] != ((counter-1+16)&15))
- _ftprintf(log, _T("%04x %2d -> %2d\n"), pid, pid2counter[pid], counter);
- pid2counter[pid] = counter;
- }
- }
-
- Append((BYTE*)buff, buffsize);
- buffsize = 0;
- }
- }
- }
- break;
- }
- }
-
- ASSERT(0);
- return -1;
+ while(1)
+ {
+ DWORD cmd = GetRequest();
+
+ switch(cmd)
+ {
+ default:
+ case CMD_EXIT:
+ if(m_socket >= 0)
+ {
+ closesocket(m_socket);
+ m_socket = -1;
+ }
+ WSACleanup();
+ if(dump) fclose(dump);
+ if(log) fclose(log);
+ Reply(S_OK);
+ return 0;
+ case CMD_RUN:
+ Reply(m_socket >= 0 ? S_OK : E_FAIL);
+
+ {
+ char buff[65536*2];
+ int buffsize = 0;
+
+ for(unsigned int i = 0; ; i++)
+ {
+ if(!(i & 0xff))
+ {
+ if(CheckRequest(NULL))
+ break;
+ }
+
+ int fromlen = sizeof(addr);
+ int len = recvfrom(m_socket, &buff[buffsize], 65536, 0, (SOCKADDR*)&addr, &fromlen);
+ if(len <= 0)
+ {
+ Sleep(1);
+ continue;
+ }
+
+ if(log)
+ {
+ if(buffsize >= len && !memcmp(&buff[buffsize-len], &buff[buffsize], len))
+ {
+ DWORD pid = ((buff[buffsize+1] << 8) | buff[buffsize+2]) & 0x1fff;
+ DWORD counter = buff[buffsize+3] & 0xf;
+ _ftprintf(log, _T("%04d %2d DUP\n"), pid, counter);
+ }
+ }
+
+ buffsize += len;
+
+ if(buffsize >= 65536 || m_len == 0)
+ {
+ if(dump)
+ {
+ fwrite(buff, buffsize, 1, dump);
+ }
+
+ if(log)
+ {
+ static BYTE pid2counter[0x2000];
+ static bool init = false;
+ if(!init)
+ {
+ memset(pid2counter, 0, sizeof(pid2counter));
+ init = true;
+ }
+
+ for(int i = 0; i < buffsize; i += 188)
+ {
+ DWORD pid = ((buff[i+1] << 8) | buff[i+2]) & 0x1fff;
+ DWORD counter = buff[i+3] & 0xf;
+ if(pid2counter[pid] != ((counter - 1 + 16) & 15))
+ _ftprintf(log, _T("%04x %2d -> %2d\n"), pid, pid2counter[pid], counter);
+ pid2counter[pid] = counter;
+ }
+ }
+
+ Append((BYTE*)buff, buffsize);
+ buffsize = 0;
+ }
+ }
+ }
+ break;
+ }
+ }
+
+ ASSERT(0);
+ return -1;
}
-CUDPStream::packet_t::packet_t(BYTE* p, __int64 start, __int64 end)
- : m_start(start)
- , m_end(end)
+CUDPStream::packet_t::packet_t(BYTE* p, __int64 start, __int64 end)
+ : m_start(start)
+ , m_end(end)
{
- int size = end - start;
- m_buff = DNew BYTE[size];
- memcpy(m_buff, p, size);
+ int size = end - start;
+ m_buff = DNew BYTE[size];
+ memcpy(m_buff, p, size);
}
diff --git a/src/filters/reader/UDPReader/UDPReader.h b/src/filters/reader/UDPReader/UDPReader.h index 863fa277d..8a42702fc 100644 --- a/src/filters/reader/UDPReader/UDPReader.h +++ b/src/filters/reader/UDPReader/UDPReader.h @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -30,60 +30,66 @@ class CUDPStream : public CAsyncStream, public CAMThread private:
CCritSec m_csLock;
- class packet_t
- {
- public:
- BYTE* m_buff;
- __int64 m_start, m_end;
- packet_t(BYTE* p, __int64 start, __int64 end);
- virtual ~packet_t() {delete [] m_buff;}
- };
+ class packet_t
+ {
+ public:
+ BYTE* m_buff;
+ __int64 m_start, m_end;
+ packet_t(BYTE* p, __int64 start, __int64 end);
+ virtual ~packet_t()
+ {
+ delete [] m_buff;
+ }
+ };
- int m_port;
- CString m_ip;
- SOCKET m_socket;
- GUID m_subtype;
- __int64 m_pos, m_len;
- bool m_drop;
- CAtlList<packet_t*> m_packets;
+ int m_port;
+ CString m_ip;
+ SOCKET m_socket;
+ GUID m_subtype;
+ __int64 m_pos, m_len;
+ bool m_drop;
+ CAtlList<packet_t*> m_packets;
- void Clear();
- void Append(BYTE* buff, int len);
+ void Clear();
+ void Append(BYTE* buff, int len);
- enum {CMD_EXIT, CMD_RUN};
- DWORD ThreadProc();
+ enum {CMD_EXIT, CMD_RUN};
+ DWORD ThreadProc();
public:
- CUDPStream();
- virtual ~CUDPStream();
+ CUDPStream();
+ virtual ~CUDPStream();
- bool Load(const WCHAR* fnw);
- const GUID& GetSubType() {return m_subtype;}
+ bool Load(const WCHAR* fnw);
+ const GUID& GetSubType()
+ {
+ return m_subtype;
+ }
HRESULT SetPointer(LONGLONG llPos);
HRESULT Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead);
LONGLONG Size(LONGLONG* pSizeAvailable);
DWORD Alignment();
void Lock();
- void Unlock();
+ void Unlock();
};
[uuid("0E4221A9-9718-48D5-A5CF-4493DAD4A015")]
-class CUDPReader
- : public CAsyncReader
- , public IFileSourceFilter
+class CUDPReader
+ : public CAsyncReader
+ , public IFileSourceFilter
{
- CUDPStream m_stream;
- CStringW m_fn;
+ CUDPStream m_stream;
+ CStringW m_fn;
public:
CUDPReader(IUnknown* pUnk, HRESULT* phr);
- ~CUDPReader();
+ ~CUDPReader();
DECLARE_IUNKNOWN
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IFileSourceFilter
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
+ // IFileSourceFilter
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
};
diff --git a/src/filters/reader/UDPReader/resource.h b/src/filters/reader/UDPReader/resource.h index 320510fa1..440a1b299 100644 --- a/src/filters/reader/UDPReader/resource.h +++ b/src/filters/reader/UDPReader/resource.h @@ -3,7 +3,7 @@ // Used by udpreader.rc
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
diff --git a/src/filters/reader/UDPReader/stdafx.cpp b/src/filters/reader/UDPReader/stdafx.cpp index a416647fd..6566b4234 100644 --- a/src/filters/reader/UDPReader/stdafx.cpp +++ b/src/filters/reader/UDPReader/stdafx.cpp @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/reader/UDPReader/stdafx.h b/src/filters/reader/UDPReader/stdafx.h index f4d095421..488c7089a 100644 --- a/src/filters/reader/UDPReader/stdafx.h +++ b/src/filters/reader/UDPReader/stdafx.h @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/reader/VTSReader/VTSReader.cpp b/src/filters/reader/VTSReader/VTSReader.cpp index 371dd4fbb..a8a0fa408 100644 --- a/src/filters/reader/VTSReader/VTSReader.cpp +++ b/src/filters/reader/VTSReader/VTSReader.cpp @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -28,47 +28,47 @@ const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
{
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_PROGRAM},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_PROGRAM},
};
const AMOVIESETUP_PIN sudOpPin[] =
{
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] =
{
- {&__uuidof(CVTSReader), L"MPC - VTS Reader", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CVTSReader), L"MPC - VTS Reader", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] =
{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CVTSReader>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CVTSReader>, NULL, &sudFilter[0]}
};
int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
- if(GetVersion()&0x80000000)
- return E_NOTIMPL;
+ if(GetVersion() & 0x80000000)
+ return E_NOTIMPL;
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}"),
- _T("0"), _T("0,12,,445644564944454F2D565453")); // "DVDVIDEO-VTS"
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}"),
+ _T("0"), _T("0,12,,445644564944454F2D565453")); // "DVDVIDEO-VTS"
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}"),
- _T("Source Filter"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}"),
+ _T("Source Filter"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}"));
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}"));
+ DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}"));
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -82,15 +82,15 @@ CFilterApp theApp; //
CVTSReader::CVTSReader(IUnknown* pUnk, HRESULT* phr)
- : CAsyncReader(NAME("CVTSReader"), pUnk, &m_stream, phr, __uuidof(this))
+ : CAsyncReader(NAME("CVTSReader"), pUnk, &m_stream, phr, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) *phr = S_OK;
- if(GetVersion()&0x80000000)
- {
- if(phr) *phr = E_NOTIMPL;
- return;
- }
+ if(GetVersion() & 0x80000000)
+ {
+ if(phr) *phr = E_NOTIMPL;
+ return;
+ }
}
CVTSReader::~CVTSReader()
@@ -101,45 +101,45 @@ STDMETHODIMP CVTSReader::NonDelegatingQueryInterface(REFIID riid, void** ppv) {
CheckPointer(ppv, E_POINTER);
- return
- QI(IFileSourceFilter)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IFileSourceFilter)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IFileSourceFilter
-STDMETHODIMP CVTSReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
+STDMETHODIMP CVTSReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(!m_stream.Load(pszFileName))
- return E_FAIL;
+ if(!m_stream.Load(pszFileName))
+ return E_FAIL;
- m_fn = pszFileName;
+ m_fn = pszFileName;
- CMediaType mt;
- mt.majortype = MEDIATYPE_Stream;
- mt.subtype = MEDIASUBTYPE_MPEG2_PROGRAM;
- m_mt = mt;
+ CMediaType mt;
+ mt.majortype = MEDIATYPE_Stream;
+ mt.subtype = MEDIASUBTYPE_MPEG2_PROGRAM;
+ m_mt = mt;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CVTSReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if(!ppszFileName) return E_POINTER;
-
- if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR))))
- return E_OUTOFMEMORY;
+ if(!ppszFileName) return E_POINTER;
+
+ if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR))))
+ return E_OUTOFMEMORY;
- wcscpy(*ppszFileName, m_fn);
+ wcscpy(*ppszFileName, m_fn);
- return S_OK;
+ return S_OK;
}
// CVTSStream
CVTSStream::CVTSStream() : m_off(0)
{
- m_vob.Attach(DNew CVobFile());
+ m_vob.Attach(DNew CVobFile());
}
CVTSStream::~CVTSStream()
@@ -148,55 +148,55 @@ CVTSStream::~CVTSStream() bool CVTSStream::Load(const WCHAR* fnw)
{
- CAtlList<CString> sl;
- return(m_vob && m_vob->Open(CString(fnw), sl) /*&& m_vob->IsDVD()*/);
+ CAtlList<CString> sl;
+ return(m_vob && m_vob->Open(CString(fnw), sl) /*&& m_vob->IsDVD()*/);
}
HRESULT CVTSStream::SetPointer(LONGLONG llPos)
{
- m_off = (int)(llPos&2047);
- int lba = (int)(llPos/2048);
+ m_off = (int)(llPos & 2047);
+ int lba = (int)(llPos / 2048);
- return lba == m_vob->Seek(lba) ? S_OK : S_FALSE;
+ return lba == m_vob->Seek(lba) ? S_OK : S_FALSE;
}
HRESULT CVTSStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead)
{
- CAutoLock lck(&m_csLock);
+ CAutoLock lck(&m_csLock);
- DWORD len = dwBytesToRead;
- BYTE* ptr = pbBuffer;
+ DWORD len = dwBytesToRead;
+ BYTE* ptr = pbBuffer;
- while(len > 0)
- {
- BYTE buff[2048];
- if(!m_vob->Read(buff))
- break;
+ while(len > 0)
+ {
+ BYTE buff[2048];
+ if(!m_vob->Read(buff))
+ break;
- int size = min(2048 - m_off, min(len, 2048));
+ int size = min(2048 - m_off, min(len, 2048));
- memcpy(ptr, &buff[m_off], size);
+ memcpy(ptr, &buff[m_off], size);
- m_off = (m_off + size)&2047;
+ m_off = (m_off + size) & 2047;
- if(m_off > 0)
- m_vob->Seek(m_vob->GetPosition()-1);
+ if(m_off > 0)
+ m_vob->Seek(m_vob->GetPosition() - 1);
- ptr += size;
- len -= size;
- }
+ ptr += size;
+ len -= size;
+ }
- if(pdwBytesRead)
- *pdwBytesRead = ptr - pbBuffer;
+ if(pdwBytesRead)
+ *pdwBytesRead = ptr - pbBuffer;
- return S_OK;
+ return S_OK;
}
LONGLONG CVTSStream::Size(LONGLONG* pSizeAvailable)
{
- LONGLONG len = 2048i64*m_vob->GetLength();
- if(pSizeAvailable) *pSizeAvailable = len;
- return(len);
+ LONGLONG len = 2048i64 * m_vob->GetLength();
+ if(pSizeAvailable) *pSizeAvailable = len;
+ return(len);
}
DWORD CVTSStream::Alignment()
diff --git a/src/filters/reader/VTSReader/VTSReader.h b/src/filters/reader/VTSReader/VTSReader.h index 992351bfc..5a3c2a0fc 100644 --- a/src/filters/reader/VTSReader/VTSReader.h +++ b/src/filters/reader/VTSReader/VTSReader.h @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -32,39 +32,39 @@ class CVTSStream : public CAsyncStream private:
CCritSec m_csLock;
- CAutoPtr<CVobFile> m_vob;
- int m_off;
+ CAutoPtr<CVobFile> m_vob;
+ int m_off;
public:
- CVTSStream();
- virtual ~CVTSStream();
+ CVTSStream();
+ virtual ~CVTSStream();
- bool Load(const WCHAR* fnw);
+ bool Load(const WCHAR* fnw);
HRESULT SetPointer(LONGLONG llPos);
HRESULT Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead);
LONGLONG Size(LONGLONG* pSizeAvailable);
DWORD Alignment();
void Lock();
- void Unlock();
+ void Unlock();
};
[uuid("773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73")]
-class CVTSReader
- : public CAsyncReader
- , public IFileSourceFilter
+class CVTSReader
+ : public CAsyncReader
+ , public IFileSourceFilter
{
- CVTSStream m_stream;
- CStringW m_fn;
+ CVTSStream m_stream;
+ CStringW m_fn;
public:
CVTSReader(IUnknown* pUnk, HRESULT* phr);
- ~CVTSReader();
+ ~CVTSReader();
DECLARE_IUNKNOWN
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IFileSourceFilter
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
+ // IFileSourceFilter
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
};
diff --git a/src/filters/reader/VTSReader/resource.h b/src/filters/reader/VTSReader/resource.h index de42e25ad..1b23a414b 100644 --- a/src/filters/reader/VTSReader/resource.h +++ b/src/filters/reader/VTSReader/resource.h @@ -3,7 +3,7 @@ // Used by vtsreader.rc
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
diff --git a/src/filters/reader/VTSReader/stdafx.cpp b/src/filters/reader/VTSReader/stdafx.cpp index edb7e9517..cbc634206 100644 --- a/src/filters/reader/VTSReader/stdafx.cpp +++ b/src/filters/reader/VTSReader/stdafx.cpp @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/reader/VTSReader/stdafx.h b/src/filters/reader/VTSReader/stdafx.h index 4c5d23feb..15801800a 100644 --- a/src/filters/reader/VTSReader/stdafx.h +++ b/src/filters/reader/VTSReader/stdafx.h @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/reader/asyncreader/asyncio.cpp b/src/filters/reader/asyncreader/asyncio.cpp index 3f6494a6f..b84d44c70 100644 --- a/src/filters/reader/asyncreader/asyncio.cpp +++ b/src/filters/reader/asyncreader/asyncio.cpp @@ -55,25 +55,33 @@ CAsyncRequest::Complete() m_pStream->Lock();
m_hr = m_pStream->SetPointer(m_llPos);
- if (S_OK == m_hr) {
+ if(S_OK == m_hr)
+ {
DWORD dwActual;
m_hr = m_pStream->Read(m_pBuffer, m_lLength, m_bAligned, &dwActual);
- if (m_hr == OLE_S_FIRST) {
- if (m_pContext) {
+ if(m_hr == OLE_S_FIRST)
+ {
+ if(m_pContext)
+ {
IMediaSample *pSample = reinterpret_cast<IMediaSample *>(m_pContext);
pSample->SetDiscontinuity(TRUE);
m_hr = S_OK;
}
}
- if (FAILED(m_hr)) {
- } else if (dwActual != (DWORD)m_lLength) {
+ if(FAILED(m_hr))
+ {
+ }
+ else if(dwActual != (DWORD)m_lLength)
+ {
// tell caller size changed - probably because of EOF
m_lLength = (LONG) dwActual;
m_hr = S_FALSE;
- } else {
+ }
+ else
+ {
m_hr = S_OK;
}
}
@@ -89,16 +97,16 @@ CAsyncRequest::Complete() // note - all events created manual reset
CAsyncIo::CAsyncIo(CAsyncStream *pStream)
- : m_hThread(NULL),
- m_evWork(TRUE),
- m_evDone(TRUE),
- m_evStop(TRUE),
- m_listWork(NAME("Work list")),
- m_listDone(NAME("Done list")),
- m_bFlushing(FALSE),
- m_cItemsOut(0),
- m_bWaiting(FALSE),
- m_pStream(pStream)
+ : m_hThread(NULL),
+ m_evWork(TRUE),
+ m_evDone(TRUE),
+ m_evStop(TRUE),
+ m_listWork(NAME("Work list")),
+ m_listDone(NAME("Done list")),
+ m_bFlushing(FALSE),
+ m_cItemsOut(0),
+ m_bWaiting(FALSE),
+ m_pStream(pStream)
{
}
@@ -114,7 +122,8 @@ CAsyncIo::~CAsyncIo() // empty the done list
POSITION pos = m_listDone.GetHeadPosition();
- while (pos) {
+ while(pos)
+ {
CAsyncRequest* pRequest = m_listDone.GetNext(pos);
delete pRequest;
}
@@ -146,17 +155,19 @@ CAsyncIo::AsyncInactive(void) // add a request to the queue.
HRESULT
CAsyncIo::Request(
- LONGLONG llPos,
- LONG lLength,
- BOOL bAligned,
- BYTE* pBuffer,
- LPVOID pContext,
- DWORD dwUser)
+ LONGLONG llPos,
+ LONG lLength,
+ BOOL bAligned,
+ BYTE* pBuffer,
+ LPVOID pContext,
+ DWORD dwUser)
{
- if (bAligned) {
- if (!IsAligned(llPos) ||
- !IsAligned(lLength) ||
- !IsAligned((LONG) pBuffer)) {
+ if(bAligned)
+ {
+ if(!IsAligned(llPos) ||
+ !IsAligned(lLength) ||
+ !IsAligned((LONG) pBuffer))
+ {
return VFW_E_BADALIGN;
}
}
@@ -164,20 +175,22 @@ CAsyncIo::Request( CAsyncRequest* pRequest = DNew CAsyncRequest;
HRESULT hr = pRequest->Request(
- this,
- m_pStream,
- llPos,
- lLength,
- bAligned,
- pBuffer,
- pContext,
- dwUser);
- if (SUCCEEDED(hr)) {
+ this,
+ m_pStream,
+ llPos,
+ lLength,
+ bAligned,
+ pBuffer,
+ pContext,
+ dwUser);
+ if(SUCCEEDED(hr))
+ {
// might fail if flushing
hr = PutWorkItem(pRequest);
}
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
delete pRequest;
}
return hr;
@@ -198,28 +211,35 @@ CAsyncIo::WaitForNext( // wait until the event is set, but since we are not
// holding the critsec when waiting, we may need to re-wait
- for (;;) {
+ for(;;)
+ {
- if (!m_evDone.Wait(dwTimeout)) {
+ if(!m_evDone.Wait(dwTimeout))
+ {
// timeout occurred
return VFW_E_TIMEOUT;
}
// get next event from list
CAsyncRequest* pRequest = GetDoneItem();
- if (pRequest) {
+ if(pRequest)
+ {
// found a completed request
// check if ok
HRESULT hr = pRequest->GetHResult();
- if (hr == S_FALSE) {
+ if(hr == S_FALSE)
+ {
// this means the actual length was less than
// requested - may be ok if he aligned the end of file
- if ((pRequest->GetActualLength() +
- pRequest->GetStart()) == Size()) {
+ if((pRequest->GetActualLength() +
+ pRequest->GetStart()) == Size())
+ {
hr = S_OK;
- } else {
+ }
+ else
+ {
// it was an actual read error
hr = E_FAIL;
}
@@ -234,10 +254,13 @@ CAsyncIo::WaitForNext( delete pRequest;
return hr;
- } else {
+ }
+ else
+ {
// Hold the critical section while checking the list state
CAutoLock lck(&m_csLists);
- if (m_bFlushing && !m_bWaiting) {
+ if(m_bFlushing && !m_bWaiting)
+ {
// can't block as we are between BeginFlush and EndFlush
@@ -257,32 +280,34 @@ CAsyncIo::WaitForNext( // Need to hold m_csFile while doing this (done in request object)
HRESULT
CAsyncIo::SyncReadAligned(
- LONGLONG llPos,
- LONG lLength,
- BYTE* pBuffer,
- LONG* pcbActual,
- PVOID pvContext
- )
+ LONGLONG llPos,
+ LONG lLength,
+ BYTE* pBuffer,
+ LONG* pcbActual,
+ PVOID pvContext
+)
{
- if (!IsAligned(llPos) ||
- !IsAligned(lLength) ||
- !IsAligned((LONG) pBuffer)) {
+ if(!IsAligned(llPos) ||
+ !IsAligned(lLength) ||
+ !IsAligned((LONG) pBuffer))
+ {
return VFW_E_BADALIGN;
}
CAsyncRequest request;
HRESULT hr = request.Request(
- this,
- m_pStream,
- llPos,
- lLength,
- TRUE,
- pBuffer,
- pvContext,
- 0);
-
- if (FAILED(hr)) {
+ this,
+ m_pStream,
+ llPos,
+ lLength,
+ TRUE,
+ pBuffer,
+ pvContext,
+ 0);
+
+ if(FAILED(hr))
+ {
return hr;
}
@@ -329,13 +354,15 @@ CAsyncIo::BeginFlush() m_bFlushing = TRUE;
CAsyncRequest * preq;
- while((preq = GetWorkItem()) != 0) {
+ while((preq = GetWorkItem()) != 0)
+ {
preq->Cancel();
PutDoneItem(preq);
}
// now wait for any outstanding requests to complete
- if (m_cItemsOut > 0) {
+ if(m_cItemsOut > 0)
+ {
// can be only one person waiting
ASSERT(!m_bWaiting);
@@ -344,7 +371,9 @@ CAsyncIo::BeginFlush() // signalled via m_evAllDone when all outstanding items are
// done. It also tells WaitForNext to continue blocking.
m_bWaiting = TRUE;
- } else {
+ }
+ else
+ {
// all done
// force m_evDone set so that even if list is empty,
@@ -359,13 +388,15 @@ CAsyncIo::BeginFlush() ASSERT(m_bWaiting);
// wait without holding critsec
- for (;;) {
+ for(;;)
+ {
m_evAllDone.Wait();
{
// hold critsec to check
CAutoLock lock(&m_csLists);
- if (m_cItemsOut == 0) {
+ if(m_cItemsOut == 0)
+ {
// now we are sure that all outstanding requests are on
// the done list and no more will be accepted
@@ -395,9 +426,12 @@ CAsyncIo::EndFlush() // m_evDone might have been set by BeginFlush - ensure it is
// set IFF m_listDone is non-empty
- if (m_listDone.GetCount() > 0) {
+ if(m_listDone.GetCount() > 0)
+ {
m_evDone.Set();
- } else {
+ }
+ else
+ {
m_evDone.Reset();
}
@@ -408,7 +442,8 @@ CAsyncIo::EndFlush() HRESULT
CAsyncIo::StartThread(void)
{
- if (m_hThread) {
+ if(m_hThread)
+ {
return S_OK;
}
@@ -423,8 +458,9 @@ CAsyncIo::StartThread(void) this,
0,
&dwThreadID);
- if (!m_hThread) {
- DWORD dwErr = GetLastError();
+ if(!m_hThread)
+ {
+ DWORD dwErr = GetLastError();
return HRESULT_FROM_WIN32(dwErr);
}
return S_OK;
@@ -437,7 +473,8 @@ CAsyncIo::CloseThread(void) // signal the thread-exit object
m_evStop.Set();
- if (m_hThread) {
+ if(m_hThread)
+ {
WaitForSingleObject(m_hThread, INFINITE);
CloseHandle(m_hThread);
@@ -459,7 +496,8 @@ CAsyncIo::GetWorkItem() CAsyncRequest * preq = m_listWork.RemoveHead();
// force event set correctly
- if (m_listWork.GetCount() == 0) {
+ if(m_listWork.GetCount() == 0)
+ {
m_evWork.Reset();
}
return preq;
@@ -483,8 +521,9 @@ CAsyncIo::GetDoneItem() // has moved to the done list which means we must wait until
// cItemsOut is 0 (which is guaranteed by m_bWaiting being TRUE).
- if (m_listDone.GetCount() == 0 &&
- (!m_bFlushing || m_bWaiting)) {
+ if(m_listDone.GetCount() == 0 &&
+ (!m_bFlushing || m_bWaiting))
+ {
m_evDone.Reset();
}
@@ -498,10 +537,12 @@ CAsyncIo::PutWorkItem(CAsyncRequest* pRequest) CAutoLock lock(&m_csLists);
HRESULT hr;
- if (m_bFlushing) {
+ if(m_bFlushing)
+ {
hr = VFW_E_WRONG_STATE;
}
- else if (m_listWork.AddTail(pRequest)) {
+ else if(m_listWork.AddTail(pRequest))
+ {
// event should now be in a set state - force this
m_evWork.Set();
@@ -509,7 +550,9 @@ CAsyncIo::PutWorkItem(CAsyncRequest* pRequest) // start the thread now if not already started
hr = StartThread();
- } else {
+ }
+ else
+ {
hr = E_OUTOFMEMORY;
}
@@ -523,12 +566,15 @@ CAsyncIo::PutDoneItem(CAsyncRequest* pRequest) {
ASSERT(CritCheckIn(&m_csLists));
- if (m_listDone.AddTail(pRequest)) {
+ if(m_listDone.AddTail(pRequest))
+ {
// event should now be in a set state - force this
m_evDone.Set();
return S_OK;
- } else {
+ }
+ else
+ {
return E_OUTOFMEMORY;
}
}
@@ -539,12 +585,14 @@ CAsyncIo::ProcessRequests(void) {
// lock to get the item and increment the outstanding count
CAsyncRequest * preq = NULL;
- for (;;) {
+ for(;;)
+ {
{
CAutoLock lock(&m_csLists);
preq = GetWorkItem();
- if (preq == NULL) {
+ if(preq == NULL)
+ {
// done
return;
}
@@ -563,8 +611,10 @@ CAsyncIo::ProcessRequests(void) PutDoneItem(preq);
- if (--m_cItemsOut == 0) {
- if (m_bWaiting) {
+ if(--m_cItemsOut == 0)
+ {
+ if(m_bWaiting)
+ {
m_evAllDone.Set();
}
}
@@ -579,20 +629,24 @@ CAsyncIo::ThreadProc(void) {
HANDLE ahev[] = {m_evStop, m_evWork};
- for (;;) {
- DWORD dw = WaitForMultipleObjects(
- 2,
- ahev,
- FALSE,
- INFINITE);
- if (dw == WAIT_OBJECT_0+1) {
-
- // requests need processing
- ProcessRequests();
- } else {
- // any error or stop event - we should exit
- return 0;
- }
+ for(;;)
+ {
+ DWORD dw = WaitForMultipleObjects(
+ 2,
+ ahev,
+ FALSE,
+ INFINITE);
+ if(dw == WAIT_OBJECT_0 + 1)
+ {
+
+ // requests need processing
+ ProcessRequests();
+ }
+ else
+ {
+ // any error or stop event - we should exit
+ return 0;
+ }
}
}
@@ -602,15 +656,16 @@ CAsyncIo::ThreadProc(void) // may not be aligned - so we will have to buffer.
HRESULT
CAsyncIo::SyncRead(
- LONGLONG llPos,
- LONG lLength,
- BYTE* pBuffer)
+ LONGLONG llPos,
+ LONG lLength,
+ BYTE* pBuffer)
{
- if (IsAligned(llPos) &&
- IsAligned(lLength) &&
- IsAligned((LONG) pBuffer)) {
+ if(IsAligned(llPos) &&
+ IsAligned(lLength) &&
+ IsAligned((LONG) pBuffer))
+ {
LONG cbUnused;
- return SyncReadAligned(llPos, lLength, pBuffer, &cbUnused, NULL);
+ return SyncReadAligned(llPos, lLength, pBuffer, &cbUnused, NULL);
}
// not aligned with requirements - use buffered file handle.
@@ -619,16 +674,17 @@ CAsyncIo::SyncRead( CAsyncRequest request;
HRESULT hr = request.Request(
- this,
- m_pStream,
- llPos,
- lLength,
- FALSE,
- pBuffer,
- NULL,
- 0);
-
- if (FAILED(hr)) {
+ this,
+ m_pStream,
+ llPos,
+ lLength,
+ FALSE,
+ pBuffer,
+ NULL,
+ 0);
+
+ if(FAILED(hr))
+ {
return hr;
}
diff --git a/src/filters/reader/asyncreader/asyncio.h b/src/filters/reader/asyncreader/asyncio.h index 0f463bf7a..bf84cd2ca 100644 --- a/src/filters/reader/asyncreader/asyncio.h +++ b/src/filters/reader/asyncreader/asyncio.h @@ -57,14 +57,14 @@ public: // init the params for this request. Issue the i/o
// if overlapped i/o is possible.
HRESULT Request(
- CAsyncIo *pIo,
+ CAsyncIo *pIo,
CAsyncStream *pStream,
- LONGLONG llPos,
- LONG lLength,
+ LONGLONG llPos,
+ LONG lLength,
BOOL bAligned,
- BYTE* pBuffer,
- LPVOID pContext, // filter's context
- DWORD dwUser); // downstream filter's context
+ BYTE* pBuffer,
+ LPVOID pContext, // filter's context
+ DWORD dwUser); // downstream filter's context
// issue the i/o if not overlapped, and block until i/o complete.
// returns error code of file i/o
@@ -73,30 +73,33 @@ public: // cancels the i/o. blocks until i/o is no longer pending
HRESULT Cancel() const
{
- return S_OK;
+ return S_OK;
};
// accessor functions
LPVOID GetContext() /*const*/
{
- return m_pContext;
+ return m_pContext;
};
DWORD GetUser() const
{
- return m_dwUser;
+ return m_dwUser;
};
- HRESULT GetHResult() const {
+ HRESULT GetHResult() const
+ {
return m_hr;
};
// we set m_lLength to the actual length
- LONG GetActualLength() const {
+ LONG GetActualLength() const
+ {
return m_lLength;
};
- LONGLONG GetStart() const {
+ LONGLONG GetStart() const
+ {
return m_llPos;
};
};
@@ -148,7 +151,8 @@ class CAsyncIo CAMEvent m_evStop; // set when thread should exit
HANDLE m_hThread;
- LONGLONG Size() {
+ LONGLONG Size()
+ {
ASSERT(m_pStream != NULL);
return m_pStream->Size();
};
@@ -179,9 +183,10 @@ class CAsyncIo // initial static thread proc calls ThreadProc with DWORD
// param as this
- static DWORD WINAPI InitialThreadProc(LPVOID pv) {
- CAsyncIo * pThis = static_cast<CAsyncIo*> (pv);
- return pThis->ThreadProc();
+ static DWORD WINAPI InitialThreadProc(LPVOID pv)
+ {
+ CAsyncIo * pThis = static_cast<CAsyncIo*>(pv);
+ return pThis->ThreadProc();
};
DWORD ThreadProc(void);
@@ -204,36 +209,36 @@ public: // queue a requested read. must be aligned.
HRESULT Request(
- LONGLONG llPos,
- LONG lLength,
- BOOL bAligned,
- BYTE* pBuffer,
- LPVOID pContext,
- DWORD dwUser);
+ LONGLONG llPos,
+ LONG lLength,
+ BOOL bAligned,
+ BYTE* pBuffer,
+ LPVOID pContext,
+ DWORD dwUser);
// wait for the next read to complete
HRESULT WaitForNext(
- DWORD dwTimeout,
- LPVOID *ppContext,
- DWORD * pdwUser,
- LONG * pcbActual
- );
+ DWORD dwTimeout,
+ LPVOID *ppContext,
+ DWORD * pdwUser,
+ LONG * pcbActual
+ );
// perform a read of an already aligned buffer
HRESULT SyncReadAligned(
- LONGLONG llPos,
- LONG lLength,
- BYTE* pBuffer,
- LONG* pcbActual,
- PVOID pvContext
- );
+ LONGLONG llPos,
+ LONG lLength,
+ BYTE* pBuffer,
+ LONG* pcbActual,
+ PVOID pvContext
+ );
// perform a synchronous read. will be buffered
// if not aligned.
HRESULT SyncRead(
- LONGLONG llPos,
- LONG lLength,
- BYTE* pBuffer);
+ LONGLONG llPos,
+ LONG lLength,
+ BYTE* pBuffer);
// return length
HRESULT Length(LONGLONG *pllTotal, LONGLONG* pllAvailable);
@@ -250,18 +255,26 @@ public: return m_pStream->Alignment();
};
- BOOL IsAligned(LONG l) {
- if ((l & (Alignment() -1)) == 0) {
- return TRUE;
- } else {
- return FALSE;
- }
+ BOOL IsAligned(LONG l)
+ {
+ if((l & (Alignment() - 1)) == 0)
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
};
- BOOL IsAligned(LONGLONG ll) {
- return IsAligned( (LONG) (ll & 0xffffffff));
+ BOOL IsAligned(LONGLONG ll)
+ {
+ return IsAligned((LONG)(ll & 0xffffffff));
};
// Accessor
- HANDLE StopEvent() const { return m_evDone; }
+ HANDLE StopEvent() const
+ {
+ return m_evDone;
+ }
};
diff --git a/src/filters/reader/asyncreader/asyncrdr.cpp b/src/filters/reader/asyncreader/asyncrdr.cpp index 5e807f8cc..7f32fdc6e 100644 --- a/src/filters/reader/asyncreader/asyncrdr.cpp +++ b/src/filters/reader/asyncreader/asyncrdr.cpp @@ -2,7 +2,7 @@ // File: AsyncRdr.cpp
//
// Desc: DirectShow sample code - base library with I/O functionality.
-// This file implements I/O source filter methods and output pin
+// This file implements I/O source filter methods and output pin
// methods for CAsyncReader and CAsyncOutputPin.
//
// Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
@@ -20,13 +20,13 @@ CAsyncOutputPin::CAsyncOutputPin( CAsyncReader *pReader,
CAsyncIo *pIo,
CCritSec * pLock)
- : CBasePin(
- NAME("Async output pin"),
- pReader,
- pLock,
- phr,
- L"Output",
- PINDIR_OUTPUT),
+ : CBasePin(
+ NAME("Async output pin"),
+ pReader,
+ pLock,
+ phr,
+ L"Output",
+ PINDIR_OUTPUT),
m_pReader(pReader),
m_pIo(pIo)
{
@@ -39,24 +39,29 @@ CAsyncOutputPin::~CAsyncOutputPin() STDMETHODIMP
CAsyncOutputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv,E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- if (riid == IID_IAsyncReader) {
+ if(riid == IID_IAsyncReader)
+ {
m_bQueriedForAsyncReader = TRUE;
- return GetInterface((IAsyncReader*) this, ppv);
- } else {
- return CBasePin::NonDelegatingQueryInterface(riid, ppv);
+ return GetInterface((IAsyncReader*) this, ppv);
+ }
+ else
+ {
+ return CBasePin::NonDelegatingQueryInterface(riid, ppv);
}
}
HRESULT
CAsyncOutputPin::GetMediaType(int iPosition, CMediaType *pMediaType)
{
- if (iPosition < 0) {
- return E_INVALIDARG;
+ if(iPosition < 0)
+ {
+ return E_INVALIDARG;
}
- if (iPosition > 0) {
- return VFW_S_NO_MORE_ITEMS;
+ if(iPosition > 0)
+ {
+ return VFW_S_NO_MORE_ITEMS;
}
*pMediaType = *m_pReader->LoadType();
@@ -69,10 +74,11 @@ CAsyncOutputPin::CheckMediaType(const CMediaType* pType) CAutoLock lck(m_pLock);
/* We treat MEDIASUBTYPE_NULL subtype as a wild card */
- if ((m_pReader->LoadType()->majortype == pType->majortype) &&
- (m_pReader->LoadType()->subtype == MEDIASUBTYPE_NULL ||
- m_pReader->LoadType()->subtype == pType->subtype)) {
- return S_OK;
+ if((m_pReader->LoadType()->majortype == pType->majortype) &&
+ (m_pReader->LoadType()->subtype == MEDIASUBTYPE_NULL ||
+ m_pReader->LoadType()->subtype == pType->subtype))
+ {
+ return S_OK;
}
return S_FALSE;
}
@@ -85,21 +91,24 @@ CAsyncOutputPin::InitAllocator(IMemAllocator **ppAlloc) CMemAllocator *pMemObject = NULL;
/* Create a default memory allocator */
- pMemObject = DNew CMemAllocator(NAME("Base memory allocator"),NULL, &hr);
- if (pMemObject == NULL) {
- return E_OUTOFMEMORY;
+ pMemObject = DNew CMemAllocator(NAME("Base memory allocator"), NULL, &hr);
+ if(pMemObject == NULL)
+ {
+ return E_OUTOFMEMORY;
}
- if (FAILED(hr)) {
- delete pMemObject;
- return hr;
+ if(FAILED(hr))
+ {
+ delete pMemObject;
+ return hr;
}
/* Get a reference counted IID_IMemAllocator interface */
- hr = pMemObject->QueryInterface(IID_IMemAllocator,(void **)ppAlloc);
- if (FAILED(hr)) {
- delete pMemObject;
- return E_NOINTERFACE;
+ hr = pMemObject->QueryInterface(IID_IMemAllocator, (void **)ppAlloc);
+ if(FAILED(hr))
+ {
+ delete pMemObject;
+ return E_NOINTERFACE;
}
ASSERT(*ppAlloc != NULL);
@@ -115,18 +124,21 @@ CAsyncOutputPin::RequestAllocator( IMemAllocator ** ppActual)
{
// we care about alignment but nothing else
- if (!pProps->cbAlign || !m_pIo->IsAligned(pProps->cbAlign)) {
- m_pIo->Alignment(&pProps->cbAlign);
+ if(!pProps->cbAlign || !m_pIo->IsAligned(pProps->cbAlign))
+ {
+ m_pIo->Alignment(&pProps->cbAlign);
}
ALLOCATOR_PROPERTIES Actual;
HRESULT hr;
- if (pPreferred) {
- hr = pPreferred->SetProperties(pProps, &Actual);
- if (SUCCEEDED(hr) && m_pIo->IsAligned(Actual.cbAlign)) {
+ if(pPreferred)
+ {
+ hr = pPreferred->SetProperties(pProps, &Actual);
+ if(SUCCEEDED(hr) && m_pIo->IsAligned(Actual.cbAlign))
+ {
pPreferred->AddRef();
- *ppActual = pPreferred;
+ *ppActual = pPreferred;
return S_OK;
}
}
@@ -134,13 +146,15 @@ CAsyncOutputPin::RequestAllocator( // create our own allocator
IMemAllocator* pAlloc;
hr = InitAllocator(&pAlloc);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
//...and see if we can make it suitable
hr = pAlloc->SetProperties(pProps, &Actual);
- if (SUCCEEDED(hr) && m_pIo->IsAligned(Actual.cbAlign)) {
+ if(SUCCEEDED(hr) && m_pIo->IsAligned(Actual.cbAlign))
+ {
// we need to release our refcount on pAlloc, and addref
// it to pass a refcount to the caller - this is a net nothing.
*ppActual = pAlloc;
@@ -152,7 +166,8 @@ CAsyncOutputPin::RequestAllocator( // if we failed because of the IsAligned test, the error code will
// not be failure
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
hr = VFW_E_BADALIGN;
}
return hr;
@@ -168,26 +183,29 @@ CAsyncOutputPin::Request( {
REFERENCE_TIME tStart, tStop;
HRESULT hr = pSample->GetTime(&tStart, &tStop);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
LONGLONG llPos = tStart / UNITS;
- LONG lLength = (LONG) ((tStop - tStart) / UNITS);
+ LONG lLength = (LONG)((tStop - tStart) / UNITS);
LONGLONG llTotal;
LONGLONG llAvailable;
hr = m_pIo->Length(&llTotal, &llAvailable);
- if (llPos + lLength > llTotal) {
+ if(llPos + lLength > llTotal)
+ {
// the end needs to be aligned, but may have been aligned
// on a coarser alignment.
LONG lAlign;
m_pIo->Alignment(&lAlign);
- llTotal = (llTotal + lAlign -1) & ~(lAlign-1);
+ llTotal = (llTotal + lAlign - 1) & ~(lAlign - 1);
- if (llPos + lLength > llTotal) {
- lLength = (LONG) (llTotal - llPos);
+ if(llPos + lLength > llTotal)
+ {
+ lLength = (LONG)(llTotal - llPos);
// must be reducing this!
ASSERT((llTotal * UNITS) <= tStop);
@@ -199,46 +217,50 @@ CAsyncOutputPin::Request( BYTE* pBuffer;
hr = pSample->GetPointer(&pBuffer);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
return m_pIo->Request(
- llPos,
- lLength,
- TRUE,
- pBuffer,
- (LPVOID)pSample,
- dwUser);
+ llPos,
+ lLength,
+ TRUE,
+ pBuffer,
+ (LPVOID)pSample,
+ dwUser);
}
// sync-aligned request. just like a request/waitfornext pair.
STDMETHODIMP
CAsyncOutputPin::SyncReadAligned(
- IMediaSample* pSample)
+ IMediaSample* pSample)
{
REFERENCE_TIME tStart, tStop;
HRESULT hr = pSample->GetTime(&tStart, &tStop);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
LONGLONG llPos = tStart / UNITS;
- LONG lLength = (LONG) ((tStop - tStart) / UNITS);
+ LONG lLength = (LONG)((tStop - tStart) / UNITS);
LONGLONG llTotal;
LONGLONG llAvailable;
hr = m_pIo->Length(&llTotal, &llAvailable);
- if (llPos + lLength > llTotal) {
+ if(llPos + lLength > llTotal)
+ {
// the end needs to be aligned, but may have been aligned
// on a coarser alignment.
LONG lAlign;
m_pIo->Alignment(&lAlign);
- llTotal = (llTotal + lAlign -1) & ~(lAlign-1);
+ llTotal = (llTotal + lAlign - 1) & ~(lAlign - 1);
- if (llPos + lLength > llTotal) {
- lLength = (LONG) (llTotal - llPos);
+ if(llPos + lLength > llTotal)
+ {
+ lLength = (LONG)(llTotal - llPos);
// must be reducing this!
ASSERT((llTotal * UNITS) <= tStop);
@@ -250,18 +272,19 @@ CAsyncOutputPin::SyncReadAligned( BYTE* pBuffer;
hr = pSample->GetPointer(&pBuffer);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
LONG cbActual;
hr = m_pIo->SyncReadAligned(
- llPos,
- lLength,
- pBuffer,
- &cbActual,
- pSample
- );
+ llPos,
+ lLength,
+ pBuffer,
+ &cbActual,
+ pSample
+ );
pSample->SetActualDataLength(cbActual);
return hr;
@@ -280,13 +303,14 @@ CAsyncOutputPin::WaitForNext( IMediaSample* pSample;
HRESULT hr = m_pIo->WaitForNext(
- dwTimeout,
- (LPVOID*) &pSample,
- (DWORD*)pdwUser,
- &cbActual
- );
-
- if (SUCCEEDED(hr)) {
+ dwTimeout,
+ (LPVOID*) &pSample,
+ (DWORD*)pdwUser,
+ &cbActual
+ );
+
+ if(SUCCEEDED(hr))
+ {
pSample->SetActualDataLength(cbActual);
}
@@ -350,19 +374,19 @@ CAsyncReader::CAsyncReader( LPUNKNOWN pUnk,
CAsyncStream *pStream,
HRESULT *phr,
- const CLSID& clsid)
- : CBaseFilter(
+ const CLSID& clsid)
+ : CBaseFilter(
pName,
- pUnk,
- &m_csFilter,
- clsid,
+ pUnk,
+ &m_csFilter,
+ clsid,
NULL
- ),
+ ),
m_OutputPin(
- phr,
- this,
- &m_Io,
- &m_csFilter),
+ phr,
+ this,
+ &m_Io,
+ &m_csFilter),
m_Io(pStream)
{
}
@@ -375,16 +399,16 @@ STDMETHODIMP CAsyncReader::NonDelegatingQueryInterface(REFIID riid, void** ppv) {
CheckPointer(ppv, E_POINTER);
- return
- (riid == __uuidof(IAMFilterMiscFlags)) ? GetInterface((IAMFilterMiscFlags*)this, ppv) :
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ (riid == __uuidof(IAMFilterMiscFlags)) ? GetInterface((IAMFilterMiscFlags*)this, ppv) :
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IAMFilterMiscFlags
ULONG CAsyncReader::GetMiscFlags()
{
- return AM_FILTER_MISC_FLAGS_IS_SOURCE;
+ return AM_FILTER_MISC_FLAGS_IS_SOURCE;
}
@@ -397,10 +421,13 @@ CAsyncReader::GetPinCount() CBasePin *
CAsyncReader::GetPin(int n)
{
- if ((GetPinCount() > 0) && (n == 0)) {
- return &m_OutputPin;
- } else {
- return NULL;
+ if((GetPinCount() > 0) && (n == 0))
+ {
+ return &m_OutputPin;
+ }
+ else
+ {
+ return NULL;
}
}
diff --git a/src/filters/reader/asyncreader/asyncrdr.h b/src/filters/reader/asyncreader/asyncrdr.h index 467662d0f..8cbf917bd 100644 --- a/src/filters/reader/asyncreader/asyncrdr.h +++ b/src/filters/reader/asyncreader/asyncrdr.h @@ -19,8 +19,8 @@ class CAsyncReader; // the output pin class
class CAsyncOutputPin
- : public IAsyncReader,
- public CBasePin
+ : public IAsyncReader,
+ public CBasePin
{
protected:
CAsyncReader* m_pReader;
@@ -39,8 +39,8 @@ public: // constructor and destructor
CAsyncOutputPin(
HRESULT * phr,
- CAsyncReader *pReader,
- CAsyncIo *pIo,
+ CAsyncReader *pReader,
+ CAsyncIo *pIo,
CCritSec * pLock);
~CAsyncOutputPin();
@@ -76,9 +76,12 @@ public: // See if it was asked for
HRESULT CompleteConnect(IPin *pReceivePin)
{
- if (m_bQueriedForAsyncReader) {
+ if(m_bQueriedForAsyncReader)
+ {
return CBasePin::CompleteConnect(pReceivePin);
- } else {
+ }
+ else
+ {
#ifdef VFW_E_NO_TRANSPORT
return VFW_E_NO_TRANSPORT;
#else
@@ -101,9 +104,9 @@ public: // this allocator will be not be committed and decommitted by
// the async reader, only by the consumer.
STDMETHODIMP RequestAllocator(
- IMemAllocator* pPreferred,
- ALLOCATOR_PROPERTIES* pProps,
- IMemAllocator ** ppActual);
+ IMemAllocator* pPreferred,
+ ALLOCATOR_PROPERTIES* pProps,
+ IMemAllocator ** ppActual);
// queue a request for data.
// media sample start and stop times contain the requested absolute
@@ -113,8 +116,8 @@ public: // samples allocated from source pin's allocator may fail
// GetPointer until after returning from WaitForNext.
STDMETHODIMP Request(
- IMediaSample* pSample,
- DWORD_PTR dwUser); // user context
+ IMediaSample* pSample,
+ DWORD_PTR dwUser); // user context
// block until the next sample is completed or the timeout occurs.
// timeout (millisecs) may be 0 or INFINITE. Samples may not
@@ -122,32 +125,32 @@ public: // notification will already have been sent by the source filter,
// and STDMETHODIMP will be an error.
STDMETHODIMP WaitForNext(
- DWORD dwTimeout,
- IMediaSample** ppSample, // completed sample
- DWORD_PTR* pdwUser); // user context
+ DWORD dwTimeout,
+ IMediaSample** ppSample, // completed sample
+ DWORD_PTR* pdwUser); // user context
// sync read of data. Sample passed in must have been acquired from
// the agreed allocator. Start and stop position must be aligned.
// equivalent to a Request/WaitForNext pair, but may avoid the
// need for a thread on the source filter.
STDMETHODIMP SyncReadAligned(
- IMediaSample* pSample);
+ IMediaSample* pSample);
// sync read. works in stopped state as well as run state.
// need not be aligned. Will fail if read is beyond actual total
// length.
STDMETHODIMP SyncRead(
- LONGLONG llPosition, // absolute file position
- LONG lLength, // nr bytes required
- BYTE* pBuffer); // write data here
+ LONGLONG llPosition, // absolute file position
+ LONG lLength, // nr bytes required
+ BYTE* pBuffer); // write data here
// return total length of stream, and currently available length.
// reads for beyond the available length but within the total length will
// normally succeed but may block for a long period.
STDMETHODIMP Length(
- LONGLONG* pTotal,
- LONGLONG* pAvailable);
+ LONGLONG* pTotal,
+ LONGLONG* pAvailable);
// cause all outstanding reads to return, possibly with a failure code
// (VFW_E_TIMEOUT) indicating they were cancelled.
@@ -179,7 +182,7 @@ protected: CMediaType m_mt;
public:
-
+
// construction / destruction
CAsyncReader(
@@ -187,14 +190,14 @@ public: LPUNKNOWN pUnk,
CAsyncStream *pStream,
HRESULT *phr,
- const CLSID& clsid);
+ const CLSID& clsid);
~CAsyncReader();
- DECLARE_IUNKNOWN;
+ DECLARE_IUNKNOWN;
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IAMFilterMiscFlags
- STDMETHODIMP_(ULONG) GetMiscFlags();
+ // IAMFilterMiscFlags
+ STDMETHODIMP_(ULONG) GetMiscFlags();
// --- CBaseFilter methods ---
int GetPinCount();
|