summaryrefslogtreecommitdiffstats
path: root/libao2
diff options
context:
space:
mode:
Diffstat (limited to 'libao2')
-rw-r--r--libao2/Makefile4
-rw-r--r--libao2/ao_alsa5.c12
-rw-r--r--libao2/ao_null.c12
-rw-r--r--libao2/ao_oss.c79
-rw-r--r--libao2/ao_sdl.c32
-rw-r--r--libao2/audio_out.c33
-rw-r--r--libao2/audio_out.h8
-rw-r--r--libao2/audio_out_internal.h6
8 files changed, 117 insertions, 69 deletions
diff --git a/libao2/Makefile b/libao2/Makefile
index 267078ff63..433962639b 100644
--- a/libao2/Makefile
+++ b/libao2/Makefile
@@ -4,10 +4,10 @@ include config.mak
LIBNAME = libao2.a
# TODO: moveout ao_sdl.c so it's only used when SDL is detected
-SRCS=audio_out.c ao_oss.c ao_null.c $(OPTIONAL_SRCS)
+SRCS=audio_out.c ao_null.c $(OPTIONAL_SRCS)
OBJS=$(SRCS:.c=.o)
-CFLAGS = $(OPTFLAGS) -I. -I..
+CFLAGS = $(OPTFLAGS) -I. -I.. $(SDL_INC)
# -I/usr/X11R6/include/
.SUFFIXES: .c .o
diff --git a/libao2/ao_alsa5.c b/libao2/ao_alsa5.c
index 2039dacd26..f058d2c829 100644
--- a/libao2/ao_alsa5.c
+++ b/libao2/ao_alsa5.c
@@ -265,6 +265,18 @@ static void reset()
}
}
+/* stop playing, keep buffers (for pause) */
+static void audio_pause()
+{
+ /* for now, just call reset(); */
+ reset();
+}
+
+/* resume playing, after audio_pause() */
+static void audio_resume()
+{
+}
+
/*
plays 'len' bytes of 'data'
returns: number of bytes played
diff --git a/libao2/ao_null.c b/libao2/ao_null.c
index 4ec360fea6..53f59236be 100644
--- a/libao2/ao_null.c
+++ b/libao2/ao_null.c
@@ -46,6 +46,18 @@ static void reset(){
}
+// stop playing, keep buffers (for pause)
+static void audio_pause()
+{
+ // for now, just call reset();
+ reset();
+}
+
+// resume playing, after audio_pause()
+static void audio_resume()
+{
+}
+
// return: how many bytes can be played without blocking
static int get_space(){
diff --git a/libao2/ao_oss.c b/libao2/ao_oss.c
index c04626c2fd..de50dc77f3 100644
--- a/libao2/ao_oss.c
+++ b/libao2/ao_oss.c
@@ -7,11 +7,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#ifdef __sun
-#include <sys/audioio.h>
-#else
#include <sys/soundcard.h>
-#endif
#include "../config.h"
@@ -36,13 +32,8 @@ LIBAO_EXTERN(oss)
// ao_outburst
// ao_buffersize
-#ifdef __sun
-static char *dsp="/dev/audio";
-static int queued_bursts = 0;
-#else
static char *dsp="/dev/dsp";
static audio_buf_info zz;
-#endif
static int audio_fd=-1;
// to set/get/query special features/parameters
@@ -69,22 +60,6 @@ static int init(int rate,int channels,int format,int flags){
return 0;
}
-#ifdef __sun
- {
- audio_info_t info;
- ioctl(audio_fd, AUDIO_GETINFO, &info);
- ioctl(audio_fd, AUDIO_DRAIN, 0);
- info.play.encoding = ao_format = format;
- info.play.precision = (format==AUDIO_ENCODING_LINEAR? AUDIO_PRECISION_16:AUDIO_PRECISION_8);
- info.play.channels = ao_channels = channels;
- --ao_channels;
- info.play.sample_rate = ao_samplerate = rate;
- if(ioctl (audio_fd, AUDIO_SETINFO, &info)<0)
- printf("audio_setup: your card doesn't support %d Hz samplerate\n",rate);
- ao_outburst=8192;
- queued_bursts = 0;
- }
-#else
ao_format=format;
ioctl (audio_fd, SNDCTL_DSP_SETFMT, &ao_format);
printf("audio_setup: sample format: 0x%X (requested: 0x%X)\n",ao_format,format);
@@ -112,7 +87,6 @@ static int init(int rate,int channels,int format,int flags){
if(ao_buffersize==-1) ao_buffersize=zz.bytes;
ao_outburst=zz.fragsize;
}
-#endif
if(ao_buffersize==-1){
// Measuring buffer size:
@@ -135,9 +109,6 @@ static int init(int rate,int channels,int format,int flags){
printf("Recompile mplayer with #undef HAVE_AUDIO_SELECT in config.h !\n\n");
return 0;
}
-#ifdef __sun
- ioctl(audio_fd, AUDIO_DRAIN, 0);
-#endif
#endif
}
@@ -161,26 +132,25 @@ static void reset(){
return;
}
-#ifdef __sun
- {
- audio_info_t info;
- ioctl(audio_fd, AUDIO_GETINFO, &info);
- ioctl(audio_fd, AUDIO_DRAIN, 0);
- info.play.encoding = ao_format;
- info.play.precision = (ao_format==AUDIO_ENCODING_LINEAR? AUDIO_PRECISION_16:AUDIO_PRECISION_8);
- info.play.channels = ao_channels+1;
- info.play.sample_rate = ao_samplerate;
- ioctl (audio_fd, AUDIO_SETINFO, &info);
- queued_bursts = 0;
- }
-#else
ioctl (audio_fd, SNDCTL_DSP_SETFMT, &ao_format);
ioctl (audio_fd, SNDCTL_DSP_STEREO, &ao_channels);
ioctl (audio_fd, SNDCTL_DSP_SPEED, &ao_samplerate);
-#endif
}
+// stop playing, keep buffers (for pause)
+static void audio_pause()
+{
+ // for now, just call reset();
+ reset();
+}
+
+// resume playing, after audio_pause()
+static void audio_resume()
+{
+}
+
+
// return: how many bytes can be played without blocking
static int get_space(){
int playsize=ao_outburst;
@@ -204,14 +174,6 @@ static int get_space(){
}
#endif
-#ifdef __sun
- {
- audio_info_t info;
- ioctl(audio_fd, AUDIO_GETINFO, &info);
- if(queued_bursts - info.play.eof > 2)
- return 0;
- }
-#endif
return ao_outburst;
}
@@ -221,12 +183,6 @@ static int get_space(){
static int play(void* data,int len,int flags){
len/=ao_outburst;
len=write(audio_fd,data,len*ao_outburst);
-#ifdef __sun
- if(len>0) {
- queued_bursts ++;
- write(audio_fd,data,0);
- }
-#endif
return len;
}
@@ -234,14 +190,6 @@ static int audio_delay_method=2;
// return: how many unplayed bytes are in the buffer
static int get_delay(){
-#ifdef __sun
- {
- int q;
- audio_info_t info;
- ioctl(audio_fd, AUDIO_GETINFO, &info);
- return (queued_bursts - info.play.eof) * ao_outburst;
- }
-#else
if(audio_delay_method==2){
//
int r=0;
@@ -256,6 +204,5 @@ static int get_delay(){
audio_delay_method=0; // fallback if not supported
}
return ao_buffersize;
-#endif
}
diff --git a/libao2/ao_sdl.c b/libao2/ao_sdl.c
index bdd11ab4c4..717a63e9da 100644
--- a/libao2/ao_sdl.c
+++ b/libao2/ao_sdl.c
@@ -11,6 +11,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include "audio_out.h"
#include "audio_out_internal.h"
@@ -57,6 +58,7 @@ static unsigned int buf_write_pos=0;
static int full_buffers=0;
static int buffered_bytes=0;
+
static int write_buffer(unsigned char* data,int len){
int len2=0;
int x;
@@ -105,6 +107,23 @@ static int read_buffer(unsigned char* data,int len){
#include <SDL/SDL.h>
#endif
+#if defined(sun) && defined(__svr4__)
+/* setenv is missing on solaris */
+static void setenv(const char *name, const char *val, int _xx)
+{
+ int len = strlen(name) + strlen(val) + 2;
+ char *env = malloc(len);
+
+ if (env != NULL) {
+ strcpy(env, name);
+ strcat(env, "=");
+ strcat(env, val);
+ putenv(env);
+ }
+}
+#endif
+
+
// to set/get/query special features/parameters
static int control(int cmd,int arg){
return -1;
@@ -196,6 +215,19 @@ static void reset(){
}
+// stop playing, keep buffers (for pause)
+static void audio_pause()
+{
+ // for now, just call reset();
+ reset();
+}
+
+// resume playing, after audio_pause()
+static void audio_resume()
+{
+}
+
+
// return: how many bytes can be played without blocking
static int get_space(){
return (NUM_BUFS-full_buffers)*BUFFSIZE - buf_write_pos;
diff --git a/libao2/audio_out.c b/libao2/audio_out.c
index afa239ccd8..3f7ae08656 100644
--- a/libao2/audio_out.c
+++ b/libao2/audio_out.c
@@ -5,7 +5,30 @@
#include "audio_out.h"
+#ifdef USE_OSS_AUDIO
#include <sys/soundcard.h> /* AFMT_* */
+#endif
+
+
+#ifndef AFMT_U8
+# define AFMT_MU_LAW 0x00000001
+# define AFMT_A_LAW 0x00000002
+# define AFMT_IMA_ADPCM 0x00000004
+# define AFMT_U8 0x00000008
+# define AFMT_S16_LE 0x00000010 /* Little endian signed
+16*/
+# define AFMT_S16_BE 0x00000020 /* Big endian signed 16
+*/
+# define AFMT_S8 0x00000040
+# define AFMT_U16_LE 0x00000080 /* Little endian U16 */
+# define AFMT_U16_BE 0x00000100 /* Big endian U16 */
+# define AFMT_MPEG 0x00000200 /* MPEG (2) audio */
+
+/* 32 bit formats (MSB aligned) formats */
+# define AFMT_S32_LE 0x00001000
+# define AFMT_S32_BE 0x00002000
+#endif
+
// there are some globals:
int ao_samplerate=0;
@@ -15,7 +38,9 @@ int ao_bps=0;
int ao_outburst=OUTBURST; // config.h default
int ao_buffersize=-1;
+#ifdef USE_OSS_AUDIO
extern ao_functions_t audio_out_oss;
+#endif
//extern ao_functions_t audio_out_ossold;
extern ao_functions_t audio_out_null;
#ifdef HAVE_ALSA5
@@ -32,10 +57,15 @@ extern ao_functions_t audio_out_null;
#ifdef HAVE_SDL
extern ao_functions_t audio_out_sdl;
#endif
+#ifdef USE_SUN_AUDIO
+extern ao_functions_t audio_out_sun;
+#endif
ao_functions_t* audio_out_drivers[] =
{
+#ifdef USE_OSS_AUDIO
&audio_out_oss,
+#endif
&audio_out_null,
#ifdef HAVE_ALSA5
&audio_out_alsa5,
@@ -51,6 +81,9 @@ ao_functions_t* audio_out_drivers[] =
#ifdef HAVE_SDL
&audio_out_sdl,
#endif
+#ifdef USE_SUN_AUDIO
+ &audio_out_sun,
+#endif
NULL
};
diff --git a/libao2/audio_out.h b/libao2/audio_out.h
index cdd58dc7d4..b730d7cf8f 100644
--- a/libao2/audio_out.h
+++ b/libao2/audio_out.h
@@ -43,6 +43,14 @@ typedef struct ao_functions_s {
*/
int (*get_delay)();
+ /*
+ */
+ void (*pause)();
+
+ /*
+ */
+ void (*resume)();
+
} ao_functions_t;
// NULL terminated array of all drivers
diff --git a/libao2/audio_out_internal.h b/libao2/audio_out_internal.h
index 5899270af2..5867d91d6c 100644
--- a/libao2/audio_out_internal.h
+++ b/libao2/audio_out_internal.h
@@ -8,6 +8,8 @@ static void reset();
static int get_space();
static int play(void* data,int len,int flags);
static int get_delay();
+static void audio_pause();
+static void audio_resume();
#define LIBAO_EXTERN(x) ao_functions_t audio_out_##x =\
{\
@@ -18,6 +20,8 @@ static int get_delay();
reset,\
get_space,\
play,\
- get_delay\
+ get_delay,\
+ audio_pause,\
+ audio_resume\
};