static int open_mint(out123_handle *ao) { const char *dev = ao->device; if(!ai) return -1; if(!dev) dev = "/dev/audio"; ao->fn = open(dev,O_WRONLY); if(ao->fn < 0) { error1("Can't open %s!",dev); return -1; } ioctl(ao->fn, AIOCGBLKSIZE, &outburst); if(outburst > MAXOUTBURST) outburst = MAXOUTBURST; if(audio_reset_parameters(ai) < 0) { close(ao->fn); return -1; } return ao->fn; }
int audio_open(struct audio_info_struct *ai) { int err; int card=0,device=0; char scard[128], sdevice[128]; if(!ai) return -1; if(ai->device) { /* parse ALSA device name */ if(strchr(ai->device,':')) { /* card with device */ strncpy(scard, ai->device, sizeof(scard)-1); scard[sizeof(scard)-1] = '\0'; if (strchr(scard,':')) *strchr(scard,':') = '\0'; card = snd_card_name(scard); if (card < 0) { fprintf(stderr, "wrong soundcard number: %s\n", scard); exit(1); } strncpy(sdevice, strchr(ai->device, ':') + 1, sizeof(sdevice)-1); } else { strncpy(sdevice, ai->device, sizeof(sdevice)-1); } sdevice[sizeof(sdevice)-1] = '\0'; device = atoi(sdevice); if (!isdigit(sdevice[0]) || device < 0 || device > 31) { fprintf(stderr, "wrong device number: %s\n", sdevice); exit(1); } } if((err=snd_pcm_open(&ai->handle, card, device, SND_PCM_OPEN_PLAYBACK)) < 0 ) { fprintf(stderr, "open failed: %s\n", snd_strerror(err)); exit(1); } if(audio_reset_parameters(ai) < 0) { audio_close(ai); return -1; } return 0; }
static int open_mint(audio_output_t *ao) { if(!ai) return -1; if(!ao->device) ao->device = "/dev/audio"; ao->fn = open(ao->device,O_WRONLY); if(ao->fn < 0) { error1("Can't open %s!",ao->device); return -1; } ioctl(ao->fn, AIOCGBLKSIZE, &outburst); if(outburst > MAXOUTBURST) outburst = MAXOUTBURST; if(audio_reset_parameters(ai) < 0) { close(ao->fn); return -1; } return ao->fn; }
int audio_open(struct audio_info_struct *ai) { audio_info_t ainfo; if(!ai->device) { if(getenv("AUDIODEV")) { if(param.verbose > 1) fprintf(stderr,"Using audio-device value from AUDIODEV environment variable!\n"); ai->device = getenv("AUDIODEV"); } else ai->device = "/dev/audio"; } ai->fn = open(ai->device,O_WRONLY); if(ai->fn < 0) return ai->fn; #ifdef SUNOS { int type; if(ioctl(ai->fn, AUDIO_GETDEV, &type) == -1) return -1; if(type == AUDIO_DEV_UNKNOWN || type == AUDIO_DEV_AMD) return -1; } #else #if defined(SOLARIS) || defined(SPARCLINUX) { struct audio_device ad; if(ioctl(ai->fn, AUDIO_GETDEV, &ad) == -1) return -1; if(param.verbose > 1) fprintf(stderr,"Audio device type: %s\n",ad.name); if(!strstr(ad.name,"dbri") && !strstr(ad.name,"CS4231") && param.verbose) fprintf(stderr,"Warning: Unknown sound system %s. But we try it.\n",ad.name); } #endif #endif if(audio_reset_parameters(ai) < 0) { return -1; } AUDIO_INITINFO(&ainfo); if(ai->output > 0) ainfo.play.port = 0; if(ai->output & AUDIO_OUT_INTERNAL_SPEAKER) ainfo.play.port |= AUDIO_SPEAKER; if(ai->output & AUDIO_OUT_HEADPHONES) ainfo.play.port |= AUDIO_HEADPHONE; if(ai->output & AUDIO_OUT_LINE_OUT) ainfo.play.port |= AUDIO_LINE_OUT; if(ai->gain != -1) ainfo.play.gain = ai->gain; if(ioctl(ai->fn, AUDIO_SETINFO, &ainfo) == -1) return -1; return ai->fn; }