Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmarsev committed Aug 8, 2015
2 parents 7ac3794 + 8afb519 commit a424d59
Show file tree
Hide file tree
Showing 10 changed files with 167 additions and 59 deletions.
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Sanear, a robust DirectShow audio renderer
==========================================

v0.3 - 2015/08/08
* Bugfixing release
* Improves status page compatibility with certain players

v0.2 - 2015/08/02
* Bugfixing release
* Fixes audible noise in dithering
Expand Down
19 changes: 18 additions & 1 deletion dll/src/sanear-dll/Entry.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#include "pch.h"

#include "OuterFilter.h"
#include "../../../src/MyPropertyPage.h"

namespace
{
// {DF557071-C9FD-433A-9627-81E0D3640ED9}
const GUID filterGuid = {0xdf557071, 0xc9fd, 0x433a, {0x96, 0x27, 0x81, 0xe0, 0xd3, 0x64, 0xe, 0xd9}};

const WCHAR filterName[] = L"Sanear Audio Renderer";

const GUID statusPageGuid = __uuidof(SaneAudioRenderer::MyPropertyPage);
const WCHAR statusPageName[] = L"Sanear Status Page";

const AMOVIESETUP_MEDIATYPE pinTypes[] = {
{&MEDIATYPE_Audio, &CLSID_NULL},
};
Expand All @@ -23,9 +26,11 @@ namespace
}

CUnknown* WINAPI CreateFilterInstance(LPUNKNOWN, HRESULT*);
CUnknown* WINAPI CreateStatusPageInstance(LPUNKNOWN, HRESULT*);

CFactoryTemplate g_Templates[] = {
{filterName, &filterGuid, CreateFilterInstance},
{statusPageName, &statusPageGuid, CreateStatusPageInstance},
};

int g_cTemplates = _countof(g_Templates);
Expand Down Expand Up @@ -106,6 +111,18 @@ CUnknown* WINAPI CreateFilterInstance(IUnknown* pUnknown, HRESULT* pResult)
return pFilter;
}

CUnknown* WINAPI CreateStatusPageInstance(IUnknown* pUnknown, HRESULT* pResult)
{
CheckPointer(pResult, nullptr);

auto pFilter = new(std::nothrow) SaneAudioRenderer::MyPropertyPage();

if (!pFilter)
*pResult = E_OUTOFMEMORY;

return pFilter;
}

STDAPI DllRegisterServer()
{
if (!IsWindowsVistaOrGreater())
Expand Down
3 changes: 3 additions & 0 deletions dll/src/sanear-dll/OuterFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ namespace SaneAudioRenderer
if (riid == IID_IUnknown)
return CUnknown::NonDelegatingQueryInterface(riid, ppv);

if (riid == IID_ISpecifyPropertyPages)
return m_innerFilter->QueryInterface(__uuidof(ISpecifyPropertyPages2), ppv);

return m_innerFilter->QueryInterface(riid, ppv);
}

Expand Down
10 changes: 5 additions & 5 deletions dll/src/sanear-dll/sanear.rc
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ IDI_ICON1 ICON "sanear.ico"
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,2,0,0
PRODUCTVERSION 0,2,0,0
FILEVERSION 0,3,0,0
PRODUCTVERSION 0,3,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -76,10 +76,10 @@ BEGIN
BEGIN
BLOCK "080904b0"
BEGIN
VALUE "FileDescription", "Robust DirectShow audio renderer"
VALUE "FileVersion", "0.2.0.0"
VALUE "FileDescription", "Sanear, a robust DirectShow audio renderer"
VALUE "FileVersion", "0.3.0.0"
VALUE "ProductName", "Sanear Audio Renderer"
VALUE "ProductVersion", "0.2.0.0"
VALUE "ProductVersion", "0.3.0.0"
END
END
BLOCK "VarFileInfo"
Expand Down
12 changes: 9 additions & 3 deletions src/DspDither.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ namespace SaneAudioRenderer
{
void DspDither::Initialize(DspFormat outputFormat)
{
m_active = (outputFormat == DspFormat::Pcm16);
m_enabled = (outputFormat == DspFormat::Pcm16);
m_active = m_enabled;

for (size_t i = 0; i < 18; i++)
{
Expand All @@ -17,13 +18,18 @@ namespace SaneAudioRenderer

bool DspDither::Active()
{
return m_active;
return m_enabled && m_active;
}

void DspDither::Process(DspChunk& chunk)
{
if (!m_active || chunk.IsEmpty() || chunk.GetFormatSize() <= DspFormatSize(DspFormat::Pcm16))
if (!m_enabled || chunk.IsEmpty() || chunk.GetFormatSize() <= DspFormatSize(DspFormat::Pcm16))
{
m_active = false;
return;
}

m_active = true;

DspChunk::ToFloat(chunk);

Expand Down
1 change: 1 addition & 0 deletions src/DspDither.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace SaneAudioRenderer

private:

bool m_enabled = false;
bool m_active = false;
std::array<float, 18> m_previous;
std::array<std::minstd_rand, 18> m_generator;
Expand Down
52 changes: 34 additions & 18 deletions src/MyFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "MyClock.h"
#include "MyTestClock.h"
#include "MyPin.h"
#include "MyPropertyPage.h"

namespace SaneAudioRenderer
{
Expand Down Expand Up @@ -69,8 +68,8 @@ namespace SaneAudioRenderer
if (riid == __uuidof(ISpecifyPropertyPages2))
return GetInterface(static_cast<ISpecifyPropertyPages2*>(this), ppv);

if (riid == IID_ISpecifyPropertyPages)
return GetInterface(static_cast<ISpecifyPropertyPages*>(this), ppv);
if (riid == __uuidof(IStatusPageData))
return GetInterface(static_cast<IStatusPageData*>(this), ppv);

return CBaseFilter::NonDelegatingQueryInterface(riid, ppv);
}
Expand Down Expand Up @@ -129,10 +128,18 @@ namespace SaneAudioRenderer
{
CheckPointer(pPages, E_POINTER);

pPages->cElems = 1;
pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID));
CheckPointer(pPages->pElems, E_OUTOFMEMORY);
*pPages->pElems = __uuidof(MyPropertyPage);
if (m_pin->IsConnected())
{
pPages->cElems = 1;
pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID));
CheckPointer(pPages->pElems, E_OUTOFMEMORY);
pPages->pElems[0] = __uuidof(MyPropertyPage);
}
else
{
pPages->cElems = 0;
pPages->pElems = nullptr;
}

return S_OK;
}
Expand All @@ -146,30 +153,39 @@ namespace SaneAudioRenderer

MyPropertyPage* pPage;

pPage = new(std::nothrow) MyPropertyPage();

CheckPointer(pPage, E_OUTOFMEMORY);

pPage->AddRef();

HRESULT result = pPage->QueryInterface(IID_PPV_ARGS(ppPage));

pPage->Release();

return result;
}

STDMETHODIMP MyFilter::GetPageData(std::vector<char>& data)
{
try
{
CAutoLock rendererLock(m_renderer.get());

auto inputFormat = m_renderer->GetInputFormat();
auto audioDevice = m_renderer->GetAudioDevice();

pPage = new MyPropertyPage(inputFormat, audioDevice,
m_renderer->GetActiveProcessors(),
m_renderer->OnExternalClock(),
m_renderer->IsLive());
data = MyPropertyPage::CreateDialogData(inputFormat, audioDevice,
m_renderer->GetActiveProcessors(),
m_renderer->OnExternalClock(),
m_renderer->IsLive());
}
catch (std::bad_alloc&)
{
return E_OUTOFMEMORY;
}

pPage->AddRef();

HRESULT result = pPage->QueryInterface(IID_PPV_ARGS(ppPage));

pPage->Release();

return result;
return S_OK;
}

template <FILTER_STATE NewState, typename PinFunction>
Expand Down
4 changes: 4 additions & 0 deletions src/MyFilter.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "Interfaces.h"
#include "MyPropertyPage.h"

namespace SaneAudioRenderer
{
Expand All @@ -13,6 +14,7 @@ namespace SaneAudioRenderer
: public CCritSec
, public CBaseFilter
, public ISpecifyPropertyPages2
, public IStatusPageData
{
public:

Expand Down Expand Up @@ -40,6 +42,8 @@ namespace SaneAudioRenderer
STDMETHODIMP GetPages(CAUUID* pPages) override;
STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage) override;

STDMETHODIMP GetPageData(std::vector<char>& data) override;

private:

template <FILTER_STATE NewState, typename PinFunction>
Expand Down
Loading

0 comments on commit a424d59

Please sign in to comment.