3312N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A /* Values: either SND_MIXER_SCHN_FRONT_xx, CHANNELS_MONO or CHANNELS_STEREO. 0N/A For SND_MIXER_SCHN_FRONT_xx, exactly this channel is set/retrieved directly. 0N/A For CHANNELS_MONO, ALSA channel SND_MIXER_SCHN_MONO is set/retrieved directly. 0N/A For CHANNELS_STEREO, ALSA channels SND_MIXER_SCHN_FRONT_LEFT and SND_MIXER_SCHN_FRONT_RIGHT 0N/A are set after a calculation that takes balance into account. Retrieved? Average of both 0N/A channels? (Using a cached value is not a good idea since the value in the HW may have been 0N/A /* Number of array elements used in elems and types. */ 0N/A /* Array of port types (PORT_SRC_UNKNOWN etc.). Indices are the same as in elems. */ 0N/A /* Number of array elements used in controls. */ 0N/A // necessary to initialize data structures 0N/A // $$mp: Should become a descriptive error code (invalid handle). 0N/A // to prevent buffer overflow 0N/A /* If an element has both playback an capture volume, it is put into the arrays 0N/A // to prevent buffer overflow 0N/A // $$mp: Should become a descriptive error code (invalid handle). 0N/A // $$mp: Should become a descriptive error code (index out of bounds). 0N/A // $$mp: Should become a descriptive error code (invalid handle). 0N/A // $$mp: Should become a descriptive error code (index out of bounds). 0N/A/* Sets portControl to a pointer to the next free array element in the PortControl (pointer) 0N/A array of the passed portMixer. Returns TRUE if successful. May return FALSE if there is no 0N/A free slot. In this case, portControl is not altered */ 0N/A/* Protect against illegal min-max values, preventing divisions by zero. 0N/A/* Idea: we may specify that if unit is an empty string, the values are linear and if unit is "dB", 0N/A the values are logarithmic. 0N/A /* $$mp: The volume values retrieved with the ALSA API are strongly supposed to be logarithmic. 0N/A So the following calculation is wrong. However, there is no correct calculation, since 0N/A for equal-distant logarithmic steps, the precision expressed in linear varies over the 0N/A // $$mp: an error code should be returned. 0N/A // $$mp: an error code should be returned. 0N/A of elements, we now can assume that we handle only to deal with either playback or 0N/A // single volume control 0N/A }
else {
// more than two channels, each channels has its own control. 0N/A // We wrap in a compound control to provide the channel name. 0N/A /* $$mp 2003-09-14: The following cast shouln't be necessary. Instead, the 0N/A declaration of PORT_NewCompoundControlPtr in Ports.h should be changed 0N/A to take a const char* parameter. */ 0N/A /* $$mp: The value for precision is chosen more or less arbitrarily. */ 0N/A /* $$mp 2003-09-14: The following cast shouln't be necessary. Instead, the 0N/A declaration of PORT_NewCompoundControlPtr in Ports.h should be changed 0N/A to take a const char* parameter. */ 0N/A ERROR1(
"PORT_GetIntValue(): inappropriate control type: %s\n",
0N/A ERROR1(
"PORT_SetIntValue(): inappropriate control type: %s\n",
0N/A // pan is the ratio of left and right 0N/A // volume is the greater value of both 0N/A * sets the unsigned values for left and right volume according to 0N/A * the given volume (0...1) and balance (-1..0..+1) 0N/A ERROR0(
"PORT_GetFloatValue(): Balance only allowed for stereo channels!\n");
0N/A ERROR1(
"PORT_GetFloatValue(): inappropriate control type: %s!\n",
0N/A ERROR0(
"PORT_SetFloatValue(): Balance only allowed for stereo channels!\n");
0N/A ERROR1(
"PORT_SetFloatValue(): inappropriate control type: %s!\n",