<commit_before>#include "pch.h"
#include "MyFilter.h"

#include "AudioRenderer.h"
#include "Factory.h"
#include "MyBasicAudio.h"
#include "MyClock.h"
#include "MyTestClock.h"
#include "MyPin.h"
#include "MyPropertyPage.h"

namespace SaneAudioRenderer
{
    MyFilter::MyFilter(IUnknown* pUnknown, REFIID guid)
        : CBaseFilter(L"SaneAudioRenderer::MyFilter", pUnknown, this, guid)
        , m_bufferFilled(TRUE/*manual reset*/)
    {
    }

    HRESULT MyFilter::Init(ISettings* pSettings)
    {
        HRESULT result = S_OK;

        try
        {
            if (SUCCEEDED(result))
                m_clock = std::make_unique<MyClock>(GetOwner(), result);

            //if (SUCCEEDED(result))
            //    m_testClock = new MyTestClock(nullptr, result);

            if (SUCCEEDED(result))
                m_renderer = std::make_unique<AudioRenderer>(pSettings, *m_clock, result);

            if (SUCCEEDED(result))
                m_basicAudio = std::make_unique<MyBasicAudio>(GetOwner(), *m_renderer);

            if (SUCCEEDED(result))
                m_pin = std::make_unique<MyPin>(*m_renderer, this, result);

            if (SUCCEEDED(result))
                result = CreatePosPassThru(GetOwner(), FALSE, m_pin.get(), &m_seeking);
        }
        catch (std::bad_alloc&)
        {
            result = E_OUTOFMEMORY;
        }

        return result;
    }

    STDMETHODIMP MyFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
    {
        if (riid == IID_IUnknown)
            return CUnknown::NonDelegatingQueryInterface(riid, ppv);

        //if (riid == IID_IReferenceClock || riid == IID_IReferenceClockTimerControl)
        //    return m_testClock->QueryInterface(riid, ppv);

        if (riid == IID_IReferenceClock || riid == IID_IReferenceClockTimerControl)
            return m_clock->NonDelegatingQueryInterface(riid, ppv);

        if (riid == IID_IBasicAudio)
            return m_basicAudio->NonDelegatingQueryInterface(riid, ppv);

        if (riid == IID_IMediaSeeking)
            return m_seeking->QueryInterface(riid, ppv);

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

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

        return CBaseFilter::NonDelegatingQueryInterface(riid, ppv);
    }

    int MyFilter::GetPinCount()
    {
        return 1;
    }

    CBasePin* MyFilter::GetPin(int n)
    {
        return (n == 0) ? m_pin.get() : nullptr;
    }

    STDMETHODIMP MyFilter::Stop()
    {
        return ChangeState<State_Stopped>(std::bind(&MyPin::Inactive, m_pin.get()));
    }

    STDMETHODIMP MyFilter::Pause()
    {
        return ChangeState<State_Paused>(std::bind(&MyPin::Active, m_pin.get()));
    }

    STDMETHODIMP MyFilter::Run(REFERENCE_TIME startTime)
    {
        return ChangeState<State_Running>(std::bind(&MyPin::Run, m_pin.get(), startTime));<commit_msg>Don't expose ISpecifyPropertyPages in MyFilter<commit_after>#include "pch.h"
#include "MyFilter.h"

#include "AudioRenderer.h"
#include "Factory.h"
#include "MyBasicAudio.h"
#include "MyClock.h"
#include "MyTestClock.h"
#include "MyPin.h"
#include "MyPropertyPage.h"

namespace SaneAudioRenderer
{
    MyFilter::MyFilter(IUnknown* pUnknown, REFIID guid)
        : CBaseFilter(L"SaneAudioRenderer::MyFilter", pUnknown, this, guid)
        , m_bufferFilled(TRUE/*manual reset*/)
    {
    }

    HRESULT MyFilter::Init(ISettings* pSettings)
    {
        HRESULT result = S_OK;

        try
        {
            if (SUCCEEDED(result))
                m_clock = std::make_unique<MyClock>(GetOwner(), result);

            //if (SUCCEEDED(result))
            //    m_testClock = new MyTestClock(nullptr, result);

            if (SUCCEEDED(result))
                m_renderer = std::make_unique<AudioRenderer>(pSettings, *m_clock, result);

            if (SUCCEEDED(result))
                m_basicAudio = std::make_unique<MyBasicAudio>(GetOwner(), *m_renderer);

            if (SUCCEEDED(result))
                m_pin = std::make_unique<MyPin>(*m_renderer, this, result);

            if (SUCCEEDED(result))
                result = CreatePosPassThru(GetOwner(), FALSE, m_pin.get(), &m_seeking);
        }
        catch (std::bad_alloc&)
        {
            result = E_OUTOFMEMORY;
        }

        return result;
    }

    STDMETHODIMP MyFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
    {
        if (riid == IID_IUnknown)
            return CUnknown::NonDelegatingQueryInterface(riid, ppv);

        //if (riid == IID_IReferenceClock || riid == IID_IReferenceClockTimerControl)
        //    return m_testClock->QueryInterface(riid, ppv);

        if (riid == IID_IReferenceClock || riid == IID_IReferenceClockTimerControl)
            return m_clock->NonDelegatingQueryInterface(riid, ppv);

        if (riid == IID_IBasicAudio)
            return m_basicAudio->NonDelegatingQueryInterface(riid, ppv);

        if (riid == IID_IMediaSeeking)
            return m_seeking->QueryInterface(riid, ppv);

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

        return CBaseFilter::NonDelegatingQueryInterface(riid, ppv);
    }

    int MyFilter::GetPinCount()
    {
        return 1;
    }

    CBasePin* MyFilter::GetPin(int n)
    {
        return (n == 0) ? m_pin.get() : nullptr;
    }

    STDMETHODIMP MyFilter::Stop()
    {
        return ChangeState<State_Stopped>(std::bind(&MyPin::Inactive, m_pin.get()));
    }

    STDMETHODIMP MyFilter::Pause()
    {
        return ChangeState<State_Paused>(std::bind(&MyPin::Active, m_pin.get()));
    }

    STDMETHODIMP MyFilter::Run(REFERENCE_TIME startTime)
    {
        return ChangeState<State_Running>(std::bind(&MyPin::Run, m_pin.get(), startTime));
{'fraction_non_alphanumeric': 0.12348178137651822, 'fraction_numerical': 0.001349527665317139, 'mean_word_length': 2.7836630504148054, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2528305', 'n_tokens_mistral': 1972, 'n_tokens_neox': 1913, 'n_words': 319}