⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 crtchannel.3

📁 linux系统下的音频通信
💻 3
📖 第 1 页 / 共 2 页
字号:
error code. In addition, if an error occurs and \fIinterp\fR is not NULL,the procedure should store an error message in \fIinterp->result\fR..SH INPUTPROC.PPThe \fIinputProc\fR field contains the address of a function called by thegeneric layer to read data from the file or device and store it in aninternal buffer. \fIInputProc\fR must match the following prototype:.PP.CStypedef int Tcl_DriverInputProc(	ClientData \fIinstanceData\fR,	char *\fIbuf\fR,	int \fIbufSize\fR,	int *\fIerrorCodePtr\fR);.CE.PP\fIInstanceData\fR is the same as the value passed to\fBTcl_CreateChannel\fR when the channel was created.  The \fIbuf\fRargument points to an array of bytes in which to store input from thedevice, and the \fIbufSize\fR argument indicates how many bytes areavailable at \fIbuf\fR..PPThe \fIerrorCodePtr\fR argument points to an integer variable provided bythe generic layer. If an error occurs, the function should set the variableto a POSIX error code that identifies the error that occurred..PPThe function should read data from the input device encapsulated by thechannel and store it at \fIbuf\fR.  On success, the function should returna nonnegative integer indicating how many bytes were read from the inputdevice and stored at \fIbuf\fR. On error, the function should return -1. Ifan error occurs after some data has been read from the device, that data islost..PPIf \fIinputProc\fR can determine that the input device has some dataavailable but less than requested by the \fIbufSize\fR argument, thefunction should only attempt to read as much data as is available andreturn without blocking. If the input device has no data availablewhatsoever and the channel is in nonblocking mode, the function shouldreturn an \fBEAGAIN\fR error. If the input device has no data availablewhatsoever and the channel is in blocking mode, the function should blockfor the shortest possible time until at least one byte of data can be readfrom the device; then, it should return as much data as it can read withoutblocking..SH OUTPUTPROC.PPThe \fIoutputProc\fR field contains the address of a function called by thegeneric layer to transfer data from an internal buffer to the output device.\fIOutputProc\fR must match the following prototype:.PP.CStypedef int Tcl_DriverOutputProc(	ClientData \fIinstanceData\fR,	char *\fIbuf\fR,	int \fItoWrite\fR,	int *\fIerrorCodePtr\fR);.CE.PP\fIInstanceData\fR is the same as the value passed to\fBTcl_CreateChannel\fR when the channel was created. The \fIbuf\fRargument contains an array of bytes to be written to the device, and the\fItoWrite\fR argument indicates how many bytes are to be written from the\fIbuf\fR argument..PPThe \fIerrorCodePtr\fR argument points to an integer variable provided bythe generic layer. If an error occurs, the function should set thisvariable to a POSIX error code that identifies the error..PPThe function should write the data at \fIbuf\fR to the output deviceencapsulated by the channel. On success, the function should return anonnegative integer indicating how many bytes were written to the outputdevice.  The return value is normally the same as \fItoWrite\fR, but may beless in some cases such as if the output operation is interrupted by asignal. If an error occurs the function should return -1.  In case oferror, some data may have been written to the device..PPIf the channel is nonblocking and the output device is unable to absorb anydata whatsoever, the function should return -1 with an \fBEAGAIN\fR errorwithout writing any data..SH SEEKPROC.PPThe \fIseekProc\fR field contains the address of a function called by thegeneric layer to move the access point at which subsequent input or outputoperations will be applied. \fISeekProc\fR must match the followingprototype:.PP.CStypedef int Tcl_DriverSeekProc(	ClientData \fIinstanceData\fR,	long \fIoffset\fR,	int \fIseekMode\fR,	int *\fIerrorCodePtr\fR);.CE.PPThe \fIinstanceData\fR argument is the same as the value given to\fBTcl_CreateChannel\fR when this channel was created.  \fIOffset\fR and\fIseekMode\fR have the same meaning as for the \fBTcl_SeekChannel\fRprocedure (described in the manual entry for \fBTcl_OpenFileChannel\fR)..PPThe \fIerrorCodePtr\fR argument points to an integer variable provided bythe generic layer for returning \fBerrno\fR values from the function.  Thefunction should set this variable to a POSIX error code if an error occurs.The function should store an \fBEINVAL\fR error code if the channel typedoes not implement seeking..PPThe return value is the new access point or -1 in case of error. If anerror occurred, the function should not move the access point..SH SETOPTIONPROC.PPThe \fIsetOptionProc\fR field contains the address of a function called bythe generic layer to set a channel type specific option on a channel.\fIsetOptionProc\fR must match the following prototype:.PP.CStypedef int Tcl_DriverSetOptionProc(	ClientData \fIinstanceData\fR,	Tcl_Interp *\fIinterp\fR,	char *\fIoptionName\fR,	char *\fIoptionValue\fR);.CE.PP\fIoptionName\fR is the name of an option to set, and \fIoptionValue\fR isthe new value for that option, as a string. The \fIinstanceData\fR is thesame as the value given to \fBTcl_CreateChannel\fR when this channel wascreated. The function should do whatever channel type specific action isrequired to implement the new value of the option..PPSome options are handled by the generic code and this function is nevercalled to set them, e.g. \fB-blockmode\fR. Other options are specific toeach channel type and the \fIsetOptionProc\fR procedure of the channeldriver will get called to implement them. The \fIsetOptionProc\fR field canbe NULL, which indicates that this channel type supports no type specificoptions. .PPIf the option value is successfully modified to the new value, the functionreturns \fBTCL_OK\fR..VSIt should call \fBTcl_BadChannelOption\fR which itself returns\fBTCL_ERROR\fR if the \fIoptionName\fR isunrecognized. .VEIf \fIoptionValue\fR specifies a value for the option thatis not supported or if a system call error occurs,the function should leave an error message in the\fIresult\fR field of \fIinterp\fR if \fIinterp\fR is not NULL. Thefunction should also call \fBTcl_SetErrno\fR to store an appropriate POSIXerror code..SH GETOPTIONPROC.PPThe \fIgetOptionProc\fR field contains the address of a function called bythe generic layer to get the value of a channel type specific option on achannel. \fIgetOptionProc\fR must match the following prototype:.PP.CStypedef int Tcl_DriverGetOptionProc(	ClientData \fIinstanceData\fR,.VS	Tcl_Interp *\fIinterp\fR,.VE	char *\fIoptionName\fR,	Tcl_DString *\fIdsPtr\fR);.CE.PP\fIOptionName\fR is the name of an option supported by this type ofchannel. If the option name is not NULL, the function stores its currentvalue, as a string, in the Tcl dynamic string \fIdsPtr\fR.If \fIoptionName\fR is NULL, the function stores in \fIdsPtr\fR analternating list of all supported options and their current values.On success, the function returns \fBTCL_OK\fR. .VSIt should call \fBTcl_BadChannelOption\fR which itself returns\fBTCL_ERROR\fR if the \fIoptionName\fR isunrecognized. If a system call error occurs,the function should leave an error message in the\fIresult\fR field of \fIinterp\fR if \fIinterp\fR is not NULL. Thefunction should also call \fBTcl_SetErrno\fR to store an appropriate POSIXerror code..VE.PPSome options are handled by the generic code and this function is nevercalled to retrieve their value, e.g. \fB-blockmode\fR. Other options arespecific to each channel type and the \fIgetOptionProc\fR procedure of thechannel driver will get called to implement them. The \fIgetOptionProc\fRfield can be NULL, which indicates that this channel type supports no typespecific options..SH WATCHPROC.VS.PPThe \fIwatchProc\fR field contains the address of a function calledby the generic layer to initialize the event notification mechanism tonotice events of interest on this channel.\fIWatchProc\fR should match the following prototype:.PP.CStypedef void Tcl_DriverWatchProc(	ClientData \fIinstanceData\fR,	int \fImask\fR);.CE.VE.PPThe \fIinstanceData\fR is the same as the value passed to\fBTcl_CreateChannel\fR when this channel was created. The \fImask\fRargument is an OR-ed combination of \fBTCL_READABLE\fR, \fBTCL_WRITABLE\fRand \fBTCL_EXCEPTION\fR; it indicates events the caller is interested innoticing on this channel..PP.VSThe function should initialize device type specific mechanisms tonotice when an event of interest is present on the channel.  When oneor more of the designated events occurs on the channel, the channeldriver is responsible for calling \fBTcl_NotifyChannel\fR to informthe generic channel module.  The driver should take care not to starveother channel drivers or sources of callbacks by invokingTcl_NotifyChannel too frequently.  Fairness can be insured by usingthe Tcl event queue to allow the channel event to be scheduled in sequencewith other events.  See the description of \fBTcl_QueueEvent\fR fordetails on how to queue an event..SH GETHANDLEPROC.PPThe \fIgetHandleProc\fR field contains the address of a function called bythe generic layer to retrieve a device-specific handle from the channel.\fIGetHandleProc\fR should match the following prototype:.PP.CStypedef int Tcl_DriverGetHandleProc(	ClientData \fIinstanceData\fR,	int \fIdirection\fR,	ClientData *\fIhandlePtr\fR);.CE.PP\fIInstanceData is the same as the value passed to\fBTcl_CreateChannel\fR when this channel was created. The \fIdirection\fRargument is either \fBTCL_READABLE\fR to retrieve the handle usedfor input, or \fBTCL_WRITABLE\fR to retrieve the handle used foroutput..PPIf the channel implementation has device-specific handles, thefunction should retrieve the appropriate handle associated with thechannel, according the \fIdirection\fR argument.  The handle should bestored in the location referred to by \fIhandlePtr\fR, and\fBTCL_OK\fR should be returned.  If the channel is not open for thespecified direction, or if the channel implementation does not usedevice handles, the function should return \fBTCL_ERROR\fR..VE.VS.SH TCL_BADCHANNELOPTION.PPThis procedure generates a "bad option" error message in an(optional) interpreter.  It is used by channel drivers when a invalid Set/Get option is requested. Its purpose is to concatenatethe generic options list to the specific ones and factorizethe generic options error message string..PPIt always return \fBTCL_ERROR\fR.PPAn error message is generated in interp's result object toindicate that a command was invoked with the a bad optionThe message has the form.CS    bad option "blah": should be one of     <...generic options...>+<...specific options...>so you get for instance:    bad option "-blah": should be one of -blocking,    -buffering, -buffersize, -eofchar, -translation,    -peername, or -socknamewhen called with optionList="peername sockname".CE"blah" is the optionName argument and "<specific options>"is a space separated list of specific option words.The function takes good care of inserting minus signs beforeeach option, commas after, and an "or" before the last option..VE.SH "SEE ALSO"Tcl_Close(3), Tcl_OpenFileChannel(3), Tcl_SetErrno(3), Tcl_QueueEvent(3).SH KEYWORDSblocking, channel driver, channel registration, channel type, nonblocking

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -