rem: _DevOpen ( ULONG              unit,
add: _DevOpen ( struct AHIRequest* ioreq, ULONG              unit,
context: _DevOpen ( ULONG              unit,	   ULONG              flags,	   struct AHIRequest* ioreq,	   struct AHIBase*    AHIBase ){  ULONG rc = 0;  BOOL  error = FALSE;  struct AHIDevUnit *iounit=NULL;  if(AHIBase->ahib_DebugLevel >= AHI_DEBUG_LOW)  {    KPrintF("OpenDevice(%ld, 0x%08lx, %ld)", unit, (ULONG) ioreq, flags);  }// Check if size includes the ahir_Version field  if(ioreq->ahir_Std.io_Message.mn_Length < (sizeof(struct IOStdReq) + 2))  {    Req( "Bad parameters to OpenDevice()." );    ioreq->ahir_Std.io_Error=IOERR_OPENFAIL;    return IOERR_OPENFAIL;  }// One more check...  if((unit != AHI_NO_UNIT) && (ioreq->ahir_Version >= Version))  {    if(ioreq->ahir_Std.io_Message.mn_Length < sizeof(struct AHIRequest))    {      Req( "Bad parameters to OpenDevice()." );      ioreq->ahir_Std.io_Error=IOERR_OPENFAIL;      return IOERR_OPENFAIL;    }  }  AHIBase->ahib_Library.lib_OpenCnt++;  ObtainSemaphore(&AHIBase->ahib_Lock);  if( ! (flags & AHIDF_NOMODESCAN))  {    // Load database if not already loaded    if(AHI_NextAudioID(AHI_INVALID_ID) == (ULONG) AHI_INVALID_ID)    {      AHI_LoadModeFile("DEVS:AudioModes");#ifdef __MORPHOS__      // Be quiet here. - Piru      {        struct Process *Self = (struct Process *) FindTask(NULL);        APTR oldwindowptr = Self->pr_WindowPtr;        Self->pr_WindowPtr = (APTR) -1;        AHI_LoadModeFile("MOSSYS:DEVS/AudioModes");        Self->pr_WindowPtr = oldwindowptr;      }#endif    }  }  if( ioreq->ahir_Version > Version)    error=TRUE;  else  {    if(unit < AHI_UNITS)    {      iounit=InitUnit(unit,AHIBase);      if(!iounit)         error=TRUE;    }    else if(unit == AHI_NO_UNIT)      InitUnit(unit,AHIBase);  }  if(!error)  {/*     KPrintF( "Tagging %08lx on task %08lx\n", ioreq, FindTask(0)); */    ioreq->ahir_Private[1] = (ULONG) ioreq;    ioreq->ahir_Std.io_Unit=(struct Unit *) iounit;    if(iounit)    // Is NULL for AHI_NO_UNIT      iounit->Unit.unit_OpenCnt++;    AHIBase->ahib_Library.lib_OpenCnt++;    AHIBase->ahib_Library.lib_Flags &=~LIBF_DELEXP;  }  else  {    rc=IOERR_OPENFAIL;    ioreq->ahir_Std.io_Error=IOERR_OPENFAIL;    ioreq->ahir_Std.io_Device=(struct Device *) -1;    ioreq->ahir_Std.io_Unit=(struct Unit *) -1;  }  ReleaseSemaphore(&AHIBase->ahib_Lock);  AHIBase->ahib_Library.lib_OpenCnt--;  if(AHIBase->ahib_DebugLevel >= AHI_DEBUG_LOW)  {    KPrintF("=>%ld\n",rc);  }  return rc;}