Supporting Multiple File Formats

The following example shows how the waveform audio MCD searches audio I/O procedures by defining MMIO_MEDIATYPE_AUDIO in the ulMedType field of the MMCTOCENTRY data structure. To search and identify other types of IOProcs, you can include one of the following media type flags:

Refer to the OS/2 Multimedia Programming Reference for further information.

           mmioinfo.aulInfo[ 3 ] = MMIO_MEDIATYPE_AUDIO;

           /* Open the file */


           pInstance->hmmio = mmioOpen ( pFileName,
                                         &mmioinfo,
                                         ulFlags);

           /* Check for errors--see comments from above */

           if (pInstance->hmmio == (ULONG) NULL)
             {
             if ( mmioinfo.ulErrorRet == MMIOERR_MEDIA_NOT_FOUND )
               {
               return  ( MCIERR_INVALID_MEDIA_TYPE );
               }

             return  ( mmioinfo.ulErrorRet );
             }

           pInstance->ulCapabilities = 0;

    else
        {
        /************************************************
        * Since the wave IOProc opened the file, we know
        * that it has the following capabilities.
        *************************************************/
        pInstance->ulCapabilities =  ( CAN_INSERT | CAN_DELETE | CAN_UNDOREDO +
                                       CAN_SAVE   | CAN_INSERT | CAN_RECORD  );
        }

  /******************************************
  * Get The Header Information
  *******************************************/

  if ( !(ulFlags & MMIO_CREATE) )
     {

      ulrc = GetAudioHeader (pInstance);

     } /* Not Create Flag */

  else
     {
     pInstance->ulDataSize = 0;
     }

  pInstance->fFileExists = TRUE;


  /*******************************************************************
  * You cannot do the set header immediately after file creation
  * because future sets on samples, bitpersample, channels may follow
 ********************************************************************/

  return (ulrc);

} /* OpenFile */


[Back: Initializing the Audio Device]
[Next: Networking Functions]