1 /*
2 * Copyright (c) 2002, 2007, 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
373
374 void addAllControls(PortInfo* info, PortControlCreator* creator, void** controlObjects, int* controlCount) {
375 int i = 0;
376
377 TRACE0(">addAllControl\n");
378 // go through all controls and add them to the vector
379 for (i = 0; i < *controlCount; i++) {
380 (creator->addControl)(creator, controlObjects[i]);
381 }
382 *controlCount = 0;
383 TRACE0("<addAllControl\n");
384 }
385
386 void PORT_GetControls(void* id, INT32 portIndex, PortControlCreator* creator) {
387 PortInfo* info = (PortInfo*) id;
388 int portCount = PORT_GetPortCount(id);
389 void* controls[4];
390 int controlCount = 0;
391 INT32 type;
392 int selectable = 1;
393
394 TRACE4(">PORT_GetControls(id=%p, portIndex=%d). controlIDs=%p, maxControlCount=%d\n",
395 id, portIndex, info->controlIDs, info->maxControlCount);
396 if ((portIndex >= 0) && (portIndex < portCount)) {
397 // if the memory isn't reserved for the control structures, allocate it
398 if (!info->controlIDs) {
399 int maxCount = 0;
400 TRACE0("getControl: allocate mem\n");
401 // get a maximum number of controls:
402 // each port has a select, balance, and volume control.
403 maxCount = 3 * portCount;
404 // then there is monitorGain and outputMuted
405 maxCount += (2 * info->targetPortCount);
406 info->maxControlCount = maxCount;
407 info->controlIDs = (PortControlID*) malloc(sizeof(PortControlID) * maxCount);
408 }
409 if (!isSourcePort(info, portIndex)) {
410 type = PORT_CONTROL_TYPE_PLAY;
411 // add master mute control
412 createPortControl(info, creator, portIndex,
|
1 /*
2 * Copyright (c) 2002, 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
373
374 void addAllControls(PortInfo* info, PortControlCreator* creator, void** controlObjects, int* controlCount) {
375 int i = 0;
376
377 TRACE0(">addAllControl\n");
378 // go through all controls and add them to the vector
379 for (i = 0; i < *controlCount; i++) {
380 (creator->addControl)(creator, controlObjects[i]);
381 }
382 *controlCount = 0;
383 TRACE0("<addAllControl\n");
384 }
385
386 void PORT_GetControls(void* id, INT32 portIndex, PortControlCreator* creator) {
387 PortInfo* info = (PortInfo*) id;
388 int portCount = PORT_GetPortCount(id);
389 void* controls[4];
390 int controlCount = 0;
391 INT32 type;
392 int selectable = 1;
393 memset(controls, 0, sizeof(controls));
394
395 TRACE4(">PORT_GetControls(id=%p, portIndex=%d). controlIDs=%p, maxControlCount=%d\n",
396 id, portIndex, info->controlIDs, info->maxControlCount);
397 if ((portIndex >= 0) && (portIndex < portCount)) {
398 // if the memory isn't reserved for the control structures, allocate it
399 if (!info->controlIDs) {
400 int maxCount = 0;
401 TRACE0("getControl: allocate mem\n");
402 // get a maximum number of controls:
403 // each port has a select, balance, and volume control.
404 maxCount = 3 * portCount;
405 // then there is monitorGain and outputMuted
406 maxCount += (2 * info->targetPortCount);
407 info->maxControlCount = maxCount;
408 info->controlIDs = (PortControlID*) malloc(sizeof(PortControlID) * maxCount);
409 }
410 if (!isSourcePort(info, portIndex)) {
411 type = PORT_CONTROL_TYPE_PLAY;
412 // add master mute control
413 createPortControl(info, creator, portIndex,
|