예제 #1
0
    STDMETHODIMP MyPin::Receive(IMediaSample* pSample)
    {
        CAutoLock receiveLock(&m_receiveMutex);

        {
            CAutoLock objectLock(this);

            if (m_state == State_Stopped)
                return VFW_E_WRONG_STATE;

            ReturnIfNotEquals(S_OK, CBaseInputPin::Receive(pSample));

            if (m_SampleProps.dwSampleFlags & AM_SAMPLE_TYPECHANGED)
            {
                // TODO: don't recreate the device when possible
                m_renderer.Finish(false, &m_bufferFilled);
                ReturnIfFailed(SetMediaType(static_cast<CMediaType*>(m_SampleProps.pMediaType)));
            }

            if (m_eosUp)
                return S_FALSE;
        }

        // Raise Receive() thread priority, once.
        if (m_hReceiveThread != GetCurrentThread())
        {
            m_hReceiveThread = GetCurrentThread();
            if (GetThreadPriority(m_hReceiveThread) < THREAD_PRIORITY_ABOVE_NORMAL)
                SetThreadPriority(m_hReceiveThread, THREAD_PRIORITY_ABOVE_NORMAL);
        }

        // Push() returns 'false' in case of interruption.
        return m_renderer.Push(pSample, m_SampleProps, &m_bufferFilled) ? S_OK : S_FALSE;
    }
예제 #2
0
    HRESULT MyPin::SetMediaType(const CMediaType* pmt)
    {
        assert(CritCheckIn(this));

        ReturnIfFailed(CBaseInputPin::SetMediaType(pmt));

        auto pFormat = reinterpret_cast<const WAVEFORMATEX*>(pmt->pbFormat);

        // No point in doing integrity checks, that was done in CheckMediaType().
        assert(pFormat);
        assert(pmt->cbFormat == sizeof(WAVEFORMATEX) + pFormat->cbSize);

        m_live = CheckLive(m_Connected);

        try
        {
            m_renderer.SetFormat(CopyWaveFormat(*pFormat), m_live);
        }
        catch (std::bad_alloc&)
        {
            return E_OUTOFMEMORY;
        }

        return S_OK;
    }
예제 #3
0
    HRESULT MyPin::CheckConnect(IPin* pPin)
    {
        assert(CritCheckIn(this));

        ReturnIfFailed(CBaseInputPin::CheckConnect(pPin));

        m_live = CheckLive(pPin);

        return S_OK;
    }
예제 #4
0
STDMETHODIMP OuterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
    if (!m_initialized)
        ReturnIfFailed(Init());

    if (riid == IID_IUnknown)
        return CUnknown::NonDelegatingQueryInterface(riid, ppv);

    return m_innerFilter->QueryInterface(riid, ppv);
}
예제 #5
0
HRESULT OuterFilter::Init()
{
    assert(!m_initialized);

    ReturnIfFailed(Factory::CreateSettings(&m_settings))
    ReturnIfFailed(Factory::CreateFilterAggregated(GetOwner(), m_guid, m_settings, &m_innerFilter));
    ReturnIfFailed(m_registryKey.Open(HKEY_CURRENT_USER, L"Software\\sanear"));
    ReturnIfFailed(m_trayWindow.Init(m_settings));

    m_initialized = true;

    std::vector<wchar_t> stringValue;
    uint32_t uintValue1;
    uint32_t uintValue2;

    if (m_registryKey.GetString(DeviceId, stringValue) &&
            m_registryKey.GetUint(DeviceExclusive, uintValue1) &&
            m_registryKey.GetUint(DeviceBufferDuration, uintValue2))
    {
        m_settings->SetOuputDevice(stringValue.data(), uintValue1, uintValue2);
    }

    if (m_registryKey.GetUint(AllowBitstreaming, uintValue1))
        m_settings->SetAllowBitstreaming(uintValue1);

    if (m_registryKey.GetUint(CrossfeedEnabled, uintValue1))
        m_settings->SetCrossfeedEnabled(uintValue1);

    if (m_registryKey.GetUint(CrossfeedCutoffFrequency, uintValue1) &&
            m_registryKey.GetUint(CrossfeedLevel, uintValue2))
    {
        m_settings->SetCrossfeedSettings(uintValue1, uintValue2);
    }

    return S_OK;
}
예제 #6
0
    STDMETHODIMP MyFilter::ChangeState(PinFunction pinFunction)
    {
        CAutoLock objectLock(this);

        if (m_State != NewState)
        {
            ReturnIfFailed(pinFunction());
            m_State = NewState;
        }

        if (!m_pin->StateTransitionFinished(0))
            return S_FALSE;

        return S_OK;
    }
    HRESULT CAudioEndPointLibrary::RegisterNotificationClient() const
    {
        HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
        if(!m_container->m_DeviceEnumerator)
        {          
            hr = m_container->m_DeviceEnumerator.CreateInstance(__uuidof(MMDeviceEnumerator));
            ReturnIfFailed(hr);
        }

        if (!m_container->m_notif_client) {
            m_container->m_notif_client = new CMMNotificationClient;            
            hr = m_container->m_DeviceEnumerator->RegisterEndpointNotificationCallback(m_container->m_notif_client);
            return hr;
        }
        return S_OK;
    }
예제 #8
0
파일: DictSink.cpp 프로젝트: emacsattic/vr
STDMETHODIMP DictSink::RecognitionStarting()
{
    BOOL test;
    m_pIDgnDictCustom->ActiveGet(&test);
    if(test==FALSE)
      debug_lprintf(50, "    Dictation is deactivated in %s\r\n", name);
    else {

    int modified, window_start, window_end, sel_start, sel_end, length;
    char *text, buf[BUFSIZ];
    HRESULT hRes;

    //debug_lprintf(64, "**  recognition starting\r\n");

    sprintf(buf, "(get-buffer-info \"%s\" %d)\n", name, tick);
    client->send_cmd(buf);
    
    GET_REPLY_INT(modified, "is-modified");

    hRes = m_pIDgnDictCustom->Lock(0);
    ReturnIfFailed(hRes, 0, "IDgnDictCustom->Lock() failed, hRes = 0x%X");

    if (modified) {
      // "modified" means that an unsynchronized change has occurred,
      // so we reload the entire buffer contents 
      
      GET_REPLY_INT(length, "text length");
      text = client->get_reply("text");
      if (! text) {
	debug_lprintf(64, "timeout waiting for text\r\n");
	return E_FAIL;
       }
      hRes = m_pIDgnDictCustom->TextSet(text, 0, -1);
      // -1 because we want to replace the entire buffer, this wasn't
      // done before

      ReturnIfFailed(hRes, 1, "IDgnDictCustom->TextSet() failed, hRes = 0x%X");
      
      /*
	the sample code does NOT free the allocated text block, but
	Dragon says it is safe to do so.
	*/
      free(text);
    }

    // now ask for the changes that may have occured as a result of the
    // get-buffer info call. 
    int cnt;
    char *c;
    GET_REPLY_INT(cnt, "change count");
    for (int i = 0; i < cnt; i++) {
      c = client->get_reply("change");
      if (! c) {
	debug_lprintf(64, "timeout waiting for change\r\n");
	m_pIDgnDictCustom->UnLock();
	return E_FAIL;
      }
      client->change_text(c+12); // discard leading "change-text " */
    }

    GET_REPLY_INT(sel_start, "selection start");
    GET_REPLY_INT(sel_end, "selection end");
    GET_REPLY_INT(window_start, "window start");
    GET_REPLY_INT(window_end, "window end");
    //Most recent buffer tick
    GET_REPLY_INT(this->tick, "tick");
		      
    hRes = m_pIDgnDictCustom->TextSelSet(sel_start, sel_end - sel_start);
    ReturnIfFailed(hRes,1, "IDgnDictCustom->TextSelSet() failed, hRes = 0x%X");

    hRes = m_pIDgnDictCustom->VisibleTextSet(window_start,
					     window_end - window_start);
    ReturnIfFailed(hRes,1,"IDgnDictCustom->VisibleTextSet() failed,hRes=0x%X");

    hRes = m_pIDgnDictCustom->UnLock(); // unlock internal buffer
    ReturnIfFailed(hRes,0, "IDgnDictCustom->UnLock() failed, hRes = 0x%X");
    
    /*

      // this dumps the first thousand characters of the DNS buffer
      // for debugging purposes
    char* buffer_dump=(char*)malloc(1000);
    for(i = 0; i < 1000; i++)
      buffer_dump [i]= 0;
    m_pIDgnDictCustom->TextGet(&buffer_dump, 0, 1000);
    debug_lprintf (1000, "DNS buffer %s:\r\n\"%s\"\r\n", name,buffer_dump);
    */
    } // dictation activated

    return S_OK; 
}