summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/audio_out/audio_alsa_out.c37
-rw-r--r--src/liba52/xine_decoder.c46
-rw-r--r--src/xine-engine/audio_out.c13
-rw-r--r--src/xine-engine/audio_out.h24
4 files changed, 76 insertions, 44 deletions
diff --git a/src/audio_out/audio_alsa_out.c b/src/audio_out/audio_alsa_out.c
index 09a13fe15..c88e1291c 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.105 2003/09/01 00:51:45 jcdutton Exp $
+ * $Id: audio_alsa_out.c,v 1.106 2003/09/01 04:08:41 jcdutton Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -321,22 +321,14 @@ static int ao_alsa_open(ao_driver_t *this_gen, uint32_t bits, uint32_t rate, int
10, NULL,
NULL);
break;
+ case AO_CAP_MODE_4_1CHANNEL:
case AO_CAP_MODE_5CHANNEL:
- this->num_channels = 5;
- pcm_device = config->register_string(config,
- "audio.alsa_surround50_device",
- "surround51",
- _("device used for 5-channel output"),
- NULL,
- 10, NULL,
- NULL);
- break;
case AO_CAP_MODE_5_1CHANNEL:
this->num_channels = 6;
pcm_device = config->register_string(config,
"audio.alsa_surround51_device",
"surround51",
- _("device used for 5.1-channel output"),
+ _("device used for 5+ channel output"),
NULL,
10, NULL,
NULL);
@@ -1205,13 +1197,6 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *da
10, NULL,
NULL);
pcm_device = config->register_string(config,
- "audio.alsa_surround50_device",
- "surround51",
- _("device used for 5-channel output"),
- NULL,
- 10, NULL,
- NULL);
- pcm_device = config->register_string(config,
"audio.alsa_surround51_device",
"surround51",
_("device used for 5.1-channel output"),
@@ -1298,7 +1283,21 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *da
} else if (class->xine->verbosity >= XINE_VERBOSITY_LOG) {
printf ("(4-channel not enabled in xine config) " );
}
- if (!(snd_pcm_hw_params_test_channels(this->audio_fd, params, 5)) &&
+ if (!(snd_pcm_hw_params_test_channels(this->audio_fd, params, 6)) &&
+ config->register_bool (config,
+ "audio.four_lfe_channel",
+ 0,
+ _("used to inform xine about what the sound card can do"),
+ NULL,
+ 0, NULL,
+ NULL) ) {
+ this->capabilities |= AO_CAP_MODE_4_1CHANNEL;
+ if (class->xine->verbosity >= XINE_VERBOSITY_LOG)
+ printf ("4.1-channel ");
+ } else if (class->xine->verbosity >= XINE_VERBOSITY_LOG) {
+ printf ("(4.1-channel not enabled in xine config) " );
+ }
+ if (!(snd_pcm_hw_params_test_channels(this->audio_fd, params, 6)) &&
config->register_bool (config,
"audio.five_channel",
0,
diff --git a/src/liba52/xine_decoder.c b/src/liba52/xine_decoder.c
index 4815b4dfe..8131b8754 100644
--- a/src/liba52/xine_decoder.c
+++ b/src/liba52/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.54 2003/08/25 21:51:40 f1rmb Exp $
+ * $Id: xine_decoder.c,v 1.55 2003/09/01 04:08:41 jcdutton Exp $
*
* stuff needed to turn liba52 into a xine decoder plugin
*/
@@ -175,6 +175,14 @@ static inline void float_to_int (float * _f, int16_t * s16, int num_channels) {
}
}
+static inline void mute_channel (int16_t * s16, int num_channels) {
+ int i;
+
+ for (i = 0; i < 256; i++) {
+ s16[num_channels*i] = 0;
+ }
+}
+
static void a52dec_decode_frame (a52dec_decoder_t *this, int64_t pts, int preview_mode) {
int output_mode = AO_CAP_MODE_STEREO;
@@ -212,10 +220,16 @@ static void a52dec_decode_frame (a52dec_decoder_t *this, int64_t pts, int previe
this->have_lfe = a52_output_flags & A52_LFE;
if (this->have_lfe)
- output_mode = AO_CAP_MODE_5_1CHANNEL;
+ if (this->audio_caps & AO_CAP_MODE_5_1CHANNEL) {
+ output_mode = AO_CAP_MODE_5_1CHANNEL;
+ } else if (this->audio_caps & AO_CAP_MODE_4_1CHANNEL) {
+ output_mode = AO_CAP_MODE_4_1CHANNEL;
+ } else {
+ printf("liba52: WHAT DO I DO!!!\n");
+ output_mode = this->ao_flags_map[a52_output_flags];
+ }
else
output_mode = this->ao_flags_map[a52_output_flags];
-
/*
* (re-)open output device
*/
@@ -270,12 +284,21 @@ static void a52dec_decode_frame (a52dec_decoder_t *this, int64_t pts, int previe
float_to_int (&samples[2*256], int_samples+(i*256*4)+2, 4); /* RL */
float_to_int (&samples[3*256], int_samples+(i*256*4)+3, 4); /* RR */
break;
+ case AO_CAP_MODE_4_1CHANNEL:
+ float_to_int (&samples[0*256], int_samples+(i*256*6)+5, 6); /* LFE */
+ float_to_int (&samples[1*256], int_samples+(i*256*6)+0, 6); /* L */
+ float_to_int (&samples[2*256], int_samples+(i*256*6)+1, 6); /* R */
+ float_to_int (&samples[3*256], int_samples+(i*256*6)+2, 6); /* RL */
+ float_to_int (&samples[4*256], int_samples+(i*256*6)+3, 6); /* RR */
+ mute_channel ( int_samples+(i*256*6)+4, 6); /* C */
+ break;
case AO_CAP_MODE_5CHANNEL:
- float_to_int (&samples[0*256], int_samples+(i*256*5)+0, 5); /* L */
- float_to_int (&samples[1*256], int_samples+(i*256*5)+4, 5); /* C */
- float_to_int (&samples[2*256], int_samples+(i*256*5)+1, 5); /* R */
- float_to_int (&samples[3*256], int_samples+(i*256*5)+2, 5); /* RL */
- float_to_int (&samples[4*256], int_samples+(i*256*5)+3, 5); /* RR */
+ float_to_int (&samples[0*256], int_samples+(i*256*6)+0, 6); /* L */
+ float_to_int (&samples[1*256], int_samples+(i*256*6)+4, 6); /* C */
+ float_to_int (&samples[2*256], int_samples+(i*256*6)+1, 6); /* R */
+ float_to_int (&samples[3*256], int_samples+(i*256*6)+2, 6); /* RL */
+ float_to_int (&samples[4*256], int_samples+(i*256*6)+3, 6); /* RR */
+ mute_channel ( int_samples+(i*256*6)+5, 6); /* LFE */
break;
case AO_CAP_MODE_5_1CHANNEL:
float_to_int (&samples[0*256], int_samples+(i*256*6)+5, 6); /* lfe */
@@ -569,6 +592,13 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre
this->ao_flags_map[A52_2F2R] = AO_CAP_MODE_4CHANNEL;
this->ao_flags_map[A52_3F2R] = AO_CAP_MODE_5CHANNEL;
+ } else if (this->audio_caps & AO_CAP_MODE_4_1CHANNEL) {
+
+ this->a52_flags_map[A52_2F2R] = A52_2F2R;
+ this->a52_flags_map[A52_3F2R] = A52_2F2R | A52_LFE;
+ this->ao_flags_map[A52_2F2R] = AO_CAP_MODE_4CHANNEL;
+ this->ao_flags_map[A52_3F2R] = AO_CAP_MODE_4CHANNEL;
+
} else if (this->audio_caps & AO_CAP_MODE_4CHANNEL) {
this->a52_flags_map[A52_2F2R] = A52_2F2R;
diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c
index 7df86a47c..43bd0b3aa 100644
--- a/src/xine-engine/audio_out.c
+++ b/src/xine-engine/audio_out.c
@@ -17,7 +17,7 @@
* along with self program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: audio_out.c,v 1.139 2003/08/29 20:35:44 miguelfreitas Exp $
+ * $Id: audio_out.c,v 1.140 2003/09/01 04:08:41 jcdutton Exp $
*
* 22-8-2001 James imported some useful AC3 sections from the previous alsa driver.
* (c) 2001 Andy Lo A Foe <andy@alsaplayer.org>
@@ -480,8 +480,8 @@ static int mode_channels( int mode ) {
return 2;
case AO_CAP_MODE_4CHANNEL:
return 4;
+ case AO_CAP_MODE_4_1CHANNEL:
case AO_CAP_MODE_5CHANNEL:
- return 5;
case AO_CAP_MODE_5_1CHANNEL:
return 6;
}
@@ -675,12 +675,8 @@ static audio_buffer_t* prepare_samples( aos_t *this, audio_buffer_t *buf) {
this->frame_buf[1]->mem, num_output_frames);
buf = swap_frame_buffers(this);
break;
+ case AO_CAP_MODE_4_1CHANNEL:
case AO_CAP_MODE_5CHANNEL:
- ensure_buffer_size(this->frame_buf[1], 10, num_output_frames);
- audio_out_resample_5channel (buf->mem, buf->num_frames,
- this->frame_buf[1]->mem, num_output_frames);
- buf = swap_frame_buffers(this);
- break;
case AO_CAP_MODE_5_1CHANNEL:
ensure_buffer_size(this->frame_buf[1], 12, num_output_frames);
audio_out_resample_6channel (buf->mem, buf->num_frames,
@@ -1290,9 +1286,8 @@ static int ao_open(xine_audio_port_t *this_gen, xine_stream_t *stream,
case AO_CAP_MODE_4CHANNEL:
stream->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] = 4;
break;
+ case AO_CAP_MODE_4_1CHANNEL:
case AO_CAP_MODE_5CHANNEL:
- stream->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] = 5;
- break;
case AO_CAP_MODE_5_1CHANNEL:
stream->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] = 6;
break;
diff --git a/src/xine-engine/audio_out.h b/src/xine-engine/audio_out.h
index 8b12d9e3c..e7aba704e 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.57 2003/08/26 21:18:32 miguelfreitas Exp $
+ * $Id: audio_out.h,v 1.58 2003/09/01 04:08:41 jcdutton Exp $
*/
#ifndef HAVE_AUDIO_OUT_H
#define HAVE_AUDIO_OUT_H
@@ -279,14 +279,22 @@ xine_audio_port_t *ao_new_port (xine_t *xine, ao_driver_t *driver, int grab_only
#define AO_CAP_MODE_STEREO 0x00000008 /* driver supports stereo output */
/* 1 sample == 8 bytes (L,R,LR,RR) */
#define AO_CAP_MODE_4CHANNEL 0x00000010 /* driver supports 4 channels */
-/* 1 sample == 10 bytes (L,R,LR,RR,C) */
-#define AO_CAP_MODE_5CHANNEL 0x00000020 /* driver supports 5 channels */
+/*
+ * Sound cards generally support, 1,2,4,6 channels, but rarely 5.
+ * So xine will take 4.1, 5 and 6 channel a52 streams and
+ * down or upmix it correctly to fill the 6 output channels.
+ * Are there any requests for 2.1 out there?
+ */
+/* 1 sample == 12 bytes (L,R,LR,RR,Null,LFE) */
+#define AO_CAP_MODE_4_1CHANNEL 0x00000020 /* driver supports 4.1 channels */
+/* 1 sample == 12 bytes (L,R,LR,RR,C, Null) */
+#define AO_CAP_MODE_5CHANNEL 0x00000040 /* driver supports 5 channels */
/* 1 sample == 12 bytes (L,R,LR,RR,C,LFE) */
-#define AO_CAP_MODE_5_1CHANNEL 0x00000040 /* driver supports 5.1 channels */
-#define AO_CAP_MIXER_VOL 0x00000080 /* driver supports mixer control */
-#define AO_CAP_PCM_VOL 0x00000100 /* driver supports pcm control */
-#define AO_CAP_MUTE_VOL 0x00000200 /* driver can mute volume */
-#define AO_CAP_8BITS 0x00000400 /* driver support 8-bit samples */
+#define AO_CAP_MODE_5_1CHANNEL 0x00000080 /* driver supports 5.1 channels */
+#define AO_CAP_MIXER_VOL 0x00000100 /* driver supports mixer control */
+#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 */
/* properties supported by get/set_property() */
#define AO_PROP_MIXER_VOL 0