static int open_output(void){	double rate;	int n, nrates, include_enc, exclude_enc;	PaSampleFormat SampleFormat, nativeSampleFormats;#ifdef AU_PORTAUDIO_DLL  {		if(&dpm == &portaudio_asio_play_mode){			if(load_portaudio_dll(PA_DLL_ASIO))				return -1;		} else if(&dpm == &portaudio_win_ds_play_mode){			if(load_portaudio_dll(PA_DLL_WIN_DS))				return -1;		} else if(&dpm == &portaudio_win_wmme_play_mode){			if(load_portaudio_dll(PA_DLL_WIN_WMME))				return -1;		} else {			return -1;		}  }#endif	if(pa_active == 0){		err = Pa_Initialize();		if( err != paNoError ) goto error;		pa_active = 1;	}#ifdef PORTAUDIO_V19	DeviceIndex = Pa_GetDefaultOutputDevice();	if(DeviceIndex==paNoDevice) goto error;	DeviceInfo = Pa_GetDeviceInfo( DeviceIndex);	if(DeviceInfo==NULL) goto error;	if (dpm.encoding & PE_24BIT) {		SampleFormat = paInt24;	}else if (dpm.encoding & PE_16BIT) {		if(nativeSampleFormats & paInt16) SampleFormat = paInt16;		else{			SampleFormat = paInt32;			conv16_32 = 1;		}	}else {		SampleFormat = paInt8;	}	stereo = (dpm.encoding & PE_MONO) ? 1 : 2;	data_nbyte = (dpm.encoding & PE_16BIT) ? 2 : 1;	data_nbyte = (dpm.encoding & PE_24BIT) ? 3 : data_nbyte;		pa_data.samplesToGo = 0;	pa_data.bufpoint = pa_data.buf;	pa_data.bufepoint = pa_data.buf;//	firsttime = 1;	numBuffers = 1; //Pa_GetMinNumBuffers( framesPerBuffer, dpm.rate );	framesPerInBuffer = numBuffers * framesPerBuffer;	if (framesPerInBuffer < 4096) framesPerInBuffer = 4096;	bytesPerInBuffer = framesPerInBuffer * data_nbyte * stereo;//	printf("%d\n",framesPerInBuffer);//	printf("%d\n",dpm.rate);	/* set StreamParameters */	StreamParameters.device = DeviceIndex;	StreamParameters.channelCount = stereo;	StreamParameters.sampleFormat = SampleFormat;	StreamParameters.suggestedLatency = DeviceInfo->defaultLowOutputLatency;	StreamParameters.hostApiSpecificStreamInfo = NULL;		err = Pa_IsFormatSupported( NULL ,                             &StreamParameters,							(double) dpm.rate );	if ( err != paNoError) goto error;	err = Pa_OpenStream(		& stream,			/* passes back stream pointer */		NULL,				/* inputStreamParameters */		&StreamParameters,	/* outputStreamParameters */		(double) dpm.rate,	/* sample rate */		paFramesPerBufferUnspecified,	/* frames per buffer */		paFramesPerBufferUnspecified,	/* PaStreamFlags */		paCallback,			/* specify our custom callback */		&pa_data			/* pass our data through to callback */		);	if ( err != paNoError) goto error;	return 0;	#else	DeviceID = Pa_GetDefaultOutputDeviceID();	if(DeviceID==paNoDevice) goto error;	DeviceInfo = Pa_GetDeviceInfo( DeviceID);		if(DeviceInfo==NULL) goto error;	nativeSampleFormats = DeviceInfo->nativeSampleFormats;	exclude_enc = PE_ULAW | PE_ALAW | PE_BYTESWAP;	include_enc = PE_SIGNED;	if (!(nativeSampleFormats & paInt16) && !(nativeSampleFormats & paInt32)) {exclude_enc |= PE_16BIT;}	if (!(nativeSampleFormats & paInt24)) {exclude_enc |= PE_24BIT;}    dpm.encoding = validate_encoding(dpm.encoding, include_enc, exclude_enc);	if (dpm.encoding & PE_24BIT) {		SampleFormat = paInt24;	}else if (dpm.encoding & PE_16BIT) {		if(nativeSampleFormats & paInt16) SampleFormat = paInt16;		else{			SampleFormat = paInt32;			conv16_32 = 1;		}	}else {		SampleFormat = paInt8;	}	stereo = (dpm.encoding & PE_MONO) ? 1 : 2;	data_nbyte = (dpm.encoding & PE_16BIT) ? 2 : 1;	data_nbyte = (dpm.encoding & PE_24BIT) ? 3 : data_nbyte;	nrates = DeviceInfo->numSampleRates;	if (nrates == -1) {	/* range supported */		rate = dpm.rate;		if (dpm.rate < DeviceInfo->sampleRates[0]) rate = DeviceInfo->sampleRates[0];		if (dpm.rate > DeviceInfo->sampleRates[1]) rate = DeviceInfo->sampleRates[1];	} else {		rate = DeviceInfo->sampleRates[nrates-1];		for (n = nrates - 1; n >= 0; n--) {	/* find nearest sample rate */			if (dpm.rate <= DeviceInfo->sampleRates[n]) rate=DeviceInfo->sampleRates[n];		}	}	dpm.rate = (int32)rate;		pa_data.samplesToGo = 0;	pa_data.bufpoint = pa_data.buf;	pa_data.bufepoint = pa_data.buf;//	firsttime = 1;	numBuffers = Pa_GetMinNumBuffers( framesPerBuffer, dpm.rate );	framesPerInBuffer = numBuffers * framesPerBuffer;	if (framesPerInBuffer < 4096) framesPerInBuffer = 4096;	bytesPerInBuffer = framesPerInBuffer * data_nbyte * stereo;//	printf("%d\n",framesPerInBuffer);//	printf("%d\n",dpm.rate);	err = Pa_OpenDefaultStream(    	&stream,        /* passes back stream pointer */    	0,              /* no input channels */    	stereo,              /* 2:stereo 1:mono output */    	SampleFormat,      /* 24bit 16bit 8bit output */		(double)dpm.rate,          /* sample rate */    	framesPerBuffer,            /* frames per buffer */    	numBuffers,              /* number of buffers, if zero then use default minimum */    	paCallback, /* specify our custom callback */    	&pa_data);   /* pass our data through to callback */	if ( err != paNoError && err != paHostError) goto error;	return 0;#endiferror:	Pa_Terminate(); pa_active = 0;#ifdef AU_PORTAUDIO_DLL  free_portaudio_dll();#endif	ctl->cmsg(  CMSG_ERROR, VERB_NORMAL, "PortAudio error: %s\n", Pa_GetErrorText( err ) );	return -1;}
4357	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4357/d8a61a4e989e33b34ddfad20b5eaa9a081eced97/portaudio_a.c/buggy/timidity/portaudio_a.c