2 #include "asiodrivers.h"
4 AsioDrivers
* asioDrivers
= 0;
6 bool loadAsioDriver(char *name
);
8 bool loadAsioDriver(char *name
)
11 asioDrivers
= new AsioDrivers();
13 return asioDrivers
->loadDriver(name
);
17 //------------------------------------------------------------------------------------
21 bool resolveASIO(unsigned long aconnID
);
23 AsioDrivers::AsioDrivers() : CodeFragments("ASIO Drivers", 'AsDr', 'Asio')
29 AsioDrivers::~AsioDrivers()
31 removeCurrentDriver();
34 bool AsioDrivers::getCurrentDriverName(char *name
)
37 return getName(curIndex
, name
);
41 long AsioDrivers::getDriverNames(char **names
, long maxDrivers
)
43 for(long i
= 0; i
< getNumFragments() && i
< maxDrivers
; i
++)
45 return getNumFragments() < maxDrivers
? getNumFragments() : maxDrivers
;
48 bool AsioDrivers::loadDriver(char *name
)
53 for(long i
= 0; i
< getNumFragments(); i
++)
55 if(getName(i
, dname
) && !strcmp(name
, dname
))
57 if(newInstance(i
, &newID
))
59 if(resolveASIO(newID
))
62 removeInstance(curIndex
, connID
);
74 void AsioDrivers::removeCurrentDriver()
77 removeInstance(curIndex
, connID
);
82 //------------------------------------------------------------------------------------
88 extern IASIO
* theAsioDriver
;
90 AsioDrivers::AsioDrivers() : AsioDriverList()
95 AsioDrivers::~AsioDrivers()
99 bool AsioDrivers::getCurrentDriverName(char *name
)
102 return asioGetDriverName(curIndex
, name
, 32) == 0 ? true : false;
107 long AsioDrivers::getDriverNames(char **names
, long maxDrivers
)
109 for(long i
= 0; i
< asioGetNumDev() && i
< maxDrivers
; i
++)
110 asioGetDriverName(i
, names
[i
], 32);
111 return asioGetNumDev() < maxDrivers
? asioGetNumDev() : maxDrivers
;
114 bool AsioDrivers::loadDriver(char *name
)
119 for(long i
= 0; i
< asioGetNumDev(); i
++)
121 if(!asioGetDriverName(i
, dname
, 32) && !strcmp(name
, dname
))
124 getCurrentDriverName(curName
); // in case we fail...
125 removeCurrentDriver();
127 if(!asioOpenDriver(i
, (void **)&theAsioDriver
))
135 if(curName
[0] && strcmp(dname
, curName
))
136 loadDriver(curName
); // try restore
144 void AsioDrivers::removeCurrentDriver()
147 asioCloseDriver(curIndex
);
153 #include "asiolist.h"
155 AsioDrivers::AsioDrivers()
161 AsioDrivers::~AsioDrivers()
165 bool AsioDrivers::getCurrentDriverName(char *name
)
170 long AsioDrivers::getDriverNames(char **names
, long maxDrivers
)
175 bool AsioDrivers::loadDriver(char *name
)
180 void AsioDrivers::removeCurrentDriver()