diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/audio_out/audio_alsa_out.c | 46 | ||||
-rw-r--r-- | src/liblpcm/xine_decoder.c | 8 | ||||
-rw-r--r-- | src/xine-engine/audio_out.h | 5 |
3 files changed, 45 insertions, 14 deletions
diff --git a/src/audio_out/audio_alsa_out.c b/src/audio_out/audio_alsa_out.c index ab3fd228f..e61eb9a79 100644 --- a/src/audio_out/audio_alsa_out.c +++ b/src/audio_out/audio_alsa_out.c @@ -26,7 +26,7 @@ * (c) 2001 James Courtier-Dutton <James@superbug.demon.co.uk> * * - * $Id: audio_alsa_out.c,v 1.139 2004/05/07 13:37:00 mroi Exp $ + * $Id: audio_alsa_out.c,v 1.140 2004/05/15 20:27:50 jcdutton Exp $ */ #ifdef HAVE_CONFIG_H @@ -333,6 +333,7 @@ static int ao_alsa_open(ao_driver_t *this_gen, uint32_t bits, uint32_t rate, int snd_pcm_uframes_t period_size_max; snd_pcm_uframes_t buffer_size_min; snd_pcm_uframes_t buffer_size_max; + snd_pcm_format_t format; #if 0 uint32_t periods; #endif @@ -441,14 +442,28 @@ static int ao_alsa_open(ao_driver_t *this_gen, uint32_t bits, uint32_t rate, int "audio_alsa_out: access type not available: %s\n", snd_strerror(err)); goto __close; } - /* set the sample format ([SU]{8,16{LE,BE}})*/ - err = snd_pcm_hw_params_set_format(this->audio_fd, params, (bits == 16) ? -#ifdef WORDS_BIGENDIAN - SND_PCM_FORMAT_S16_BE -#else - SND_PCM_FORMAT_S16_LE -#endif - : SND_PCM_FORMAT_U8); + /* set the sample format ([SU]{8,16,24,FLOAT}) */ + /* ALSA automatically appends _LE or _BE depending on the CPU */ + switch (bits>>3) { + case 1: + format = SND_PCM_FORMAT_U8; + break; + case 2: + format = SND_PCM_FORMAT_S16; + break; + case 3: + format = SND_PCM_FORMAT_S24; + break; + case 4: + format = SND_PCM_FORMAT_FLOAT; + break; + default: + format = SND_PCM_FORMAT_S16; + xprintf (this->class->xine, XINE_VERBOSITY_DEBUG, + "audio_alsa_out: pcm format bits=%d unknown. failed: %s\n", bits, snd_strerror(err)); + break; + } + err = snd_pcm_hw_params_set_format(this->audio_fd, params, format ); if (err < 0) { xprintf (this->class->xine, XINE_VERBOSITY_DEBUG, "audio_alsa_out: sample format non available: %s\n", snd_strerror(err)); @@ -1451,6 +1466,19 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *da this->capabilities |= AO_CAP_8BITS; xprintf(class->xine, XINE_VERBOSITY_LOG, _("8bit ")); } + /* ALSA automatically appends _LE or _BE depending on the CPU */ + if (!(snd_pcm_hw_params_test_format(this->audio_fd, params, SND_PCM_FORMAT_S16))) { + this->capabilities |= AO_CAP_16BITS; + xprintf(class->xine, XINE_VERBOSITY_LOG, _("16bit ")); + } + if (!(snd_pcm_hw_params_test_format(this->audio_fd, params, SND_PCM_FORMAT_S24))) { + this->capabilities |= AO_CAP_24BITS; + xprintf(class->xine, XINE_VERBOSITY_LOG, _("24bit ")); + } + if (!(snd_pcm_hw_params_test_format(this->audio_fd, params, SND_PCM_FORMAT_FLOAT))) { + this->capabilities |= AO_CAP_32BITS; + xprintf(class->xine, XINE_VERBOSITY_LOG, _("32bit ")); + } if (!(snd_pcm_hw_params_test_channels(this->audio_fd, params, 1))) { this->capabilities |= AO_CAP_MODE_MONO; xprintf(class->xine, XINE_VERBOSITY_LOG, _("mono ")); diff --git a/src/liblpcm/xine_decoder.c b/src/liblpcm/xine_decoder.c index d15521b83..93b0295f8 100644 --- a/src/liblpcm/xine_decoder.c +++ b/src/liblpcm/xine_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_decoder.c,v 1.51 2004/01/12 17:35:16 miguelfreitas Exp $ + * $Id: xine_decoder.c,v 1.52 2004/05/15 20:27:51 jcdutton Exp $ * * 31-8-2001 Added LPCM rate sensing. * (c) 2001 James Courtier-Dutton James@superbug.demon.co.uk @@ -123,10 +123,10 @@ static void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { if (this->output_open) this->stream->audio_out->close (this->stream->audio_out, this->stream); - this->ao_cap_mode=(this->number_of_channels == 2) ? AO_CAP_MODE_STEREO : AO_CAP_MODE_MONO; - + this->ao_cap_mode=(this->number_of_channels == 2) ? AO_CAP_MODE_STEREO : AO_CAP_MODE_MONO; + this->output_open = this->stream->audio_out->open (this->stream->audio_out, this->stream, - (this->bits_per_sample>16)?16:this->bits_per_sample, + this->bits_per_sample, this->rate, this->ao_cap_mode) ; diff --git a/src/xine-engine/audio_out.h b/src/xine-engine/audio_out.h index 9ed8decbc..25bb9955c 100644 --- a/src/xine-engine/audio_out.h +++ b/src/xine-engine/audio_out.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: audio_out.h,v 1.67 2004/02/12 18:09:19 mroi Exp $ + * $Id: audio_out.h,v 1.68 2004/05/15 20:27:51 jcdutton Exp $ */ #ifndef HAVE_AUDIO_OUT_H #define HAVE_AUDIO_OUT_H @@ -298,6 +298,9 @@ int _x_ao_mode2channels( int mode ); #define AO_CAP_PCM_VOL 0x00000200 /* driver supports pcm control */ #define AO_CAP_MUTE_VOL 0x00000400 /* driver can mute volume */ #define AO_CAP_8BITS 0x00000800 /* driver support 8-bit samples */ +#define AO_CAP_16BITS 0x00001000 /* driver support 16-bit samples */ +#define AO_CAP_24BITS 0x00002000 /* driver support 24-bit samples */ +#define AO_CAP_32BITS 0x00004000 /* driver support 32-bit samples. i.e. Floats */ /* properties supported by get/set_property() */ #define AO_PROP_MIXER_VOL 0 |