diff options
| author | Girish Pattabiraman <[email protected]> | 2018-11-12 10:26:01 -0800 |
|---|---|---|
| committer | Adonais Romero González <[email protected]> | 2018-11-12 10:26:01 -0800 |
| commit | c9110a3bc1634a5be8e7922119ad383311104095 (patch) | |
| tree | 9f902e7fe1d56649dfe2371f2311225eb35d212a | |
| parent | 1a37d4aff3ce9d75306d176c3bcfc8343eab63ef (diff) | |
Replace FastMutex with Spinlock for DeviceFormatsAndModes to work well at DISPATCH_LEVEL (#296)
* Format Changes
==============
* Add KSEVENT_PINCAPS_FORMATCHANGE to Bluetooth HFP Endpoints
* Remove 8 bit formats from Bluetooth HFP Endpoints
Name Template
==============
* Bluetooth Endpoints are now based on templates in INF and then customized with endpoints specific data
Sideband Common Interface for future Sideband buses
===================================================
* Add ISidebandDevice
* Add current directory to TabletAudioSample include path. Remove unused compiler flags.
* RS4 bug fixes
* Replace FastMutex with Spinlock for DeviceFormatsAndModes to work well at DISPATCH_LEVEL
* Resync with Microsoft-master branch
* Replace FastMutex with Spinlock for DeviceFormatsAndModes to work well at DISPATCH_LEVEL
| -rw-r--r-- | audio/sysvad/EndpointsCommon/minwavert.cpp | 8 | ||||
| -rw-r--r-- | audio/sysvad/EndpointsCommon/minwavert.h | 89 |
2 files changed, 49 insertions, 48 deletions
diff --git a/audio/sysvad/EndpointsCommon/minwavert.cpp b/audio/sysvad/EndpointsCommon/minwavert.cpp index 8ad0e09d..d56462a6 100644 --- a/audio/sysvad/EndpointsCommon/minwavert.cpp +++ b/audio/sysvad/EndpointsCommon/minwavert.cpp @@ -1317,11 +1317,11 @@ CMiniportWaveRT::EvtFormatChangeHandler if (This->m_DeviceType == eBthHfpMicDevice) { // swap the device formats and modes for bt - ExAcquireFastMutex(&This->m_DeviceFormatsAndModesLock); + This->AcquireFormatsAndModesLock(); This->m_DeviceFormatsAndModes = This->m_pSidebandDevice->GetFormatsAndModes(This->m_DeviceType); - ExReleaseFastMutex(&This->m_DeviceFormatsAndModesLock); + This->ReleaseFormatsAndModesLock(); This->GenerateEventList( (GUID*)&KSEVENTSETID_PinCapsChange, @@ -1334,11 +1334,11 @@ CMiniportWaveRT::EvtFormatChangeHandler else if(This->m_DeviceType == eBthHfpSpeakerDevice) { // swap the device formats and modes for bt - ExAcquireFastMutex(&This->m_DeviceFormatsAndModesLock); + This->AcquireFormatsAndModesLock(); This->m_DeviceFormatsAndModes = This->m_pSidebandDevice->GetFormatsAndModes(This->m_DeviceType); - ExReleaseFastMutex(&This->m_DeviceFormatsAndModesLock); + This->ReleaseFormatsAndModesLock(); This->GenerateEventList( (GUID*)&KSEVENTSETID_PinCapsChange, diff --git a/audio/sysvad/EndpointsCommon/minwavert.h b/audio/sysvad/EndpointsCommon/minwavert.h index 0e91708b..848e4c9a 100644 --- a/audio/sysvad/EndpointsCommon/minwavert.h +++ b/audio/sysvad/EndpointsCommon/minwavert.h @@ -143,7 +143,8 @@ private: PKSDATAFORMAT_WAVEFORMATEXTENSIBLE m_pDeviceFormat; PCFILTER_DESCRIPTOR m_FilterDesc; PIN_DEVICE_FORMATS_AND_MODES * m_DeviceFormatsAndModes; - FAST_MUTEX m_DeviceFormatsAndModesLock; // To serialize access. + KSPIN_LOCK m_DeviceFormatsAndModesLock; // To serialize access. + KIRQL m_DeviceFormatsAndModesIrql; ULONG m_DeviceFormatsAndModesCount; USHORT m_DeviceMaxChannels; PDRMPORT m_pDrmPort; @@ -339,8 +340,10 @@ public: } } - ExInitializeFastMutex(&m_DeviceFormatsAndModesLock); #endif // defined(SYSVAD_BTH_BYPASS) + + KeInitializeSpinLock(&m_DeviceFormatsAndModesLock); + m_DeviceFormatsAndModesIrql = PASSIVE_LEVEL; } #pragma code_seg() @@ -488,7 +491,24 @@ public: ); private: -#pragma code_seg("PAGE") +#pragma code_seg() + _IRQL_raises_(DISPATCH_LEVEL) + _Acquires_lock_(m_DeviceFormatsAndModesLock) + _Requires_lock_not_held_(m_DeviceFormatsAndModesLock) + _IRQL_saves_global_(SpinLock, m_DeviceFormatsAndModesIrql) + VOID AcquireFormatsAndModesLock() + { + KeAcquireSpinLock(&m_DeviceFormatsAndModesLock, &m_DeviceFormatsAndModesIrql); + } + + _Releases_lock_(m_DeviceFormatsAndModesLock) + _Requires_lock_held_(m_DeviceFormatsAndModesLock) + _IRQL_restores_global_(SpinLock, m_DeviceFormatsAndModesIrql) + VOID ReleaseFormatsAndModesLock() + { + KeReleaseSpinLock(&m_DeviceFormatsAndModesLock, m_DeviceFormatsAndModesIrql); + } + //--------------------------------------------------------------------------- // GetPinSupportedDeviceFormats // @@ -504,11 +524,9 @@ private: _Post_satisfies_(return > 0) ULONG GetPinSupportedDeviceFormats(_In_ ULONG PinId, _Outptr_opt_result_buffer_(return) KSDATAFORMAT_WAVEFORMATEXTENSIBLE **ppFormats) { - PAGED_CODE(); - PPIN_DEVICE_FORMATS_AND_MODES pDeviceFormatsAndModes = NULL; - ExAcquireFastMutex(&m_DeviceFormatsAndModesLock); + AcquireFormatsAndModesLock(); pDeviceFormatsAndModes = m_DeviceFormatsAndModes; ASSERT(m_DeviceFormatsAndModesCount > PinId); @@ -520,7 +538,7 @@ private: *ppFormats = pDeviceFormatsAndModes[PinId].WaveFormats; } - ExReleaseFastMutex(&m_DeviceFormatsAndModesLock); + ReleaseFormatsAndModesLock(); return pDeviceFormatsAndModes[PinId].WaveFormatsCount; } @@ -544,9 +562,7 @@ private: ULONG i; PPIN_DEVICE_FORMATS_AND_MODES pDeviceFormatsAndModes = NULL; - PAGED_CODE(); - - ExAcquireFastMutex(&m_DeviceFormatsAndModesLock); + AcquireFormatsAndModesLock(); pDeviceFormatsAndModes = m_DeviceFormatsAndModes; @@ -568,7 +584,7 @@ private: *ppFormats = pDeviceFormatsAndModes[i].WaveFormats; } - ExReleaseFastMutex(&m_DeviceFormatsAndModesLock); + ReleaseFormatsAndModesLock(); return pDeviceFormatsAndModes[i].WaveFormatsCount; } @@ -590,9 +606,7 @@ private: PMODE_AND_DEFAULT_FORMAT modes; ULONG numModes; - PAGED_CODE(); - - ExAcquireFastMutex(&m_DeviceFormatsAndModesLock); + AcquireFormatsAndModesLock(); ASSERT(m_DeviceFormatsAndModesCount > PinId); ASSERT((m_DeviceFormatsAndModes[PinId].ModeAndDefaultFormatCount == 0) == (m_DeviceFormatsAndModes[PinId].ModeAndDefaultFormat == NULL)); @@ -634,16 +648,16 @@ private: } } - ExReleaseFastMutex(&m_DeviceFormatsAndModesLock); + ReleaseFormatsAndModesLock(); return numModes; } + #pragma code_seg() protected: -#pragma code_seg("PAGE") +#pragma code_seg() BOOL IsRenderDevice() { - PAGED_CODE(); return (m_DeviceType == eSpeakerDevice || m_DeviceType == eSpeakerHpDevice || m_DeviceType == eSpeakerHsDevice || @@ -655,13 +669,11 @@ protected: BOOL IsCellularDevice() { - PAGED_CODE(); return (m_DeviceType == eCellularDevice) ? TRUE : FALSE; } BOOL IsLoopbackSupported() { - PAGED_CODE(); // // It is assumed that loopback is supported when offload is supported @@ -671,91 +683,82 @@ protected: BOOL IsOffloadSupported() { - PAGED_CODE(); return (m_DeviceFlags & ENDPOINT_OFFLOAD_SUPPORTED) ? TRUE : FALSE; } BOOL IsSystemCapturePin(ULONG nPinId) { - PAGED_CODE(); - ExAcquireFastMutex(&m_DeviceFormatsAndModesLock); + AcquireFormatsAndModesLock(); PINTYPE pinType = m_DeviceFormatsAndModes[nPinId].PinType; - ExReleaseFastMutex(&m_DeviceFormatsAndModesLock); + ReleaseFormatsAndModesLock(); return (pinType == SystemCapturePin); } BOOL IsCellularBiDiCapturePin(ULONG nPinId) { - PAGED_CODE(); - ExAcquireFastMutex(&m_DeviceFormatsAndModesLock); + AcquireFormatsAndModesLock(); PINTYPE pinType = m_DeviceFormatsAndModes[nPinId].PinType; - ExReleaseFastMutex(&m_DeviceFormatsAndModesLock); + ReleaseFormatsAndModesLock(); return (pinType == TelephonyBidiPin); } BOOL IsSystemRenderPin(ULONG nPinId) { - PAGED_CODE(); - ExAcquireFastMutex(&m_DeviceFormatsAndModesLock); + AcquireFormatsAndModesLock(); PINTYPE pinType = m_DeviceFormatsAndModes[nPinId].PinType; - ExReleaseFastMutex(&m_DeviceFormatsAndModesLock); + ReleaseFormatsAndModesLock(); return (pinType == SystemRenderPin); } BOOL IsLoopbackPin(ULONG nPinId) { - PAGED_CODE(); - ExAcquireFastMutex(&m_DeviceFormatsAndModesLock); + AcquireFormatsAndModesLock(); PINTYPE pinType = m_DeviceFormatsAndModes[nPinId].PinType; - ExReleaseFastMutex(&m_DeviceFormatsAndModesLock); + ReleaseFormatsAndModesLock(); return (pinType == RenderLoopbackPin); } BOOL IsOffloadPin(ULONG nPinId) { - PAGED_CODE(); - ExAcquireFastMutex(&m_DeviceFormatsAndModesLock); + AcquireFormatsAndModesLock(); PINTYPE pinType = m_DeviceFormatsAndModes[nPinId].PinType; - ExReleaseFastMutex(&m_DeviceFormatsAndModesLock); + ReleaseFormatsAndModesLock(); return (pinType == OffloadRenderPin); } BOOL IsBridgePin(ULONG nPinId) { - PAGED_CODE(); - ExAcquireFastMutex(&m_DeviceFormatsAndModesLock); + AcquireFormatsAndModesLock(); PINTYPE pinType = m_DeviceFormatsAndModes[nPinId].PinType; - ExReleaseFastMutex(&m_DeviceFormatsAndModesLock); + ReleaseFormatsAndModesLock(); return (pinType == BridgePin); } BOOL IsKeywordDetectorPin(ULONG nPinId) { - PAGED_CODE(); - ExAcquireFastMutex(&m_DeviceFormatsAndModesLock); + AcquireFormatsAndModesLock(); PINTYPE pinType = m_DeviceFormatsAndModes[nPinId].PinType; - ExReleaseFastMutex(&m_DeviceFormatsAndModesLock); + ReleaseFormatsAndModesLock(); return (pinType == KeywordCapturePin); } // These three pins are the pins used by the audio engine for host, loopback, and offload. ULONG GetSystemPinId() { - PAGED_CODE(); ASSERT(IsRenderDevice()); ASSERT(!IsCellularDevice()); return IsOffloadSupported() ? KSPIN_WAVE_RENDER_SINK_SYSTEM : KSPIN_WAVE_RENDER2_SINK_SYSTEM; @@ -764,7 +767,6 @@ protected: ULONG GetLoopbackPinId() { - PAGED_CODE(); ASSERT(IsRenderDevice()); ASSERT(!IsCellularDevice()); return IsOffloadSupported() ? KSPIN_WAVE_RENDER_SINK_LOOPBACK : KSPIN_WAVE_RENDER2_SINK_LOOPBACK; @@ -773,7 +775,6 @@ protected: ULONG GetOffloadPinId() { - PAGED_CODE(); ASSERT(IsRenderDevice()); ASSERT(IsOffloadSupported()); ASSERT(!IsCellularDevice()); |
