kodi
ALSAHControlMonitor.h
1 /*
2  * Copyright (C) 2014-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "platform/Platform.h"
12 
13 #include <map>
14 #include <string>
15 #include <vector>
16 
17 #include <alsa/asoundlib.h>
18 
20 {
21 public:
24 
25  bool Add(const std::string& ctlHandleName,
26  snd_ctl_elem_iface_t interface,
27  unsigned int device,
28  const std::string& name);
29 
30  void Clear();
31 
32  void Start();
33  void Stop();
34 
35 private:
36  static int HCTLCallback(snd_hctl_elem_t *elem, unsigned int mask);
37  static void FDEventCallback(int id, int fd, short revents, void *data);
38 
39  snd_hctl_t* GetHandle(const std::string& ctlHandleName);
40  void PutHandle(const std::string& ctlHandleName);
41 
42  struct CTLHandle
43  {
44  snd_hctl_t *handle;
45  int useCount = 0;
46 
47  explicit CTLHandle(snd_hctl_t *handle_) : handle(handle_) {}
48  CTLHandle() : handle(NULL) {}
49  };
50 
51  std::map<std::string, CTLHandle> m_ctlHandles;
52 
53  std::vector<int> m_fdMonitorIds;
54 };
Base class for services.
Definition: Platform.h:14
Definition: ALSAHControlMonitor.h:19