Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmisc.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS Configuration of network devices 00004 * FILE: dll/directx/dsound_new/misc.c 00005 * PURPOSE: Misc support routines 00006 * 00007 * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) 00008 */ 00009 00010 #include "precomp.h" 00011 00012 const GUID KSPROPSETID_Pin = {0x8C134960L, 0x51AD, 0x11CF, {0x87, 0x8A, 0x94, 0xF8, 0x01, 0xC1, 0x00, 0x00}}; 00013 const GUID KSPROPSETID_Topology = {0x720D4AC0L, 0x7533, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}; 00014 const GUID KSPROPSETID_Audio = {0x45FFAAA0L, 0x6E1B, 0x11D0, {0xBC, 0xF2, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}; 00015 00016 00017 VOID 00018 PerformChannelConversion( 00019 PUCHAR Buffer, 00020 ULONG BufferLength, 00021 PULONG BytesRead, 00022 ULONG OldChannels, 00023 ULONG NewChannels, 00024 ULONG BitsPerSample, 00025 PUCHAR Result, 00026 ULONG ResultLength, 00027 PULONG BytesWritten) 00028 { 00029 DWORD Samples; 00030 DWORD NewIndex, OldIndex; 00031 DWORD NewLength, Skip; 00032 00033 Samples = BufferLength / (BitsPerSample / 8) / OldChannels; 00034 00035 if (NewChannels > OldChannels) 00036 { 00037 UNIMPLEMENTED 00038 ASSERT(0); 00039 } 00040 00041 /* setup index */ 00042 NewIndex = 0; 00043 OldIndex = 0; 00044 00045 /* calculate offsets */ 00046 NewLength = NewChannels * (BitsPerSample/8); 00047 Skip = OldChannels * (BitsPerSample/8); 00048 00049 do 00050 { 00051 if (NewIndex + NewLength>= ResultLength) 00052 { 00053 NewIndex = ResultLength; 00054 break; 00055 } 00056 00057 if (OldIndex + Skip >= BufferLength) 00058 { 00059 OldIndex = BufferLength; 00060 break; 00061 } 00062 00063 /* copy first channel */ 00064 RtlMoveMemory(&Result[NewIndex], &Buffer[OldIndex], NewLength); 00065 00066 /* skip other channels */ 00067 OldIndex += Skip; 00068 00069 /* increment offset */ 00070 NewIndex += NewLength; 00071 00072 }while(TRUE); 00073 00074 *BytesRead = OldIndex; 00075 *BytesWritten = NewIndex; 00076 } 00077 00078 00079 BOOL 00080 SetPinFormat( 00081 IN HANDLE hPin, 00082 IN LPWAVEFORMATEX WaveFormatEx) 00083 { 00084 DWORD dwResult; 00085 KSPROPERTY Property; 00086 KSDATAFORMAT_WAVEFORMATEX DataFormat; 00087 00088 /* setup connection request */ 00089 Property.Id = KSPROPERTY_CONNECTION_DATAFORMAT; 00090 Property.Set = KSPROPSETID_Connection; 00091 Property.Flags = KSPROPERTY_TYPE_SET; 00092 00093 /* setup data format */ 00094 DataFormat.WaveFormatEx.wFormatTag = WaveFormatEx->wFormatTag; 00095 DataFormat.WaveFormatEx.nSamplesPerSec = WaveFormatEx->nSamplesPerSec; 00096 DataFormat.WaveFormatEx.nBlockAlign = WaveFormatEx->nBlockAlign; 00097 DataFormat.WaveFormatEx.cbSize = 0; 00098 DataFormat.DataFormat.FormatSize = sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEX); 00099 DataFormat.DataFormat.Flags = 0; 00100 DataFormat.DataFormat.Reserved = 0; 00101 DataFormat.DataFormat.MajorFormat = KSDATAFORMAT_TYPE_AUDIO; 00102 DataFormat.DataFormat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; 00103 DataFormat.DataFormat.Specifier = KSDATAFORMAT_SPECIFIER_WAVEFORMATEX; 00104 DataFormat.DataFormat.SampleSize = 4; 00105 DataFormat.WaveFormatEx.nChannels = WaveFormatEx->nChannels; 00106 DataFormat.WaveFormatEx.nAvgBytesPerSec = WaveFormatEx->nAvgBytesPerSec; 00107 DataFormat.WaveFormatEx.wBitsPerSample = WaveFormatEx->wBitsPerSample; 00108 00109 dwResult = SyncOverlappedDeviceIoControl(hPin, IOCTL_KS_PROPERTY, (LPVOID)&Property, sizeof(KSPROPERTY),(LPVOID)&DataFormat, sizeof(KSDATAFORMAT_WAVEFORMATEX), NULL); 00110 00111 if (dwResult == ERROR_SUCCESS) 00112 return TRUE; 00113 else 00114 return FALSE; 00115 } 00116 00117 00118 BOOL 00119 DoDataIntersection( 00120 HANDLE hFilter, 00121 DWORD PinId, 00122 DWORD SampleFrequency, 00123 LPWAVEFORMATEX WaveFormatEx, 00124 DWORD MinimumBitsPerSample, 00125 DWORD MaximumBitsPerSample, 00126 DWORD MaximumChannels, 00127 LPWAVEFORMATEX WaveFormatOut) 00128 { 00129 DWORD nChannels, nBitsPerSample; 00130 KSDATAFORMAT_WAVEFORMATEX WaveFormat; 00131 PKSP_PIN Pin; 00132 PKSMULTIPLE_ITEM Item; 00133 PKSDATAFORMAT_WAVEFORMATEX DataFormat; 00134 DWORD dwResult; 00135 00136 /* allocate request */ 00137 Pin = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(KSP_PIN) + sizeof(KSMULTIPLE_ITEM) + sizeof(KSDATAFORMAT_WAVEFORMATEX)); 00138 if (!Pin) 00139 { 00140 /* no memory */ 00141 return FALSE; 00142 } 00143 00144 Item = (PKSMULTIPLE_ITEM)(Pin + 1); 00145 DataFormat = (PKSDATAFORMAT_WAVEFORMATEX)(Item + 1); 00146 00147 /* setup request */ 00148 Pin->PinId = PinId; 00149 Pin->Property.Flags = KSPROPERTY_TYPE_GET; 00150 Pin->Property.Set = KSPROPSETID_Pin; 00151 Pin->Property.Id = KSPROPERTY_PIN_DATAINTERSECTION; 00152 Item->Count = 1; 00153 Item->Size = sizeof(KSDATAFORMAT_WAVEFORMATEX); 00154 00155 00156 DataFormat->WaveFormatEx.wFormatTag = WaveFormatEx->wFormatTag; 00157 DataFormat->WaveFormatEx.nSamplesPerSec = SampleFrequency; 00158 DataFormat->WaveFormatEx.nBlockAlign = WaveFormatEx->nBlockAlign; 00159 DataFormat->WaveFormatEx.cbSize = 0; 00160 DataFormat->DataFormat.FormatSize = sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEX); 00161 DataFormat->DataFormat.Flags = 0; 00162 DataFormat->DataFormat.Reserved = 0; 00163 DataFormat->DataFormat.MajorFormat = KSDATAFORMAT_TYPE_AUDIO; 00164 DataFormat->DataFormat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; 00165 DataFormat->DataFormat.Specifier = KSDATAFORMAT_SPECIFIER_WAVEFORMATEX; 00166 DataFormat->DataFormat.SampleSize = 4; 00167 00168 for(nChannels = 1; nChannels <= 2; nChannels++) 00169 { 00170 for(nBitsPerSample = MinimumBitsPerSample; nBitsPerSample <= MaximumBitsPerSample; nBitsPerSample += 8) 00171 { 00172 DataFormat->WaveFormatEx.nChannels = nChannels; 00173 DataFormat->WaveFormatEx.nAvgBytesPerSec = (nBitsPerSample / 8) * nChannels * SampleFrequency; 00174 DataFormat->WaveFormatEx.wBitsPerSample = nBitsPerSample; 00175 00176 DPRINT("CurrentFormat: InFormat nChannels %u wBitsPerSample %u nSamplesPerSec %u\n", 00177 nChannels, nBitsPerSample, SampleFrequency); 00178 00179 dwResult = SyncOverlappedDeviceIoControl(hFilter, IOCTL_KS_PROPERTY, (LPVOID)Pin, sizeof(KSP_PIN) + sizeof(KSMULTIPLE_ITEM) + sizeof(KSDATAFORMAT_WAVEFORMATEX), 00180 (LPVOID)&WaveFormat, sizeof(KSDATAFORMAT_WAVEFORMATEX), NULL); 00181 00182 DPRINT("dwResult %x\n", dwResult); 00183 00184 00185 if (dwResult == ERROR_SUCCESS) 00186 { 00187 /* found a compatible audio range */ 00188 WaveFormatOut->cbSize = 0; 00189 WaveFormatOut->nBlockAlign = WaveFormatEx->nBlockAlign; 00190 WaveFormatOut->wFormatTag = WaveFormatEx->wFormatTag; 00191 WaveFormatOut->nAvgBytesPerSec = (nBitsPerSample / 8) * nChannels * SampleFrequency; 00192 WaveFormatOut->wBitsPerSample = nBitsPerSample; 00193 WaveFormatOut->nSamplesPerSec = SampleFrequency; 00194 WaveFormatOut->nChannels = nChannels; 00195 00196 /* free buffer */ 00197 HeapFree(GetProcessHeap(), 0, Pin); 00198 00199 DPRINT("InFormat nChannels %u wBitsPerSample %u nSamplesPerSec %u\nOutFormat nChannels %u nBitsPerSample %u nSamplesPerSec %u\n", 00200 WaveFormatEx->nChannels, WaveFormatEx->wBitsPerSample, WaveFormatEx->nSamplesPerSec, 00201 WaveFormatOut->nChannels, WaveFormatOut->wBitsPerSample, WaveFormatOut->nSamplesPerSec); 00202 00203 return TRUE; 00204 } 00205 } 00206 } 00207 00208 /* free buffer */ 00209 HeapFree(GetProcessHeap(), 0, Pin); 00210 ASSERT(0); 00211 return FALSE; 00212 } 00213 00214 DWORD 00215 OpenPin( 00216 HANDLE hFilter, 00217 ULONG PinId, 00218 LPWAVEFORMATEX WaveFormatEx, 00219 PHANDLE hPin, 00220 BOOL bLoop) 00221 { 00222 DWORD Size, Result; 00223 PKSPIN_CONNECT PinConnect; 00224 PKSDATAFORMAT_WAVEFORMATEX DataFormat; 00225 00226 /* calculate request size */ 00227 Size = sizeof(KSPIN_CONNECT) + sizeof(KSDATAFORMAT_WAVEFORMATEX); 00228 00229 PinConnect = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Size); 00230 if (!PinConnect) 00231 { 00232 /* not enough memory */ 00233 return DSERR_OUTOFMEMORY; 00234 } 00235 /* build pin request */ 00236 PinConnect->Interface.Set = KSINTERFACESETID_Standard; 00237 00238 if (bLoop) 00239 PinConnect->Interface.Id = KSINTERFACE_STANDARD_LOOPED_STREAMING; 00240 else 00241 PinConnect->Interface.Id = KSINTERFACE_STANDARD_STREAMING; 00242 00243 PinConnect->Interface.Flags = 0; 00244 PinConnect->Medium.Set = KSMEDIUMSETID_Standard; 00245 PinConnect->Medium.Id = KSMEDIUM_TYPE_ANYINSTANCE; 00246 PinConnect->Medium.Flags = 0; 00247 PinConnect->PinToHandle = NULL; 00248 PinConnect->PinId = PinId; 00249 PinConnect->Priority.PriorityClass = KSPRIORITY_NORMAL; 00250 PinConnect->Priority.PrioritySubClass = 1; 00251 00252 DataFormat = (PKSDATAFORMAT_WAVEFORMATEX) (PinConnect + 1); 00253 00254 /* initialize data format */ 00255 DataFormat->WaveFormatEx.wFormatTag = WaveFormatEx->wFormatTag; 00256 DataFormat->WaveFormatEx.nChannels = WaveFormatEx->nChannels; 00257 DataFormat->WaveFormatEx.nSamplesPerSec = WaveFormatEx->nSamplesPerSec; 00258 DataFormat->WaveFormatEx.nBlockAlign = WaveFormatEx->nBlockAlign; 00259 DataFormat->WaveFormatEx.nAvgBytesPerSec = WaveFormatEx->nAvgBytesPerSec; 00260 DataFormat->WaveFormatEx.wBitsPerSample = WaveFormatEx->wBitsPerSample; 00261 DataFormat->WaveFormatEx.cbSize = 0; 00262 DataFormat->DataFormat.FormatSize = sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEX); 00263 DataFormat->DataFormat.Flags = 0; 00264 DataFormat->DataFormat.Reserved = 0; 00265 DataFormat->DataFormat.MajorFormat = KSDATAFORMAT_TYPE_AUDIO; 00266 00267 DataFormat->DataFormat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; 00268 DataFormat->DataFormat.Specifier = KSDATAFORMAT_SPECIFIER_WAVEFORMATEX; 00269 DataFormat->DataFormat.SampleSize = 4; 00270 00271 Result = KsCreatePin(hFilter, PinConnect, GENERIC_READ | GENERIC_WRITE, hPin); 00272 00273 HeapFree(GetProcessHeap(), 0, PinConnect); 00274 00275 return Result; 00276 } 00277 00278 00279 DWORD 00280 OpenFilter( 00281 IN LPCWSTR lpFileName, 00282 IN PHANDLE OutHandle) 00283 { 00284 HANDLE Handle; 00285 00286 /* open the filter */ 00287 Handle = CreateFileW(lpFileName, GENERIC_WRITE | GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL); 00288 00289 /* check for success */ 00290 if (Handle == INVALID_HANDLE_VALUE) 00291 { 00292 DPRINT("Failed to open Filter %ws\n", lpFileName); 00293 return GetLastError(); 00294 } 00295 00296 *OutHandle = Handle; 00297 return ERROR_SUCCESS; 00298 } 00299 00300 DWORD 00301 SyncOverlappedDeviceIoControl( 00302 IN HANDLE Handle, 00303 IN DWORD IoControlCode, 00304 IN LPVOID InBuffer, 00305 IN DWORD InBufferSize, 00306 OUT LPVOID OutBuffer, 00307 IN DWORD OutBufferSize, 00308 OUT LPDWORD BytesTransferred OPTIONAL) 00309 { 00310 OVERLAPPED Overlapped; 00311 BOOLEAN IoResult; 00312 DWORD Transferred = 0; 00313 00314 /* Overlapped I/O is done here - this is used for waiting for completion */ 00315 ZeroMemory(&Overlapped, sizeof(OVERLAPPED)); 00316 Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); 00317 00318 if (!Overlapped.hEvent) 00319 return GetLastError(); 00320 00321 /* Talk to the device */ 00322 IoResult = DeviceIoControl(Handle, 00323 IoControlCode, 00324 InBuffer, 00325 InBufferSize, 00326 OutBuffer, 00327 OutBufferSize, 00328 BytesTransferred, 00329 &Overlapped); 00330 00331 /* If failure occurs, make sure it's not just due to the overlapped I/O */ 00332 if (!IoResult) 00333 { 00334 if ( GetLastError() != ERROR_IO_PENDING ) 00335 { 00336 CloseHandle(Overlapped.hEvent); 00337 return GetLastError(); 00338 } 00339 } 00340 00341 /* Wait for the I/O to complete */ 00342 IoResult = GetOverlappedResult(Handle, 00343 &Overlapped, 00344 &Transferred, 00345 TRUE); 00346 00347 /* Don't need this any more */ 00348 CloseHandle(Overlapped.hEvent); 00349 00350 if (!IoResult) 00351 return GetLastError(); 00352 00353 if ( BytesTransferred ) 00354 *BytesTransferred = Transferred; 00355 00356 return ERROR_SUCCESS; 00357 } 00358 00359 DWORD 00360 GetFilterPinCount( 00361 IN HANDLE hFilter, 00362 OUT PULONG NumPins) 00363 { 00364 KSPROPERTY Pin; 00365 00366 *NumPins = 0; 00367 00368 /* setup the pin request */ 00369 Pin.Flags = KSPROPERTY_TYPE_GET; 00370 Pin.Set = KSPROPSETID_Pin; 00371 Pin.Id = KSPROPERTY_PIN_CTYPES; 00372 00373 /* query the device */ 00374 return SyncOverlappedDeviceIoControl(hFilter, IOCTL_KS_PROPERTY, (LPVOID)&Pin, sizeof(KSPROPERTY), (PVOID)NumPins, sizeof(ULONG), NULL); 00375 } 00376 00377 DWORD 00378 GetFilterNodeProperty( 00379 IN HANDLE hFilter, 00380 IN ULONG PropertyId, 00381 OUT PKSMULTIPLE_ITEM *OutMultipleItem) 00382 { 00383 DWORD Status, BytesReturned; 00384 PKSMULTIPLE_ITEM MultipleItem; 00385 KSPROPERTY Property; 00386 00387 /* setup query request */ 00388 Property.Id = PropertyId; 00389 Property.Flags = KSPROPERTY_TYPE_GET; 00390 Property.Set = KSPROPSETID_Topology; 00391 00392 /* query the size */ 00393 Status = SyncOverlappedDeviceIoControl(hFilter, IOCTL_KS_PROPERTY, (LPVOID)&Property, sizeof(KSPROPERTY), NULL, 0, &BytesReturned); 00394 00395 if (Status != ERROR_MORE_DATA) 00396 { 00397 /* failed */ 00398 DPRINT("Failed to query PropertyId %lu ErrorCode %lx\n", PropertyId, Status); 00399 return Status; 00400 } 00401 00402 MultipleItem = HeapAlloc(GetProcessHeap(), 0, BytesReturned); 00403 if (!MultipleItem) 00404 { 00405 /* not enough memory */ 00406 DPRINT("Failed to allocate %u Bytes\n", BytesReturned); 00407 return ERROR_OUTOFMEMORY; 00408 } 00409 00410 /* retrieve data ranges */ 00411 Status = SyncOverlappedDeviceIoControl(hFilter, IOCTL_KS_PROPERTY, (LPVOID)&Property, sizeof(KSP_PIN), (LPVOID)MultipleItem, BytesReturned, &BytesReturned); 00412 00413 00414 if (Status != ERROR_SUCCESS) 00415 { 00416 /* failed to get data ranges */ 00417 DPRINT("SyncOverlappedDeviceIoControl failed with %lx\n", Status); 00418 00419 HeapFree(GetProcessHeap(), 0, MultipleItem); 00420 return Status; 00421 } 00422 00423 /* save result */ 00424 *OutMultipleItem = MultipleItem; 00425 return Status; 00426 00427 } 00428 00429 DWORD 00430 GetFilterPinCommunication( 00431 IN HANDLE hFilter, 00432 IN ULONG PinId, 00433 OUT PKSPIN_COMMUNICATION Communication) 00434 { 00435 KSP_PIN Property; 00436 00437 Property.Property.Flags = KSPROPERTY_TYPE_GET; 00438 Property.Property.Set = KSPROPSETID_Pin; 00439 Property.Property.Id = KSPROPERTY_PIN_COMMUNICATION; 00440 Property.PinId = PinId; 00441 Property.Reserved = 0; 00442 00443 return SyncOverlappedDeviceIoControl(hFilter, IOCTL_KS_PROPERTY, (LPVOID)&Property, sizeof(KSP_PIN), (LPVOID)Communication, sizeof(KSPIN_COMMUNICATION), NULL); 00444 } 00445 00446 DWORD 00447 GetFilterPinDataFlow( 00448 IN HANDLE hFilter, 00449 IN ULONG PinId, 00450 OUT PKSPIN_DATAFLOW DataFlow) 00451 { 00452 KSP_PIN Property; 00453 00454 Property.Property.Flags = KSPROPERTY_TYPE_GET; 00455 Property.Property.Set = KSPROPSETID_Pin; 00456 Property.Property.Id = KSPROPERTY_PIN_DATAFLOW; 00457 Property.PinId = PinId; 00458 Property.Reserved = 0; 00459 00460 return SyncOverlappedDeviceIoControl(hFilter, IOCTL_KS_PROPERTY, (LPVOID)&Property, sizeof(KSP_PIN), (LPVOID)DataFlow, sizeof(KSPIN_DATAFLOW), NULL); 00461 } 00462 00463 DWORD 00464 GetFilterPinDataRanges( 00465 IN HANDLE hFilter, 00466 IN ULONG PinId, 00467 IN OUT PKSMULTIPLE_ITEM * OutMultipleItem) 00468 { 00469 KSP_PIN Property; 00470 ULONG BytesReturned = 0; 00471 DWORD Status; 00472 PKSMULTIPLE_ITEM MultipleItem; 00473 00474 /* prepare request */ 00475 Property.Reserved = 0; 00476 Property.PinId = PinId; 00477 Property.Property.Set = KSPROPSETID_Pin; 00478 Property.Property.Id = KSPROPERTY_PIN_DATARANGES; 00479 Property.Property.Flags = KSPROPERTY_TYPE_GET; 00480 00481 /* retrieve size of data ranges buffer */ 00482 Status = SyncOverlappedDeviceIoControl(hFilter, IOCTL_KS_PROPERTY, (LPVOID)&Property, sizeof(KSP_PIN), NULL, 0, &BytesReturned); 00483 00484 #if 0 00485 if (Status != ERROR_MORE_DATA) 00486 { 00487 DPRINT("SyncOverlappedDeviceIoControl failed with %lx\n", Status); 00488 return Status; 00489 } 00490 #endif 00491 00492 ASSERT(BytesReturned); 00493 MultipleItem = HeapAlloc(GetProcessHeap(), 0, BytesReturned); 00494 if (!MultipleItem) 00495 { 00496 /* not enough memory */ 00497 DPRINT("Failed to allocate %u Bytes\n", BytesReturned); 00498 return ERROR_OUTOFMEMORY; 00499 } 00500 00501 /* retrieve data ranges */ 00502 Status = SyncOverlappedDeviceIoControl(hFilter, IOCTL_KS_PROPERTY, (LPVOID)&Property, sizeof(KSP_PIN), (LPVOID)MultipleItem, BytesReturned, &BytesReturned); 00503 00504 00505 if (Status != ERROR_SUCCESS) 00506 { 00507 /* failed to get data ranges */ 00508 DPRINT("SyncOverlappedDeviceIoControl failed with %lx\n", Status); 00509 00510 HeapFree(GetProcessHeap(), 0, MultipleItem); 00511 return Status; 00512 } 00513 00514 /* save result */ 00515 *OutMultipleItem = MultipleItem; 00516 return Status; 00517 } 00518 00519 BOOL 00520 CreateCompatiblePin( 00521 IN HANDLE hFilter, 00522 IN DWORD PinId, 00523 IN BOOL bLoop, 00524 IN LPWAVEFORMATEX WaveFormatEx, 00525 OUT LPWAVEFORMATEX WaveFormatOut, 00526 OUT PHANDLE hPin) 00527 { 00528 PKSMULTIPLE_ITEM Item = NULL; 00529 PKSDATARANGE_AUDIO AudioRange; 00530 DWORD dwResult; 00531 DWORD dwIndex, nChannels; 00532 00533 dwResult = GetFilterPinDataRanges(hFilter, PinId, &Item); 00534 00535 if (dwResult != ERROR_SUCCESS) 00536 { 00537 /* failed to get data ranges */ 00538 return FALSE; 00539 } 00540 00541 CopyMemory(WaveFormatOut, WaveFormatEx, sizeof(WAVEFORMATEX)); 00542 00543 /* iterate through all dataranges */ 00544 AudioRange = (PKSDATARANGE_AUDIO)(Item + 1); 00545 for(dwIndex = 0; dwIndex < Item->Count; dwIndex++) 00546 { 00547 if (AudioRange->DataRange.FormatSize != sizeof(KSDATARANGE_AUDIO)) 00548 { 00549 UNIMPLEMENTED 00550 AudioRange = (PKSDATARANGE_AUDIO)((PUCHAR)AudioRange + AudioRange->DataRange.FormatSize); 00551 continue; 00552 } 00553 00554 if (WaveFormatOut->nSamplesPerSec < AudioRange->MinimumSampleFrequency) 00555 WaveFormatOut->nSamplesPerSec = AudioRange->MinimumSampleFrequency; 00556 else if (WaveFormatOut->nSamplesPerSec > AudioRange->MaximumSampleFrequency) 00557 WaveFormatOut->nSamplesPerSec = AudioRange->MaximumSampleFrequency; 00558 00559 if (WaveFormatOut->wBitsPerSample < AudioRange->MinimumBitsPerSample) 00560 WaveFormatOut->wBitsPerSample = AudioRange->MinimumBitsPerSample; 00561 else if (WaveFormatOut->wBitsPerSample > AudioRange->MaximumBitsPerSample) 00562 WaveFormatOut->wBitsPerSample = AudioRange->MaximumBitsPerSample; 00563 00564 DPRINT("MinimumBitsPerSample %u MaximumBitsPerSample %u MinimumSampleFrequency %u MaximumSampleFrequency %u\n", 00565 AudioRange->MinimumBitsPerSample, AudioRange->MaximumBitsPerSample, AudioRange->MinimumSampleFrequency, AudioRange->MaximumSampleFrequency); 00566 00567 for(nChannels = 1; nChannels <= AudioRange->MaximumChannels; nChannels++) 00568 { 00569 WaveFormatOut->nChannels = nChannels; 00570 00571 dwResult = OpenPin(hFilter, PinId, WaveFormatOut, hPin, TRUE); 00572 if (dwResult == ERROR_SUCCESS) 00573 { 00574 DPRINT("InFormat nChannels %u wBitsPerSample %u nSamplesPerSec %u\nOutFormat nChannels %u nBitsPerSample %u nSamplesPerSec %u\n", 00575 WaveFormatEx->nChannels, WaveFormatEx->wBitsPerSample, WaveFormatEx->nSamplesPerSec, 00576 WaveFormatOut->nChannels, WaveFormatOut->wBitsPerSample, WaveFormatOut->nSamplesPerSec); 00577 00578 00579 /* free buffer */ 00580 HeapFree(GetProcessHeap(), 0, Item); 00581 return TRUE; 00582 } 00583 } 00584 AudioRange = (PKSDATARANGE_AUDIO)((PUCHAR)AudioRange + AudioRange->DataRange.FormatSize); 00585 } 00586 00587 /* free buffer */ 00588 HeapFree(GetProcessHeap(), 0, Item); 00589 return FALSE; 00590 } 00591 Generated on Sat May 26 2012 04:15:47 for ReactOS by
1.7.6.1
|