File: fweelin_amixer.h

package info (click to toggle)
freewheeling 0.6.4-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,244 kB
  • sloc: cpp: 24,079; xml: 3,631; ansic: 1,818; sh: 1,232; makefile: 31
file content (100 lines) | stat: -rw-r--r-- 3,431 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef __FWEELIN_AMIXER_H
#define __FWEELIN_AMIXER_H

/* Copyright 2004-2011 Jan Pekau
   
   This file is part of Freewheeling.
   
   Freewheeling is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 2 of the License, or
   (at your option) any later version.
   
   Freewheeling is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with Freewheeling.  If not, see <http://www.gnu.org/licenses/>. */

/* This file contains code from amixer.c, ALSA's command line mixer utility:
 *
 *   ALSA command line mixer utility
 *   Copyright (c) 1999-2000 by Jaroslav Kysela <perex@perex.cz>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>

#ifndef __MACOSX__
#include <alsa/asoundlib.h>
#endif

#include "fweelin_core.h"

class Fweelin;

/**
 * Interface class for directly talking to the audio hardware (ALSA) mixer
 *
 * Taken almost verbatim from amixer.c in alsa-utils, with minor changes to fit
 * Freewheeling.
 */
class HardwareMixerInterface {
public:
  HardwareMixerInterface(Fweelin *app) : app(app), prev_hwid(-1) {};

#ifndef __MACOSX__
  /*
   * Set an ALSA Mixer control
   *
   * Parameters:
   * the HW id (ie hw:0, hw:1, etc)
   * the control numid (ie numid=5)
   * and between 1 and 4 values.
   *
   * Returns zero on success.
   */
  int ALSAMixerControlSet(int hwid, int numid, int val1, int val2 = -1, int val3 = -1, int val4 = -1);

private:
  const char *control_type(snd_ctl_elem_info_t *info);
  const char *control_access(snd_ctl_elem_info_t *info);
  long get_integer(char **ptr, long min, long max);
  long get_integer64(char **ptr, long long min, long long max);
  int parse_control_id(const char *str, snd_ctl_elem_id_t *id);
  const char *control_iface(snd_ctl_elem_id_t *id);
  void show_control_id(snd_ctl_elem_id_t *id);
  void print_spaces(unsigned int spaces);
  void print_dB(long dB);
  void decode_tlv(unsigned int spaces, unsigned int *tlv, unsigned int tlv_size);
  int show_control(char *card, const char *space, snd_hctl_elem_t *elem,
      int level);
  int get_ctl_enum_item_index(snd_ctl_t *handle, snd_ctl_elem_info_t *info,
      char **ptrp);
  int cset(char *card, int argc, char *argv[], int roflag, int keep_handle, int debugflag);
#endif

  Fweelin *app;
  int prev_hwid;  // Previous cset call, what was the hwid?
};

#endif