ftp.nice.ch/peanuts/GeneralData/Documents/NeXT/MIDIDriver.tar.gz#/MIDIDriver/CFunctions/HandlingReplies.rtf

This is HandlingReplies.rtf in view mode; [Download] [Up]

paperh22175 margl-907 margr0 margt0 margb0 {fonttblf0fswiss Helvetica;f1froman Times;f2fmodern Courier;f3ftech Symbol;f4froman Palantino;}fi0 ri0 ql sb0 f1 fs24 Release 2.0  Copyright f3 'e3f1 1991 by NeXT Computer, Inc.  All Rights Reserved.

b fs36 f1 ql ri1007 li1108 fi-503 Handling Replies
fs16 
fs36 pard s28 li1108 fi0 ri1007 ql fs16 

fs36 midi_reply_handler()
fs16 
fs36 pard s20 li4636 fi-2520 ri1007 ql tx4636 b0 fs28 fs16 
fs28 SUMMARY	Dispatch messages sent asynchronously from the MIDI driver.
fs16 
fs28 pard s29 li2116 fi0 ri1007 ql fs16 fs28 SYNOPSIS
pard s5 li2620 fi0 ri1007 ql tx3124 tx3628 tx4132 b #import <midi/midi_reply_handler.h>
fs16 
fs28 pard s11 li3124 fi-503 ri1007 ql b0 kern_return_t b midi_reply_handler(b0 msg_header_t *i msgi0 , midi_reply_t *i midi_replyb i0 )
s9 li2116 fi503 fi0 b0 fs16 

fs28 ARGUMENTS
pard s17 li3124 fi-503 ri1007 ql tx3124 tx3628 tx4132 i msgi0 :  Pointer to message received from MIDI driver.
fs16 
fs28 i midi_replyi0 :  Pointer to the dispatch structure (see description).
fs16 
fs28 pard s9 li2116 fi0 ri1007 ql fs16 
fs28 DESCRIPTION
pard s2 li2620 fi0 ri1007 ql tx3124 tx3628 tx4132 The function b midi_reply_handler()b0  parses certain messages sent asynchronously by the driver, and then calls the appropriate one of several application-implemented functions.
fs16 
fs28 Specifically, b midi_get_data()b0  and b midi_output_queue_notify()b0  cause the driver to send messages asynchronously to the reply port specified in those calls.  (The maximum size of these messages is MIDI_REPLY_INMSG_SIZE.)  The application should retrieve each of these messages by calling b msg_receive()b0  (see the i NeXT Operating System Softwarei0  manual).  It should then examine the b msg_local_portb0  field of the message structure to verify that it'27s the same port as the reply port.  If so, it should pass a pointer to the received message as the first argument (i msgi0 ) to b midi_reply_handler()b0 .
fs16 
fs28 The second argument, i midi_replyi0 , is a pointer to a structure of the following type:
fs16 
fs28 s16 f2 fs24 typedef struct midi_reply {
fi0     kern_return_t (*ret_raw_data)(
fi0         void           *arg,
fi0         midi_raw_t      midi_raw_data,
fi0         u_int           midi_raw_dataCnt);
fi0     kern_return_t (*ret_cooked_data)(
fi0         void           *arg,
fi0         midi_cooked_t   midi_cooked_data,
fi0         u_int           midi_cooked_dataCnt);
fi0     kern_return_t (*ret_packed_data)(
fi0         void           *arg,
fi0         u_int           quanta,
fi0         midi_packed_t   midi_packed_data,
fi0         u_int           midi_packed_dataCnt);
fi0     kern_return_t (*queue_notify)(
fi0         void           *arg,
fi0         u_int           queue_size);
fi0     void *arg;            // argument to pass to function
fi0     int   timeout;        // timeout for RPC return msg_send
fi0 } midi_reply_t;
fi0 
pard s2 li2620 fi0 ri1007 ql tx3124 tx3628 tx4132 f1 fs28 This structure describes how the received message is to be dispatched.  The first four fields of the structure are pointers to application-supplied functions.  If the received message contains incoming MIDI data (resulting from an invocation of b midi_get_data()b0 ), b midi_reply_handler()b0  calls the appropriate one of the first three functions, depending on whether the data is raw, cooked, or packed.  Similarly, if the received message is a notification of available space in the output queue (resulting from an invocation of b midi_output_queue_notify()b0 ), b midi_reply_handler()b0  calls the fourth function.
fs16 
fs28 Each application-supplied function is passed the b void *b0 i  argi0  element from the structure as its first parameter.  If no function is specified (that is, the value of the appropriate structure member is zero), the received message is discarded.
fs16 
fs28 For example code, see b /NextDeveloper/Examples/MidiDriverb0 .
fs16 
fs28 pard s9 li2116 fi0 ri1007 ql fs16 
fs28 RETURN
pard s17 li3124 fi-503 ri1007 ql tx3124 tx3628 tx4132 KERN_SUCCESS:  Message dispatched.
fs16 
fs28 pard s28 li1108 fi0 ri1007 ql b fs36 fs16 



fs36 midi_timer_reply_handler()
fs16 
fs36 pard s20 li4636 fi-2520 ri1007 ql tx4636 b0 fs28 fs16 
fs28 SUMMARY	Dispatch messages sent asynchronously from the timer.
fs16 
fs28 pard s29 li2116 fi0 ri1007 ql fs16 fs28 SYNOPSIS
pard s5 li2620 fi0 ri1007 ql tx3124 tx3628 tx4132 b #import <midi/midi_timer_reply_handler.h>
fs16 
fs28 pard s11 li3124 fi-503 ri1007 ql b0 kern_return_t b midi_timer_reply_handler(b0 msg_header_t *i msgi0 , midi_timer_reply_t *i midi_timer_replyb i0 )
s9 li2116 fi503 fi0 b0 fs16 

fs28 ARGUMENTS
pard s17 li3124 fi-503 ri1007 ql tx3124 tx3628 tx4132 i msgi0 :  Pointer to message received from timer.
fs16 
fs28 i midi_timer_replyi0 :  Pointer to the dispatch structure (see description).
fs16 
fs28 pard s9 li2116 fi0 ri1007 ql fs16 
fs28 DESCRIPTION
pard s2 li2620 fi0 ri1007 ql tx3124 tx3628 tx4132 The function b midi_timer_reply_handler()b0  parses messages sent asynchronously by the timer, and then calls an appropriate application-implemented function.
fs16 
fs28 Specifically, b timer_timeval_req()b0  and b timer_quanta_req()b0  cause the timer to send messages asynchronously to the timer reply port specified in those calls.  (The maximum size of such a message is MIDI_TIMER_REPLY_INMSG_SIZE.)  The application should retrieve each of these messages by calling b msg_receive()b0  (see the i NeXT Operating System Softwarei0  manual).  It should then examine the b msg_local_portb0  field of the message structure to verify that it'27s the same port as the timer reply port.  (This port should be different from the reply port used by b midi_get_data()b0  and b midi_output_queue_notify()b0 .  Messages on that reply port should instead be handled by b midi_reply_handler()b0 .)  If the local port is the timer reply port, the application should pass a pointer to the received message as the first argument (i msgi0 ) to b midi_timer_reply_handler()b0 .
fs16 
fs28 The second argument, i midi_timer_replyi0 , is a pointer to a structure of the following type:
fs16 
fs28 s16 f2 fs24 typedef struct midi_timer_reply {
fi0     kern_return_t (*timer_event)(
fi0         void               *arg,
fi0         timeval_t           timeval,
fi0         u_int               quanta,
fi0         u_int               usec_per_quantum,
fi0         u_int               real_usec_per_quantum,
fi0         boolean_t           timer_expired,
fi0         boolean_t           timer_stopped,
fi0         boolean_t           timer_forward);
fi0     void *arg;                  // argument to pass to function
fi0     int   timeout;              // timeout for RPC return msg_send
fi0 } midi_timer_reply_t;
fi0 
pard s2 li2620 fi0 ri1007 ql tx3124 tx3628 tx4132 f1 fs28 This structure describes how the received message is to be dispatched.  The first field of the structure is a pointer to an application-supplied function that b midi_timer_reply_handler()b0  will call.  This application-supplied function is passed the b void *b0 i  argi0  element from the structure as its first parameter.  If no function is specified (that is, the value of the first structure member is zero), the received message is discarded.
fs16 
fs28 The application-supplied function is passed i timevali0  and i quantai0  parameters that indicate the time that the event occurred.  The i usec_per_quantumi0  parameter specifies the number of microseconds per quantum.  The i real_usec_per_quantumi0  parameter specifies the number of microseconds per quantum with respect to the system clock, rather than the timer'27s notion of seconds and microseconds.  The i timer_expiredi0  parameter, if set, indicates that the event that was requested has expired.  No further events will occur on this port.  If not set, it indicates that some other aspect of the timer has changed.  The i timer_stoppedi0  parameter indicates whether the timer is started or stopped.  The i timer_forwardi0  parameter indicates the direction in which the timer is changing, either forwards or backwards.
fs16 
fs28 For example code, see b /NextDeveloper/Examples/MidiDriverb0 .
fs16 
fs28 pard s9 li2116 fi0 ri1007 ql fs16 
fs28 RETURN
pard s2 li2620 fi0 ri1007 ql tx3124 tx3628 tx4132 KERN_SUCCESS:  Message dispatched.
fs16 
fs28 pard s24 li1108 fi-503 ri1007 ql b fs36 fs16 



fs36 }

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.