summaryrefslogtreecommitdiff
path: root/src/mixer.h
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-09-25 17:08:44 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-09-25 17:08:44 +0200
commit4f6b15ea26b5fa09f300f67e4ce1057c2b39a3aa (patch)
tree45d7bb4a9a90ef603b5a7a65a4d4d4309a7a1538 /src/mixer.h
parent0602763044f0f0f9163f2a888627213347d3dbb7 (diff)
New API, new name, new version.
Diffstat (limited to 'src/mixer.h')
-rw-r--r--src/mixer.h125
1 files changed, 125 insertions, 0 deletions
diff --git a/src/mixer.h b/src/mixer.h
new file mode 100644
index 0000000..0adcdda
--- /dev/null
+++ b/src/mixer.h
@@ -0,0 +1,125 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * mixer.h
+ *
+ * Tue Sep 23 14:38:54 CEST 2014
+ * Copyright 2014 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of LibAudioIO.
+ *
+ * LibAudioIO is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * LibAudioIO 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with LibAudioIO; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef __LIBAUDIOIO_MIXER_H__
+#define __LIBAUDIOIO_MIXER_H__
+
+// Make API behave like ALSA 1.x.x with ALSA 0.9.x
+#define ALSA_PCM_NEW_HW_PARAMS_API
+
+#include <asoundlib.h>
+
+#include <exception>
+#include <string>
+#include <vector>
+
+/**
+ * A Mixer object represents a single group of channels, for example the two
+ * channels of a stereo mixer.
+ */
+class Mixer {
+public:
+ /**
+ * Mixer constructor is not to be called "manually" is is invoked by
+ * Device::getMixer()
+ */
+ Mixer(snd_mixer_t *handle, snd_mixer_elem_t *elem);
+ ~Mixer();
+
+ /**
+ * Get number of channels in this mixer 'strip'
+ */
+ int numberOfChannels();
+
+ /**
+ * Return true if this mixer is a capture device, false otherwise.
+ */
+ bool isCapture();
+
+ /**
+ * Return true if this mixer is a playback device, false otherwise.
+ */
+ bool isPlayback();
+
+ /**
+ * Return true if this mixer is a enum, false otherwise.
+ */
+ bool isEnum();
+
+ /**
+ * For capture channels only!
+ * Set arm for recording flag on all mixer channels.
+ */
+ void setCapture(bool capture);
+
+ /**
+ * Return true if all channels are armed for recording.
+ * Return false if not a capture channels strip, or if at least one channel
+ * is not armed.
+ */
+ bool capture();
+
+ /**
+ * Set enum value.
+ */
+ void setEnumValue(std::string value);
+
+ /**
+ * Get enum value.
+ */
+ std::string enumValue();
+
+ /**
+ * Get list of possible enum values.
+ */
+ std::vector<std::string> enumValues();
+
+ /**
+ * Get/set mixer volume level in dB.
+ * On error (no such channel) -INF is returned.
+ */
+ int setLevel(int channel, float level);
+ // 0 on success, 1 on error.
+ float level(int channel);
+
+ typedef struct {
+ float min;
+ float max;
+ } range_t;
+ /**
+ * Poll the valid volume range of this mixer in dB.
+ */
+ range_t range();
+
+private:
+ snd_mixer_selem_channel_id_t chanId(int idx);
+
+ snd_mixer_t *handle;
+ snd_mixer_elem_t *elem;
+};
+
+#endif/*__LIBAUDIOIO_MIXER_H__*/