aboutsummaryrefslogtreecommitdiffhomepage
path: root/libao2
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@mplayer2.org>2012-07-28 20:20:17 +0200
committerGravatar wm4 <wm4@mplayer2.org>2012-07-28 20:44:59 +0200
commit16145ff43fd92947cb8fe301ebce46e7be52a9fb (patch)
tree5a5ade633d922f416d3b1c7c68e8aff878da9a8f /libao2
parentf03eed6469e34a5bff975ed43292016a621296ea (diff)
libvo, libao: remove useless video and audio output drivers
Some of these have only limited use, and some of these have no use at all. Remove them. They make maintainance harder and nobody needs them. It's possible that many of the removed drivers were very useful a dozen of years ago, but now it's 2012. Note that some of these could be added back, in case they were more useful than I thought. But right now, they are just a burden. Reason for removal for each module: vo_3dfx, vo_dfbmga, vo_dxr3, vo_ivtv, vo_mga, vo_s3fb, vo_tdfxfb, vo_xmga, vo_tdfx_vid: All of these are for very specific and outdated hardware. Some of them require non-standard kernel drivers or do direct HW access. vo_dga: the most crappy and ancient way to get fast output on X. vo_aa: there's vo_caca for the same purpose. vo_ggi: this never lived, and is entirely useless. vo_mpegpes: for DVB cards, I can't test this and it's crappy. vo_fbdev, vo_fbdev2: there's vo_directfb2 vo_bl: what is this even? But it's neither important, nor alive. vo_svga, vo_vesa: you want to use this? You can't be serious. vo_wii: I can't test this, and who the hell uses this? vo_xvr100: some Sun thing. vo_xover: only useful in connection with xvr100. ao_nas: still alive, but I doubt it has any meaning today. ao_sun: Sun. ao_win32: use ao_dsound or ao_portaudio instead. ao_ivtv: removed along vo_ivtv. Also get rid of anything SDL related. SDL 1.x is total crap for video output, and will be replaced with SDL 2.x soon (perhaps), so if you want to use SDL, write output drivers for SDL 2.x. Additionally, I accidentally damaged Sun support, which made me completely remove Sun/Solaris support. Nobody cares about this anyway. Some left overs from previous commits removing modules were cleaned up.
Diffstat (limited to 'libao2')
-rw-r--r--libao2/ao_ivtv.c161
-rw-r--r--libao2/ao_mpegpes.c336
-rw-r--r--libao2/ao_nas.c646
-rw-r--r--libao2/ao_sdl.c319
-rw-r--r--libao2/ao_sun.c692
-rw-r--r--libao2/ao_win32.c326
-rw-r--r--libao2/audio_out.c33
7 files changed, 0 insertions, 2513 deletions
diff --git a/libao2/ao_ivtv.c b/libao2/ao_ivtv.c
deleted file mode 100644
index e05537cbd8..0000000000
--- a/libao2/ao_ivtv.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * audio output for WinTV PVR-150/250/350 (a.k.a IVTV) cards
- * through Connexant hardware MPEG decoder
- * See http://ivtvdriver.org/index.php/Main_Page for more details on the
- * cards supported by the ivtv driver.
- *
- * WARNING: You need to force -ac hwmpa for audio output to work.
- *
- * Copyright (C) 2006 Benjamin Zores
- *
- * This file is part of MPlayer.
- *
- * MPlayer 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 of the License, or
- * (at your option) any later version.
- *
- * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <inttypes.h>
-
-#include "config.h"
-
-#include "mp_msg.h"
-
-#include "audio_out.h"
-#include "audio_out_internal.h"
-#include "libaf/af_format.h"
-#include "libmpdemux/mpeg_packetizer.h"
-#include "libvo/vo_ivtv.h"
-
-#define MPEG_AUDIO_ID 0x1C0
-
-static int freq = 0;
-
-static const ao_info_t info =
-{
- "IVTV MPEG Audio Decoder output",
- "ivtv",
- "Benjamin Zores",
- ""
-};
-
-LIBAO_EXTERN(ivtv)
-
-/* to set/get/query special features/parameters */
-static int
-control (int cmd,void *arg)
-{
- return CONTROL_UNKNOWN;
-}
-
-/* open & setup audio device */
-static int
-init (int rate, int channels, int format, int flags)
-{
- if (ivtv_fd < 0)
- return 0;
-
- if (format != AF_FORMAT_MPEG2)
- {
- mp_msg (MSGT_AO, MSGL_FATAL,
- "AO: [ivtv] can only handle MPEG audio streams.\n");
- return 0;
- }
-
- ao_data.outburst = 2048;
- ao_data.samplerate = rate;
- ao_data.channels = channels;
- ao_data.format = AF_FORMAT_MPEG2;
- ao_data.buffersize = 2048;
- ao_data.bps = rate * 2 * 2;
- ao_data.brokenpts = 0;
- freq = rate;
-
- /* check for supported audio rate */
- if (rate != 32000 || rate != 41000 || rate != 48000)
- {
- mp_tmsg (MSGT_AO, MSGL_ERR, "[AO MPEGPES] %d Hz not supported, try to resample.\n", rate);
- rate = 48000;
- }
-
- return 1;
-}
-
-/* close audio device */
-static void
-uninit (int immed)
-{
- /* nothing to do */
-}
-
-/* stop playing and empty buffers (for seeking/pause) */
-static void
-reset (void)
-{
- /* nothing to do */
-}
-
-/* stop playing, keep buffers (for pause) */
-static void
-audio_pause (void)
-{
- reset ();
-}
-
-/* resume playing, after audio_pause() */
-static void
-audio_resume (void)
-{
- /* nothing to do */
-}
-
-/* how many bytes can be played without blocking */
-static int
-get_space (void)
-{
- extern int vo_pts;
- float x;
- int y;
-
- x = (float) (vo_pts - ao_data.brokenpts) / 90000.0;
- if (x <= 0)
- return 0;
-
- y = freq * 4 * x;
- y /= ao_data.outburst;
- y *= ao_data.outburst;
-
- if (y > 32000)
- y = 32000;
-
- return y;
-}
-
-/* number of bytes played */
-static int
-play (void *data, int len, int flags)
-{
- if (ao_data.format != AF_FORMAT_MPEG2)
- return 0;
-
- send_mpeg_pes_packet (data, len, MPEG_AUDIO_ID, ao_data.brokenpts, 2, ivtv_write);
-
- return len;
-}
-
-/* delay in seconds between first and last sample in buffer */
-static float
-get_delay (void)
-{
- return 0.0;
-}
diff --git a/libao2/ao_mpegpes.c b/libao2/ao_mpegpes.c
deleted file mode 100644
index fe3f20fc85..0000000000
--- a/libao2/ao_mpegpes.c
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- * MPEG-PES audio output driver
- *
- * This file is part of MPlayer.
- *
- * MPlayer 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 of the License, or
- * (at your option) any later version.
- *
- * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <inttypes.h>
-#include <errno.h>
-
-#include "config.h"
-
-#include "audio_out.h"
-#include "audio_out_internal.h"
-
-#include "libaf/af_format.h"
-#include "libmpdemux/mpeg_packetizer.h"
-#include "subopt-helper.h"
-
-#include "mp_msg.h"
-
-#ifdef CONFIG_DVB
-#include <poll.h>
-#include <sys/ioctl.h>
-#include <linux/dvb/audio.h>
-audio_mixer_t dvb_mixer={255,255};
-#endif
-
-#define true 1
-#define false 0
-
-extern int vo_mpegpes_fd;
-int ao_mpegpes_fd = -1;
-
-#include <errno.h>
-
-static const ao_info_t info =
-{
-#ifdef CONFIG_DVB
- "DVB audio output",
-#else
- "MPEG-PES audio output",
-#endif
- "mpegpes",
- "A'rpi",
- ""
-};
-
-LIBAO_EXTERN(mpegpes)
-
-
-// to set/get/query special features/parameters
-static int control(int cmd,void *arg){
-#ifdef CONFIG_DVB
- switch(cmd){
- case AOCONTROL_GET_VOLUME:
- if(ao_mpegpes_fd >= 0){
- ((ao_control_vol_t*)(arg))->left=dvb_mixer.volume_left/2.56;
- ((ao_control_vol_t*)(arg))->right=dvb_mixer.volume_right/2.56;
- return CONTROL_OK;
- }
- return CONTROL_ERROR;
- case AOCONTROL_SET_VOLUME:
- if(ao_mpegpes_fd >= 0){
- dvb_mixer.volume_left=((ao_control_vol_t*)(arg))->left*2.56;
- dvb_mixer.volume_right=((ao_control_vol_t*)(arg))->right*2.56;
- if(dvb_mixer.volume_left>255) dvb_mixer.volume_left=255;
- if(dvb_mixer.volume_right>255) dvb_mixer.volume_right=255;
- // printf("Setting DVB volume: %d ; %d \n",dvb_mixer.volume_left,dvb_mixer.volume_right);
- if ( (ioctl(vo_mpegpes_fd,AUDIO_SET_MIXER, &dvb_mixer) < 0)){
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO MPEGPES] DVB audio set mixer failed: %s.\n",
- strerror(errno));
- return CONTROL_ERROR;
- }
- return CONTROL_OK;
- }
- return CONTROL_ERROR;
- }
-#endif
- return CONTROL_UNKNOWN;
-}
-
-static int freq=0;
-static int freq_id=0;
-
-#ifdef CONFIG_DVB
-static int init_device(int card)
-{
- char ao_file[30];
- sprintf(ao_file, "/dev/dvb/adapter%d/audio0", card);
- mp_msg(MSGT_VO,MSGL_INFO, "Opening %s\n", ao_file);
- if((ao_mpegpes_fd = open(ao_file,O_RDWR|O_NONBLOCK)) < 0)
- {
- mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO DEVICE: %s\n", strerror(errno));
- return -1;
- }
- if( (ioctl(ao_mpegpes_fd, AUDIO_SELECT_SOURCE, AUDIO_SOURCE_MEMORY) < 0))
- {
- mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SELECT SOURCE: %s\n", strerror(errno));
- goto fail;
- }
- if((ioctl(ao_mpegpes_fd, AUDIO_PLAY) < 0))
- {
- mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO PLAY: %s\n", strerror(errno));
- goto fail;
- }
- if((ioctl(ao_mpegpes_fd, AUDIO_SET_AV_SYNC, true) < 0))
- {
- mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SET AV SYNC: %s\n", strerror(errno));
- goto fail;
- }
- //FIXME: in vo_mpegpes audio was initialized as MUTEd
- if((ioctl(ao_mpegpes_fd, AUDIO_SET_MUTE, false) < 0))
- {
- mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SET MUTE: %s\n", strerror(errno));
- goto fail;
- }
- return ao_mpegpes_fd;
-fail:
- close(ao_mpegpes_fd);
- ao_mpegpes_fd = -1;
- return -1;
-}
-#endif
-
-static int preinit(const char *arg)
-{
- int card = -1;
- char *ao_file = NULL;
-
- const opt_t subopts[] = {
- {"card", OPT_ARG_INT, &card, NULL},
- {"file", OPT_ARG_MSTRZ, &ao_file, NULL},
- {NULL}
- };
-
- if(subopt_parse(ao_subdevice, subopts) != 0)
- {
- mp_msg(MSGT_VO, MSGL_ERR, "AO_MPEGPES, Unrecognized options\n");
- return -1;
- }
- if(card==-1)
- {
- //search the first usable card
- int n;
- char file[30];
- for(n=0; n<4; n++)
- {
- sprintf(file, "/dev/dvb/adapter%d/audio0", n);
- if(access(file, F_OK | W_OK)==0)
- {
- card = n+1;
- break;
- }
- }
- }
- if((card < 1) || (card > 4))
- {
- mp_msg(MSGT_VO, MSGL_ERR, "DVB card number must be between 1 and 4\n");
- return -1;
- }
- card--;
-
-#ifdef CONFIG_DVB
- if(!ao_file)
- return init_device(card);
-#else
- if(!ao_file)
- return vo_mpegpes_fd; //video fd
-#endif
-
- ao_mpegpes_fd = open(ao_file, O_WRONLY | O_CREAT, 0666);
- if(ao_mpegpes_fd < 0)
- {
- mp_msg(MSGT_VO, MSGL_ERR, "ao_mpegpes: %s\n", strerror(errno));
- return -1;
- }
- return ao_mpegpes_fd;
-}
-
-static int my_ao_write(const unsigned char* data,int len){
- int orig_len = len;
-#ifdef CONFIG_DVB
-#define NFD 1
- struct pollfd pfd[NFD];
-
- pfd[0].fd = ao_mpegpes_fd;
- pfd[0].events = POLLOUT;
-
- while(len>0){
- if(poll(pfd,NFD,1)){
- if(pfd[0].revents & POLLOUT){
- int ret = write(ao_mpegpes_fd, data, len);
- if(ret<=0){
- mp_msg(MSGT_VO, MSGL_ERR, "ao_mpegpes write: %s\n", strerror(errno));
- usleep(0);
- } else {
- len-=ret;
- data+=ret;
- }
- } else usleep(1000);
- }
- }
-
-#else
- if(ao_mpegpes_fd < 0) return 0; // no file
- write(ao_mpegpes_fd, data, len); // write to file
-#endif
- return orig_len;
-}
-
-
-// open & setup audio device
-// return: 1=success 0=fail
-static int init(int rate,int channels,int format,int flags){
- if(preinit(NULL)<0) return 0;
-
- ao_data.channels=2;
- ao_data.outburst=2000;
- switch(format){
- case AF_FORMAT_S16_BE:
- case AF_FORMAT_MPEG2:
- case AF_FORMAT_AC3_BE:
- ao_data.format=format;
- break;
- case AF_FORMAT_AC3_LE:
- ao_data.format=AF_FORMAT_AC3_BE;
- break;
- default:
- ao_data.format=AF_FORMAT_S16_BE;
- }
-
- switch(rate){
- case 48000: freq_id=0;break;
- case 96000: freq_id=1;break;
- case 44100: freq_id=2;break;
- case 32000: freq_id=3;break;
- default:
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO MPEGPES] %d Hz not supported, try to resample.\n", rate);
-#if 0
- if(rate>48000) rate=96000; else
- if(rate>44100) rate=48000; else
- if(rate>32000) rate=44100; else
- rate=32000;
- goto retry;
-#else
- rate=48000; freq_id=0;
-#endif
- }
-
- ao_data.bps=rate*2*2;
- freq=ao_data.samplerate=rate;
-
- return 1;
-}
-
-// close audio device
-static void uninit(int immed){
- if (ao_mpegpes_fd >= 0)
- close(ao_mpegpes_fd);
- ao_mpegpes_fd = -1;
-}
-
-// stop playing and empty buffers (for seeking/pause)
-static void reset(void){
-
-}
-
-// stop playing, keep buffers (for pause)
-static void audio_pause(void)
-{
- // for now, just call reset();
- reset();
-}
-
-// resume playing, after audio_pause()
-static void audio_resume(void)
-{
-}
-
-extern int vo_pts;
-
-// return: how many bytes can be played without blocking
-static int get_space(void){
- float x=(float)(vo_pts-ao_data.brokenpts)/90000.0;
- int y;
- //FIXME: is it correct?
- if(vo_mpegpes_fd < 0) return 32000; //not using -vo mpegpes
-// printf("vo_pts: %5.3f ao_pts: %5.3f\n",vo_pts/90000.0,ao_data.brokenpts/90000.0);
- if(x<=0) return 0;
- y=freq*4*x;y/=ao_data.outburst;y*=ao_data.outburst;
- if(y>32000) y=32000;
-// printf("diff: %5.3f -> %d \n",x,y);
- return y;
-}
-
-// plays 'len' bytes of 'data'
-// it should round it down to outburst*n
-// return: number of bytes played
-static int play(void* data,int len,int flags){
-// printf("\nao_mpegpes: play(%d) freq=%d\n",len,freq_id);
- if(ao_data.format==AF_FORMAT_MPEG2)
- send_mpeg_pes_packet (data, len, 0x1C0, ao_data.brokenpts, 1, my_ao_write);
- else {
-// if(len>2000) len=2000;
-// printf("ao_mpegpes: len=%d \n",len);
- send_mpeg_lpcm_packet(data, len, 0xA0, ao_data.brokenpts, freq_id, my_ao_write);
- }
- return len;
-}
-
-// return: delay in seconds between first and last sample in buffer
-static float get_delay(void){
-
- return 0.0;
-}
diff --git a/libao2/ao_nas.c b/libao2/ao_nas.c
deleted file mode 100644
index d3274df9a5..0000000000
--- a/libao2/ao_nas.c
+++ /dev/null
@@ -1,646 +0,0 @@
-/*
- * NAS audio output driver
- *
- * copyright (c) 2001 Tobias Diedrich <ranma@gmx.at>
- *
- * Based on the libaudiooss parts rewritten by me, which were
- * originally based on the NAS output plugin for XMMS.
- *
- * XMMS plugin by Willem Monsuwe
- * adapted for libaudiooss by Jon Trulson
- * further modified by Erik Inge Bolsø
- * largely rewritten and used for this ao driver by Tobias Diedrich
- *
- * This file is part of MPlayer.
- *
- * MPlayer 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 of the License, or
- * (at your option) any later version.
- *
- * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/*
- * Theory of operation:
- *
- * The NAS consists of two parts, a server daemon and a client.
- * We setup the server to use a buffer of size bytes_per_second
- * with a low watermark of buffer_size - NAS_FRAG_SIZE.
- * Upon starting the flow the server will generate a buffer underrun
- * event and the event handler will fill the buffer for the first time.
- * Now the server will generate a lowwater event when the server buffer
- * falls below the low watermark value. The event handler gets called
- * again and refills the buffer by the number of bytes requested by the
- * server (usually a multiple of 4096). To prevent stuttering on
- * startup (start of playing, seeks, unpausing) the client buffer should
- * be bigger than the server buffer. (For debugging we also do some
- * accounting of what we think how much of the server buffer is filled)
- */
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <pthread.h>
-#include <limits.h>
-#include <audio/audiolib.h>
-
-#include "config.h"
-#include "mp_msg.h"
-
-#include "audio_out.h"
-#include "audio_out_internal.h"
-#include "libaf/af_format.h"
-
-/* NAS_FRAG_SIZE must be a power-of-two value */
-#define NAS_FRAG_SIZE 4096
-
-static const char * const nas_event_types[] = {
- "Undefined",
- "Undefined",
- "ElementNotify",
- "GrabNotify",
- "MonitorNotify",
- "BucketNotify",
- "DeviceNotify"
-};
-
-static const char * const nas_elementnotify_kinds[] = {
- "LowWater",
- "HighWater",
- "State",
- "Unknown"
-};
-
-static const char * const nas_states[] = {
- "Stop",
- "Start",
- "Pause",
- "Any"
-};
-
-static const char * const nas_reasons[] = {
- "User",
- "Underrun",
- "Overrun",
- "EOF",
- "Watermark",
- "Hardware",
- "Any"
-};
-
-static const char* nas_reason(unsigned int reason)
-{
- if (reason > 6) reason = 6;
- return nas_reasons[reason];
-}
-
-static const char* nas_elementnotify_kind(unsigned int kind)
-{
- if (kind > 2) kind = 3;
- return nas_elementnotify_kinds[kind];
-}
-
-static const char* nas_event_type(unsigned int type) {
- if (type > 6) type = 0;
- return nas_event_types[type];
-}
-
-static const char* nas_state(unsigned int state) {
- if (state>3) state = 3;
- return nas_states[state];
-}
-
-static const ao_info_t info =
-{
- "NAS audio output",
- "nas",
- "Tobias Diedrich <ranma+mplayer@tdiedrich.de>",
- ""
-};
-
-struct ao_nas_data {
- AuServer *aud;
- AuFlowID flow;
- AuDeviceID dev;
- AuFixedPoint gain;
-
- unsigned int state;
- int expect_underrun;
-
- char *client_buffer;
- char *server_buffer;
- unsigned int client_buffer_size;
- unsigned int client_buffer_used;
- unsigned int server_buffer_size;
- unsigned int server_buffer_used;
- pthread_mutex_t buffer_mutex;
-
- pthread_t event_thread;
- int stop_thread;
-};
-
-static struct ao_nas_data *nas_data;
-
-LIBAO_EXTERN(nas)
-
-static void nas_print_error(AuServer *aud, const char *prefix, AuStatus as)
-{
- char s[100];
- AuGetErrorText(aud, as, s, 100);
- mp_msg(MSGT_AO, MSGL_ERR, "ao_nas: %s: returned status %d (%s)\n", prefix, as, s);
-}
-
-static int nas_readBuffer(struct ao_nas_data *nas_data, unsigned int num)
-{
- AuStatus as;
-
- pthread_mutex_lock(&nas_data->buffer_mutex);
- mp_msg(MSGT_AO, MSGL_DBG2, "ao_nas: nas_readBuffer(): num=%d client=%d/%d server=%d/%d\n",
- num,
- nas_data->client_buffer_used, nas_data->client_buffer_size,
- nas_data->server_buffer_used, nas_data->server_buffer_size);
-
- if (nas_data->client_buffer_used == 0) {
- mp_msg(MSGT_AO, MSGL_DBG2, "ao_nas: buffer is empty, nothing read.\n");
- pthread_mutex_unlock(&nas_data->buffer_mutex);
- return 0;
- }
- if (num > nas_data->client_buffer_used)
- num = nas_data->client_buffer_used;
-
- /*
- * It is not appropriate to call AuWriteElement() here because the
- * buffer is locked and delays writing to the network will cause
- * other threads to block waiting for buffer_mutex. Instead the
- * data is copied to "server_buffer" and written to the network
- * outside of the locked section of code.
- *
- * (Note: Rather than these two buffers, a single circular buffer
- * could eliminate the memcpy/memmove steps.)
- */
- /* make sure we don't overflow the buffer */
- if (num > nas_data->server_buffer_size)
- num = nas_data->server_buffer_size;
- memcpy(nas_data->server_buffer, nas_data->client_buffer, num);
-
- nas_data->client_buffer_used -= num;
- nas_data->server_buffer_used += num;
- memmove(nas_data->client_buffer, nas_data->client_buffer + num, nas_data->client_buffer_used);
- pthread_mutex_unlock(&nas_data->buffer_mutex);
-
- /*
- * Now write the new buffer to the network.
- */
- AuWriteElement(nas_data->aud, nas_data->flow, 0, num, nas_data->server_buffer, AuFalse, &as);
- if (as != AuSuccess)
- nas_print_error(nas_data->aud, "nas_readBuffer(): AuWriteElement", as);
-
- return num;
-}
-
-static int nas_writeBuffer(struct ao_nas_data *nas_data, void *data, unsigned int len)
-{
- pthread_mutex_lock(&nas_data->buffer_mutex);
- mp_msg(MSGT_AO, MSGL_DBG2, "ao_nas: nas_writeBuffer(): len=%d client=%d/%d server=%d/%d\n",
- len, nas_data->client_buffer_used, nas_data->client_buffer_size,
- nas_data->server_buffer_used, nas_data->server_buffer_size);
-
- /* make sure we don't overflow the buffer */
- if (len > nas_data->client_buffer_size - nas_data->client_buffer_used)
- len = nas_data->client_buffer_size - nas_data->client_buffer_used;
- memcpy(nas_data->client_buffer + nas_data->client_buffer_used, data, len);
- nas_data->client_buffer_used += len;
-
- pthread_mutex_unlock(&nas_data->buffer_mutex);
-
- return len;
-}
-
-static int nas_empty_event_queue(struct ao_nas_data *nas_data)
-{
- AuEvent ev;
- int result = 0;
-
- while (AuScanForTypedEvent(nas_data->aud, AuEventsQueuedAfterFlush,
- AuTrue, AuEventTypeElementNotify, &ev)) {
- AuDispatchEvent(nas_data->aud, &ev);
- result = 1;
- }
- return result;
-}
-
-static void *nas_event_thread_start(void *data)
-{
- struct ao_nas_data *nas_data = data;
-
- do {
- mp_msg(MSGT_AO, MSGL_DBG2,
- "ao_nas: event thread heartbeat (state=%s)\n",
- nas_state(nas_data->state));
- nas_empty_event_queue(nas_data);
- usleep(1000);
- } while (!nas_data->stop_thread);
-
- return NULL;
-}
-
-static AuBool nas_error_handler(AuServer* aud, AuErrorEvent* ev)
-{
- char s[100];
- AuGetErrorText(aud, ev->error_code, s, 100);
- mp_msg(MSGT_AO, MSGL_ERR, "ao_nas: error [%s]\n"
- "error_code: %d\n"
- "request_code: %d\n"
- "minor_code: %d\n",
- s,
- ev->error_code,
- ev->request_code,
- ev->minor_code);
-
- return AuTrue;
-}
-
-static AuBool nas_event_handler(AuServer *aud, AuEvent *ev, AuEventHandlerRec *hnd)
-{
- AuElementNotifyEvent *event = (AuElementNotifyEvent *) ev;
- struct ao_nas_data *nas_data = hnd->data;
-
- mp_msg(MSGT_AO, MSGL_DBG2, "ao_nas: event_handler(): type %s kind %s state %s->%s reason %s numbytes %d expect_underrun %d\n",
- nas_event_type(event->type),
- nas_elementnotify_kind(event->kind),
- nas_state(event->prev_state),
- nas_state(event->cur_state),
- nas_reason(event->reason),
- (int)event->num_bytes,
- nas_data->expect_underrun);
-
- if (event->num_bytes > INT_MAX) {
- mp_msg(MSGT_AO, MSGL_ERR, "ao_nas: num_bytes > 2GB, server buggy?\n");
- }
-
- if (event->num_bytes > nas_data->server_buffer_used)
- event->num_bytes = nas_data->server_buffer_used;
- nas_data->server_buffer_used -= event->num_bytes;
-
- switch (event->reason) {
- case AuReasonWatermark:
- nas_readBuffer(nas_data, event->num_bytes);
- break;
- case AuReasonUnderrun:
- // buffer underrun -> refill buffer
- nas_data->server_buffer_used = 0;
- if (nas_data->expect_underrun) {
- nas_data->expect_underrun = 0;
- } else {
- static int hint = 1;
- mp_msg(MSGT_AO, MSGL_WARN,
- "ao_nas: Buffer underrun.\n");
- if (hint) {
- hint = 0;
- mp_msg(MSGT_AO, MSGL_HINT,
- "Possible reasons are:\n"
- "1) Network congestion.\n"
- "2) Your NAS server is too slow.\n"
- "Try renicing your nasd to e.g. -15.\n");
- }
- }
- if (nas_readBuffer(nas_data,
- nas_data->server_buffer_size -
- nas_data->server_buffer_used) != 0) {
- event->cur_state = AuStateStart;
- break;
- }
- mp_msg(MSGT_AO, MSGL_DBG2,
- "ao_nas: Can't refill buffer, stopping flow.\n");
- AuStopFlow(aud, nas_data->flow, NULL);
- break;
- default:
- break;
- }
- nas_data->state=event->cur_state;
- return AuTrue;
-}
-
-static AuDeviceID nas_find_device(AuServer *aud, int nch)
-{
- int i;
- for (i = 0; i < AuServerNumDevices(aud); i++) {
- AuDeviceAttributes *dev = AuServerDevice(aud, i);
- if ((AuDeviceKind(dev) == AuComponentKindPhysicalOutput) &&
- AuDeviceNumTracks(dev) == nch) {
- return AuDeviceIdentifier(dev);
- }
- }
- return AuNone;
-}
-
-static unsigned int nas_aformat_to_auformat(unsigned int *format)
-{
- switch (*format) {
- case AF_FORMAT_U8:
- return AuFormatLinearUnsigned8;
- case AF_FORMAT_S8:
- return AuFormatLinearSigned8;
- case AF_FORMAT_U16_LE:
- return AuFormatLinearUnsigned16LSB;
- case AF_FORMAT_U16_BE:
- return AuFormatLinearUnsigned16MSB;
- case AF_FORMAT_S16_LE:
- return AuFormatLinearSigned16LSB;
- case AF_FORMAT_S16_BE:
- return AuFormatLinearSigned16MSB;
- case AF_FORMAT_MU_LAW:
- return AuFormatULAW8;
- default:
- *format=AF_FORMAT_S16_NE;
- return nas_aformat_to_auformat(format);
- }
-}
-
-// to set/get/query special features/parameters
-static int control(int cmd, void *arg)
-{
- AuElementParameters aep;
- AuStatus as;
- int retval = CONTROL_UNKNOWN;
-
- ao_control_vol_t *vol = (ao_control_vol_t *)arg;
-
- switch (cmd) {
- case AOCONTROL_GET_VOLUME:
-
- vol->right = (float)nas_data->gain/AU_FIXED_POINT_SCALE*50;
- vol->left = vol->right;
-
- mp_msg(MSGT_AO, MSGL_DBG2, "ao_nas: AOCONTROL_GET_VOLUME: %.2f\n", vol->right);
- retval = CONTROL_OK;
- break;
-
- case AOCONTROL_SET_VOLUME:
- /*
- * kn: we should have vol->left == vol->right but i don't
- * know if something can change it outside of ao_nas
- * so i take the mean of both values.
- */
- nas_data->gain = AU_FIXED_POINT_SCALE*((vol->left+vol->right)/2)/50;
- mp_msg(MSGT_AO, MSGL_DBG2, "ao_nas: AOCONTROL_SET_VOLUME: %.2f\n", (vol->left+vol->right)/2);
-
- aep.parameters[AuParmsMultiplyConstantConstant]=nas_data->gain;
- aep.flow = nas_data->flow;
- aep.element_num = 1;
- aep.num_parameters = AuParmsMultiplyConstant;
-
- AuSetElementParameters(nas_data->aud, 1, &aep, &as);
- if (as != AuSuccess) {
- nas_print_error(nas_data->aud,
- "control(): AuSetElementParameters", as);
- retval = CONTROL_ERROR;
- } else retval = CONTROL_OK;
- break;
- };
-
- return retval;
-}
-
-// open & setup audio device
-// return: 1=success 0=fail
-static int init(int rate,int channels,int format,int flags)
-{
- AuElement elms[3];
- AuStatus as;
- unsigned char auformat = nas_aformat_to_auformat(&format);
- int bytes_per_sample = channels * AuSizeofFormat(auformat);
- int buffer_size;
- char *server;
-
- (void)flags; /* shut up 'unused parameter' warning */
-
- global_ao->no_persistent_volume = true;
-
- nas_data=malloc(sizeof(struct ao_nas_data));
- memset(nas_data, 0, sizeof(struct ao_nas_data));
-
- mp_msg(MSGT_AO, MSGL_V, "ao2: %d Hz %d chans %s\n",rate,channels,
- af_fmt2str_short(format));
-
- ao_data.format = format;
- ao_data.samplerate = rate;
- ao_data.channels = channels;
- ao_data.outburst = NAS_FRAG_SIZE;
- ao_data.bps = rate * bytes_per_sample;
- buffer_size = ao_data.bps; /* buffer 1 second */
- /*
- * round up to multiple of NAS_FRAG_SIZE
- * divide by 3 first because of 2:1 split
- */
- buffer_size = (buffer_size/3 + NAS_FRAG_SIZE-1) & ~(NAS_FRAG_SIZE-1);
- ao_data.buffersize = buffer_size*3;
-
- nas_data->client_buffer_size = buffer_size*2;
- nas_data->client_buffer = malloc(nas_data->client_buffer_size);
- nas_data->server_buffer_size = buffer_size;
- nas_data->server_buffer = malloc(nas_data->server_buffer_size);
-
- if (!bytes_per_sample) {
- mp_msg(MSGT_AO, MSGL_ERR, "ao_nas: init(): Zero bytes per sample -> nosound\n");
- return 0;
- }
-
- if (!(server = getenv("AUDIOSERVER")) &&
- !(server = getenv("DISPLAY"))) {
- mp_msg(MSGT_AO, MSGL_ERR, "ao_nas: init(): AUDIOSERVER environment variable not set -> nosound\n");
- return 0;
- }
-
- mp_msg(MSGT_AO, MSGL_V, "ao_nas: init(): Using audioserver %s\n", server);
-
- nas_data->aud = AuOpenServer(server, 0, NULL, 0, NULL, NULL);
- if (!nas_data->aud) {
- mp_msg(MSGT_AO, MSGL_ERR, "ao_nas: init(): Can't open nas audio server -> nosound\n");
- return 0;
- }
-
- while (channels>0) {
- nas_data->dev = nas_find_device(nas_data->aud, channels);
- if (nas_data->dev != AuNone &&
- ((nas_data->flow = AuCreateFlow(nas_data->aud, NULL)) != 0))
- break;
- channels--;
- }
-
- if (nas_data->flow == 0) {
- mp_msg(MSGT_AO, MSGL_ERR, "ao_nas: init(): Can't find a suitable output device -> nosound\n");
- AuCloseServer(nas_data->aud);
- nas_data->aud = 0;
- return 0;
- }
-
- AuMakeElementImportClient(elms, rate, auformat, channels, AuTrue,
- buffer_size / bytes_per_sample,
- (buffer_size - NAS_FRAG_SIZE) /
- bytes_per_sample, 0, NULL);
- nas_data->gain = AuFixedPointFromFraction(1, 1);
- AuMakeElementMultiplyConstant(elms+1, 0, nas_data->gain);
- AuMakeElementExportDevice(elms+2, 1, nas_data->dev, rate,
- AuUnlimitedSamples, 0, NULL);
- AuSetElements(nas_data->aud, nas_data->flow, AuTrue, sizeof(elms)/sizeof(*elms), elms, &as);
- if (as != AuSuccess) {
- nas_print_error(nas_data->aud, "init(): AuSetElements", as);
- AuCloseServer(nas_data->aud);
- nas_data->aud = 0;
- return 0;
- }
- AuRegisterEventHandler(nas_data->aud, AuEventHandlerIDMask |
- AuEventHandlerTypeMask,
- AuEventTypeElementNotify, nas_data->flow,
- nas_event_handler, (AuPointer) nas_data);
- AuSetErrorHandler(nas_data->aud, nas_error_handler);
- nas_data->state=AuStateStop;
- nas_data->expect_underrun=0;
-
- pthread_mutex_init(&nas_data->buffer_mutex, NULL);
- pthread_create(&nas_data->event_thread, NULL, &nas_event_thread_start, nas_data);
-
- return 1;
-}
-
-// close audio device
-static void uninit(int immed){
-
- mp_msg(MSGT_AO, MSGL_DBG3, "ao_nas: uninit()\n");
-
- nas_data->expect_underrun = 1;
- if (!immed)
- while (nas_data->state != AuStateStop) usleep(1000);
- nas_data->stop_thread = 1;
- pthread_join(nas_data->event_thread, NULL);
- AuCloseServer(nas_data->aud);
- nas_data->aud = 0;
- free(nas_data->client_buffer);
- free(nas_data->server_buffer);
-}
-
-// stop playing and empty buffers (for seeking/pause)
-static void reset(void){
- AuStatus as;
-
- mp_msg(MSGT_AO, MSGL_DBG3, "ao_nas: reset()\n");
-
- pthread_mutex_lock(&nas_data->buffer_mutex);
- nas_data->client_buffer_used = 0;
- pthread_mutex_unlock(&nas_data->buffer_mutex);
- while (nas_data->state != AuStateStop) {
- AuStopFlow(nas_data->aud, nas_data->flow, &as);
- if (as != AuSuccess)
- nas_print_error(nas_data->aud, "reset(): AuStopFlow", as);
- usleep(1000);
- }
-}
-
-// stop playing, keep buffers (for pause)
-static void audio_pause(void)
-{
- AuStatus as;
- mp_msg(MSGT_AO, MSGL_DBG3, "ao_nas: audio_pause()\n");
-
- AuStopFlow(nas_data->aud, nas_data->flow, &as);
-}
-
-// resume playing, after audio_pause()
-static void audio_resume(void)
-{
- AuStatus as;
-
- mp_msg(MSGT_AO, MSGL_DBG3, "ao_nas: audio_resume()\n");
-
- AuStartFlow(nas_data->aud, nas_data->flow, &as);
- if (as != AuSuccess)
- nas_print_error(nas_data->aud,
- "play(): AuStartFlow", as);
-}
-
-
-// return: how many bytes can be played without blocking
-static int get_space(void)
-{
- int result;
-
- mp_msg(MSGT_AO, MSGL_DBG3, "ao_nas: get_space()\n");
-
- pthread_mutex_lock(&nas_data->buffer_mutex);
- result = nas_data->client_buffer_size - nas_data->client_buffer_used;
- pthread_mutex_unlock(&nas_data->buffer_mutex);
-
- return result;
-}
-
-// plays 'len' bytes of 'data'
-// it should round it down to outburst*n
-// return: number of bytes played
-static int play(void* data,int len,int flags)
-{
- int written, maxbursts = 0, playbursts = 0;
- AuStatus as;
-
- mp_msg(MSGT_AO, MSGL_DBG3,
- "ao_nas: play(%p, %d, %d)\n",
- data, len, flags);
-
- if (len == 0)
- return 0;
-
- if (!(flags & AOPLAY_FINAL_CHUNK)) {
- pthread_mutex_lock(&nas_data->buffer_mutex);
- maxbursts = (nas_data->client_buffer_size -
- nas_data->client_buffer_used) / ao_data.outburst;
- playbursts = len / ao_data.outburst;
- len = (playbursts > maxbursts ? maxbursts : playbursts) *
- ao_data.outburst;
- pthread_mutex_unlock(&nas_data->buffer_mutex);
- }
-
- /*
- * If AOPLAY_FINAL_CHUNK is set, we did not actually check len fits
- * into the available buffer space, but mplayer.c shouldn't give us
- * more to play than we report to it by get_space(), so this should be
- * fine.
- */
- written = nas_writeBuffer(nas_data, data, len);
-
- if (nas_data->state != AuStateStart &&
- (maxbursts == playbursts ||
- flags & AOPLAY_FINAL_CHUNK)) {
- mp_msg(MSGT_AO, MSGL_DBG2, "ao_nas: play(): Starting flow.\n");
- nas_data->expect_underrun = 1;
- AuStartFlow(nas_data->aud, nas_data->flow, &as);
- if (as != AuSuccess)
- nas_print_error(nas_data->aud, "play(): AuStartFlow", as);
- }
-
- return written;
-}
-
-// return: delay in seconds between first and last sample in buffer
-static float get_delay(void)
-{
- float result;
-
- mp_msg(MSGT_AO, MSGL_DBG3, "ao_nas: get_delay()\n");
-
- pthread_mutex_lock(&nas_data->buffer_mutex);
- result = ((float)(nas_data->client_buffer_used +
- nas_data->server_buffer_used)) /
- (float)ao_data.bps;
- pthread_mutex_unlock(&nas_data->buffer_mutex);
-
- return result;
-}
diff --git a/libao2/ao_sdl.c b/libao2/ao_sdl.c
deleted file mode 100644
index 6ff8b83cb3..0000000000
--- a/libao2/ao_sdl.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * SDLlib audio output driver for MPlayer
- *
- * Copyleft 2001 by Felix Bünemann (atmosfear@users.sf.net)
- *
- * This file is part of MPlayer.
- *
- * MPlayer 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 of the License, or
- * (at your option) any later version.
- *
- * MPlayer 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
- * along with MPlayer; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "config.h"
-#include "mp_msg.h"
-
-#include "audio_out.h"
-#include "audio_out_internal.h"
-#include "libaf/af_format.h"
-#ifdef CONFIG_SDL_SDL_H
-#include <SDL/SDL.h>
-#else
-#include <SDL.h>
-#endif
-#include "osdep/timer.h"
-
-#include "libavutil/fifo.h"
-
-static const ao_info_t info =
-{
- "SDLlib audio output",
- "sdl",
- "Felix Buenemann <atmosfear@users.sourceforge.net>",
- ""
-};
-
-LIBAO_EXTERN(sdl)
-
-// turn this on if you want to use the slower SDL_MixAudio
-#undef USE_SDL_INTERNAL_MIXER
-
-// Samplesize used by the SDLlib AudioSpec struct
-#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__AMIGAOS4__)
-#define SAMPLESIZE 2048
-#else
-#define SAMPLESIZE 1024
-#endif
-
-#define CHUNK_SIZE 4096
-#define NUM_CHUNKS 8
-#define BUFFSIZE (NUM_CHUNKS * CHUNK_SIZE)
-
-static AVFifoBuffer *buffer;
-
-#ifdef USE_SDL_INTERNAL_MIXER
-static unsigned char volume=SDL_MIX_MAXVOLUME;
-#endif
-
-static int write_buffer(unsigned char* data,int len){
- int free = av_fifo_space(buffer);
- if (len > free) len = free;
- return av_fifo_generic_write(buffer, data, len, NULL);
-}
-
-#ifdef USE_SDL_INTERNAL_MIXER
-static void mix_audio(void *dst, void *src, int len) {
- SDL_MixAudio(dst, src, len, volume);
-}
-#endif
-
-static int read_buffer(unsigned char* data,int len){
- int buffered = av_fifo_size(buffer);
- if (len > buffered) len = buffered;
-#ifdef USE_SDL_INTERNAL_MIXER
- av_fifo_generic_read(buffer, data, len, mix_audio);
-#else
- av_fifo_generic_read(buffer, data, len, NULL);
-#endif
- return len;
-}
-
-// end ring buffer stuff
-
-
-// to set/get/query special features/parameters
-static int control(int cmd,void *arg){
-#ifdef USE_SDL_INTERNAL_MIXER
- switch (cmd) {
- case AOCONTROL_GET_VOLUME:
- {
- ao_control_vol_t* vol = (ao_control_vol_t*)arg;
- vol->left = vol->right = volume * 100 / SDL_MIX_MAXVOLUME;
- return CONTROL_OK;
- }
- case AOCONTROL_SET_VOLUME:
- {
- int diff;
- ao_control_vol_t* vol = (ao_control_vol_t*)arg;
- diff = (vol->left+vol->right) / 2;
- volume = diff * SDL_MIX_MAXVOLUME / 100;
- return CONTROL_OK;
- }
- }
-#endif
- return CONTROL_UNKNOWN;
-}
-
-// SDL Callback function
-static void outputaudio(void *unused, Uint8 *stream, int len)
-{
- //SDL_MixAudio(stream, read_buffer(buffers, len), len, SDL_MIX_MAXVOLUME);
- //if(!full_buffers) printf("SDL: Buffer underrun!\n");
-
- read_buffer(stream, len);
- //printf("SDL: Full Buffers: %i\n", full_buffers);
-}
-
-// open & setup audio device
-// return: 1=success 0=fail
-static int init(int rate,int channels,int format,int flags){
-
- /* SDL Audio Specifications */
- SDL_AudioSpec aspec, obtained;
-
- global_ao->no_persistent_volume = true;
-
- /* Allocate ring-buffer memory */
- buffer = av_fifo_alloc(BUFFSIZE);
-
- mp_tmsg(MSGT_AO,MSGL_INFO,"[AO SDL] Samplerate: %iHz Channels: %s Format %s\n", rate, (channels > 1) ? "Stereo" : "Mono", af_fmt2str_short(format));
-
- if(ao_subdevice) {
- setenv("SDL_AUDIODRIVER", ao_subdevice, 1);
- mp_tmsg(MSGT_AO,MSGL_INFO,"[AO SDL] using %s audio driver.\n", ao_subdevice);
- }
-
- ao_data.channels=channels;
- ao_data.samplerate=rate;
- ao_data.format=format;
-
- ao_data.bps=channels*rate;
- if(format != AF_FORMAT_U8 && format != AF_FORMAT_S8)
- ao_data.bps*=2;
-
- /* The desired audio format (see SDL_AudioSpec) */
- switch(format) {
- case AF_FORMAT_U8:
- aspec.format = AUDIO_U8;
- break;
- case AF_FORMAT_S16_LE:
- aspec.format = AUDIO_S16LSB;
- break;
- case AF_FORMAT_S16_BE:
- aspec.format = AUDIO_S16MSB;
- break;
- case AF_FORMAT_S8:
- aspec.format = AUDIO_S8;
- break;
- case AF_FORMAT_U16_LE:
- aspec.format = AUDIO_U16LSB;
- break;
- case AF_FORMAT_U16_BE:
- aspec.format = AUDIO_U16MSB;
- break;
- default:
- aspec.format = AUDIO_S16LSB;
- ao_data.format = AF_FORMAT_S16_LE;
- mp_tmsg(MSGT_AO,MSGL_WARN,"[AO SDL] Unsupported audio format: 0x%x.\n", format);
- }
-
- /* The desired audio frequency in samples-per-second. */
- aspec.freq = rate;
-
- /* Number of channels (mono/stereo) */
- aspec.channels = channels;
-
- /* The desired size of the audio buffer in samples. This number should be a power of two, and may be adjusted by the audio driver to a value more suitable for the hardware. Good values seem to range between 512 and 8192 inclusive, depending on the application and CPU speed. Smaller values yield faster response time, but can lead to underflow if the application is doing heavy processing and cannot fill the audio buffer in time. A stereo sample consists of both right and left channels in LR ordering. Note that the number of samples is directly related to time by the following formula: ms = (samples*1000)/freq */
- aspec.samples = SAMPLESIZE;
-
- /* This should be set to a function that will be called when the audio device is ready for more data. It is passed a pointer to the audio buffer, and the length in bytes of the audio buffer. This function usually runs in a separate thread, and so you should protect data structures that it accesses by calling SDL_LockAudio and SDL_UnlockAudio in your code. The callback prototype is:
-void callback(void *userdata, Uint8 *stream, int len); userdata is the pointer stored in userdata field of the SDL_AudioSpec. stream is a pointer to the audio buffer you want to fill with information and len is the length of the audio buffer in bytes. */
- aspec.callback = outputaudio;
-
- /* This pointer is passed as the first parameter to the callback function. */
- aspec.userdata = NULL;
-
- /* initialize the SDL Audio system */
- if (SDL_Init (SDL_INIT_AUDIO/*|SDL_INIT_NOPARACHUTE*/)) {
- mp_tmsg(MSGT_AO,MSGL_ERR,"[AO SDL] SDL Audio initialization failed: %s\n", SDL_GetError());
- return 0;
- }
-
- /* Open the audio device and start playing sound! */
- if(SDL_OpenAudio(&aspec, &obtained) < 0) {
- mp_tmsg(MSGT_AO,MSGL_ERR,"[AO SDL] Unable to open audio: %s\n", SDL_GetError());
- return 0;
- }
-
- /* did we got what we wanted ? */
- ao_data.channels=obtained.channels;
- ao_data.samplerate=obtained.freq;
-
- switch(obtained.format) {
- case AUDIO_U8 :
- ao_data.format = AF_FORMAT_U8;
- break;
- case AUDIO_S16LSB :
- ao_data.format = AF_FORMAT_S16_LE;
- break;
- case AUDIO_S16MSB :
- ao_data.format = AF_FORMAT_S16_BE;
- break;
- case AUDIO_S8 :
- ao_data.format = AF_FORMAT_S8;
- break;
- case AUDIO_U16LSB :
- ao_data.format = AF_FORMAT_U16_LE;
- break;
- case AUDIO_U16MSB :
- ao_data.format = AF_FORMAT_U16_BE;
- break;
- default:
- mp_tmsg(MSGT_AO,MSGL_WARN,"[AO SDL] Unsupported audio format: 0x%x.\n", obtained.format);
- return 0;
- }
-
- mp_msg(MSGT_AO,MSGL_V,"SDL: buf size = %d\n",obtained.size);
- ao_data.buffersize=obtained.size;
- ao_data.outburst = CHUNK_SIZE;
-
- /* unsilence audio, if callback is ready */
- SDL_PauseAudio(0);
-
- return 1;
-}
-
-// close audio device
-static void uninit(int immed){
- mp_msg(MSGT_AO,MSGL_V,"SDL: Audio Subsystem shutting down!\n");
- if (!immed)
- usec_sleep(get_delay() * 1000 * 1000);
- SDL_CloseAudio();
- SDL_QuitSubSystem(SDL_INIT_AUDIO);
- av_fifo_free(buffer);
-}
-
-// stop playing and empty buffers (for seeking/pause)
-static void reset(void){
-
- //printf("SDL: reset called!\n");
-
- SDL_PauseAudio(1);
- /* Reset ring-buffer state */
- av_fifo_reset(buffer);
- SDL_PauseAudio(0);
-}
-
-// stop playing, keep buffers (for pause)
-static void audio_pause(void)
-{
-
- //printf("SDL: audio_pause called!\n");
- SDL_PauseAudio(1);
-
-}
-
-// resume playing, after audio_pause()
-static void audio_resume(void)
-{
- //printf("SDL: audio_resume called!\n");
- SDL_PauseAudio(0);
-}
-
-
-// return: how many bytes can be played without blocking
-static int get_space(void){
- return av_fifo_space(buffer);
-}
-
-// plays 'len' bytes of 'data'
-// it should round it down to outburst*n
-// return: number of bytes played
-static int play(void* data,int len,int flags){
-
- if (!(flags & AOPLAY_FINAL_CHUNK))
- len = (len/ao_data.outburst)*ao_data.outburst;
-#if 0
- int ret;
-
- /* Audio locking prohibits call of outputaudio */
- SDL_LockAudio();
- // copy audio stream into ring-buffer
- ret = write_buffer(data, len);
- SDL_UnlockAudio();
-
- return ret;
-#else
- return write_buffer(data, len);
-#endif
-}
-
-// return: delay in seconds between first and last sample in buffer
-static float get_delay(void){
- int buffered = av_fifo_size(buffer); // could be less
- return (float)(buffered + ao_data.buffersize)/(float)ao_data.bps;
-}
diff --git a/libao2/ao_sun.c b/libao2/ao_sun.c
deleted file mode 100644
index ecdb23d4af..0000000000
--- a/libao2/ao_sun.c
+++ /dev/null
@@ -1,692 +0,0 @@
-/*
- * SUN audio output driver
- *
- * This file is part of MPlayer.
- *
- * MPlayer 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 of the License, or
- * (at your option) any later version.
- *
- * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/audioio.h>
-#ifdef AUDIO_SWFEATURE_MIXER /* solaris8 or newer? */
-# define HAVE_SYS_MIXER_H 1
-#endif
-#if HAVE_SYS_MIXER_H
-# include <sys/mixer.h>
-#endif
-#ifdef __svr4__
-#include <stropts.h>
-#endif
-
-#include "config.h"
-#include "mixer.h"
-
-#include "audio_out.h"
-#include "audio_out_internal.h"
-#include "libaf/af_format.h"
-#include "mp_msg.h"
-
-static const ao_info_t info =
-{
- "Sun audio output",
- "sun",
- "Juergen Keil",
- ""
-};
-
-LIBAO_EXTERN(sun)
-
-
-/* These defines are missing on NetBSD */
-#ifndef AUDIO_PRECISION_8
-#define AUDIO_PRECISION_8 8
-#define AUDIO_PRECISION_16 16
-#endif
-#ifndef AUDIO_CHANNELS_MONO
-#define AUDIO_CHANNELS_MONO 1
-#define AUDIO_CHANNELS_STEREO 2
-#endif
-
-
-static char *sun_mixer_device = NULL;
-static char *audio_dev = NULL;
-static int queued_bursts = 0;
-static int queued_samples = 0;
-static int bytes_per_sample = 0;
-static int byte_per_sec = 0;
-static int audio_fd = -1;
-static enum {
- RTSC_UNKNOWN = 0,
- RTSC_ENABLED,
- RTSC_DISABLED
-} enable_sample_timing;
-
-
-static void flush_audio(int fd) {
-#ifdef AUDIO_FLUSH
- ioctl(fd, AUDIO_FLUSH, 0);
-#elif defined(__svr4__)
- ioctl(fd, I_FLUSH, FLUSHW);
-#endif
-}
-
-// convert an OSS audio format specification into a sun audio encoding
-static int af2sunfmt(int format)
-{
- switch (format){
- case AF_FORMAT_MU_LAW:
- return AUDIO_ENCODING_ULAW;
- case AF_FORMAT_A_LAW:
- return AUDIO_ENCODING_ALAW;
- case AF_FORMAT_S16_NE:
- return AUDIO_ENCODING_LINEAR;
-#ifdef AUDIO_ENCODING_LINEAR8 // Missing on SunOS 5.5.1...
- case AF_FORMAT_U8:
- return AUDIO_ENCODING_LINEAR8;
-#endif
- case AF_FORMAT_S8:
- return AUDIO_ENCODING_LINEAR;
-#ifdef AUDIO_ENCODING_DVI // Missing on NetBSD...
- case AF_FORMAT_IMA_ADPCM:
- return AUDIO_ENCODING_DVI;
-#endif
- default:
- return AUDIO_ENCODING_NONE;
- }
-}
-
-// try to figure out, if the soundcard driver provides usable (precise)
-// sample counter information
-static int realtime_samplecounter_available(char *dev)
-{
- int fd = -1;
- audio_info_t info;
- int rtsc_ok = RTSC_DISABLED;
- int len;
- void *silence = NULL;
- struct timeval start, end;
- struct timespec delay;
- int usec_delay;
- unsigned last_samplecnt;
- unsigned increment;
- unsigned min_increment;
-
- len = 44100 * 4 / 4; /* amount of data for 0.25sec of 44.1khz, stereo,
- * 16bit. 44kbyte can be sent to all supported
- * sun audio devices without blocking in the
- * "write" below.
- */
- silence = calloc(1, len);
- if (silence == NULL)
- goto error;
-
- if ((fd = open(dev, O_WRONLY)) < 0)
- goto error;
-
- AUDIO_INITINFO(&info);
- info.play.sample_rate = 44100;
- info.play.channels = AUDIO_CHANNELS_STEREO;
- info.play.precision = AUDIO_PRECISION_16;
- info.play.encoding = AUDIO_ENCODING_LINEAR;
- info.play.samples = 0;
- if (ioctl(fd, AUDIO_SETINFO, &info)) {
- if ( mp_msg_test(MSGT_AO,MSGL_V) )
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO SUN] rtsc: SETINFO failed.\n");
- goto error;
- }
-
- if (write(fd, silence, len) != len) {
- if ( mp_msg_test(MSGT_AO,MSGL_V) )
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO SUN] rtsc: write failed.\n");
- goto error;
- }
-
- if (ioctl(fd, AUDIO_GETINFO, &info)) {
- if ( mp_msg_test(MSGT_AO,MSGL_V) )
- perror("rtsc: GETINFO1");
- goto error;
- }
-
- last_samplecnt = info.play.samples;
- min_increment = ~0;
-
- gettimeofday(&start, NULL);
- for (;;) {
- delay.tv_sec = 0;
- delay.tv_nsec = 10000000;
- nanosleep(&delay, NULL);
- gettimeofday(&end, NULL);
- usec_delay = (end.tv_sec - start.tv_sec) * 1000000
- + end.tv_usec - start.tv_usec;
-
- // stop monitoring sample counter after 0.2 seconds
- if (usec_delay > 200000)
- break;
-
- if (ioctl(fd, AUDIO_GETINFO, &info)) {
- if ( mp_msg_test(MSGT_AO,MSGL_V) )
- perror("rtsc: GETINFO2 failed");
- goto error;
- }
- if (info.play.samples < last_samplecnt) {
- if ( mp_msg_test(MSGT_AO,MSGL_V) )
- mp_msg(MSGT_AO,MSGL_V,"rtsc: %d > %d?\n", last_samplecnt, info.play.samples);
- goto error;
- }
-
- if ((increment = info.play.samples - last_samplecnt) > 0) {
- if ( mp_msg_test(MSGT_AO,MSGL_V) )
- mp_msg(MSGT_AO,MSGL_V,"ao_sun: sample counter increment: %d\n", increment);
- if (increment < min_increment) {
- min_increment = increment;
- if (min_increment < 2000)
- break; // looks good
- }
- }
- last_samplecnt = info.play.samples;
- }
-
- /*
- * For 44.1kkz, stereo, 16-bit format we would send sound data in 16kbytes
- * chunks (== 4096 samples) to the audio device. If we see a minimum
- * sample counter increment from the soundcard driver of less than
- * 2000 samples, we assume that the driver provides a useable realtime
- * sample counter in the AUDIO_INFO play.samples field. Timing based
- * on sample counts should be much more accurate than counting whole
- * 16kbyte chunks.
- */
- if (min_increment < 2000)
- rtsc_ok = RTSC_ENABLED;
-
- if ( mp_msg_test(MSGT_AO,MSGL_V) )
- mp_msg(MSGT_AO,MSGL_V,"ao_sun: minimum sample counter increment per 10msec interval: %d\n"
- "\t%susing sample counter based timing code\n",
- min_increment, rtsc_ok == RTSC_ENABLED ? "" : "not ");
-
-
-error:
- free(silence);
- if (fd >= 0) {
- // remove the 0 bytes from the above measurement from the
- // audio driver's STREAMS queue
- flush_audio(fd);
- close(fd);
- }
-
- return rtsc_ok;
-}
-
-
-// match the requested sample rate |sample_rate| against the
-// sample rates supported by the audio device |dev|. Return
-// a supported sample rate, if that sample rate is close to
-// (< 1% difference) the requested rate; return 0 otherwise.
-
-#define MAX_RATE_ERR 1
-
-static unsigned
-find_close_samplerate_match(int dev, unsigned sample_rate)
-{
-#if HAVE_SYS_MIXER_H
- am_sample_rates_t *sr;
- unsigned i, num, err, best_err, best_rate;
-
- for (num = 16; num < 1024; num *= 2) {
- sr = malloc(AUDIO_MIXER_SAMP_RATES_STRUCT_SIZE(num));
- if (!sr)
- return 0;
- sr->type = AUDIO_PLAY;
- sr->flags = 0;
- sr->num_samp_rates = num;
- if (ioctl(dev, AUDIO_MIXER_GET_SAMPLE_RATES, sr)) {
- free(sr);
- return 0;
- }
- if (sr->num_samp_rates <= num)
- break;
- free(sr);
- }
-
- if (sr->flags & MIXER_SR_LIMITS) {
- /*
- * HW can playback any rate between
- * sr->samp_rates[0] .. sr->samp_rates[1]
- */
- free(sr);
- return 0;
- } else {
- /* HW supports fixed sample rates only */
-
- best_err = 65535;
- best_rate = 0;
-
- for (i = 0; i < sr->num_samp_rates; i++) {
- err = abs(sr->samp_rates[i] - sample_rate);
- if (err == 0) {
- /*
- * exact supported sample rate match, no need to
- * retry something else
- */
- best_rate = 0;
- break;
- }
- if (err < best_err) {
- best_err = err;
- best_rate = sr->samp_rates[i];
- }
- }
-
- free(sr);
-
- if (best_rate > 0 && (100/MAX_RATE_ERR)*best_err < sample_rate) {
- /* found a supported sample rate with <1% error? */
- return best_rate;
- }
- return 0;
- }
-#else /* old audioio driver, cannot return list of supported rates */
- /* XXX: hardcoded sample rates */
- unsigned i, err;
- unsigned audiocs_rates[] = {
- 5510, 6620, 8000, 9600, 11025, 16000, 18900, 22050,
- 27420, 32000, 33075, 37800, 44100, 48000, 0
- };
-
- for (i = 0; audiocs_rates[i]; i++) {
- err = abs(audiocs_rates[i] - sample_rate);
- if (err == 0) {
- /*
- * exact supported sample rate match, no need to
- * retry something elise
- */
- return 0;
- }
- if ((100/MAX_RATE_ERR)*err < audiocs_rates[i]) {
- /* <1% error? */
- return audiocs_rates[i];
- }
- }
-
- return 0;
-#endif
-}
-
-
-// return the highest sample rate supported by audio device |dev|.
-static unsigned
-find_highest_samplerate(int dev)
-{
-#if HAVE_SYS_MIXER_H
- am_sample_rates_t *sr;
- unsigned i, num, max_rate;
-
- for (num = 16; num < 1024; num *= 2) {
- sr = malloc(AUDIO_MIXER_SAMP_RATES_STRUCT_SIZE(num));
- if (!sr)
- return 0;
- sr->type = AUDIO_PLAY;
- sr->flags = 0;
- sr->num_samp_rates = num;
- if (ioctl(dev, AUDIO_MIXER_GET_SAMPLE_RATES, sr)) {
- free(sr);
- return 0;
- }
- if (sr->num_samp_rates <= num)
- break;
- free(sr);
- }
-
- if (sr->flags & MIXER_SR_LIMITS) {
- /*
- * HW can playback any rate between
- * sr->samp_rates[0] .. sr->samp_rates[1]
- */
- max_rate = sr->samp_rates[1];
- } else {
- /* HW supports fixed sample rates only */
- max_rate = 0;
- for (i = 0; i < sr->num_samp_rates; i++) {
- if (sr->samp_rates[i] > max_rate)
- max_rate = sr->samp_rates[i];
- }
- }
- free(sr);
- return max_rate;
-
-#else /* old audioio driver, cannot return list of supported rates */
- return 44100; /* should be supported even on old ISA SB cards */
-#endif
-}
-
-
-static void setup_device_paths(void)
-{
- if (audio_dev == NULL) {
- if ((audio_dev = getenv("AUDIODEV")) == NULL)
- audio_dev = "/dev/audio";
- }
-
- if (sun_mixer_device == NULL) {
- if ((sun_mixer_device = mixer_device) == NULL || !sun_mixer_device[0]) {
- sun_mixer_device = malloc(strlen(audio_dev) + 4);
- strcpy(sun_mixer_device, audio_dev);
- strcat(sun_mixer_device, "ctl");
- }
- }
-
- if (ao_subdevice) audio_dev = ao_subdevice;
-}
-
-// to set/get/query special features/parameters
-static int control(int cmd,void *arg){
- switch(cmd){
- case AOCONTROL_GET_VOLUME:
- {
- int fd;
-
- if ( !sun_mixer_device ) /* control function is used before init? */
- setup_device_paths();
-
- fd=open( sun_mixer_device,O_RDONLY );
- if ( fd != -1 )
- {
- ao_control_vol_t *vol = (ao_control_vol_t *)arg;
- float volume;
- struct audio_info info;
- ioctl( fd,AUDIO_GETINFO,&info);
- volume = info.play.gain * 100. / AUDIO_MAX_GAIN;
- if ( info.play.balance == AUDIO_MID_BALANCE ) {
- vol->right = vol->left = volume;
- } else if ( info.play.balance < AUDIO_MID_BALANCE ) {
- vol->left = volume;
- vol->right = volume * info.play.balance / AUDIO_MID_BALANCE;
- } else {
- vol->left = volume * (AUDIO_RIGHT_BALANCE-info.play.balance)
- / AUDIO_MID_BALANCE;
- vol->right = volume;
- }
- close( fd );
- return CONTROL_OK;
- }
- return CONTROL_ERROR;
- }
- case AOCONTROL_SET_VOLUME:
- {
- ao_control_vol_t *vol = (ao_control_vol_t *)arg;
- int fd;
-
- if ( !sun_mixer_device ) /* control function is used before init? */
- setup_device_paths();
-
- fd=open( sun_mixer_device,O_RDONLY );
- if ( fd != -1 )
- {
- struct audio_info info;
- float volume;
- AUDIO_INITINFO(&info);
- volume = vol->right > vol->left ? vol->right : vol->left;
- if ( volume != 0 ) {
- info.play.gain = volume * AUDIO_MAX_GAIN / 100;
- if ( vol->right == vol->left )
- info.play.balance = AUDIO_MID_BALANCE;
- else
- info.play.balance = (vol->right - vol->left + volume) * AUDIO_RIGHT_BALANCE / (2*volume);
- }
-#if !defined (__OpenBSD__) && !defined (__NetBSD__)
- info.output_muted = (volume == 0);
-#endif
- ioctl( fd,AUDIO_SETINFO,&info );
- close( fd );
- return CONTROL_OK;
- }
- return CONTROL_ERROR;
- }
- }
- return CONTROL_UNKNOWN;
-}
-
-// open & setup audio device
-// return: 1=success 0=fail
-static int init(int rate,int channels,int format,int flags){
-
- audio_info_t info;
- int pass;
- int ok;
- int convert_u8_s8;
-
- setup_device_paths();
-
- if (enable_sample_timing == RTSC_UNKNOWN
- && !getenv("AO_SUN_DISABLE_SAMPLE_TIMING")) {
- enable_sample_timing = realtime_samplecounter_available(audio_dev);
- }
-
- mp_msg(MSGT_AO,MSGL_STATUS,"ao2: %d Hz %d chans %s [0x%X]\n",
- rate,channels,af_fmt2str_short(format),format);
-
- audio_fd=open(audio_dev, O_WRONLY);
- if(audio_fd<0){
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO SUN] Can't open audio device %s, %s -> nosound.\n", audio_dev, strerror(errno));
- return 0;
- }
-
- if (af2sunfmt(format) == AUDIO_ENCODING_NONE)
- format = AF_FORMAT_S16_NE;
-
- for (ok = pass = 0; pass <= 5; pass++) { /* pass 6&7 not useful */
-
- AUDIO_INITINFO(&info);
- info.play.encoding = af2sunfmt(ao_data.format = format);
- info.play.precision =
- (format==AF_FORMAT_S16_NE
- ? AUDIO_PRECISION_16
- : AUDIO_PRECISION_8);
- info.play.channels = ao_data.channels = channels;
- info.play.sample_rate = ao_data.samplerate = rate;
-
- convert_u8_s8 = 0;
-
- if (pass & 1) {
- /*
- * on some sun audio drivers, 8-bit unsigned LINEAR8 encoding is
- * not supported, but 8-bit signed encoding is.
- *
- * Try S8, and if it works, use our own U8->S8 conversion before
- * sending the samples to the sound driver.
- */
-#ifdef AUDIO_ENCODING_LINEAR8
- if (info.play.encoding != AUDIO_ENCODING_LINEAR8)
-#endif
- continue;
- info.play.encoding = AUDIO_ENCODING_LINEAR;
- convert_u8_s8 = 1;
- }
-
- if (pass & 2) {
- /*
- * on some sun audio drivers, only certain fixed sample rates are
- * supported.
- *
- * In case the requested sample rate is very close to one of the
- * supported rates, use the fixed supported rate instead.
- */
- if (!(info.play.sample_rate =
- find_close_samplerate_match(audio_fd, rate)))
- continue;
-
- /*
- * I'm not returning the correct sample rate in
- * |ao_data.samplerate|, to avoid software resampling.
- *
- * ao_data.samplerate = info.play.sample_rate;
- */
- }
-
- if (pass & 4) {
- /* like "pass & 2", but use the highest supported sample rate */
- if (!(info.play.sample_rate
- = ao_data.samplerate
- = find_highest_samplerate(audio_fd)))
- continue;
- }
-
- ok = ioctl(audio_fd, AUDIO_SETINFO, &info) >= 0;
- if (ok) {
- /* audio format accepted by audio driver */
- break;
- }
-
- /*
- * format not supported?
- * retry with different encoding and/or sample rate
- */
- }
-
- if (!ok) {
- char buf[128];
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO SUN] audio_setup: your card doesn't support %d channel, %s, %d Hz samplerate.\n",
- channels, af_fmt2str(format, buf, 128), rate);
- return 0;
- }
-
- if (convert_u8_s8)
- ao_data.format = AF_FORMAT_S8;
-
- bytes_per_sample = channels * info.play.precision / 8;
- ao_data.bps = byte_per_sec = bytes_per_sample * ao_data.samplerate;
- ao_data.outburst = byte_per_sec > 100000 ? 16384 : 8192;
-
- reset();
-
- return 1;
-}
-
-// close audio device
-static void uninit(int immed){
- // throw away buffered data in the audio driver's STREAMS queue
- if (immed)
- flush_audio(audio_fd);
- else
- ioctl(audio_fd, AUDIO_DRAIN, 0);
- close(audio_fd);
-}
-
-// stop playing and empty buffers (for seeking/pause)
-static void reset(void){
- audio_info_t info;
- flush_audio(audio_fd);
-
- AUDIO_INITINFO(&info);
- info.play.samples = 0;
- info.play.eof = 0;
- info.play.error = 0;
- ioctl(audio_fd, AUDIO_SETINFO, &info);
-
- queued_bursts = 0;
- queued_samples = 0;
-}
-
-// stop playing, keep buffers (for pause)
-static void audio_pause(void)
-{
- struct audio_info info;
- AUDIO_INITINFO(&info);
- info.play.pause = 1;
- ioctl(audio_fd, AUDIO_SETINFO, &info);
-}
-
-// resume playing, after audio_pause()
-static void audio_resume(void)
-{
- struct audio_info info;
- AUDIO_INITINFO(&info);
- info.play.pause = 0;
- ioctl(audio_fd, AUDIO_SETINFO, &info);
-}
-
-
-// return: how many bytes can be played without blocking
-static int get_space(void){
- audio_info_t info;
-
- // check buffer
-#ifdef HAVE_AUDIO_SELECT
- {
- fd_set rfds;
- struct timeval tv;
- FD_ZERO(&rfds);
- FD_SET(audio_fd, &rfds);
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- if(!select(audio_fd+1, NULL, &rfds, NULL, &tv)) return 0; // not block!
- }
-#endif
-
- ioctl(audio_fd, AUDIO_GETINFO, &info);
-#if !defined (__OpenBSD__) && !defined(__NetBSD__)
- if (queued_bursts - info.play.eof > 2)
- return 0;
- return ao_data.outburst;
-#else
- return info.hiwat * info.blocksize - info.play.seek;
-#endif
-
-}
-
-// plays 'len' bytes of 'data'
-// it should round it down to outburst*n
-// return: number of bytes played
-static int play(void* data,int len,int flags){
- if (!(flags & AOPLAY_FINAL_CHUNK)) {
- len /= ao_data.outburst;
- len *= ao_data.outburst;
- }
- if (len <= 0) return 0;
-
- len = write(audio_fd, data, len);
- if(len > 0) {
- queued_samples += len / bytes_per_sample;
- if (write(audio_fd,data,0) < 0)
- perror("ao_sun: send EOF audio record");
- else
- queued_bursts ++;
- }
- return len;
-}
-
-
-// return: delay in seconds between first and last sample in buffer
-static float get_delay(void){
- audio_info_t info;
- ioctl(audio_fd, AUDIO_GETINFO, &info);
-#if defined (__OpenBSD__) || defined(__NetBSD__)
- return (float) info.play.seek/ (float)byte_per_sec ;
-#else
- if (info.play.samples && enable_sample_timing == RTSC_ENABLED)
- return (float)(queued_samples - info.play.samples) / (float)ao_data.samplerate;
- else
- return (float)((queued_bursts - info.play.eof) * ao_data.outburst) / (float)byte_per_sec;
-#endif
-}
diff --git a/libao2/ao_win32.c b/libao2/ao_win32.c
deleted file mode 100644
index 55ed17b457..0000000000
--- a/libao2/ao_win32.c
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * Windows waveOut interface
- *
- * Copyright (c) 2002 - 2004 Sascha Sommer <saschasommer@freenet.de>
- *
- * This file is part of MPlayer.
- *
- * MPlayer 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 of the License, or
- * (at your option) any later version.
- *
- * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-#include <mmsystem.h>
-
-#include "config.h"
-#include "libaf/af_format.h"
-#include "audio_out.h"
-#include "audio_out_internal.h"
-#include "mp_msg.h"
-#include "libvo/fastmemcpy.h"
-#include "osdep/timer.h"
-
-#define WAVE_FORMAT_DOLBY_AC3_SPDIF 0x0092
-#define WAVE_FORMAT_EXTENSIBLE 0xFFFE
-
-static const GUID KSDATAFORMAT_SUBTYPE_PCM = {
- 0x1,0x0000,0x0010,{0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71}
-};
-
-typedef struct {
- WAVEFORMATEX Format;
- union {
- WORD wValidBitsPerSample;
- WORD wSamplesPerBlock;
- WORD wReserved;
- } Samples;
- DWORD dwChannelMask;
- GUID SubFormat;
-} WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;
-
-#define SPEAKER_FRONT_LEFT 0x1
-#define SPEAKER_FRONT_RIGHT 0x2
-#define SPEAKER_FRONT_CENTER 0x4
-#define SPEAKER_LOW_FREQUENCY 0x8
-#define SPEAKER_BACK_LEFT 0x10
-#define SPEAKER_BACK_RIGHT 0x20
-#define SPEAKER_FRONT_LEFT_OF_CENTER 0x40
-#define SPEAKER_FRONT_RIGHT_OF_CENTER 0x80
-#define SPEAKER_BACK_CENTER 0x100
-#define SPEAKER_SIDE_LEFT 0x200
-#define SPEAKER_SIDE_RIGHT 0x400
-#define SPEAKER_TOP_CENTER 0x800
-#define SPEAKER_TOP_FRONT_LEFT 0x1000
-#define SPEAKER_TOP_FRONT_CENTER 0x2000
-#define SPEAKER_TOP_FRONT_RIGHT 0x4000
-#define SPEAKER_TOP_BACK_LEFT 0x8000
-#define SPEAKER_TOP_BACK_CENTER 0x10000
-#define SPEAKER_TOP_BACK_RIGHT 0x20000
-
-static const int channel_mask[] = {
- SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY,
- SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY,
- SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_CENTER | SPEAKER_LOW_FREQUENCY,
- SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_LOW_FREQUENCY
-};
-
-
-
-#define SAMPLESIZE 1024
-#define BUFFER_SIZE 4096
-#define BUFFER_COUNT 16
-
-
-static WAVEHDR* waveBlocks; //pointer to our ringbuffer memory
-static HWAVEOUT hWaveOut; //handle to the waveout device
-static unsigned int buf_write=0;
-static volatile int buf_read=0;
-
-
-static const ao_info_t info =
-{
- "Windows waveOut audio output",
- "win32",
- "Sascha Sommer <saschasommer@freenet.de>",
- ""
-};
-
-LIBAO_EXTERN(win32)
-
-static void CALLBACK waveOutProc(HWAVEOUT hWaveOut,UINT uMsg,DWORD dwInstance,
- DWORD dwParam1,DWORD dwParam2)
-{
- if(uMsg != WOM_DONE)
- return;
- buf_read = (buf_read + 1) % BUFFER_COUNT;
-}
-
-// to set/get/query special features/parameters
-static int control(int cmd,void *arg)
-{
- DWORD volume;
- switch (cmd)
- {
- case AOCONTROL_GET_VOLUME:
- {
- ao_control_vol_t* vol = (ao_control_vol_t*)arg;
- waveOutGetVolume(hWaveOut,&volume);
- vol->left = (float)(LOWORD(volume)/655.35);
- vol->right = (float)(HIWORD(volume)/655.35);
- mp_msg(MSGT_AO, MSGL_DBG2,"ao_win32: volume left:%f volume right:%f\n",vol->left,vol->right);
- return CONTROL_OK;
- }
- case AOCONTROL_SET_VOLUME:
- {
- ao_control_vol_t* vol = (ao_control_vol_t*)arg;
- volume = MAKELONG(vol->left*655.35,vol->right*655.35);
- waveOutSetVolume(hWaveOut,volume);
- return CONTROL_OK;
- }
- }
- return -1;
-}
-
-// open & setup audio device
-// return: 1=success 0=fail
-static int init(int rate,int channels,int format,int flags)
-{
- WAVEFORMATEXTENSIBLE wformat;
- MMRESULT result;
- unsigned char* buffer;
- int i;
-
- if (AF_FORMAT_IS_AC3(format))
- format = AF_FORMAT_AC3_NE;
- switch(format){
- case AF_FORMAT_AC3_NE:
- case AF_FORMAT_S24_LE:
- case AF_FORMAT_S16_LE:
- case AF_FORMAT_U8:
- break;
- default:
- mp_msg(MSGT_AO, MSGL_V,"ao_win32: format %s not supported defaulting to Signed 16-bit Little-Endian\n",af_fmt2str_short(format));
- format=AF_FORMAT_S16_LE;
- }
-
- // FIXME multichannel mode is buggy
- if(channels > 2)
- channels = 2;
-
- //fill global ao_data
- ao_data.channels=channels;
- ao_data.samplerate=rate;
- ao_data.format=format;
- ao_data.bps=channels*rate;
- if(format != AF_FORMAT_U8 && format != AF_FORMAT_S8)
- ao_data.bps*=2;
- ao_data.outburst = BUFFER_SIZE;
- if(ao_data.buffersize==-1)
- {
- ao_data.buffersize=af_fmt2bits(format)/8;
- ao_data.buffersize*= channels;
- ao_data.buffersize*= SAMPLESIZE;
- }
- mp_msg(MSGT_AO, MSGL_V,"ao_win32: Samplerate:%iHz Channels:%i Format:%s\n",rate, channels, af_fmt2str_short(format));
- mp_msg(MSGT_AO, MSGL_V,"ao_win32: Buffersize:%d\n",ao_data.buffersize);
-
- //fill waveformatex
- ZeroMemory( &wformat, sizeof(WAVEFORMATEXTENSIBLE));
- wformat.Format.cbSize = (channels>2)?sizeof(WAVEFORMATEXTENSIBLE)-sizeof(WAVEFORMATEX):0;
- wformat.Format.nChannels = channels;
- wformat.Format.nSamplesPerSec = rate;
- if(AF_FORMAT_IS_AC3(format))
- {
- wformat.Format.wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF;
- wformat.Format.wBitsPerSample = 16;
- wformat.Format.nBlockAlign = 4;
- }
- else
- {
- wformat.Format.wFormatTag = (channels>2)?WAVE_FORMAT_EXTENSIBLE:WAVE_FORMAT_PCM;
- wformat.Format.wBitsPerSample = af_fmt2bits(format);
- wformat.Format.nBlockAlign = wformat.Format.nChannels * (wformat.Format.wBitsPerSample >> 3);
- }
- if(channels>2)
- {
- wformat.dwChannelMask = channel_mask[channels-3];
- wformat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
- wformat.Samples.wValidBitsPerSample=af_fmt2bits(format);
- }
-
- wformat.Format.nAvgBytesPerSec = wformat.Format.nSamplesPerSec * wformat.Format.nBlockAlign;
-
- //open sound device
- //WAVE_MAPPER always points to the default wave device on the system
- result = waveOutOpen(&hWaveOut,WAVE_MAPPER,(WAVEFORMATEX*)&wformat,(DWORD_PTR)waveOutProc,0,CALLBACK_FUNCTION);
- if(result == WAVERR_BADFORMAT)
- {
- mp_msg(MSGT_AO, MSGL_ERR,"ao_win32: format not supported switching to default\n");
- ao_data.channels = wformat.Format.nChannels = 2;
- ao_data.samplerate = wformat.Format.nSamplesPerSec = 44100;
- ao_data.format = AF_FORMAT_S16_LE;
- ao_data.bps=ao_data.channels * ao_data.samplerate*2;
- wformat.Format.wBitsPerSample=16;
- wformat.Format.wFormatTag=WAVE_FORMAT_PCM;
- wformat.Format.nBlockAlign = wformat.Format.nChannels * (wformat.Format.wBitsPerSample >> 3);
- wformat.Format.nAvgBytesPerSec = wformat.Format.nSamplesPerSec * wformat.Format.nBlockAlign;
- ao_data.buffersize=(wformat.Format.wBitsPerSample>>3)*wformat.Format.nChannels*SAMPLESIZE;
- result = waveOutOpen(&hWaveOut,WAVE_MAPPER,(WAVEFORMATEX*)&wformat,(DWORD_PTR)waveOutProc,0,CALLBACK_FUNCTION);
- }
- if(result != MMSYSERR_NOERROR)
- {
- mp_msg(MSGT_AO, MSGL_ERR,"ao_win32: unable to open wave mapper device (result=%i)\n",result);
- return 0;
- }
- //allocate buffer memory as one big block
- buffer = calloc(BUFFER_COUNT, BUFFER_SIZE + sizeof(WAVEHDR));
- //and setup pointers to each buffer
- waveBlocks = (WAVEHDR*)buffer;
- buffer += sizeof(WAVEHDR) * BUFFER_COUNT;
- for(i = 0; i < BUFFER_COUNT; i++) {
- waveBlocks[i].lpData = buffer;
- buffer += BUFFER_SIZE;
- }
- buf_write=0;
- buf_read=0;
-
- return 1;
-}
-
-// close audio device
-static void uninit(int immed)
-{
- if(!immed)
- usec_sleep(get_delay() * 1000 * 1000);
- else
- waveOutReset(hWaveOut);
- while (waveOutClose(hWaveOut) == WAVERR_STILLPLAYING) usec_sleep(0);
- mp_msg(MSGT_AO, MSGL_V,"waveOut device closed\n");
- free(waveBlocks);
- mp_msg(MSGT_AO, MSGL_V,"buffer memory freed\n");
-}
-
-// stop playing and empty buffers (for seeking/pause)
-static void reset(void)
-{
- waveOutReset(hWaveOut);
- buf_write=0;
- buf_read=0;
-}
-
-// stop playing, keep buffers (for pause)
-static void audio_pause(void)
-{
- waveOutPause(hWaveOut);
-}
-
-// resume playing, after audio_pause()
-static void audio_resume(void)
-{
- waveOutRestart(hWaveOut);
-}
-
-// return: how many bytes can be played without blocking
-static int get_space(void)
-{
- int free = buf_read - buf_write - 1;
- if (free < 0) free += BUFFER_COUNT;
- return free * BUFFER_SIZE;
-}
-
-//writes data into buffer, based on ringbuffer code in ao_sdl.c
-static int write_waveOutBuffer(unsigned char* data,int len){
- WAVEHDR* current;
- int len2=0;
- int x;
- while(len>0){
- int buf_next = (buf_write + 1) % BUFFER_COUNT;
- current = &waveBlocks[buf_write];
- if(buf_next == buf_read) break;
- //unprepare the header if it is prepared
- if(current->dwFlags & WHDR_PREPARED)
- waveOutUnprepareHeader(hWaveOut, current, sizeof(WAVEHDR));
- x=BUFFER_SIZE;
- if(x>len) x=len;
- fast_memcpy(current->lpData,data+len2,x);
- len2+=x; len-=x;
- //prepare header and write data to device
- current->dwBufferLength = x;
- waveOutPrepareHeader(hWaveOut, current, sizeof(WAVEHDR));
- waveOutWrite(hWaveOut, current, sizeof(WAVEHDR));
-
- buf_write = buf_next;
- }
- return len2;
-}
-
-// plays 'len' bytes of 'data'
-// it should round it down to outburst*n
-// return: number of bytes played
-static int play(void* data,int len,int flags)
-{
- if (!(flags & AOPLAY_FINAL_CHUNK))
- len = (len/ao_data.outburst)*ao_data.outburst;
- return write_waveOutBuffer(data,len);
-}
-
-// return: delay in seconds between first and last sample in buffer
-static float get_delay(void)
-{
- int used = buf_write - buf_read;
- if (used < 0) used += BUFFER_COUNT;
- return (float)(used * BUFFER_SIZE + ao_data.buffersize)/(float)ao_data.bps;
-}
diff --git a/libao2/audio_out.c b/libao2/audio_out.c
index 36b3e2d7c6..6836963d66 100644
--- a/libao2/audio_out.c
+++ b/libao2/audio_out.c
@@ -34,25 +34,14 @@ char *ao_subdevice = NULL;
extern const struct ao_driver audio_out_oss;
extern const struct ao_driver audio_out_coreaudio;
-extern const struct ao_driver audio_out_arts;
extern const struct ao_driver audio_out_rsound;
-extern const struct ao_driver audio_out_esd;
extern const struct ao_driver audio_out_pulse;
extern const struct ao_driver audio_out_jack;
extern const struct ao_driver audio_out_openal;
extern const struct ao_driver audio_out_null;
extern const struct ao_driver audio_out_alsa;
-extern const struct ao_driver audio_out_nas;
-extern const struct ao_driver audio_out_sdl;
-extern const struct ao_driver audio_out_sun;
-extern const struct ao_driver audio_out_sgi;
-extern const struct ao_driver audio_out_win32;
extern const struct ao_driver audio_out_dsound;
-extern const struct ao_driver audio_out_kai;
-extern const struct ao_driver audio_out_dart;
-extern const struct ao_driver audio_out_ivtv;
extern const struct ao_driver audio_out_v4l2;
-extern const struct ao_driver audio_out_mpegpes;
extern const struct ao_driver audio_out_pcm;
extern const struct ao_driver audio_out_pss;
extern const struct ao_driver audio_out_portaudio;
@@ -62,15 +51,6 @@ static const struct ao_driver * const audio_out_drivers[] = {
#ifdef CONFIG_DIRECTX
&audio_out_dsound,
#endif
-#ifdef CONFIG_WIN32WAVEOUT
- &audio_out_win32,
-#endif
-#ifdef CONFIG_KAI
- &audio_out_kai,
-#endif
-#ifdef CONFIG_DART
- &audio_out_dart,
-#endif
#ifdef CONFIG_COREAUDIO
&audio_out_coreaudio,
#endif
@@ -86,26 +66,13 @@ static const struct ao_driver * const audio_out_drivers[] = {
#ifdef CONFIG_PORTAUDIO
&audio_out_portaudio,
#endif
-#ifdef CONFIG_SUN_AUDIO
- &audio_out_sun,
-#endif
// wrappers:
#ifdef CONFIG_JACK
&audio_out_jack,
#endif
-#ifdef CONFIG_NAS
- &audio_out_nas,
-#endif
#ifdef CONFIG_OPENAL
&audio_out_openal,
#endif
-#ifdef CONFIG_SDL
- &audio_out_sdl,
-#endif
- &audio_out_mpegpes,
-#ifdef CONFIG_IVTV
- &audio_out_ivtv,
-#endif
#ifdef CONFIG_V4L2_DECODER
&audio_out_v4l2,
#endif