Mercurial > mplayer.hg
changeset 1058:cab5ba9ffc6c
fixed AFMT_ stuff (inclue afmt.h)
author | arpi_esp |
---|---|
date | Fri, 08 Jun 2001 23:31:06 +0000 |
parents | 555f58131861 |
children | ebb2605b9c60 |
files | dec_audio.c libao2/afmt.h libao2/ao_alsa1x.c libao2/ao_alsa5.c libao2/ao_alsa9.c libao2/ao_oss.c libao2/ao_sun.c libao2/audio_out.c |
diffstat | 8 files changed, 80 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/dec_audio.c Fri Jun 08 23:30:09 2001 +0000 +++ b/dec_audio.c Fri Jun 08 23:31:06 2001 +0000 @@ -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 @@ 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 @@ 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);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libao2/afmt.h Fri Jun 08 23:31:06 2001 +0000 @@ -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 +
--- a/libao2/ao_alsa1x.c Fri Jun 08 23:30:09 2001 +0000 +++ b/libao2/ao_alsa1x.c Fri Jun 08 23:31:06 2001 +0000 @@ -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;
--- a/libao2/ao_alsa5.c Fri Jun 08 23:30:09 2001 +0000 +++ b/libao2/ao_alsa5.c Fri Jun 08 23:31:06 2001 +0000 @@ -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;
--- a/libao2/ao_alsa9.c Fri Jun 08 23:30:09 2001 +0000 +++ b/libao2/ao_alsa9.c Fri Jun 08 23:31:06 2001 +0000 @@ -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;
--- a/libao2/ao_oss.c Fri Jun 08 23:30:09 2001 +0000 +++ b/libao2/ao_oss.c Fri Jun 08 23:31:06 2001 +0000 @@ -13,6 +13,7 @@ #include "audio_out.h" #include "audio_out_internal.h" +//#include "afmt.h" static ao_info_t info = {
--- a/libao2/ao_sun.c Fri Jun 08 23:30:09 2001 +0000 +++ b/libao2/ao_sun.c Fri Jun 08 23:31:06 2001 +0000 @@ -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 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 @@ 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 @@ 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 @@ 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 @@ 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;
--- a/libao2/audio_out.c Fri Jun 08 23:30:09 2001 +0000 +++ b/libao2/audio_out.c Fri Jun 08 23:31:06 2001 +0000 @@ -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 @@ 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"); }