123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181(*
Copyright (C) 2003 Bardur Arantsson
Copyright (C) 2004-2010 The Savonet Team
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*)typedevicetypet={device:device;mutableclosed:bool}typedriver_kind_t=[`LIVE|`FILE|`UNKNOWN]typebyte_format_t=[`LITTLE_ENDIAN|`BIG_ENDIAN|`NATIVE|`UNKNOWN]typedriver_t={id:int;kind:driver_kind_t;short_name:string;name:string;comment:string;author:string;priority:int;preferred_byte_format:byte_format_t;options:stringlist}typeinternal_driver_t=intexceptionClosedexceptionInvalid_valuelet()=Callback.register_exception"ocaml_ao_exn_invalid_value"Invalid_valueexternal_initialize:unit->unit="ocaml_ao_stubs_initialize"external_shutdown:unit->unit="ocaml_ao_stubs_shutdown"let()=_initialize();at_exit_shutdownexternaldriver_kind:internal_driver_t->driver_kind_t="ocaml_ao_stubs_driver_kind"externaldriver_name:internal_driver_t->string="ocaml_ao_stubs_driver_name"externaldriver_short_name:internal_driver_t->string="ocaml_ao_stubs_driver_short_name"externaldriver_comment:internal_driver_t->string="ocaml_ao_stubs_driver_comment"externaldriver_author:internal_driver_t->string="ocaml_ao_stubs_driver_author"externaldriver_priority:internal_driver_t->int="ocaml_ao_stubs_driver_priority"externaldriver_preferred_byte_format:internal_driver_t->byte_format_t="ocaml_ao_stubs_driver_preferred_byte_format"externaldriver_options:internal_driver_t->stringlist="ocaml_ao_stubs_driver_options"letdriver_of_internal_driverx={id=x;kind=driver_kindx;short_name=driver_short_namex;name=driver_namex;comment=driver_commentx;author=driver_authorx;priority=driver_priorityx;preferred_byte_format=driver_preferred_byte_formatx;options=driver_optionsx}externalget_default_driver:unit->internal_driver_t="ocaml_ao_stubs_get_default_driver"letget_default_driver()=driver_of_internal_driver(get_default_driver())externalget_drivers:unit->internal_driver_tlist="ocaml_ao_stubs_get_drivers"letget_drivers()=List.mapdriver_of_internal_driver(get_drivers())externalfind_driver:string->internal_driver_t="ocaml_ao_stubs_find_driver"letfind_driverx=driver_of_internal_driver(find_driverx)letdrivers=get_drivers()externalclose:device->unit="ocaml_ao_stubs_close"letgc_closex=ifnotx.closedthenclosex.deviceletclosex=ifx.closedthenraiseClosed;closex.device;x.closed<-trueexternalopen_live_aux:int->int->int->string->byte_format_t->(string*string)list->internal_driver_t->device="ocaml_ao_stubs_open_live_aux_bytecode""ocaml_ao_stubs_open_live_aux_native"letopen_live?bits:(bits=16)?rate:(rate=44100)?channels:(channels=2)?channels_matrix?byte_format:(byte_format=`LITTLE_ENDIAN)?options:(options=[])?driver:(driver=get_default_driver())()=letchannels_matrix=matchchannels_matrixwith|None->""|Somex->xinletdev=open_live_auxbitsratechannelschannels_matrixbyte_formatoptionsdriver.idinletret={device=dev;closed=false}inGc.finalisegc_closeret;retexternalopen_file_aux:int->int->int->string->byte_format_t->(string*string)list->internal_driver_t->bool->string->device="ocaml_ao_stubs_open_file_aux_bytecode""ocaml_ao_stubs_open_file_aux_native"letopen_file?bits:(bits=16)?rate:(rate=44100)?channels:(channels=2)?channels_matrix?byte_format:(byte_format=`LITTLE_ENDIAN)?options:(options=[])?driver:(driver=get_default_driver())?overwrite:(overwrite=false)(filename:string)=letchannels_matrix=matchchannels_matrixwith|None->""|Somex->xinletdev=open_file_auxbitsratechannelschannels_matrixbyte_formatoptionsdriver.idoverwritefilenameinletret={device=dev;closed=false}inGc.finalisegc_closeret;retexternalplay:device->string->unit="ocaml_ao_stubs_play"letplayxs=ifx.closedthenraiseClosed;playx.devicesletdriver_kindd=d.kindletdriver_named=d.nameletdriver_short_named=d.short_nameletdriver_commentd=d.commentletdriver_authord=d.authorletdriver_priorityd=d.priorityletdriver_preferred_byte_formatd=d.preferred_byte_formatletdriver_optionsd=d.options