dpm.id_name = safe_malloc(strlen(audio_dev)); dpm.name = safe_malloc(strlen(audio_dev)); 
dpm.id_name = safe_malloc(strlen(audio_dev)+1); dpm.name = safe_malloc(strlen(audio_dev)+1); 
static int open_output(void){    int include_enc = 0, exclude_enc = PE_BYTESWAP;    struct stat sb;    audio_info_t auinfo;    char *audio_dev, *audio_ctl_dev, *tmp_audio;    /* See if the AUDIODEV environment variable is defined, and set the       audio device accordingly  - Lalit Chhabra 23/Oct/2001 */    if((audio_dev  = getenv("AUDIODEV")) != NULL)    {      dpm.id_name = safe_malloc(strlen(audio_dev));      dpm.name = safe_malloc(strlen(audio_dev));      strcpy(dpm.name, audio_dev);      strcpy(dpm.id_name, audio_dev);      tmp_audio = safe_malloc(strlen(audio_dev) + 3);      audio_ctl_dev = safe_malloc(strlen(audio_dev) + 3);      strcpy(tmp_audio, audio_dev);      strcpy(audio_ctl_dev, strcat(tmp_audio, "ctl"));    }    else    {      audio_ctl_dev = safe_malloc(strlen(AUDIO_CTLDEV) + 3);      strcpy(audio_ctl_dev, AUDIO_CTLDEV);    }    output_counter = play_samples_offset = 0;    /* Open the audio device */    if((audioctl_fd = open(audio_ctl_dev, O_RDWR)) < 0)    {	ctl->cmsg(CMSG_ERROR, VERB_NORMAL,		  "%s: %s", audio_ctl_dev, strerror(errno));	return -1;    }/* ############## */#if 0    if((dpm.fd = open(dpm.name, O_WRONLY | O_NDELAY)) == -1)    {	ctl->cmsg(CMSG_WARNING, VERB_NORMAL,		  "%s: %s", dpm.name, strerror(errno));	if(errno == EBUSY)	{	    if((dpm.fd = open(dpm.name, O_WRONLY)) == -1)	    {		ctl->cmsg(CMSG_ERROR, VERB_NORMAL,			  "%s: %s", dpm.name, strerror(errno));		close_output();		return -1;	    }	}    }#endif    if((dpm.fd = open(dpm.name, O_WRONLY)) == -1)    {	ctl->cmsg(CMSG_ERROR, VERB_NORMAL,		  "%s: %s", dpm.name, strerror(errno));	close_output();	return -1;    }    if(stat(dpm.name, &sb) < 0)    {	ctl->cmsg(CMSG_ERROR, VERB_NORMAL,		  "%s: %s", dpm.name, strerror(errno));	close_output();	return -1;    }    if(!S_ISCHR(sb.st_mode))    {	ctl->cmsg(CMSG_ERROR, VERB_NORMAL,		  "%s: Not a audio device", dpm.name);	close_output();	return -1;    }    if(sun_audio_getinfo(&auinfo) < 0)    { 	/* from Francesco Zanichelli's */	/* If it doesn't give info, it probably won't take requests	    either. Assume it's an old device that does 8kHz uLaw only.	      Disclaimer: I don't know squat about the various Sun audio		  devices, so if this is not what we should do, I'll gladly		      accept modifications. */	ctl->cmsg(CMSG_WARNING, VERB_NORMAL, "Cannot inquire %s", dpm.name);	include_enc = PE_ULAW|PE_ALAW|PE_MONO;	exclude_enc = PE_SIGNED|PE_16BIT|PE_BYTESWAP;	dpm.encoding = validate_encoding(dpm.encoding,					 include_enc, exclude_enc);	if(dpm.rate != 8000)	    ctl->cmsg(CMSG_WARNING, VERB_VERBOSE,		      "Sample rate is changed %d to 8000",		      dpm.rate);	dpm.rate = 8000;	return 1;    }    if(!(dpm.encoding & PE_16BIT))	exclude_enc |= PE_SIGNED; /* Always unsigned */    dpm.encoding = validate_encoding(dpm.encoding, include_enc, exclude_enc);    AUDIO_INITINFO(&auinfo);    auinfo.play.sample_rate = dpm.rate;    auinfo.play.channels = (dpm.encoding & PE_MONO) ? 1 : 2;    auinfo.play.encoding = sun_audio_encoding(dpm.encoding);    auinfo.play.precision = (dpm.encoding & PE_16BIT) ? 16 : 8;    if(sun_audio_setinfo(&auinfo) == -1)    {	ctl->cmsg(CMSG_ERROR, VERB_NORMAL,		  "rate=%d, channels=%d, precision=%d, encoding=%s",		  auinfo.play.sample_rate, auinfo.play.channels,		  auinfo.play.precision, output_encoding_string(dpm.encoding));	close_output();	return -1;    }    return 0;}
4357	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4357/361cc5df1e14516b0a3eef7766539860da9a9721/sun_a.c/buggy/timidity/sun_a.c