src/share/classes/com/sun/media/sound/PortMixer.java

Print this page


   1 /*
   2  * Copyright (c) 2002, 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


 195 
 196         case DST_UNKNOWN:      return new PortInfo(nGetPortName(getID(), portIndex), false);
 197         case DST_SPEAKER:      return Port.Info.SPEAKER;
 198         case DST_HEADPHONE:    return Port.Info.HEADPHONE;
 199         case DST_LINE_OUT:     return Port.Info.LINE_OUT;
 200         }
 201         // should never happen...
 202         if (Printer.debug) Printer.debug("unknown port type: "+type);
 203         return null;
 204     }
 205 
 206     int getMixerIndex() {
 207         return ((PortMixerProvider.PortMixerInfo) getMixerInfo()).getIndex();
 208     }
 209 
 210     Port getPort(int index) {
 211         if (ports == null) {
 212             ports = new PortMixerPort[portInfos.length];
 213         }
 214         if (ports[index] == null) {
 215             ports[index] = new PortMixerPort((Port.Info)portInfos[index], this, index);
 216             return ports[index];
 217         }
 218         // $$fb TODO: return (Port) (ports[index].clone());
 219         return ports[index];
 220     }
 221 
 222     long getID() {
 223         return id;
 224     }
 225 
 226     // INNER CLASSES
 227 
 228     /**
 229      * Private inner class representing a Port for the PortMixer.
 230      */
 231     private static final class PortMixerPort extends AbstractLine
 232             implements Port {
 233 
 234         private final int portIndex;
 235         private long id;


   1 /*
   2  * Copyright (c) 2002, 2014, 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


 195 
 196         case DST_UNKNOWN:      return new PortInfo(nGetPortName(getID(), portIndex), false);
 197         case DST_SPEAKER:      return Port.Info.SPEAKER;
 198         case DST_HEADPHONE:    return Port.Info.HEADPHONE;
 199         case DST_LINE_OUT:     return Port.Info.LINE_OUT;
 200         }
 201         // should never happen...
 202         if (Printer.debug) Printer.debug("unknown port type: "+type);
 203         return null;
 204     }
 205 
 206     int getMixerIndex() {
 207         return ((PortMixerProvider.PortMixerInfo) getMixerInfo()).getIndex();
 208     }
 209 
 210     Port getPort(int index) {
 211         if (ports == null) {
 212             ports = new PortMixerPort[portInfos.length];
 213         }
 214         if (ports[index] == null) {
 215             ports[index] = new PortMixerPort(portInfos[index], this, index);
 216             return ports[index];
 217         }
 218         // $$fb TODO: return (Port) (ports[index].clone());
 219         return ports[index];
 220     }
 221 
 222     long getID() {
 223         return id;
 224     }
 225 
 226     // INNER CLASSES
 227 
 228     /**
 229      * Private inner class representing a Port for the PortMixer.
 230      */
 231     private static final class PortMixerPort extends AbstractLine
 232             implements Port {
 233 
 234         private final int portIndex;
 235         private long id;