1 /*
2  * Strawberry Music Player
3  * This file was part of Clementine.
4  * Copyright 2014, David Sansome <me@davidsansome.com>
5  * Copyright 2019-2021, Jonas Kvinge <jonas@jkvinge.net>
6  *
7  * Strawberry is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * Strawberry is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with Strawberry.  If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifdef INTERFACE
23 #  undef INTERFACE
24 #endif
25 
26 #include "config.h"
27 
28 #include <dsound.h>
29 
30 #include <QList>
31 #include <QVariant>
32 #include <QString>
33 #include <QUuid>
34 
35 #include "directsounddevicefinder.h"
36 #include "core/logging.h"
37 
DirectSoundDeviceFinder()38 DirectSoundDeviceFinder::DirectSoundDeviceFinder() : DeviceFinder("directsound", { "directsound", "dsound", "directsoundsink", "directx", "directx2" }) {}
39 
ListDevices()40 QList<DeviceFinder::Device> DirectSoundDeviceFinder::ListDevices() {
41   State state;
42   DirectSoundEnumerateA(&DirectSoundDeviceFinder::EnumerateCallback, &state);
43   return state.devices;
44 }
45 
EnumerateCallback(LPGUID guid,LPCSTR description,LPCSTR module,LPVOID state_voidptr)46 BOOL DirectSoundDeviceFinder::EnumerateCallback(LPGUID guid, LPCSTR description, LPCSTR module, LPVOID state_voidptr) {
47 
48   Q_UNUSED(module);
49 
50   State *state = reinterpret_cast<State*>(state_voidptr);
51 
52   Device dev;
53   dev.description = QString::fromLatin1(description);
54   if (guid) dev.value = QUuid(*guid).toString();
55   dev.iconname = GuessIconName(dev.description);
56   state->devices.append(dev);
57 
58   return 1;
59 
60 }
61