head 1.3; access; symbols pkgsrc-2013Q2:1.3.0.54 pkgsrc-2013Q2-base:1.3 pkgsrc-2012Q4:1.3.0.52 pkgsrc-2012Q4-base:1.3 pkgsrc-2011Q4:1.3.0.50 pkgsrc-2011Q4-base:1.3 pkgsrc-2011Q2:1.3.0.48 pkgsrc-2011Q2-base:1.3 pkgsrc-2009Q4:1.3.0.46 pkgsrc-2009Q4-base:1.3 pkgsrc-2008Q4:1.3.0.44 pkgsrc-2008Q4-base:1.3 pkgsrc-2008Q3:1.3.0.42 pkgsrc-2008Q3-base:1.3 cube-native-xorg:1.3.0.40 cube-native-xorg-base:1.3 pkgsrc-2008Q2:1.3.0.38 pkgsrc-2008Q2-base:1.3 pkgsrc-2008Q1:1.3.0.36 pkgsrc-2008Q1-base:1.3 pkgsrc-2007Q4:1.3.0.34 pkgsrc-2007Q4-base:1.3 pkgsrc-2007Q3:1.3.0.32 pkgsrc-2007Q3-base:1.3 pkgsrc-2007Q2:1.3.0.30 pkgsrc-2007Q2-base:1.3 pkgsrc-2007Q1:1.3.0.28 pkgsrc-2007Q1-base:1.3 pkgsrc-2006Q4:1.3.0.26 pkgsrc-2006Q4-base:1.3 pkgsrc-2006Q3:1.3.0.24 pkgsrc-2006Q3-base:1.3 pkgsrc-2006Q2:1.3.0.22 pkgsrc-2006Q2-base:1.3 pkgsrc-2006Q1:1.3.0.20 pkgsrc-2006Q1-base:1.3 pkgsrc-2005Q4:1.3.0.18 pkgsrc-2005Q4-base:1.3 pkgsrc-2005Q3:1.3.0.16 pkgsrc-2005Q3-base:1.3 pkgsrc-2005Q2:1.3.0.14 pkgsrc-2005Q2-base:1.3 pkgsrc-2005Q1:1.3.0.12 pkgsrc-2005Q1-base:1.3 pkgsrc-2004Q4:1.3.0.10 pkgsrc-2004Q4-base:1.3 pkgsrc-2004Q3:1.3.0.8 pkgsrc-2004Q3-base:1.3 pkgsrc-2004Q2:1.3.0.6 pkgsrc-2004Q2-base:1.3 pkgsrc-2004Q1:1.3.0.4 pkgsrc-2004Q1-base:1.3 pkgsrc-2003Q4:1.3.0.2 pkgsrc-2003Q4-base:1.3 buildlink2-base:1.3 netbsd-1-5-PATCH001:1.2; locks; strict; comment @# @; 1.3 date 2001.08.08.09.18.29; author lukem; state dead; branches; next 1.2; 1.2 date 2001.05.12.21.26.40; author mycroft; state Exp; branches; next 1.1; 1.1 date 2001.03.20.09.57.37; author wiz; state Exp; branches; next ; desc @@ 1.3 log @update to version 0.7.0 @ text @$NetBSD: patch-ah,v 1.2 2001/05/12 21:26:40 mycroft Exp $ --- src/plugins/sun/ao_sun.c.orig Mon Mar 19 19:34:22 2001 +++ src/plugins/sun/ao_sun.c @@@@ -0,0 +1,150 @@@@ +/* + * + * ao_sun.c Solaris/NetBSD/OpenBSD + * + * Original Copyright (C) Aaron Holtzman - May 1999 + * Modifications Copyright (C) Stan Seibert - July 2000 + * and Copyright (C) Christian Weisgerber - March 2001 + * + * libao is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * libao is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef AUDIO_ENCODING_SLINEAR +#define AUDIO_ENCODING_SLINEAR AUDIO_ENCODING_LINEAR /* Solaris */ +#endif + +#include + +ao_info_t ao_sun_info = { + "Sun audio driver output", + "sun", + "Christian Weisgerber ", + "Outputs to the sun audio system." +}; + +typedef struct ao_sun_internal_s { + char *dev; + int fd; +} ao_sun_internal_t; + +void ao_sun_parse_options(ao_sun_internal_t *state, ao_option_t *options) +{ + state->dev = NULL; + + while (options) { + if (!strcmp(options->key, "dev")) + state->dev = strdup(options->value); + options = options->next; + } +} + +ao_internal_t *plugin_open(uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) +{ + ao_sun_internal_t *state; + audio_info_t info; + + state = malloc(sizeof(ao_sun_internal_t)); + + if (state == NULL) { + fprintf(stderr,"libao: Error allocating state memory: %s\n", + strerror(errno)); + goto ERR; + } + + ao_sun_parse_options(state, options); + + if (state->dev != NULL) { + /* open the user-specified path */ + state->fd = open(state->dev, O_WRONLY); + if (state->fd < 0) { + fprintf(stderr, "libao: Error opening audio device %s: %s\n", + state->dev, strerror(errno)); + goto ERR; + } + } else { + /* default */ + state->dev = strdup("/dev/sound"); + state->fd = open(state->dev, O_WRONLY); + if (state->fd < 0) { + fprintf(stderr, + "libao: Could not open default device %s: %s\n", + state->dev, strerror(errno)); + goto ERR; + } + } + + AUDIO_INITINFO(&info); +#ifdef AUMODE_PLAY /* NetBSD/OpenBSD */ + info.mode = AUMODE_PLAY; +#endif + info.play.encoding = AUDIO_ENCODING_SLINEAR; + info.play.precision = bits; + info.play.sample_rate = rate; + info.play.channels = channels; + + if (ioctl(state->fd, AUDIO_SETINFO, &info) < 0) { + fprintf(stderr, + "libao: Cannot set device to %d bits, %d Hz, %d channels: %s\n", + bits, rate, channels, strerror(errno)); + goto ERR; + } + + return state; + +ERR: + if (state != NULL) { + if (state->fd >= 0) + close(state->fd); + if (state->dev) + free(state->dev); + free(state); + } + return NULL; +} + +void plugin_play(ao_internal_t *state, void *output_samples, uint_32 num_bytes) +{ + write(((ao_sun_internal_t *)state)->fd, output_samples, num_bytes); +} + +void plugin_close(ao_internal_t *state) +{ + ao_sun_internal_t *s = (ao_sun_internal_t *)state; + close(s->fd); + free(s->dev); + free(s); +} + +int plugin_get_latency(ao_internal_t *state) +{ + /* dummy */ + return 0; +} + +ao_info_t *plugin_get_driver_info(void) +{ + return &ao_sun_info; +} @ 1.2 log @Use /dev/sound. @ text @d1 1 a1 1 $NetBSD: patch-ah,v 1.1 2001/03/20 09:57:37 wiz Exp $ @ 1.1 log @Add native Open/NetBSD audio support, supplied by Christian Weisgerber in private communication; a patch against a memory leak in the wav file writer, forwarded from the vorbis-dev list by Jeremy C. Reed; also use pkgsrc libtool instead of included one, and don't depend on esd anymore. Bump version to 0.6.0nb1. @ text @d1 1 a1 1 $NetBSD$ d94 1 a94 1 + state->dev = strdup("/dev/audio"); @