Annotation of driverkit/libDriver/Kernel/AudioCommand.m, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: 
                     25: #import "AudioCommand.h"
                     26: #import <driverkit/IOAudioPrivate.h>           // AD_CMD_MSG_SYNCHRONOUS
                     27: 
                     28: #import <mach/message.h>               // msg_header_t
                     29: #import <machkit/NXLock.h>
                     30: #import <driverkit/kernelDriver.h>
                     31:  
                     32: /*
                     33:  * FIXME: This is from <kern/ipc_basics.h>, which can't be
                     34:  * imported because of a conflict with <mach/mach_types.h>
                     35:  */
                     36: extern msg_return_t msg_send_from_kernel();
                     37: 
                     38: @implementation AudioCommand
                     39: 
                     40: - initPort:(port_t)port
                     41: {
                     42:     [super init];
                     43: 
                     44:     interLock = [[NXConditionLock alloc] initWith:AUDIO_COMMAND_IDLE];
                     45:     driverPort_kern = port;
                     46:     return self;
                     47: }
                     48: 
                     49: - free
                     50: {
                     51:     [interLock free];
                     52:     return [super free];
                     53: }
                     54: 
                     55: - (ADCommand) command
                     56: {
                     57:     return (command);
                     58: }
                     59: 
                     60: - (void)done:(int)_ret
                     61: {
                     62:     if ([interLock condition] == AUDIO_COMMAND_BUSY) {
                     63:        [interLock lock];
                     64:        ret = _ret;
                     65:        [interLock unlockWith:AUDIO_COMMAND_DONE];
                     66:     }
                     67: 
                     68: }
                     69: 
                     70: - (int)send:(ADCommand)_command
                     71: {
                     72:     msg_header_t       msg = { 0 };
                     73:     int                        result = 0;
                     74:  
                     75:  
                     76:      [interLock lockWhen:AUDIO_COMMAND_IDLE];
                     77:         
                     78:     command = _command;
                     79:     
                     80:     msg.msg_size = sizeof (msg);
                     81:     msg.msg_remote_port = driverPort_kern;
                     82:     msg.msg_id =  AD_CMD_MSG_SYNCHRONOUS;
                     83:     
                     84:     [interLock unlockWith:AUDIO_COMMAND_BUSY];
                     85:     
                     86:     result = msg_send_from_kernel(&msg, SEND_TIMEOUT, 1000);
                     87:     if (result == SEND_SUCCESS) {
                     88:        [interLock lockWhen:AUDIO_COMMAND_DONE];
                     89:        result = ret;
                     90:     }
                     91:     else
                     92:        [interLock lock];
                     93:     
                     94:     [interLock unlockWith:AUDIO_COMMAND_IDLE];
                     95:     
                     96:     return (result);
                     97: 
                     98: }
                     99: 
                    100: @end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.