summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-06-08 23:31:06 +0000
committerarpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-06-08 23:31:06 +0000
commit0b3d0c82a7fd24331350142ef59aed00ac6538ad (patch)
treef4cf8de37c2d5856d219af2d5488750449b8931f
parent7d96a77e0df64332dc5e0c93fa5e955a9c4e43ef (diff)
downloadmpv-0b3d0c82a7fd24331350142ef59aed00ac6538ad.tar.bz2
mpv-0b3d0c82a7fd24331350142ef59aed00ac6538ad.tar.xz
fixed AFMT_ stuff (inclue afmt.h)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1059 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--dec_audio.c22
-rw-r--r--libao2/afmt.h34
-rw-r--r--libao2/ao_alsa1x.c2
-rw-r--r--libao2/ao_alsa5.c2
-rw-r--r--libao2/ao_alsa9.c2
-rw-r--r--libao2/ao_oss.c1
-rw-r--r--libao2/ao_sun.c39
-rw-r--r--libao2/audio_out.c30
8 files changed, 80 insertions, 52 deletions
diff --git a/dec_audio.c b/dec_audio.c
index 0d6baa6480..f7bc573cef 100644
--- a/dec_audio.c
+++ b/dec_audio.c
@@ -3,19 +3,7 @@
#include <stdlib.h>
#include "config.h"
-
-#ifdef USE_OSS_AUDIO
-#include <sys/soundcard.h>
-#endif
-#ifdef USE_SUN_AUDIO
-#include <sys/types.h>
-#include <sys/audioio.h>
-#define AFMT_MU_LAW AUDIO_ENCODING_ULAW
-#define AFMT_A_LAW AUDIO_ENCODING_ALAW
-#define AFMT_S16_LE AUDIO_ENCODING_LINEAR
-#define AFMT_IMA_ADPCM AUDIO_ENCODING_DVI
-#define AFMT_U8 AUDIO_ENCODING_LINEAR8
-#endif
+#include "libao2/afmt.h"
extern int verbose; // defined in mplayer.c
@@ -172,12 +160,8 @@ case 2: {
switch(sh_audio->format){ // hardware formats:
case 0x6: sh_audio->sample_format=AFMT_A_LAW;break;
case 0x7: sh_audio->sample_format=AFMT_MU_LAW;break;
-#if !defined(__NetBSD__)
case 0x11: sh_audio->sample_format=AFMT_IMA_ADPCM;break;
-#endif
-#if !defined(__sun) && !defined(__NetBSD__)
case 0x50: sh_audio->sample_format=AFMT_MPEG;break;
-#endif
// case 0x2000: sh_audio->sample_format=AFMT_AC3;
default: sh_audio->sample_format=(sh_audio->samplesize==2)?AFMT_S16_LE:AFMT_U8;
}
@@ -278,12 +262,10 @@ int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){
switch(sh_audio->codec->driver){
case 1: // MPEG layer 2 or 3
len=MP3_DecodeFrame(buf,-1);
- sh_audio->channels=2; // hack
break;
case 2: // AVI PCM
- { len=demux_read_data(sh_audio->ds,buf,minlen);
+ len=demux_read_data(sh_audio->ds,buf,minlen);
break;
- }
case 8: // DVD PCM
{ int j;
len=demux_read_data(sh_audio->ds,buf,minlen);
diff --git a/libao2/afmt.h b/libao2/afmt.h
new file mode 100644
index 0000000000..29f2de1912
--- /dev/null
+++ b/libao2/afmt.h
@@ -0,0 +1,34 @@
+
+/* Defines that AFMT_ stuff */
+
+#ifdef HAVE_SYS_SOUNDCARD_H
+#include <sys/soundcard.h> /* For AFMT_* on linux */
+#endif
+
+/* standard, old OSS audio formats */
+#ifndef AFMT_MU_LAW
+# 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 */
+#endif
+
+#ifndef AFMT_MPEG
+# define AFMT_MPEG 0x00000200 /* MPEG (2) audio */
+#endif
+
+#ifndef AFMT_AC3
+# define AFMT_AC3 0x00000400 /* Dolby Digital AC3 */
+#endif
+
+/* 32 bit formats (MSB aligned) formats */
+#ifndef AFMT_S32_LE
+# define AFMT_S32_LE 0x00001000
+# define AFMT_S32_BE 0x00002000
+#endif
+
diff --git a/libao2/ao_alsa1x.c b/libao2/ao_alsa1x.c
index 71ee42e9be..626d034380 100644
--- a/libao2/ao_alsa1x.c
+++ b/libao2/ao_alsa1x.c
@@ -5,13 +5,13 @@
*/
#include <errno.h>
-#include <sys/soundcard.h> /* AFMT_* */
#include <sys/asoundlib.h>
#include "../config.h"
#include "audio_out.h"
#include "audio_out_internal.h"
+#include "afmt.h"
extern int verbose;
diff --git a/libao2/ao_alsa5.c b/libao2/ao_alsa5.c
index 158732f771..c4395f4d4a 100644
--- a/libao2/ao_alsa5.c
+++ b/libao2/ao_alsa5.c
@@ -7,13 +7,13 @@
*/
#include <errno.h>
-#include <sys/soundcard.h> /* AFMT_* */
#include <sys/asoundlib.h>
#include "../config.h"
#include "audio_out.h"
#include "audio_out_internal.h"
+#include "afmt.h"
extern int verbose;
diff --git a/libao2/ao_alsa9.c b/libao2/ao_alsa9.c
index 71ee42e9be..626d034380 100644
--- a/libao2/ao_alsa9.c
+++ b/libao2/ao_alsa9.c
@@ -5,13 +5,13 @@
*/
#include <errno.h>
-#include <sys/soundcard.h> /* AFMT_* */
#include <sys/asoundlib.h>
#include "../config.h"
#include "audio_out.h"
#include "audio_out_internal.h"
+#include "afmt.h"
extern int verbose;
diff --git a/libao2/ao_oss.c b/libao2/ao_oss.c
index de50dc77f3..4e94f9af6b 100644
--- a/libao2/ao_oss.c
+++ b/libao2/ao_oss.c
@@ -13,6 +13,7 @@
#include "audio_out.h"
#include "audio_out_internal.h"
+//#include "afmt.h"
static ao_info_t info =
{
diff --git a/libao2/ao_sun.c b/libao2/ao_sun.c
index 93218dff2e..e6032a4fb4 100644
--- a/libao2/ao_sun.c
+++ b/libao2/ao_sun.c
@@ -16,6 +16,7 @@
#include "audio_out.h"
#include "audio_out_internal.h"
+#include "afmt.h"
static ao_info_t info =
{
@@ -46,6 +47,27 @@ static char *dsp="/dev/audio";
static int queued_bursts = 0;
static int audio_fd=-1;
+// convert an OSS audio format specification into a sun audio encoding
+static int oss2sunfmt(int oss_format)
+{
+ switch (oss_format){
+ case AFMT_MU_LAW:
+ return AUDIO_ENCODING_ULAW;
+ case AFMT_A_LAW:
+ return AUDIO_ENCODING_ALAW;
+ case AFMT_S16_LE:
+ return AUDIO_ENCODING_LINEAR;
+ case AFMT_U8:
+ return AUDIO_ENCODING_LINEAR8;
+#ifdef AUDIO_ENCODING_DVI // Missing on NetBSD...
+ case AFMT_IMA_ADPCM:
+ return AUDIO_ENCODING_DVI;
+#endif
+ default:
+ return AUDIO_ENCODING_NONE;
+ }
+}
+
// to set/get/query special features/parameters
static int control(int cmd,int arg){
switch(cmd){
@@ -76,18 +98,16 @@ static int init(int rate,int channels,int format,int flags){
ioctl(audio_fd, AUDIO_DRAIN, 0);
AUDIO_INITINFO(&info);
- info.play.encoding = ao_format = format;
- info.play.precision = (format==AUDIO_ENCODING_LINEAR? AUDIO_PRECISION_16:AUDIO_PRECISION_8);
+ info.play.encoding = oss2sunfmt(ao_format = format);
+ info.play.precision = (format==AFMT_S16_LE? AUDIO_PRECISION_16:AUDIO_PRECISION_8);
info.play.channels = ao_channels = channels;
--ao_channels;
info.play.sample_rate = ao_samplerate = rate;
info.play.samples = 0;
info.play.eof = 0;
if(ioctl (audio_fd, AUDIO_SETINFO, &info)<0)
- printf("audio_setup: your card doesn't support %d Hz samplerate\n",rate);
- byte_per_sec = (channels
- * (format==AUDIO_ENCODING_LINEAR ? 16 : 8)
- * rate);
+ printf("audio_setup: your card doesn't support %d channel, %s, %d Hz samplerate\n",channels,audio_out_format_name(format),rate);
+ byte_per_sec = (channels * info.play.precision * rate);
ao_outburst=byte_per_sec > 100000 ? 16384 : 8192;
queued_bursts = 0;
@@ -113,6 +133,8 @@ static int init(int rate,int channels,int format,int flags){
return 0;
}
#ifdef __svr4__
+ // remove the 0 bytes from the above ao_buffersize measurement from the
+ // audio driver's STREAMS queue
ioctl(audio_fd, I_FLUSH, FLUSHW);
#endif
ioctl(audio_fd, AUDIO_DRAIN, 0);
@@ -132,6 +154,7 @@ static void reset(){
audio_info_t info;
#ifdef __svr4__
+ // throw away buffered data in the audio driver's STREAMS queue
ioctl(audio_fd, I_FLUSH, FLUSHW);
#endif
uninit();
@@ -144,8 +167,8 @@ static void reset(){
ioctl(audio_fd, AUDIO_DRAIN, 0);
AUDIO_INITINFO(&info);
- info.play.encoding = ao_format;
- info.play.precision = (ao_format==AUDIO_ENCODING_LINEAR? AUDIO_PRECISION_16:AUDIO_PRECISION_8);
+ info.play.encoding = oss2sunfmt(ao_format);
+ info.play.precision = (ao_format==AFMT_S16_LE? AUDIO_PRECISION_16:AUDIO_PRECISION_8);
info.play.channels = ao_channels+1;
info.play.sample_rate = ao_samplerate;
info.play.samples = 0;
diff --git a/libao2/audio_out.c b/libao2/audio_out.c
index f23aa9b535..cc03b01bd3 100644
--- a/libao2/audio_out.c
+++ b/libao2/audio_out.c
@@ -2,26 +2,8 @@
#include <stdlib.h>
#include "../config.h"
-
#include "audio_out.h"
-
-#include <sys/soundcard.h> /* AFMT_* */
-
-#ifndef SOUNCARD_H
-# 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
+#include "afmt.h"
// there are some globals:
int ao_samplerate=0;
@@ -99,10 +81,16 @@ char *audio_out_format_name(int format)
return("Unsigned 16-bit (Big-Endian)");
case AFMT_MPEG:
return("MPEG (2) audio");
+ // the following two formats are not available with old linux kernel
+ // headers (e.g. in 2.2.16)
+#ifdef AFMT_S32_LE
case AFMT_S32_LE:
- return("Signed 32-bit (Little-Endian");
+ return("Signed 32-bit (Little-Endian)");
+#endif
+#ifdef AFMT_S32_BE
case AFMT_S32_BE:
- return("Signed 32-bit (Big-Endian");
+ return("Signed 32-bit (Big-Endian)");
+#endif
}
return("Unknown");
}