VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/testcase/tstAudioClient3.cpp@ 101539

Last change on this file since 101539 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/* $Id: tstAudioClient3.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * Audio testcase - Tests for the IAudioClient3 interface.
4 */
5
6/*
7 * Copyright (C) 2021-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32
33#include <iprt/errcore.h>
34#include <iprt/initterm.h>
35#include <iprt/mem.h>
36#include <iprt/rand.h>
37#include <iprt/stream.h>
38#include <iprt/string.h>
39#include <iprt/test.h>
40
41#include <iprt/win/windows.h>
42
43#include <Audioclient.h>
44#include <mmdeviceapi.h>
45
46int main(int argc, char **argv)
47{
48 RTR3InitExe(argc, &argv, 0);
49
50 /*
51 * Initialize IPRT and create the test.
52 */
53 RTTEST hTest;
54 int rc = RTTestInitAndCreate("tstAudioMixBuffer", &hTest);
55 if (rc)
56 return rc;
57 RTTestBanner(hTest);
58
59 /* Note: IAudioClient3 is supported on Win8 or newer. */
60
61 /** @todo Very crude for now, lacks error checking and such. Later. */
62
63 HRESULT hr = CoInitialize(NULL);
64
65 IMMDeviceEnumerator* pEnumerator;
66 hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL,
67 __uuidof(IMMDeviceEnumerator),
68 reinterpret_cast<void**>(&pEnumerator));
69
70 IMMDevice* pDevice;
71 hr = pEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &pDevice);
72
73 IAudioClient3* pAudioClient;
74 hr = pDevice->Activate(__uuidof(IAudioClient3), CLSCTX_ALL, NULL, reinterpret_cast<void**>(&pAudioClient));
75
76 WAVEFORMATEX* pFormat;
77 hr = pAudioClient->GetMixFormat(&pFormat);
78
79 UINT32 defaultPeriodInFrames;
80 UINT32 fundamentalPeriodInFrames;
81 UINT32 minPeriodInFrames;
82 UINT32 maxPeriodInFrames;
83 hr = pAudioClient->GetSharedModeEnginePeriod(pFormat,
84 &defaultPeriodInFrames,
85 &fundamentalPeriodInFrames,
86 &minPeriodInFrames,
87 &maxPeriodInFrames);
88
89 RTTestPrintf(hTest, RTTESTLVL_ALWAYS, "def=%RU32, fundamental=%RU32, min=%RU32, max=%RU32\n",
90 defaultPeriodInFrames, fundamentalPeriodInFrames, minPeriodInFrames, maxPeriodInFrames);
91
92 uint32_t cfDefault = defaultPeriodInFrames * 2;
93
94 RTTestPrintf(hTest, RTTESTLVL_ALWAYS, "Trying to set %RU32 as default ...\n", cfDefault);
95
96 hr = pAudioClient->InitializeSharedAudioStream(0, cfDefault, pFormat, NULL);
97 if (hr != S_OK)
98 RTTestPrintf(hTest, RTTESTLVL_ALWAYS, "Unable to set new period");
99 else
100 {
101 RTTestPrintf(hTest, RTTESTLVL_ALWAYS, "OK");
102
103 hr = pAudioClient->Start();
104
105 /** @todo Do some waiting / testing here. */
106 }
107
108 /*
109 * Summary
110 */
111 return RTTestSummaryAndDestroy(hTest);
112}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette