From 4f6b15ea26b5fa09f300f67e4ce1057c2b39a3aa Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 25 Sep 2014 17:08:44 +0200 Subject: New API, new name, new version. --- src/mixer.h | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 src/mixer.h (limited to 'src/mixer.h') 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 + +#include +#include +#include + +/** + * 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 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__*/ -- cgit v1.2.3