Exemplo n.º 1
0
void OSS_Reset(void)
{
    if (audio_fd >= 0)
    {
    	int value = 0;
	
    	Hidd_UnixIO_IOControlFile((HIDD *)unixio, audio_fd, SNDCTL_DSP_RESET, &value, NULL);
    }
}
Exemplo n.º 2
0
static BOOL get_capabilities(void)
{    
    if (audio_capabilities) return TRUE;
    if (audio_fd < 0) return FALSE;
    
    Hidd_UnixIO_IOControlFile((HIDD *)unixio, audio_fd, SNDCTL_DSP_GETCAPS, &audio_capabilities, NULL);
    
    return TRUE;
    
}
Exemplo n.º 3
0
static BOOL get_supported_fmts(void)
{
    if (audio_supported_fmts) return TRUE;
    if (audio_fd < 0) return FALSE;
    
    Hidd_UnixIO_IOControlFile((HIDD *)unixio, audio_fd, SNDCTL_DSP_GETFMTS, &audio_supported_fmts, NULL);
    
    return TRUE;
    
}
Exemplo n.º 4
0
BOOL OSS_SetStereo(void)
{
    int val = 1;
    int retval;
    
    if (audio_fd < 0) return FALSE;
    
    retval = Hidd_UnixIO_IOControlFile((HIDD *)unixio, audio_fd, SNDCTL_DSP_STEREO, &val, NULL);
    
    if ((retval < 0) || (val != 1)) return FALSE;
    
    return TRUE;
}
Exemplo n.º 5
0
BOOL OSS_SetTrigger(BOOL input, BOOL output)
{
    int val = 0;
    int retval;
    
    if (audio_fd < 0) return FALSE;
    
    if (input) val |= PCM_ENABLE_INPUT;
    if (output) val |= PCM_ENABLE_OUTPUT;

    retval = Hidd_UnixIO_IOControlFile((HIDD *)unixio, audio_fd, SNDCTL_DSP_SETTRIGGER, &val, NULL);   
    
    return (retval < 0) ? FALSE : TRUE;
}
Exemplo n.º 6
0
BOOL OSS_SetNumChannels(int numchannels)
{
    int val = numchannels;
    int retval;
    
    if (audio_fd < 0) return FALSE;
    
    retval = Hidd_UnixIO_IOControlFile((HIDD *)unixio, audio_fd, SNDCTL_DSP_CHANNELS, &val, NULL);   
    if (retval < 0)
    {
    	return (numchannels > 1) ? OSS_SetStereo() : OSS_SetMono();
    }
    
    return TRUE;  
}
Exemplo n.º 7
0
BOOL OSS_SetFragmentSize(int num_fragments, int fragment_size)
{
    if (audio_fd >= 0)
    {
    	int value;
	int retval;
	
	value = (num_fragments << 16) | fragment_size;
	
	retval = Hidd_UnixIO_IOControlFile((HIDD *)unixio, audio_fd, SNDCTL_DSP_SETFRAGMENT, &value, NULL);
	return (retval < 0) ? FALSE : TRUE;
    }
    else
    {
    	return FALSE;
    }
}
Exemplo n.º 8
0
BOOL OSS_SetWriteRate(int rate, int *used_rate)
{
    int val = rate;
    int retval;
    
    if (audio_fd < 0) return FALSE;
    
    retval = Hidd_UnixIO_IOControlFile((HIDD *)unixio, audio_fd, SOUND_PCM_WRITE_RATE, &val, NULL);   
    if (retval < 0)
    {
    	return FALSE;
    }
    
    if (used_rate) *used_rate = val;
    
    return TRUE;  
}
Exemplo n.º 9
0
static BOOL set_format(int fmt)
{
    if (audio_fd >= 0)
    {
    	int val = fmt;	
    	int retval = Hidd_UnixIO_IOControlFile((HIDD *)unixio, audio_fd, SNDCTL_DSP_SETFMT, &val, NULL);

	if ((val != fmt) || (retval < 0))
	{
	    return FALSE;
	}
	
	return TRUE;
    	
    }
    else
    {
    	return FALSE;
    }
}
Exemplo n.º 10
0
BOOL OSS_GetOutputPointer(int *processed_bytes, int *fragment_transitions, int *dmapointer)
{
    if (audio_fd >= 0)
    {
    	count_info info;
	
	Hidd_UnixIO_IOControlFile((HIDD *)unixio, audio_fd, SNDCTL_DSP_GETOPTR, &info, NULL);
	
	if (processed_bytes) *processed_bytes = info.bytes;
	if (fragment_transitions) *fragment_transitions = info.blocks;
	if (dmapointer) *dmapointer = info.ptr;
	
	return TRUE;
    }
    else
    {
    	return FALSE;
    }
    
}
Exemplo n.º 11
0
BOOL OSS_GetOutputInfo(int *num_fragments_available, int *num_fragments_allocated,
    	    	       int *fragment_size, int *num_bytes_available)

{
    if (audio_fd >= 0)
    {
    	audio_buf_info info;
	
	Hidd_UnixIO_IOControlFile((HIDD *)unixio, audio_fd, SNDCTL_DSP_GETOSPACE, &info, NULL);
	
	if (num_fragments_available) *num_fragments_available = info.fragments;
	if (num_fragments_allocated) *num_fragments_allocated = info.fragstotal;
	if (fragment_size) *fragment_size = info.fragsize;
	if (num_bytes_available) *num_bytes_available = info.bytes;
	
	return TRUE;
    }
    else
    {
    	return FALSE;
    }
}
Exemplo n.º 12
0
/******* TapUnit::New() ***********************************/
OOP_Object *UXTapUnit__Root__New(OOP_Class *cl, OOP_Object *obj, struct pRoot_New *msg)
{
	struct HIDDTapUnitData * data;
	static const struct TagItem tags[] = {{ TAG_END, 0}};
	struct TagItem *tag, *tstate;
	ULONG unitnum = 0;
	
	EnterFunc(bug("TapUnit::New()\n"));

	tstate = msg->attrList;
	while ((tag = NextTagItem((const struct TagItem **)&tstate))) {
		ULONG idx;

		if (IS_HIDDTAPUNIT_ATTR(tag->ti_Tag, idx)) {
			switch (idx) {
				case aoHidd_TapUnit_Unit:
					unitnum = (ULONG)tag->ti_Data;
				break;
			}
		}

	} /* while (tags to process) */
		
	D(bug("!!!!Request for unit number %d\n",unitnum));

	obj = (OOP_Object *)OOP_DoSuperMethod(cl, obj, (OOP_Msg)msg);

	if (obj) {
		data = OOP_INST_DATA(cl, obj);
		
		data->unitnum = unitnum;

		D(bug("Creating network device %s.\n",unitname[data->unitnum]));

		data->filedescriptor = unix_open_nonblock("/dev/net/tun");
		if (data->filedescriptor < 0)
			data->filedescriptor = unix_open_nonblock("/dev/tap");

		D(bug("Opened %s on handle %d\n",unitname[data->unitnum], data->filedescriptor));
		
		if (-1 != data->filedescriptor) {
			struct ifreq ifr;
			memset(&ifr, 0, sizeof(ifr));
			ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
			strncpy(ifr.ifr_name, unitname[data->unitnum], IFNAMSIZ);
			
			/*
			** Configure the tty driver ?!?!?!
			*/
			{
				data->replyport_read = AllocMem(sizeof(struct MsgPort), MEMF_PUBLIC|MEMF_CLEAR);
				data->replyport_write= AllocMem(sizeof(struct MsgPort), MEMF_PUBLIC|MEMF_CLEAR);

				if (data->replyport_read && data->replyport_write) {
					/*
					** Init the msg ports. They don't need a signal to be allocated
					*/
					NEWLIST(&data->replyport_read->mp_MsgList);
					data->replyport_read ->mp_Node.ln_Type = NT_MSGPORT;

					NEWLIST(&data->replyport_write->mp_MsgList);
					data->replyport_write->mp_Node.ln_Type = NT_MSGPORT;

					data->softint_read	= AllocMem(sizeof(struct Interrupt), MEMF_CLEAR);
					data->softint_write = AllocMem(sizeof(struct Interrupt), MEMF_CLEAR);

					if (data->softint_read && data->softint_write) {
						data->softint_read->is_Data = data;
						data->softint_read->is_Code = tapunit_receive_data;

						data->softint_write->is_Data = data;
						data->softint_write->is_Code = tapunit_write_more_data;

						data->replyport_read->mp_Flags = PA_SOFTINT;
						data->replyport_read->mp_SoftInt = data->softint_read;

						data->replyport_write->mp_Flags = PA_SOFTINT;
						data->replyport_write->mp_SoftInt = data->softint_write;

						data->unixio_read	= OOP_NewObject(NULL, CLID_Hidd_UnixIO, (struct TagItem *)tags);
						data->unixio_write = OOP_NewObject(NULL, CLID_Hidd_UnixIO, (struct TagItem *)tags);

						if (NULL != data->unixio_read && NULL != data->unixio_write)
						{
							Hidd_UnixIO_IOControlFile(data->unixio_read, 
							    data->filedescriptor,
							    TUNSETIFF,
							    &ifr,
							    NULL);
							    
							ULONG error;
							D(bug("Creating UnixIO AsyncIO command!\n"));

							error = Hidd_UnixIO_AsyncIO(data->unixio_read,
							                            data->filedescriptor,
							                            vHidd_UnixIO_Terminal,
							                            data->replyport_read,
							                            vHidd_UnixIO_Read | vHidd_UnixIO_Keep,
							                            SysBase);

							error = Hidd_UnixIO_AsyncIO(data->unixio_write,
							                            data->filedescriptor,
							                            vHidd_UnixIO_Terminal,
							                            data->replyport_write,
							                            vHidd_UnixIO_Write | vHidd_UnixIO_Keep,
							                            SysBase);
							goto exit;

						}

						if (NULL != data->unixio_read)
							OOP_DisposeObject(data->unixio_read);

						if (NULL != data->unixio_write)
							OOP_DisposeObject(data->unixio_write);
					}
					
					if (data->softint_read) 
						FreeMem(data->softint_read, sizeof(struct Interrupt));
					if (data->softint_write)
						FreeMem(data->softint_write, sizeof(struct Interrupt));
				}
				
				if (data->replyport_read)
					FreeMem(data->replyport_read , sizeof(struct MsgPort));
				if (data->replyport_write)
					FreeMem(data->replyport_write, sizeof(struct MsgPort));

			} 
			
			close(data->filedescriptor);	
		}

		OOP_DisposeObject(obj);
		obj = NULL;
	} /* if (obj) */

	D(bug("%s - an error occurred!\n",__FUNCTION__));

exit:
	ReturnPtr("TapUnit::New()", OOP_Object *, obj);
}