Ejemplo n.º 1
0
/*****************************************************************************
 * TryMPU()
 *****************************************************************************
 * See if the MPU401 is free.
 */
BOOLEAN
TryMPU
(
    IN      PUCHAR      PortBase
)
{
    BOOLEAN success;
    USHORT  numPolls;
    UCHAR   status;

    _DbgPrintF(DEBUGLVL_BLAB, ("TryMPU"));
    numPolls = 0;

    while (numPolls < kMPUPollTimeout)
    {
        status = READ_PORT_UCHAR(PortBase + MPU401_REG_STATUS);

        if (UartFifoOkForWrite(status)) // Is this a good time to write data?
        {
            break;
        }
        numPolls++;
    }
    if (numPolls >= kMPUPollTimeout)
    {
        success = FALSE;
        _DbgPrintF(DEBUGLVL_BLAB, ("TryMPU failed"));
    }
    else
    {
        success = TRUE;
    }

    return success;
}
Ejemplo n.º 2
0
/*****************************************************************************
 * CKsAudioCaptureFilter::CreateCapturePin()
 *****************************************************************************
 *//*!
 * @brief
 */
CKsAudioCapturePin *
CKsAudioCaptureFilter::
CreateCapturePin
(
	IN		PWAVEFORMATEX	WaveFormatEx,
	IN		BOOL			Looped
)
{
    HRESULT hr = S_OK;

    CKsAudioCapturePin * Pin = FindViablePin(WaveFormatEx);

    if (!Pin)
    {
 		_DbgPrintF(DEBUGLVL_ERROR,("[CKsAudioCaptureFilter::CreateCapturePin] - Could not find a Capture pin that supports the given wave format"));

        hr = E_FAIL;
    }
    else
    {
        hr = Pin->SetFormat(WaveFormatEx);

        if (FAILED(hr))
        {
 			_DbgPrintF(DEBUGLVL_ERROR,("[CKsAudioCaptureFilter::CreateCapturePin] - Failed to set Capture Pin format"));
        }
    }

    if (SUCCEEDED(hr))
    {
        hr = Pin->Instantiate(Looped);

        if (SUCCEEDED(hr))
        {
 			_DbgPrintF(DEBUGLVL_BLAB,("[CKsAudioCaptureFilter::CreateCapturePin] - Successfully instantiated Capture Pin.  Handle = 0x%08x", Pin->GetHandle()));
        }
        else
        {
 			_DbgPrintF(DEBUGLVL_ERROR,("[CKsAudioCaptureFilter::CreateCapturePin] - Failed to instantiate Capture Pin"));
        }
    }

    if (FAILED(hr))
    {
        delete Pin;

        Pin = NULL;
    }

   return Pin;
}
Ejemplo n.º 3
0
/*****************************************************************************
 * CKsPin::ReadData()
 *****************************************************************************
 *//*!
 * @brief
 * Submit some memory for the pin to read into, using the provided 
 * KSSTREAM_HEADER and OVERLAPPED structures. If the caller submits a valid 
 * event in the KSSTREAM_HEADER, the event must be unsignaled.
 * @param
 * KsStreamHeader Pointer to the KSSTREAM_HEADER structure describing the data
 * to send to the pin.
 * @param
 * Overlapped Pointer to the OVERLAPPED structure to use when doing the 
 * asynchronous I/O.
 * @return
 * Returns S_OK on success, otherwise appropriate error code.
 */
HRESULT 
CKsPin::
ReadData
(
    IN		PKSSTREAM_HEADER	KsStreamHeader,
    IN		LPOVERLAPPED		Overlapped
)
{
    HRESULT hr = S_OK;
    
	ULONG BytesReturned = 0;

    BOOL Result = DeviceIoControl
					(
						m_Handle,
						IOCTL_KS_READ_STREAM,
						NULL,
						0,
						KsStreamHeader,
						KsStreamHeader->Size,
						&BytesReturned,
						Overlapped
					);

    // we're paused, we should return false!
    if (Result)
    {
		_DbgPrintF(DEBUGLVL_TERSE,("[CKsPin::ReadData] - DeviceIoControl returned TRUE even though the pin is paused"));
    }
    else
    {
        // if it did return FALSE then GetLastError should return ERROR_IO_PENDING
        DWORD w32Error = GetLastError();

        if (ERROR_IO_PENDING == w32Error)
        {
            //Life is good
            hr = S_OK;
        }
        else
        {
 			_DbgPrintF(DEBUGLVL_TERSE,("[CKsPin::ReadData] - DeviceIoControl Failed!  Error=0x%#08x", w32Error));
	    
			hr = E_FAIL;
        }
    }

    return hr;
}
Ejemplo n.º 4
0
/*****************************************************************************
 * CDmSynthStream::SyncToMaster()
 *****************************************************************************
 * Sync this stream to the master clock, using the given time, and
 * whether we are starting now.
 */
STDMETHODIMP 
CDmSynthStream::SyncToMaster(_In_ REFERENCE_TIME  rtTime,
                             _In_ BOOL            fStart)
{
    PAGED_CODE();

    _DbgPrintF(DEBUGLVL_BLAB, ("CDmSynthStream::SyncToMaster"));

    REFERENCE_TIME rtMasterTime;
    m_pMasterClock->GetTime(&rtMasterTime);

    if (!fStart)
    {
        m_SampleClock.SyncToMaster(rtTime, rtMasterTime);
    }
    else
    {
        m_llStartPosition = ((rtTime / 1000) * m_PortParams.SampleRate) / 10000;

        m_SampleClock.Start(m_pMasterClock, m_PortParams.SampleRate, m_llStartPosition);
    }


    return S_OK;
}
Ejemplo n.º 5
0
/*****************************************************************************
 * CKsFilter::CKsFilter()
 *****************************************************************************
 *//*!
 * @brief
 * Constructor.
 */
CKsFilter::
CKsFilter 
(
    IN		LPCTSTR		SymbolicLink,
    IN		LPCTSTR		FriendlyName,
    OUT		HRESULT *	OutHResult
)
:	CKsIrpTarget(INVALID_HANDLE_VALUE)
{
    HRESULT hr = InternalInit();

    if (NULL == SymbolicLink)
    {
        hr = E_INVALIDARG;

        _DbgPrintF(DEBUGLVL_ERROR,("SymbolicLink cannot be NULL"));
    }

    if (SUCCEEDED(hr))
    {
        _tcsncpy(m_SymbolicLink, SymbolicLink, MAX_PATH);
        
		_tcsncpy(m_FriendlyName, FriendlyName, MAX_PATH);
    }
    
    *OutHResult = hr;
}
Ejemplo n.º 6
0
/*****************************************************************************
 * CKsFilter::Instantiate()
 *****************************************************************************
 *//*!
 * @brief
 * Instantiates the filter.
 */
HRESULT 
CKsFilter::
Instantiate
(	void
)
{
    HRESULT hr = S_OK;

    m_Handle = CreateFile
				(
					m_SymbolicLink,
					GENERIC_READ | GENERIC_WRITE,
					0,
					NULL,
					OPEN_EXISTING,
					FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
					NULL
				);

    if (!IsValidHandle(m_Handle))
    {
        hr = E_FAIL;
    }
    
    if (FAILED(hr))
    {
        DWORD w32Error = GetLastError();

        _DbgPrintF(DEBUGLVL_ERROR,("[CKsFilter::Instantiate] - CreateFile failed for device %s.  ErrorCode = 0x%08x", m_SymbolicLink, w32Error));
    }
    
    return hr;
}
Ejemplo n.º 7
0
/*****************************************************************************
 * CMidiFilterFactory::NonDelegatingQueryInterface()
 *****************************************************************************
 *//*!
 * @brief
 * Obtains an interface.
 * @details
 * This function works just like a COM QueryInterface call and is used if
 * the object is not being aggregated.
 * @param
 * Interface The GUID of the interface to be retrieved.
 * @param
 * Object Pointer to the location to store the retrieved interface object.
 * @return
 * Returns STATUS_SUCCESS if the interface is found. Otherwise, returns
 * STATUS_INVALID_PARAMETER.
 */
STDMETHODIMP
CMidiFilterFactory::
NonDelegatingQueryInterface
(
    IN		REFIID  Interface,
    OUT		PVOID * Object
)
{
    PAGED_CODE();

    ASSERT(Object);

    _DbgPrintF(DEBUGLVL_BLAB,("[CMidiFilterFactory::NonDelegatingQueryInterface]"));

    if (IsEqualGUIDAligned(Interface,IID_IUnknown))
    {
        *Object = PVOID(PUNKNOWN(this));
    }
    else
    {
        *Object = NULL;
    }

    if (*Object)
    {
        //
        // We reference the interface for the caller.
        //
        PUNKNOWN(*Object)->AddRef();
        return STATUS_SUCCESS;
    }

    return STATUS_INVALID_PARAMETER;
}
Ejemplo n.º 8
0
/*****************************************************************************
 * CAudioFilterFactory::~CAudioFilterFactory()
 *****************************************************************************
 *//*!
 * @brief
 * Destructor.
 */
CAudioFilterFactory::
~CAudioFilterFactory
(   void
)
{
    PAGED_CODE();

    _DbgPrintF(DEBUGLVL_BLAB,("[~CAudioFilterFactory::~CAudioFilterFactory]"));

	if (m_AudioDevice)
	{
		m_AudioDevice->SetInterruptHandler(NULL, NULL);
		m_AudioDevice->Release();
	}

	if (m_UsbDevice)
	{
		m_UsbDevice->Release();
	}

	if (m_KsAdapter)
    {
        m_KsAdapter->Release();
    }
}
Ejemplo n.º 9
0
//
// We initialize the UART with interrupts suppressed so we don't
// try to service the chip prematurely.
//
NTSTATUS CMiniportDMusUART::InitializeHardware(PINTERRUPTSYNC interruptSync,PUCHAR portBase)
{
    PAGED_CODE();

    NTSTATUS    ntStatus;
    if (m_UseIRQ)
    {
        ntStatus = interruptSync->CallSynchronizedRoutine(InitMPU,PVOID(portBase));
    }
    else
    {
        ntStatus = InitMPU(NULL,PVOID(portBase));
    }

    if (NT_SUCCESS(ntStatus))
    {
        //
        // Start the UART (this should trigger an interrupt).
        //
        ntStatus = ResetHardware(portBase);
    }
    else
    {
        _DbgPrintF(DEBUGLVL_TERSE,("*** InitMPU returned with ntStatus 0x%08x ***",ntStatus));
    }

    m_fMPUInitialized = NT_SUCCESS(ntStatus);

    return ntStatus;
}
Ejemplo n.º 10
0
/*****************************************************************************
 * CKsPin::SetState()
 *****************************************************************************
 *//*!
 * @brief
 */
HRESULT 
CKsPin::
SetState
(
    IN		KSSTATE	KsState
)
{
    HRESULT hr = SetPropertySimple
					(
						KSPROPSETID_Connection,
						KSPROPERTY_CONNECTION_STATE,
						&KsState,
						sizeof(KSSTATE)
					);

    if (SUCCEEDED(hr))
    {
        m_KsState = KsState;
    }

    if (FAILED(hr))
    {
		_DbgPrintF(DEBUGLVL_ERROR,("[CKsPin::SetState] - Failed to Set Pin[%d] State: 0x%x", m_PinId, hr));
    }

    return hr;
}
Ejemplo n.º 11
0
CMiniportWaveCyclic::PinCount
(
    IN      ULONG   PinId,
    IN  OUT PULONG  FilterNecessary,
    IN  OUT PULONG  FilterCurrent,
    IN  OUT PULONG  FilterPossible,
    IN  OUT PULONG  GlobalCurrent,
    IN  OUT PULONG  GlobalPossible
)
/*++

Routine Description:

  Provide a way for the miniport to modify the pin counts for this miniport.

Arguments:

  PinId - KS pin number being referenced

  FilterNecessary - number of pins required on this pin factory
  FilterCurrent   - number of pins opened on this pin factory
  FilterPossible  - number of pins possible on this pin factory
  GlobalCurrent   - total number of pins opened, across all pin instances on this filter
  GlobalPossible  - total number of pins possible, across all pin factories on this filter

Return Value:

  OUT parameters for the five pin counts.

--*/
{
    UNREFERENCED_PARAMETER(PinId);
    UNREFERENCED_PARAMETER(FilterNecessary);
    UNREFERENCED_PARAMETER(FilterCurrent);
    UNREFERENCED_PARAMETER(FilterPossible);
    UNREFERENCED_PARAMETER(GlobalCurrent);
    UNREFERENCED_PARAMETER(GlobalPossible);

    PAGED_CODE();

    _DbgPrintF( DEBUGLVL_VERBOSE,
                ("PinCount PID:0x%08x FN(0x%08p):%d FC(0x%08p):%d FP(0x%08p):%d GC(0x%08p):%d GP(0x%08p):%d",
                  PinId,
                  FilterNecessary,*FilterNecessary,
                  FilterCurrent,  *FilterCurrent,
                  FilterPossible, *FilterPossible,
                  GlobalCurrent,  *GlobalCurrent,
                  GlobalPossible, *GlobalPossible ) );

    //
    // Something like the following:
    //
//    if (0 == PinId)
//    {
//        *FilterPossible += 1;
//    }

} // PinCount
Ejemplo n.º 12
0
/*****************************************************************************
 * CKsPin::Reset()
 *****************************************************************************
 *//*!
 * @brief
 * Reset the pin.
 */
HRESULT 
CKsPin::
Reset
(	void
)
{
    ULONG ResetState = KSRESET_BEGIN;

    HRESULT hr = SynchronizedIoctl
					(
						m_Handle,
						IOCTL_KS_RESET_STATE,
						&ResetState,
						sizeof(ULONG),
						NULL,
						0,
						NULL
					);

    if (FAILED(hr))
    {
		_DbgPrintF(DEBUGLVL_ERROR,("[CKsPin::Reset] - IOCTL_KS_RESET_STATE failed"));
    }

    ResetState = KSRESET_END;
 
    hr = SynchronizedIoctl
			(
				m_Handle,
				IOCTL_KS_RESET_STATE,
				&ResetState,
				sizeof(ULONG),
				NULL,
				0,
				NULL
			);


    if (FAILED(hr))
    {
		_DbgPrintF(DEBUGLVL_ERROR,("[CKsPin::Reset] - IOCTL_KS_RESET_STATE failed"));
    }

    return hr;
}
Ejemplo n.º 13
0
/*****************************************************************************
 * CKsIrpTarget::GetHandle()
 *****************************************************************************
 *//*!
 * @brief
 */
HANDLE 
CKsIrpTarget::
GetHandle
(	void
)
{ 
    _DbgPrintF(DEBUGLVL_TERSE,("[CKsIrpTarget::GetHandle]"));

	return m_Handle; 
}
Ejemplo n.º 14
0
/*****************************************************************************
 * CKsIrpTarget::CKsIrpTarget()
 *****************************************************************************
 *//*!
 * @brief
 * Constructor.
 */
CKsIrpTarget::
CKsIrpTarget
(
	IN		HANDLE	Handle
)
{
    _DbgPrintF(DEBUGLVL_TERSE,("[CKsIrpTarget::CKsIrpTarget]"));

	m_Handle = Handle;
}
Ejemplo n.º 15
0
/*****************************************************************************
 * CDmSynthStream::RefTimeToSample()
 *****************************************************************************
 * Translate between sample time and reference clock time.
 */
STDMETHODIMP
CDmSynthStream::RefTimeToSample(_In_  REFERENCE_TIME  rtTime,
                                _Out_ LONGLONG *      pllSampleTime)
{
    _DbgPrintF(DEBUGLVL_BLAB, ("CDmSynthStream::RefTimeToSample"));
    ASSERT(pllSampleTime);

    *pllSampleTime = m_SampleClock.RefTimeToSample(rtTime) - m_llStartPosition;
  
    return S_OK;
}
Ejemplo n.º 16
0
/*****************************************************************************
 * DllUnregisterServer()
 *****************************************************************************
 */
STDAPI 
DllUnregisterServer
(   void
)
{
	_DbgPrintF(DEBUGLVL_VERBOSE,("[DllUnregisterServer]"));

	HRESULT hr = UnregisterServer(NULL);

	return hr;
}
Ejemplo n.º 17
0
/*****************************************************************************
 * CDmSynthStream::SampleToRefTime()
 *****************************************************************************
 * Translate between sample time and reference clock time.
 */
STDMETHODIMP
CDmSynthStream::SampleToRefTime(_In_  LONGLONG         llSampleTime,
                                _Out_ REFERENCE_TIME * prtTime)
{
    _DbgPrintF(DEBUGLVL_BLAB, ("CDmSynthStream::SampleToRefTime"));
    ASSERT(prtTime);

    m_SampleClock.SampleToRefTime(llSampleTime + m_llStartPosition, prtTime);

    return S_OK;
}
Ejemplo n.º 18
0
void
CES1371::WriteCodecRegister(UCHAR Reg, USHORT Val)
{
    ULONG i;
//  ULONG dtemp, dinit;

    // Don't write if the value is the same as
    // what is in the register but always let writes
    // to the reset register go through.
    if ( (m_usCRegs[Reg/2] == Val) &&
         (AC97_RESET != Reg)  )
      return;

#ifdef DBG
    _DbgPrintF( DEBUGLVL_VERBOSE, ("[CodecWrite] Reg %x Val %x", Reg, Val));
#endif

    /* wait for WIP to go away */
    for( i = 0; i < 0x1000UL; ++i )
        if( !(READ_PORT_ULONG((PULONG)(m_pPciAddr + ES1371_dCODECCTL_OFF)) & (1UL << 30)) )
            break;

//    /* save the current state for later */
//    dinit = READ_PORT_ULONG((PULONG)(m_pPciAddr + ES1371_dSRCIO_OFF));
//
//    /* enable SRC state data in SRC mux */
//    for( i = 0; i < 0x1000UL; ++i )
//        if( !((dtemp = READ_PORT_ULONG((PULONG)(m_pPciAddr + ES1371_dSRCIO_OFF))) & SRC_BUSY) )
//            break;
//    WRITE_PORT_ULONG((PULONG)(m_pPciAddr + ES1371_dSRCIO_OFF), (dtemp & SRC_CTLMASK) | 0x00010000UL);
//
//    /* wait for a SAFE time to write addr/data and then do it */
////    _disable();
//    for( i = 0; i < 0x1000UL; ++i )
//        if( (READ_PORT_ULONG((PULONG)(m_pPciAddr + ES1371_dSRCIO_OFF)) & 0x00870000UL) ==
//                0x00010000UL )
//        break;

    WRITE_PORT_ULONG((PULONG)(m_pPciAddr + ES1371_dCODECCTL_OFF),
                        ((ULONG) Reg << 16) | Val);
////    _enable();
//
//    /* restore SRC reg */
//    for( i = 0; i < 0x1000UL; ++i )
//        if( !(READ_PORT_ULONG((PULONG)(m_pPciAddr + ES1371_dSRCIO_OFF)) & SRC_BUSY) )
//            break;
//     WRITE_PORT_ULONG((PULONG)(m_pPciAddr + ES1371_dSRCIO_OFF), dinit & SRC_CTLMASK );

    /* store the written value in our local storage */
    m_usCRegs[Reg/2] = Val;

    return;
}
Ejemplo n.º 19
0
/*****************************************************************************
 * DllInstall()
 *****************************************************************************
 */
STDAPI 
DllInstall
(
	IN		BOOL	Install,
	IN		LPCWSTR	CmdLine
)
{
	_DbgPrintF(DEBUGLVL_VERBOSE,("[DllInstall]"));

	HRESULT hr = S_OK;

	_DbgPrintF(DEBUGLVL_VERBOSE,("[DllInstall] - Install : %d, CmdLine : %ws", Install, CmdLine));

	if (CmdLine)
	{
		PWCHAR DevicePathW = wcsstr(CmdLine, L"/DevPath");

		if (DevicePathW)
		{
			DevicePathW += wcslen(L"/DevPath")+1;

			TCHAR SymbolicLink[MAX_PATH];

			_stprintf(SymbolicLink, "%ws", DevicePathW);

			_DbgPrintF(DEBUGLVL_BLAB,("[DllInstall] - SymbolicLink : %s", SymbolicLink));

			if (Install)
			{
				hr = RegisterServer(SymbolicLink);
			}
			else
			{
				hr = UnregisterServer(SymbolicLink);
			}
		}
	}

	return hr;
}
Ejemplo n.º 20
0
/*****************************************************************************
 * WriteMPU()
 *****************************************************************************
 * Write a byte out to the MPU401.
 */
NTSTATUS
WriteMPU
(
    IN      PUCHAR      PortBase,
    IN      BOOLEAN     IsCommand,
    IN      UCHAR       Value
)
{
    _DbgPrintF(DEBUGLVL_BLAB, ("WriteMPU"));
    NTSTATUS ntStatus = STATUS_IO_DEVICE_ERROR;

    if (!PortBase)
    {
        _DbgPrintF(DEBUGLVL_TERSE, ("O: PortBase is zero\n"));
        return ntStatus;
    }
    PUCHAR deviceAddr = PortBase + MPU401_REG_DATA;

    if (IsCommand)
    {
        deviceAddr = PortBase + MPU401_REG_COMMAND;
    }

    ULONGLONG startTime = PcGetTimeInterval(0);

    while (PcGetTimeInterval(startTime) < GTI_MILLISECONDS(50))
    {
        UCHAR status
        = READ_PORT_UCHAR(PortBase + MPU401_REG_STATUS);

        if (UartFifoOkForWrite(status)) // Is this a good time to write data?
        {                               // yep (Jon comment)
            WRITE_PORT_UCHAR(deviceAddr,Value);
            _DbgPrintF(DEBUGLVL_BLAB, ("WriteMPU emitted 0x%02x",Value));
            ntStatus = STATUS_SUCCESS;
            break;
        }
    }
    return ntStatus;
}
Ejemplo n.º 21
0
/*****************************************************************************
 * CControlFilterFactory::SetupFriendlyName()
 *****************************************************************************
 *//*!
 * @brief
 * Change the generic device name to match the USB device ones.
 * @param
 * <None>
 * @return
 * <None>
 */
VOID
CControlFilterFactory::
SetupFriendlyName
(
	IN		PKSADAPTER				KsAdapter,
	IN		PKSFILTER_DESCRIPTOR	KsFilterDescriptor,
	IN		PWCHAR					RefString
)
{
    PAGED_CODE();

    _DbgPrintF(DEBUGLVL_VERBOSE,("[CControlFilterFactory::SetupFriendlyName]"));

	PUSB_DEVICE UsbDevice = KsAdapter->GetUsbDevice();

	UCHAR iIndex = 0;

	PUSB_DEVICE_DESCRIPTOR DeviceDescriptor = NULL;

	NTSTATUS ntStatus = UsbDevice->GetDeviceDescriptor(&DeviceDescriptor);

	if (NT_SUCCESS(ntStatus))
	{
		iIndex = DeviceDescriptor->iProduct;
	}

	if (iIndex)
	{
		struct
		{
			UCHAR	bLength;
			UCHAR	bDescriptorType;
			WCHAR	bString[126];
		} FriendlyNameDescriptor;

		RtlZeroMemory(&FriendlyNameDescriptor, sizeof(FriendlyNameDescriptor));

		FriendlyNameDescriptor.bLength = sizeof(FriendlyNameDescriptor);

		USHORT LanguageId = KsAdapter->GetLanguageId();

		ntStatus = UsbDevice->GetStringDescriptor(iIndex, LanguageId, PUSB_STRING_DESCRIPTOR(&FriendlyNameDescriptor));

		if (NT_SUCCESS(ntStatus))
		{
			for (ULONG i = 0; i < KsFilterDescriptor->CategoriesCount; i++)
			{
				KsAdapter->SetSubDeviceParameter(RefString, KsFilterDescriptor->Categories[i], L"FriendlyName", REG_SZ, FriendlyNameDescriptor.bString, sizeof(FriendlyNameDescriptor.bString));
			}
		}
	}
}
Ejemplo n.º 22
0
/*****************************************************************************
 * CDmSynthStream::Render()
 *****************************************************************************
 * Render is called from the port driver, to fill the given buffer.  This is 
 * in turn forwarded to the synth (which -- roughly -- goes to the different 
 * voices, which goes to the DigitalAudios, which goes to the mix functions).
 *
 * Typically, a synthesizer manages converting messages into
 * rendered wave data in two processes. First, it time stamps the MIDI 
 * messages it receives from the application via calls to 
 * PlayBuffer and places them in its own internal queue. 
 * 
 * Then, in response to Render, it generates audio by pulling MIDI 
 * messages from the queue and synthesizing the appropriate tones within
 * the time span of the requested render buffer.
 * 
 * As the synthesizer renders the MIDI messages into the buffer, it
 * calls RefTimeToSample to translate the MIDI time stamps into sample 
 * positions. This guarantees extremely accurate timing.
 */
void CDmSynthStream::Render(
                            _In_  PBYTE       pBuffer,
                            _In_  DWORD       dwLength,
                            _In_  LONGLONG    llPosition)
{
    PAGED_CODE();

    _DbgPrintF(DEBUGLVL_BLAB, ("CDmSynthStream::Render"));
    ASSERT(pBuffer);

    m_pSynth->Mix((short*)pBuffer, dwLength, llPosition);

    m_llLastPosition = llPosition + dwLength;
}
Ejemplo n.º 23
0
NTSTATUS AddDevice
(
    _In_ struct _DRIVER_OBJECT* DriverObject,   // Context for the class driver.
    _In_ struct _DEVICE_OBJECT* PhysicalDeviceObject    // Context for the class driver.
)
{
    PAGED_CODE();
    _DbgPrintF(DEBUGLVL_VERBOSE, ("AddDevice"));

    //
    // Tell the class driver to add the device.
    //
    return PcAddAdapterDevice(DriverObject, PhysicalDeviceObject, StartDevice, MAX_MINIPORTS, 0);
}
Ejemplo n.º 24
0
/*****************************************************************************
 * CKsPin::GetState()
 *****************************************************************************
 *//*!
 * @brief
 */
HRESULT 
CKsPin::
GetState
(
    OUT		KSSTATE *	OutKsState
)
{
    HRESULT hr = S_OK;


    if (NULL == OutKsState)
    {
        hr = E_INVALIDARG;

		_DbgPrintF(DEBUGLVL_ERROR,("[CKsPin::GetState] - OutKsState == NULL"));
    }
    else if (!IsValidHandle(m_Handle))
    {
        hr = E_FAIL;

		_DbgPrintF(DEBUGLVL_ERROR,("[CKsPin::GetState] - No valid pin handle"));
    }

    if (SUCCEEDED(hr))
    {
        hr = GetPropertySimple
				(
					KSPROPSETID_Connection,
					KSPROPERTY_CONNECTION_STATE,
					OutKsState,
					sizeof(KSSTATE)
				);
    }

    return hr;
}
Ejemplo n.º 25
0
NTSTATUS
DriverEntry
(
    IN      PVOID   Context1,   // Context for the class driver.
    IN      PVOID   Context2    // Context for the class driver.
)
{
    _DbgPrintF(DEBUGLVL_VERBOSE, ("DriverEntry"));
//    _DbgPrintF(DEBUGLVL_ERROR, ("Starting breakpoint for debugging"));

    //
    // Tell the class driver to initialize the driver.
    //
    return PcInitializeAdapterDriver((PDRIVER_OBJECT)Context1,
                                     (PUNICODE_STRING)Context2,
                                     (PDRIVER_ADD_DEVICE)AddDevice);
}
Ejemplo n.º 26
0
/*****************************************************************************
 * CMidiFilterFactory::GetDescription()
 *****************************************************************************
 *//*!
 * @brief
 * Gets the filter description.
 * @details
 * Gets a pointer to a filter description. It provides a location
 * to deposit a pointer in miniport's description structure. This is the
 * placeholder for the FromNode or ToNode fields in connections which
 * describe connections to the filter's pins.
 * @param
 * OutKsFilterDescriptor Pointer to the filter description.
 * @return
 * Returns STATUS_SUCCESS if successful. Otherwise, returns an appropriate
 * error code.
 */
NTSTATUS 
CMidiFilterFactory::
GetFilterDescription
(
	OUT		PKSFILTER_DESCRIPTOR *	OutKsFilterDescriptor
)
{
    PAGED_CODE();

    ASSERT(OutKsFilterDescriptor);

    _DbgPrintF(DEBUGLVL_VERBOSE,("[CMidiFilterFactory::GetDescription]"));

    *OutKsFilterDescriptor = PKSFILTER_DESCRIPTOR(&m_KsFilterDescriptor);

    return STATUS_SUCCESS;
}
Ejemplo n.º 27
0
NTSTATUS
DriverEntry
(
    IN      PVOID   Context1,   // Context for the class driver.
    IN      PVOID   Context2    // Context for the class driver.
)
{
    PAGED_CODE();
    _DbgPrintF(DEBUGLVL_VERBOSE, ("DriverEntry"));

    //
    // Tell the class driver to initialize the driver.
    //
    return PcInitializeAdapterDriver((PDRIVER_OBJECT)Context1,
                                     (PUNICODE_STRING)Context2,
                                     (PDRIVER_ADD_DEVICE)AddDevice);
}
Ejemplo n.º 28
0
/*****************************************************************************
 * CControlFilterFactory::Init()
 *****************************************************************************
 *//*!
 * @brief
 * Initializes the filter factory.
 * @details
 * The caller of @b Init should run at IRQL_PASSIVE_LEVEL.
 * @return
 * Returns STATUS_SUCCESS if the call was successful. Otherwise, the method
 * returns an appropriate error code.
 */
NTSTATUS
CControlFilterFactory::
Init
(
	IN		PKSDEVICE	KsDevice,
	IN		PVOID		Parameter1,
	IN		PVOID		Parameter2
)
{
    PAGED_CODE();

    ASSERT(KsDevice);

    _DbgPrintF(DEBUGLVL_BLAB,("[CControlFilterFactory::Init]"));

	m_KsDevice = KsDevice;

	m_KsAdapter = PKSADAPTER(KsDevice->Context);
	m_KsAdapter->AddRef();

	m_UsbDevice = m_KsAdapter->GetUsbDevice();
	m_UsbDevice->AddRef();

	NTSTATUS ntStatus = STATUS_SUCCESS;

	// Normally you would figure out what the filter descriptor here...

	if (!NT_SUCCESS(ntStatus))
	{
		// Cleanup the mess...
		if (m_UsbDevice)
		{
			m_UsbDevice->Release();
			m_UsbDevice = NULL;
		}

		if (m_KsAdapter)
		{
			m_KsAdapter->Release();
			m_KsAdapter = NULL;
		}
	}

    return ntStatus;
}
Ejemplo n.º 29
0
/*****************************************************************************
 * AddDevice()
 *****************************************************************************
 * This function is called by the operating system when the device is added.
 * All adapter drivers can use this code without change.
 */
NTSTATUS AddDevice
(
    IN PDRIVER_OBJECT   DriverObject,
    IN PDEVICE_OBJECT   PhysicalDeviceObject
)
{
    PAGED_CODE();
    _DbgPrintF(DEBUGLVL_VERBOSE, ("AddDevice"));

    // disable prefast warning 28152 because 
    // DO_DEVICE_INITIALIZING is cleared in PcAddAdapterDevice
#pragma warning(disable:28152)

    //
    // Tell the class driver to add the device.
    //
    return PcAddAdapterDevice(DriverObject,PhysicalDeviceObject,StartDevice,MAX_MINIPORTS,0);
}
Ejemplo n.º 30
0
/*****************************************************************************
 * CKsPin::Instantiate()
 *****************************************************************************
 *//*!
 * @brief
 */
HRESULT 
CKsPin::
Instantiate
(
    IN		BOOL	Looped
)
{
    HRESULT hr = S_OK;

    if (m_KsPinConnect)
	{
		if (m_LinkPin)
		{
			ASSERT((KSPIN_COMMUNICATION_SINK == m_LinkPin->m_PinDescriptor.Communication) ||
				   (KSPIN_COMMUNICATION_BOTH == m_LinkPin->m_PinDescriptor.Communication));

			m_KsPinConnect->PinToHandle = m_LinkPin->m_Handle;
		}

		m_Looped = Looped;

		m_KsPinConnect->Interface.Id = m_Looped ? KSINTERFACE_STANDARD_LOOPED_STREAMING : KSINTERFACE_STANDARD_STREAMING;

		DWORD w32Error = KsCreatePin(m_KsFilter->m_Handle, m_KsPinConnect, GENERIC_WRITE | GENERIC_READ, &m_Handle);

		if (ERROR_SUCCESS != w32Error)
		{
			 hr = HRESULT_FROM_WIN32(w32Error);

			 if (SUCCEEDED(hr))
			 {
				// Sometimes the error codes don't map to error HRESULTs.
				hr = E_FAIL;
			 }
		}

		if (FAILED(hr))
		{
			_DbgPrintF(DEBUGLVL_ERROR,("[CKsPin::Instantiate] - Failed to instantiate pin. hr=0x%08x", hr));
		}
	}

    return hr;
}