Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1041 lines
27 KiB

  1. /***************************************************************************
  2. *
  3. * Copyright (C) 1995,1996 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dsprvobj.c
  6. * Content: DirectSound Private Object wrapper functions.
  7. * History:
  8. * Date By Reason
  9. * ==== == ======
  10. * 02/12/98 dereks Created.
  11. *
  12. ***************************************************************************/
  13. #define DIRECTSOUND_VERSION 0x0600
  14. // We'll ask for what we need, thank you.
  15. #ifndef WIN32_LEAN_AND_MEAN
  16. #define WIN32_LEAN_AND_MEAN
  17. #endif // WIN32_LEAN_AND_MEAN
  18. // Public includes
  19. #include <windows.h>
  20. #include <mmsystem.h>
  21. #include <dsound.h>
  22. #include "dsprv.h"
  23. // Private includes
  24. #include "dsprvobj.h"
  25. /***************************************************************************
  26. *
  27. * DirectSoundPrivateCreate
  28. *
  29. * Description:
  30. * Creates and initializes a DirectSoundPrivate object.
  31. *
  32. * Arguments:
  33. * LPKSPROPERTYSET * [out]: receives IKsPropertySet interface to the
  34. * object.
  35. *
  36. * Returns:
  37. * HRESULT: DirectSound/COM result code.
  38. *
  39. ***************************************************************************/
  40. HRESULT DirectSoundPrivateCreate
  41. (
  42. LPKSPROPERTYSET * ppKsPropertySet
  43. )
  44. {
  45. typedef HRESULT (STDAPICALLTYPE *LPFNDLLGETCLASSOBJECT)(REFCLSID, REFIID, LPVOID *);
  46. HINSTANCE hLibDsound = NULL;
  47. LPFNGETCLASSOBJECT pfnDllGetClassObject = NULL;
  48. LPCLASSFACTORY pClassFactory = NULL;
  49. LPKSPROPERTYSET pKsPropertySet = NULL;
  50. HRESULT hr = DS_OK;
  51. // Get dsound.dll's instance handle. The dll must already be loaded at this
  52. // point.
  53. hLibDsound =
  54. GetModuleHandle
  55. (
  56. TEXT("dsound.dll")
  57. );
  58. if(!hLibDsound)
  59. {
  60. hr = DSERR_GENERIC;
  61. }
  62. // Find DllGetClassObject
  63. if(SUCCEEDED(hr))
  64. {
  65. pfnDllGetClassObject = (LPFNDLLGETCLASSOBJECT)
  66. GetProcAddress
  67. (
  68. hLibDsound,
  69. "DllGetClassObject"
  70. );
  71. if(!pfnDllGetClassObject)
  72. {
  73. hr = DSERR_GENERIC;
  74. }
  75. }
  76. // Create a class factory object
  77. if(SUCCEEDED(hr))
  78. {
  79. hr =
  80. pfnDllGetClassObject
  81. (
  82. CLSID_DirectSoundPrivate,
  83. IID_IClassFactory,
  84. (LPVOID *)&pClassFactory
  85. );
  86. }
  87. // Create the DirectSoundPrivate object and query for an IKsPropertySet
  88. // interface
  89. if(SUCCEEDED(hr))
  90. {
  91. hr =
  92. pClassFactory->CreateInstance
  93. (
  94. NULL,
  95. IID_IKsPropertySet,
  96. (LPVOID *)&pKsPropertySet
  97. );
  98. }
  99. // Release the class factory
  100. if(pClassFactory)
  101. {
  102. pClassFactory->Release();
  103. }
  104. // Success
  105. if(SUCCEEDED(hr))
  106. {
  107. *ppKsPropertySet = pKsPropertySet;
  108. }
  109. return hr;
  110. }
  111. /***************************************************************************
  112. *
  113. * PrvGetMixerSrcQuality
  114. *
  115. * Description:
  116. * Gets the mixer SRC quality for a given DirectSound device.
  117. *
  118. * Arguments:
  119. * LPKSPROPERTYSET [in]: IKsPropertySet interface to the
  120. * DirectSoundPrivate object.
  121. * REFGUID [in]: DirectSound device GUID.
  122. * DIRECTSOUNDMIXER_SRCQUALITY * [out]: receives mixer SRC quality.
  123. *
  124. * Returns:
  125. * HRESULT: DirectSound/COM result code.
  126. *
  127. ***************************************************************************/
  128. HRESULT PrvGetMixerSrcQuality
  129. (
  130. LPKSPROPERTYSET pKsPropertySet,
  131. REFGUID guidDeviceId,
  132. DIRECTSOUNDMIXER_SRCQUALITY * pSrcQuality
  133. )
  134. {
  135. DSPROPERTY_DIRECTSOUNDMIXER_SRCQUALITY_DATA Data;
  136. HRESULT hr;
  137. Data.DeviceId = guidDeviceId;
  138. hr =
  139. pKsPropertySet->Get
  140. (
  141. DSPROPSETID_DirectSoundMixer,
  142. DSPROPERTY_DIRECTSOUNDMIXER_SRCQUALITY,
  143. NULL,
  144. 0,
  145. &Data,
  146. sizeof(Data),
  147. NULL
  148. );
  149. if(SUCCEEDED(hr))
  150. {
  151. *pSrcQuality = Data.Quality;
  152. }
  153. return hr;
  154. }
  155. /***************************************************************************
  156. *
  157. * PrvSetMixerSrcQuality
  158. *
  159. * Description:
  160. * Sets the mixer SRC quality for a given DirectSound device.
  161. *
  162. * Arguments:
  163. * LPKSPROPERTYSET [in]: IKsPropertySet interface to the
  164. * DirectSoundPrivate object.
  165. * REFGUID [in]: DirectSound device GUID.
  166. * DIRECTSOUNDMIXER_SRCQUALITY [in]: mixer SRC quality.
  167. *
  168. * Returns:
  169. * HRESULT: DirectSound/COM result code.
  170. *
  171. ***************************************************************************/
  172. HRESULT PrvSetMixerSrcQuality
  173. (
  174. LPKSPROPERTYSET pKsPropertySet,
  175. REFGUID guidDeviceId,
  176. DIRECTSOUNDMIXER_SRCQUALITY SrcQuality
  177. )
  178. {
  179. DSPROPERTY_DIRECTSOUNDMIXER_SRCQUALITY_DATA Data;
  180. HRESULT hr;
  181. Data.DeviceId = guidDeviceId;
  182. Data.Quality = SrcQuality;
  183. hr =
  184. pKsPropertySet->Set
  185. (
  186. DSPROPSETID_DirectSoundMixer,
  187. DSPROPERTY_DIRECTSOUNDMIXER_SRCQUALITY,
  188. NULL,
  189. 0,
  190. &Data,
  191. sizeof(Data)
  192. );
  193. return hr;
  194. }
  195. /***************************************************************************
  196. *
  197. * PrvGetMixerAcceleration
  198. *
  199. * Description:
  200. * Gets the mixer acceleration flags for a given DirectSound device.
  201. *
  202. * Arguments:
  203. * LPKSPROPERTYSET [in]: IKsPropertySet interface to the
  204. * DirectSoundPrivate object.
  205. * REFGUID [in]: DirectSound device GUID.
  206. * LPDWORD [out]: receives acceleration flags.
  207. *
  208. * Returns:
  209. * HRESULT: DirectSound/COM result code.
  210. *
  211. ***************************************************************************/
  212. HRESULT PrvGetMixerAcceleration
  213. (
  214. LPKSPROPERTYSET pKsPropertySet,
  215. REFGUID guidDeviceId,
  216. LPDWORD pdwAcceleration
  217. )
  218. {
  219. DSPROPERTY_DIRECTSOUNDMIXER_ACCELERATION_DATA Data;
  220. HRESULT hr;
  221. Data.DeviceId = guidDeviceId;
  222. hr =
  223. pKsPropertySet->Get
  224. (
  225. DSPROPSETID_DirectSoundMixer,
  226. DSPROPERTY_DIRECTSOUNDMIXER_ACCELERATION,
  227. NULL,
  228. 0,
  229. &Data,
  230. sizeof(Data),
  231. NULL
  232. );
  233. if(SUCCEEDED(hr))
  234. {
  235. *pdwAcceleration = Data.Flags;
  236. }
  237. return hr;
  238. }
  239. /***************************************************************************
  240. *
  241. * PrvSetMixerAcceleration
  242. *
  243. * Description:
  244. * Sets the mixer acceleration flags for a given DirectSound device.
  245. *
  246. * Arguments:
  247. * LPKSPROPERTYSET [in]: IKsPropertySet interface to the
  248. * DirectSoundPrivate object.
  249. * REFGUID [in]: DirectSound device GUID.
  250. * DWORD [in]: acceleration flags.
  251. *
  252. * Returns:
  253. * HRESULT: DirectSound/COM result code.
  254. *
  255. ***************************************************************************/
  256. HRESULT PrvSetMixerAcceleration
  257. (
  258. LPKSPROPERTYSET pKsPropertySet,
  259. REFGUID guidDeviceId,
  260. DWORD dwAcceleration
  261. )
  262. {
  263. DSPROPERTY_DIRECTSOUNDMIXER_ACCELERATION_DATA Data;
  264. HRESULT hr;
  265. Data.DeviceId = guidDeviceId;
  266. Data.Flags = dwAcceleration;
  267. hr =
  268. pKsPropertySet->Set
  269. (
  270. DSPROPSETID_DirectSoundMixer,
  271. DSPROPERTY_DIRECTSOUNDMIXER_ACCELERATION,
  272. NULL,
  273. 0,
  274. &Data,
  275. sizeof(Data)
  276. );
  277. return hr;
  278. }
  279. /***************************************************************************
  280. *
  281. * PrvGetDevicePresence
  282. *
  283. * Description:
  284. * Determines whether a device is enabled.
  285. *
  286. * Arguments:
  287. * LPKSPROPERTYSET [in]: IKsPropertySet interface to the
  288. * DirectSoundPrivate object.
  289. * REFGUID [in]: DirectSound device GUID.
  290. * LPBOOL [out]: receives TRUE if the device is enabled.
  291. *
  292. * Returns:
  293. * HRESULT: DirectSound/COM result code.
  294. *
  295. ***************************************************************************/
  296. HRESULT PrvGetDevicePresence
  297. (
  298. LPKSPROPERTYSET pKsPropertySet,
  299. REFGUID guidDeviceId,
  300. LPBOOL pfEnabled
  301. )
  302. {
  303. DSPROPERTY_DIRECTSOUNDDEVICE_PRESENCE_DATA Data;
  304. HRESULT hr;
  305. Data.DeviceId = guidDeviceId;
  306. hr =
  307. pKsPropertySet->Get
  308. (
  309. DSPROPSETID_DirectSoundDevice,
  310. DSPROPERTY_DIRECTSOUNDDEVICE_PRESENCE,
  311. NULL,
  312. 0,
  313. &Data,
  314. sizeof(Data),
  315. NULL
  316. );
  317. if(SUCCEEDED(hr))
  318. {
  319. *pfEnabled = Data.Present;
  320. }
  321. return hr;
  322. }
  323. /***************************************************************************
  324. *
  325. * PrvSetDevicePresence
  326. *
  327. * Description:
  328. * Sets whether a device is enabled.
  329. *
  330. * Arguments:
  331. * LPKSPROPERTYSET [in]: IKsPropertySet interface to the
  332. * DirectSoundPrivate object.
  333. * REFGUID [in]: DirectSound device GUID.
  334. * BOOL [in]: TRUE if the device is enabled.
  335. *
  336. * Returns:
  337. * HRESULT: DirectSound/COM result code.
  338. *
  339. ***************************************************************************/
  340. HRESULT PrvSetDevicePresence
  341. (
  342. LPKSPROPERTYSET pKsPropertySet,
  343. REFGUID guidDeviceId,
  344. BOOL fEnabled
  345. )
  346. {
  347. DSPROPERTY_DIRECTSOUNDDEVICE_PRESENCE_DATA Data;
  348. HRESULT hr;
  349. Data.DeviceId = guidDeviceId;
  350. Data.Present = fEnabled;
  351. hr =
  352. pKsPropertySet->Set
  353. (
  354. DSPROPSETID_DirectSoundDevice,
  355. DSPROPERTY_DIRECTSOUNDDEVICE_PRESENCE,
  356. NULL,
  357. 0,
  358. &Data,
  359. sizeof(Data)
  360. );
  361. return hr;
  362. }
  363. /***************************************************************************
  364. *
  365. * PrvGetWaveDeviceMapping
  366. *
  367. * Description:
  368. * Gets the DirectSound device id (if any) for a given waveIn or
  369. * waveOut device description. This is the description given by
  370. * waveIn/OutGetDevCaps (szPname).
  371. *
  372. * Arguments:
  373. * LPKSPROPERTYSET [in]: IKsPropertySet interface to the
  374. * DirectSoundPrivate object.
  375. * LPCSTR [in]: wave device description.
  376. * BOOL [in]: TRUE if the device description refers to a waveIn device.
  377. * LPGUID [out]: receives DirectSound device GUID.
  378. *
  379. * Returns:
  380. * HRESULT: DirectSound/COM result code.
  381. *
  382. ***************************************************************************/
  383. HRESULT PrvGetWaveDeviceMapping
  384. (
  385. LPKSPROPERTYSET pKsPropertySet,
  386. LPCTSTR pszWaveDevice,
  387. BOOL fCapture,
  388. LPGUID pguidDeviceId
  389. )
  390. {
  391. DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_DATA Data;
  392. HRESULT hr;
  393. Data.DeviceName = (LPTSTR)pszWaveDevice;
  394. Data.DataFlow = fCapture ? DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE : DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
  395. hr =
  396. pKsPropertySet->Get
  397. (
  398. DSPROPSETID_DirectSoundDevice,
  399. DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING,
  400. NULL,
  401. 0,
  402. &Data,
  403. sizeof(Data),
  404. NULL
  405. );
  406. if(SUCCEEDED(hr))
  407. {
  408. *pguidDeviceId = Data.DeviceId;
  409. }
  410. return hr;
  411. }
  412. /***************************************************************************
  413. *
  414. * PrvGetDeviceDescription
  415. *
  416. * Description:
  417. * Gets the extended description for a given DirectSound device.
  418. *
  419. * Arguments:
  420. * LPKSPROPERTYSET [in]: IKsPropertySet interface to the
  421. * DirectSoundPrivate object.
  422. * REFGUID [in]: DirectSound device id.
  423. * PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA [out]: receives
  424. * description.
  425. *
  426. * Returns:
  427. * HRESULT: DirectSound/COM result code.
  428. *
  429. ***************************************************************************/
  430. HRESULT PrvGetDeviceDescription
  431. (
  432. LPKSPROPERTYSET pKsPropertySet,
  433. REFGUID guidDeviceId,
  434. PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA *ppData
  435. )
  436. {
  437. PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA pData = NULL;
  438. ULONG cbData;
  439. DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA Basic;
  440. HRESULT hr;
  441. Basic.DeviceId = guidDeviceId;
  442. hr =
  443. pKsPropertySet->Get
  444. (
  445. DSPROPSETID_DirectSoundDevice,
  446. DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
  447. NULL,
  448. 0,
  449. &Basic,
  450. sizeof(Basic),
  451. &cbData
  452. );
  453. if(SUCCEEDED(hr))
  454. {
  455. pData = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA)new BYTE [cbData];
  456. if(!pData)
  457. {
  458. hr = DSERR_OUTOFMEMORY;
  459. }
  460. }
  461. if(SUCCEEDED(hr))
  462. {
  463. ZeroMemory(pData, cbData);
  464. pData->DeviceId = guidDeviceId;
  465. hr =
  466. pKsPropertySet->Get
  467. (
  468. DSPROPSETID_DirectSoundDevice,
  469. DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
  470. NULL,
  471. 0,
  472. pData,
  473. cbData,
  474. NULL
  475. );
  476. }
  477. if(SUCCEEDED(hr))
  478. {
  479. *ppData = pData;
  480. }
  481. else if(pData)
  482. {
  483. delete pData;
  484. }
  485. return hr;
  486. }
  487. /***************************************************************************
  488. *
  489. * PrvReleaseDeviceDescription
  490. *
  491. ***************************************************************************/
  492. HRESULT PrvReleaseDeviceDescription( PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA pData )
  493. {
  494. delete[] pData;
  495. return S_OK;
  496. }
  497. /***************************************************************************
  498. *
  499. * PrvEnumerateDevices
  500. *
  501. * Description:
  502. * Enumerates all DirectSound devices.
  503. *
  504. * Arguments:
  505. * LPKSPROPERTYSET [in]: IKsPropertySet interface to the
  506. * DirectSoundPrivate object.
  507. * LPFNDIRECTSOUNDDEVICEENUMERATECALLBACK [in]: pointer to the callback
  508. * function.
  509. * LPVOID [in]: context argument to pass to the callback function.
  510. *
  511. * Returns:
  512. * HRESULT: DirectSound/COM result code.
  513. *
  514. ***************************************************************************/
  515. HRESULT PrvEnumerateDevices
  516. (
  517. LPKSPROPERTYSET pKsPropertySet,
  518. LPFNDIRECTSOUNDDEVICEENUMERATECALLBACK pfnCallback,
  519. LPVOID pvContext
  520. )
  521. {
  522. DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA Data;
  523. HRESULT hr;
  524. Data.Callback = pfnCallback;
  525. Data.Context = pvContext;
  526. hr =
  527. pKsPropertySet->Get
  528. (
  529. DSPROPSETID_DirectSoundDevice,
  530. DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE,
  531. NULL,
  532. 0,
  533. &Data,
  534. sizeof(Data),
  535. NULL
  536. );
  537. return hr;
  538. }
  539. /***************************************************************************
  540. *
  541. * PrvGetBasicAcceleration
  542. *
  543. * Description:
  544. * Gets basic acceleration flags for a given DirectSound device. This
  545. * is the accleration level that the multimedia control panel uses.
  546. *
  547. * Arguments:
  548. * LPKSPROPERTYSET [in]: IKsPropertySet interface to the
  549. * DirectSoundPrivate object.
  550. * REFGUID [in]: DirectSound device GUID.
  551. * DIRECTSOUNDBASICACCELERATION_LEVEL * [out]: receives basic
  552. * acceleration level.
  553. *
  554. * Returns:
  555. * HRESULT: DirectSound/COM result code.
  556. *
  557. ***************************************************************************/
  558. HRESULT PrvGetBasicAcceleration
  559. (
  560. LPKSPROPERTYSET pKsPropertySet,
  561. REFGUID guidDeviceId,
  562. DIRECTSOUNDBASICACCELERATION_LEVEL * pLevel
  563. )
  564. {
  565. DSPROPERTY_DIRECTSOUNDBASICACCELERATION_ACCELERATION_DATA Data;
  566. HRESULT hr;
  567. Data.DeviceId = guidDeviceId;
  568. hr =
  569. pKsPropertySet->Get
  570. (
  571. DSPROPSETID_DirectSoundBasicAcceleration,
  572. DSPROPERTY_DIRECTSOUNDBASICACCELERATION_ACCELERATION,
  573. NULL,
  574. 0,
  575. &Data,
  576. sizeof(Data),
  577. NULL
  578. );
  579. if(SUCCEEDED(hr))
  580. {
  581. *pLevel = Data.Level;
  582. }
  583. return hr;
  584. }
  585. /***************************************************************************
  586. *
  587. * PrvSetBasicAcceleration
  588. *
  589. * Description:
  590. * Sets basic acceleration flags for a given DirectSound device. This
  591. * is the accleration level that the multimedia control panel uses.
  592. *
  593. * Arguments:
  594. * LPKSPROPERTYSET [in]: IKsPropertySet interface to the
  595. * DirectSoundPrivate object.
  596. * REFGUID [in]: DirectSound device GUID.
  597. * DIRECTSOUNDBASICACCELERATION_LEVEL [in]: basic acceleration level.
  598. *
  599. * Returns:
  600. * HRESULT: DirectSound/COM result code.
  601. *
  602. ***************************************************************************/
  603. HRESULT PrvSetBasicAcceleration
  604. (
  605. LPKSPROPERTYSET pKsPropertySet,
  606. REFGUID guidDeviceId,
  607. DIRECTSOUNDBASICACCELERATION_LEVEL Level
  608. )
  609. {
  610. DSPROPERTY_DIRECTSOUNDBASICACCELERATION_ACCELERATION_DATA Data;
  611. HRESULT hr;
  612. Data.DeviceId = guidDeviceId;
  613. Data.Level = Level;
  614. hr =
  615. pKsPropertySet->Set
  616. (
  617. DSPROPSETID_DirectSoundBasicAcceleration,
  618. DSPROPERTY_DIRECTSOUNDBASICACCELERATION_ACCELERATION,
  619. NULL,
  620. 0,
  621. &Data,
  622. sizeof(Data)
  623. );
  624. return hr;
  625. }
  626. /***************************************************************************
  627. *
  628. * PrvGetDebugInformation
  629. *
  630. * Description:
  631. * Gets the current DirectSound debug settings.
  632. *
  633. * Arguments:
  634. * LPKSPROPERTYSET [in]: IKsPropertySet interface to the
  635. * DirectSoundPrivate object.
  636. * LPDWORD [in]: receives DPF flags.
  637. * PULONG [out]: receives DPF level.
  638. * PULONG [out]: receives break level.
  639. * LPSTR [out]: receives log file name.
  640. *
  641. * Returns:
  642. * HRESULT: DirectSound/COM result code.
  643. *
  644. ***************************************************************************/
  645. HRESULT PrvGetDebugInformation
  646. (
  647. LPKSPROPERTYSET pKsPropertySet,
  648. LPDWORD pdwFlags,
  649. PULONG pulDpfLevel,
  650. PULONG pulBreakLevel,
  651. LPTSTR pszLogFile
  652. )
  653. {
  654. DSPROPERTY_DIRECTSOUNDDEBUG_DPFINFO_DATA Data;
  655. HRESULT hr;
  656. hr =
  657. pKsPropertySet->Get
  658. (
  659. DSPROPSETID_DirectSoundDebug,
  660. DSPROPERTY_DIRECTSOUNDDEBUG_DPFINFO,
  661. NULL,
  662. 0,
  663. &Data,
  664. sizeof(Data),
  665. NULL
  666. );
  667. if(SUCCEEDED(hr) && pdwFlags)
  668. {
  669. *pdwFlags = Data.Flags;
  670. }
  671. if(SUCCEEDED(hr) && pulDpfLevel)
  672. {
  673. *pulDpfLevel = Data.DpfLevel;
  674. }
  675. if(SUCCEEDED(hr) && pulBreakLevel)
  676. {
  677. *pulBreakLevel = Data.BreakLevel;
  678. }
  679. if(SUCCEEDED(hr) && pszLogFile)
  680. {
  681. lstrcpy
  682. (
  683. pszLogFile,
  684. Data.LogFile
  685. );
  686. }
  687. return hr;
  688. }
  689. /***************************************************************************
  690. *
  691. * PrvSetDebugInformation
  692. *
  693. * Description:
  694. * Sets the current DirectSound debug settings.
  695. *
  696. * Arguments:
  697. * LPKSPROPERTYSET [in]: IKsPropertySet interface to the
  698. * DirectSoundPrivate object.
  699. * DWORD [in]: DPF flags.
  700. * ULONG [in]: DPF level.
  701. * ULONG [in]: break level.
  702. * LPCSTR [in]: log file name.
  703. *
  704. * Returns:
  705. * HRESULT: DirectSound/COM result code.
  706. *
  707. ***************************************************************************/
  708. HRESULT PrvSetDebugInformation
  709. (
  710. LPKSPROPERTYSET pKsPropertySet,
  711. DWORD dwFlags,
  712. ULONG ulDpfLevel,
  713. ULONG ulBreakLevel,
  714. LPCTSTR pszLogFile
  715. )
  716. {
  717. DSPROPERTY_DIRECTSOUNDDEBUG_DPFINFO_DATA Data;
  718. HRESULT hr;
  719. Data.Flags = dwFlags;
  720. Data.DpfLevel = ulDpfLevel;
  721. Data.BreakLevel = ulBreakLevel;
  722. lstrcpy
  723. (
  724. Data.LogFile,
  725. pszLogFile
  726. );
  727. hr =
  728. pKsPropertySet->Set
  729. (
  730. DSPROPSETID_DirectSoundDebug,
  731. DSPROPERTY_DIRECTSOUNDDEBUG_DPFINFO,
  732. NULL,
  733. 0,
  734. &Data,
  735. sizeof(Data)
  736. );
  737. return hr;
  738. }
  739. /***************************************************************************
  740. *
  741. * PrvGetPersistentData
  742. *
  743. * Description:
  744. * Gets a registry value stored under the DirectSound subkey of a
  745. * specific hardware device.
  746. *
  747. * Arguments:
  748. * LPKSPROPERTYSET [in]: IKsPropertySet interface to the
  749. * DirectSoundPrivate object.
  750. * REFGUID [in]: DirectSound device id.
  751. * LPCSTR [in]: subkey path.
  752. * LPCSTR [in]: value name.
  753. * LPDWORD [in/out]: receives registry data type.
  754. * LPVOID [out]: data buffer.
  755. * LPDWORD [in/out]: size of above buffer. On entry, this argument is
  756. * filled with the maximum size of the data buffer.
  757. * On exit, this argument is filled with the required
  758. * size.
  759. *
  760. * Returns:
  761. * HRESULT: DirectSound/COM result code.
  762. *
  763. ***************************************************************************/
  764. HRESULT PrvGetPersistentData
  765. (
  766. LPKSPROPERTYSET pKsPropertySet,
  767. REFGUID guidDeviceId,
  768. LPCTSTR pszSubkey,
  769. LPCTSTR pszValue,
  770. LPDWORD pdwRegType,
  771. LPVOID pvData,
  772. LPDWORD pcbData
  773. )
  774. {
  775. PDSPROPERTY_DIRECTSOUNDPERSISTENTDATA_PERSISTDATA_DATA pPersist;
  776. ULONG cbPersist;
  777. HRESULT hr;
  778. cbPersist = sizeof(*pPersist) + *pcbData;
  779. pPersist = (PDSPROPERTY_DIRECTSOUNDPERSISTENTDATA_PERSISTDATA_DATA)
  780. LocalAlloc
  781. (
  782. LPTR,
  783. cbPersist
  784. );
  785. if(pPersist)
  786. {
  787. pPersist->DeviceId = guidDeviceId;
  788. pPersist->SubKeyName = (LPTSTR)pszSubkey;
  789. pPersist->ValueName = (LPTSTR)pszValue;
  790. if(pdwRegType)
  791. {
  792. pPersist->RegistryDataType = *pdwRegType;
  793. }
  794. hr =
  795. pKsPropertySet->Get
  796. (
  797. DSPROPSETID_DirectSoundPersistentData,
  798. DSPROPERTY_DIRECTSOUNDPERSISTENTDATA_PERSISTDATA,
  799. NULL,
  800. 0,
  801. pPersist,
  802. cbPersist,
  803. &cbPersist
  804. );
  805. }
  806. else
  807. {
  808. hr = DSERR_OUTOFMEMORY;
  809. }
  810. if(SUCCEEDED(hr))
  811. {
  812. CopyMemory
  813. (
  814. pvData,
  815. pPersist + 1,
  816. *pcbData
  817. );
  818. }
  819. *pcbData = cbPersist - sizeof(*pPersist);
  820. if(pPersist && pdwRegType)
  821. {
  822. *pdwRegType = pPersist->RegistryDataType;
  823. }
  824. if(pPersist)
  825. {
  826. LocalFree(pPersist);
  827. }
  828. return hr;
  829. }
  830. /***************************************************************************
  831. *
  832. * PrvSetPersistentData
  833. *
  834. * Description:
  835. * Sets a registry value stored under the DirectSound subkey of a
  836. * specific hardware device.
  837. *
  838. * Arguments:
  839. * LPKSPROPERTYSET [in]: IKsPropertySet interface to the
  840. * DirectSoundPrivate object.
  841. * REFGUID [in]: DirectSound device id.
  842. * LPCSTR [in]: subkey path.
  843. * LPCSTR [in]: value name.
  844. * DWORD [in]: registry data type.
  845. * LPVOID [out]: data buffer.
  846. * DWORD [in]: size of above buffer.
  847. *
  848. * Returns:
  849. * HRESULT: DirectSound/COM result code.
  850. *
  851. ***************************************************************************/
  852. HRESULT PrvSetPersistentData
  853. (
  854. LPKSPROPERTYSET pKsPropertySet,
  855. REFGUID guidDeviceId,
  856. LPCTSTR pszSubkey,
  857. LPCTSTR pszValue,
  858. DWORD dwRegType,
  859. LPVOID pvData,
  860. DWORD cbData
  861. )
  862. {
  863. PDSPROPERTY_DIRECTSOUNDPERSISTENTDATA_PERSISTDATA_DATA pPersist;
  864. ULONG cbPersist;
  865. HRESULT hr;
  866. cbPersist = sizeof(*pPersist) + cbData;
  867. pPersist = (PDSPROPERTY_DIRECTSOUNDPERSISTENTDATA_PERSISTDATA_DATA)
  868. LocalAlloc
  869. (
  870. LPTR,
  871. cbPersist
  872. );
  873. if(pPersist)
  874. {
  875. pPersist->DeviceId = guidDeviceId;
  876. pPersist->SubKeyName = (LPTSTR)pszSubkey;
  877. pPersist->ValueName = (LPTSTR)pszValue;
  878. pPersist->RegistryDataType = dwRegType;
  879. CopyMemory
  880. (
  881. pPersist + 1,
  882. pvData,
  883. cbData
  884. );
  885. hr =
  886. pKsPropertySet->Set
  887. (
  888. DSPROPSETID_DirectSoundPersistentData,
  889. DSPROPERTY_DIRECTSOUNDPERSISTENTDATA_PERSISTDATA,
  890. NULL,
  891. 0,
  892. pPersist,
  893. cbPersist
  894. );
  895. }
  896. else
  897. {
  898. hr = DSERR_OUTOFMEMORY;
  899. }
  900. if(pPersist)
  901. {
  902. LocalFree(pPersist);
  903. }
  904. return hr;
  905. }