[Contents] [Index] [Help] [Retrace] [Browse <] [Browse >]

Three primary steps are required to open the narrator device:

   *  Create a message port using CreatePort(). Reply messages from the
      device must be directed to a message port.

   *  Create an extended I/O request structure of type narrator_rb.  The
      narrator_rb structure is created by the CreateExtIO() function.

   *  Open the narrator device.  Call OpenDevice() passing the I/O request.

    struct MsgPort *VoiceMP;
    struct narrator_rb *VoiceIO;

    if (VoiceMP = CreatePort("speech_write",0))
        if (VoiceIO = (struct narrator_rb *)
                        CreateExtIO(VoiceMP,sizeof(struct narrator_rb));
            if (OpenDevice("narrator.device", 0, VoiceIO, 0))
                    printf("narrator.device did not open\n");

When the narrator device is first opened, it initializes certain fields in
the user's narrator_rb I/O request structure.  In order to maintain
backwards compatibility with older versions of the narrator device, a
mechanism was needed for the device to ascertain whether it was being
opened with a V37 or pre-V37 style I/O request structure. The pad field in
the pre-V37 narrator_rb I/O request structure (which no one should have
ever touched!) has been replaced by the flags field in the V37 narrator_rb
structure, and is our path to upward compatibility.  The device checks to
see if a bit is set in this flags field.  This bit must be set before
opening the device if V37 or later features of the narrator device are to
be used.  There are two defined constants in the include file, NDB_NEWIORB
and NDF_NEWIORB. NDB_NEWIORB specifies the bit which must be set in the
flags field, NDF_NEWIORB is the field definition of the bit (1 <<

Once the device is opened, the mouth_rb (read) I/O request structure can
be set up.  Each CMD_READ request must be matched with an associated
CMD_WRITE request.  This is necessary for the device to match the various
sync events with a particular utterance.  The read I/O request structure
is easily set up as follows:

   *  Create a read message port using the CreatePort() function.

   *  Allocate memory for the mouth_rb extended I/O request structure using

   *  Copy the narrator_rb I/O request structure used to open the device
      into the voice field of the mouth_rb I/O request structure. This will
      set the fields necessary for the device to make the correct
      correspondence between read and write requests.

   *  Copy the pointer to the read message port returned from CreatePort()
      into the voice.message.io_Message.mn_ReplyPort field of the mouth_rb

The following code fragment, in conjunction with the OpenDevice() code
fragment above, shows how to set up the mouth_rb structure:

    struct  MsgPort   *MouthMP;
    struct  mouth_rb  *MouthIO;

    if (MouthMP = CreatePort("narrator_read", 0))
      if (!(MouthIO = (struct mouth_rb *)
                 AllocMem(sizeof(struct mouth_rb),MEMF_PUBLIC|MEMF_CLEAR)))
          /* Copy I/O request used in OpenDevice */
          MouthIO->voice = *VoiceIO;
          /* Set port */
          printf("AllocMem failed\n");
        printf("CreatePort failed\n");

[Back to Amiga Developer Docs]