< prev index next >

src/java.desktop/unix/native/libjsound/PLATFORM_API_BsdOS_ALSA_Ports.c

Print this page
rev 16300 : 8170798: Fix minor issues in java2d and sound coding.
Reviewed-by: prr, serb
   1 /*
   2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 368        scale. */
 369     precision = 1.0F / getRange(min, max);
 370     control = (creator->newFloatControl)(creator, portControl, CONTROL_TYPE_VOLUME, 0.0F, +1.0F, precision, "");
 371     return control;
 372 }
 373 
 374 
 375 void PORT_GetControls(void* id, INT32 portIndex, PortControlCreator* creator) {
 376     PortMixer* portMixer;
 377     snd_mixer_elem_t* elem;
 378     void* control;
 379     PortControl* portControl;
 380     void* controls[10];
 381     int numControls;
 382     char* portName;
 383     int isPlayback = 0;
 384     int isMono;
 385     int isStereo;
 386     char* type;
 387     snd_mixer_selem_channel_id_t channel;

 388 
 389     TRACE0("> PORT_GetControls\n");
 390     if (id == NULL) {
 391         ERROR0("Invalid handle!");
 392         // $$mp: an error code should be returned.
 393         return;
 394     }
 395     portMixer = (PortMixer*) id;
 396     if (portIndex < 0 || portIndex >= portMixer->numElems) {
 397         ERROR0("Port index out of range!");
 398         // $$mp: an error code should be returned.
 399         return;
 400     }
 401     numControls = 0;
 402     elem = portMixer->elems[portIndex];
 403     if (snd_mixer_selem_has_playback_volume(elem) || snd_mixer_selem_has_capture_volume(elem)) {
 404         /* Since we've split/duplicated elements with both playback and capture on the recovery
 405            of elements, we now can assume that we handle only to deal with either playback or
 406            capture. */
 407         isPlayback = isPlaybackFunction(portMixer->types[portIndex]);


   1 /*
   2  * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 368        scale. */
 369     precision = 1.0F / getRange(min, max);
 370     control = (creator->newFloatControl)(creator, portControl, CONTROL_TYPE_VOLUME, 0.0F, +1.0F, precision, "");
 371     return control;
 372 }
 373 
 374 
 375 void PORT_GetControls(void* id, INT32 portIndex, PortControlCreator* creator) {
 376     PortMixer* portMixer;
 377     snd_mixer_elem_t* elem;
 378     void* control;
 379     PortControl* portControl;
 380     void* controls[10];
 381     int numControls;
 382     char* portName;
 383     int isPlayback = 0;
 384     int isMono;
 385     int isStereo;
 386     char* type;
 387     snd_mixer_selem_channel_id_t channel;
 388     memset(controls, 0, sizeof(controls));
 389 
 390     TRACE0("> PORT_GetControls\n");
 391     if (id == NULL) {
 392         ERROR0("Invalid handle!");
 393         // $$mp: an error code should be returned.
 394         return;
 395     }
 396     portMixer = (PortMixer*) id;
 397     if (portIndex < 0 || portIndex >= portMixer->numElems) {
 398         ERROR0("Port index out of range!");
 399         // $$mp: an error code should be returned.
 400         return;
 401     }
 402     numControls = 0;
 403     elem = portMixer->elems[portIndex];
 404     if (snd_mixer_selem_has_playback_volume(elem) || snd_mixer_selem_has_capture_volume(elem)) {
 405         /* Since we've split/duplicated elements with both playback and capture on the recovery
 406            of elements, we now can assume that we handle only to deal with either playback or
 407            capture. */
 408         isPlayback = isPlaybackFunction(portMixer->types[portIndex]);


< prev index next >