1/* 2 * Copyright (c) 1998-2010 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * The contents of this file constitute Original Code as defined in and 7 * are subject to the Apple Public Source License Version 1.1 (the 8 * "License"). You may not use this file except in compliance with the 9 * License. Please obtain a copy of the License at 10 * http://www.apple.com/publicsource and read it before using this file. 11 * 12 * This Original Code and all software distributed under the License are 13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER 14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the 17 * License for the specific language governing rights and limitations 18 * under the License. 19 * 20 * @APPLE_LICENSE_HEADER_END@ 21 */ 22 23#include "IOAudioToggleControl.h" 24#include "IOAudioTypes.h" 25#include "IOAudioDefines.h" 26 27#define super IOAudioControl 28 29OSDefineMetaClassAndStructors(IOAudioToggleControl, IOAudioControl) 30OSMetaClassDefineReservedUnused(IOAudioToggleControl, 0); 31OSMetaClassDefineReservedUnused(IOAudioToggleControl, 1); 32OSMetaClassDefineReservedUnused(IOAudioToggleControl, 2); 33OSMetaClassDefineReservedUnused(IOAudioToggleControl, 3); 34OSMetaClassDefineReservedUnused(IOAudioToggleControl, 4); 35OSMetaClassDefineReservedUnused(IOAudioToggleControl, 5); 36OSMetaClassDefineReservedUnused(IOAudioToggleControl, 6); 37OSMetaClassDefineReservedUnused(IOAudioToggleControl, 7); 38OSMetaClassDefineReservedUnused(IOAudioToggleControl, 8); 39OSMetaClassDefineReservedUnused(IOAudioToggleControl, 9); 40OSMetaClassDefineReservedUnused(IOAudioToggleControl, 10); 41OSMetaClassDefineReservedUnused(IOAudioToggleControl, 11); 42OSMetaClassDefineReservedUnused(IOAudioToggleControl, 12); 43OSMetaClassDefineReservedUnused(IOAudioToggleControl, 13); 44OSMetaClassDefineReservedUnused(IOAudioToggleControl, 14); 45OSMetaClassDefineReservedUnused(IOAudioToggleControl, 15); 46 47// New code added here 48IOAudioToggleControl *IOAudioToggleControl::createPassThruMuteControl (bool initialValue, 49 UInt32 channelID, 50 const char *channelName, 51 UInt32 cntrlID) 52{ 53 return create(initialValue, channelID, channelName, cntrlID, kIOAudioToggleControlSubTypeMute, kIOAudioControlUsagePassThru); 54} 55 56// Original code... 57IOAudioToggleControl *IOAudioToggleControl::create(bool initialValue, 58 UInt32 channelID, 59 const char *channelName, 60 UInt32 cntrlID, 61 UInt32 subType, 62 UInt32 usage) 63{ 64 IOAudioToggleControl *control; 65 66 control = new IOAudioToggleControl; 67 68 if (control) { 69 if (!control->init(initialValue, channelID, channelName, cntrlID, subType, usage)) { 70 control->release(); 71 control = 0; 72 } 73 } 74 75 return control; 76} 77 78IOAudioToggleControl *IOAudioToggleControl::createMuteControl(bool initialValue, 79 UInt32 channelID, 80 const char *channelName, 81 UInt32 cntrlID, 82 UInt32 usage) 83{ 84 return create(initialValue, channelID, channelName, cntrlID, kIOAudioToggleControlSubTypeMute, usage); 85} 86 87bool IOAudioToggleControl::init(bool initialValue, 88 UInt32 channelID, 89 const char *channelName, 90 UInt32 cntrlID, 91 UInt32 subType, 92 UInt32 usage, 93 OSDictionary *properties) 94{ 95 bool result = false; 96 OSNumber *number; 97 98 number = OSNumber::withNumber((initialValue == 0) ? 0 : 1, 8); 99 100 if (number) { 101 result = super::init(kIOAudioControlTypeToggle, number, channelID, channelName, cntrlID, subType, usage, properties); 102 103 number->release(); 104 } 105 106 return result; 107} 108 109