summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2001-11-15 23:18:04 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2001-11-15 23:18:04 +0000
commit9635738cc349e37e76f23a4d99eda696197cb715 (patch)
treec77eaa18c0a85983252dd7f5ef5bbba04e18a015
parent230d3c07ef6fca8fb08ae8f14235c56b535d7e64 (diff)
downloadxine-lib-9635738cc349e37e76f23a4d99eda696197cb715.tar.gz
xine-lib-9635738cc349e37e76f23a4d99eda696197cb715.tar.bz2
improved audio/spu channel selection, let the user take control over both if he/she wants to
CVS patchset: 1047 CVS date: 2001/11/15 23:18:04
-rw-r--r--src/libspudec/xine_decoder.c4
-rw-r--r--src/xine-engine/audio_decoder.c121
-rw-r--r--src/xine-engine/video_decoder.c6
-rw-r--r--src/xine-engine/video_out.c10
-rw-r--r--src/xine-engine/video_out.h4
-rw-r--r--src/xine-engine/xine.c85
-rw-r--r--src/xine-engine/xine_internal.h16
7 files changed, 157 insertions, 89 deletions
diff --git a/src/libspudec/xine_decoder.c b/src/libspudec/xine_decoder.c
index 6346f4849..9a968bb63 100644
--- a/src/libspudec/xine_decoder.c
+++ b/src/libspudec/xine_decoder.c
@@ -19,7 +19,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.32 2001/11/10 13:48:03 guenter Exp $
+ * $Id: xine_decoder.c,v 1.33 2001/11/15 23:18:04 guenter Exp $
*
* stuff needed to turn libspu into a xine decoder plugin
*/
@@ -378,6 +378,7 @@ static void spu_process (spudec_decoder_t *this, uint32_t stream_id) {
do {
if (!this->spu_stream_state[stream_id].ra_seq.finished) {
+
//spudec_nextseq(this);
/* Get do commands to build the event. */
spu_do_commands(&this->state, this->cur_seq, &this->overlay);
@@ -385,6 +386,7 @@ static void spu_process (spudec_decoder_t *this, uint32_t stream_id) {
* For subtitles, open event.
* For menus, store it for later.
*/
+
if ((this->xine->spu_channel != stream_id) &&
(this->state.menu == 0) ) {
xprintf (VERBOSE|SPU, "Dropping SPU channel %d\n", stream_id);
diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c
index e9ea5941c..6f13ffcda 100644
--- a/src/xine-engine/audio_decoder.c
+++ b/src/xine-engine/audio_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: audio_decoder.c,v 1.53 2001/11/15 17:11:20 heikos Exp $
+ * $Id: audio_decoder.c,v 1.54 2001/11/15 23:18:04 guenter Exp $
*
*
* functions that implement audio decoding
@@ -109,7 +109,7 @@ void *audio_decoder_loop (void *this_gen) {
pthread_mutex_unlock (&this->finished_lock);
- this->audio_channel_suggested = -1;
+ this->audio_channel_auto = -1;
/* future magic - coming soon
lrb_flush (this->audio_temp);
@@ -153,7 +153,7 @@ void *audio_decoder_loop (void *this_gen) {
{
printf ("audio_decoder: suggested switching to stream_id %02x\n",
buf->decoder_info[0]);
- this->audio_channel_suggested = buf->decoder_info[0] & 0xff;
+ this->audio_channel_auto = buf->decoder_info[0] & 0xff;
}
break;
@@ -177,12 +177,14 @@ void *audio_decoder_loop (void *this_gen) {
uint32_t audio_type = 0;
int i,j;
-/*
- printf("AUDIO DECODER:%08X %08X %08X %08X\n",
- buf->type, this->audio_type,
- this->audio_channel_suggested,
- this->audio_channel);
- */
+
+ /*
+ printf("audio_decoder: buf_type=%08x auto=%08x user=%08x\n",
+ buf->type,
+ this->audio_channel_auto,
+ this->audio_channel_user);
+ */
+
/* update track map */
i = 0;
@@ -202,57 +204,61 @@ void *audio_decoder_loop (void *this_gen) {
/* find out which audio type to decode */
- if (this->audio_channel == -1) {
- audio_type = this->audio_track_map[0];
- } else {
- audio_type = this->audio_track_map[this->audio_channel];
- }
- if ((this->audio_channel_suggested>=0) &&
- ((buf->type & 0xFF) == this->audio_channel_suggested) ) {
- audio_type = buf->type;
- this->audio_channel_suggested = -1;
- }
+ if (this->audio_channel_user > -2) {
- /* now, decode this buffer if it's the right audio type */
+ if (this->audio_channel_user == -1) {
- if (buf->type == audio_type) {
-
- int streamtype = (buf->type>>16) & 0xFF;
+ /* auto */
- decoder = this->audio_decoder_plugins [streamtype];
+ if (this->audio_channel_auto>=0) {
+
+ if ((buf->type & 0xFF) == this->audio_channel_auto) {
+ audio_type = buf->type;
+ } else
+ audio_type = -1;
- /* close old decoder of audio type has changed */
+ } else
+ audio_type = this->audio_track_map[0];
- if (audio_type != this->audio_type) {
+ } else
+ audio_type = this->audio_track_map[this->audio_channel_user];
- if (this->cur_audio_decoder_plugin) {
- this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin);
- this->cur_audio_decoder_plugin = NULL;
- }
-
- if (decoder) {
- xine_event_t event;
- printf ("audio_loop: using decoder >%s< \n",
- decoder->get_identifier());
- this->cur_audio_decoder_plugin = decoder;
- this->cur_audio_decoder_plugin->init (this->cur_audio_decoder_plugin, this->audio_out);
+ /* now, decode this buffer if it's the right audio type */
+
+ if (buf->type == audio_type) {
+
+ int streamtype = (buf->type>>16) & 0xFF;
+
+ decoder = this->audio_decoder_plugins [streamtype];
+
+ /* close old decoder of audio type has changed */
+
+ if (audio_type != this->audio_type) {
- this->audio_type = audio_type;
- for (i=0;i < this->audio_track_map_entries; i++) {
- if ( this->audio_track_map[i] == audio_type) {
- this->audio_channel=i;
- break;
- }
- }
- event.type = XINE_EVENT_UI_CHANNELS_CHANGED;
- xine_send_event(this, &event);
+ if (this->cur_audio_decoder_plugin) {
+ this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin);
+ this->cur_audio_decoder_plugin = NULL;
+ }
+
+ if (decoder) {
+ xine_event_t event;
+ printf ("audio_loop: using decoder >%s< \n",
+ decoder->get_identifier());
+ this->cur_audio_decoder_plugin = decoder;
+ this->cur_audio_decoder_plugin->init (this->cur_audio_decoder_plugin, this->audio_out);
+
+ this->audio_type = audio_type;
+
+ event.type = XINE_EVENT_UI_CHANNELS_CHANGED;
+ xine_send_event(this, &event);
+ }
}
- }
-
- /* finally - decode data */
-
- if (decoder)
+
+ /* finally - decode data */
+
+ if (decoder)
decoder->decode_data (decoder, buf);
+ }
}
} else
printf ("audio_loop: unknown buffer type: %08x\n", buf->type);
@@ -279,8 +285,8 @@ void audio_decoder_init (xine_t *this) {
}
this->audio_fifo = fifo_buffer_new (50, 8192);
- this->audio_channel = -1;
- this->audio_channel_suggested = -1;
+ this->audio_channel_user = -1;
+ this->audio_channel_auto = 0;
this->audio_type = 0;
/* future magic - coming soon
@@ -330,16 +336,15 @@ void xine_select_audio_channel (xine_t *this, int channel) {
pthread_mutex_lock (&this->xine_lock);
- if (channel < -1)
- channel = -1;
+ if (channel < -2)
+ channel = -2;
- this->audio_channel = channel;
+ this->audio_channel_user = channel;
pthread_mutex_unlock (&this->xine_lock);
}
int xine_get_audio_selection (xine_t *this) {
-
- return this->audio_channel;
+ return this->audio_channel_user;
}
diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c
index 20a59d96b..87ca1a956 100644
--- a/src/xine-engine/video_decoder.c
+++ b/src/xine-engine/video_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: video_decoder.c,v 1.63 2001/11/13 21:47:59 heikos Exp $
+ * $Id: video_decoder.c,v 1.64 2001/11/15 23:18:04 guenter Exp $
*
*/
@@ -145,7 +145,9 @@ void *video_decoder_loop (void *this_gen) {
break;
case BUF_CONTROL_SPU_CHANNEL:
- this->spu_channel = buf->decoder_info[0];
+ this->spu_channel_auto = buf->decoder_info[0];
+ if (this->spu_channel_user == -1)
+ this->spu_channel = this->spu_channel_auto;
break;
case BUF_CONTROL_END:
diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c
index c13b34583..63b2f4a91 100644
--- a/src/xine-engine/video_out.c
+++ b/src/xine-engine/video_out.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: video_out.c,v 1.53 2001/11/13 21:47:59 heikos Exp $
+ * $Id: video_out.c,v 1.54 2001/11/15 23:18:04 guenter Exp $
*
*/
@@ -304,7 +304,7 @@ static void *video_out_loop (void *this_gen) {
profiler_start_count (prof_spu_blend);
ovl = this->overlay_source->get_overlay (this->overlay_source, img->PTS);
- if (this->video_loop_running && ovl && this->driver->overlay_blend)
+ if (this->video_loop_running && ovl && this->driver->overlay_blend && this->overlay_enabled)
this->driver->overlay_blend (this->driver, img, ovl);
profiler_stop_count (prof_spu_blend);
@@ -578,6 +578,10 @@ static void vo_unregister_ovl_src (vo_instance_t *this, ovl_src_t *ovl_src)
this->overlay_source = NULL;
}
+static void vo_enable_overlay (vo_instance_t *this, int overlay_enabled) {
+ this->overlay_enabled = overlay_enabled;
+}
+
vo_instance_t *vo_new_instance (vo_driver_t *driver, metronom_t *metronom) {
vo_instance_t *this;
@@ -595,6 +599,7 @@ vo_instance_t *vo_new_instance (vo_driver_t *driver, metronom_t *metronom) {
this->get_capabilities = vo_get_capabilities;
this->register_ovl_src = vo_register_ovl_src;
this->unregister_ovl_src = vo_unregister_ovl_src;
+ this->enable_ovl = vo_enable_overlay;
this->num_frames_delivered = 0;
this->num_frames_skipped = 0;
@@ -604,6 +609,7 @@ vo_instance_t *vo_new_instance (vo_driver_t *driver, metronom_t *metronom) {
this->video_loop_running = 0;
this->pts_per_frame = 0;
this->pts_per_half_frame = 0;
+ this->overlay_enabled = 1;
for (i=0; i<NUM_FRAME_BUFFERS; i++) {
vo_frame_t *img;
diff --git a/src/xine-engine/video_out.h b/src/xine-engine/video_out.h
index a57e2bba1..c6467c1ec 100644
--- a/src/xine-engine/video_out.h
+++ b/src/xine-engine/video_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: video_out.h,v 1.28 2001/11/13 21:47:59 heikos Exp $
+ * $Id: video_out.h,v 1.29 2001/11/15 23:18:04 guenter Exp $
*
*
* xine version of video_out.h
@@ -134,7 +134,9 @@ struct vo_instance_s {
/* overlay stuff */
void (*register_ovl_src) (vo_instance_t *this, ovl_src_t *ovl_src);
void (*unregister_ovl_src) (vo_instance_t *this, ovl_src_t *ovl_src);
+ void (*enable_ovl) (vo_instance_t *this, int ovl_enable);
ovl_src_t *overlay_source;
+ int overlay_enabled;
/* video driver is no longer used by decoder => close */
void (*close) (vo_instance_t *this);
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c
index 40164625b..c64d3490e 100644
--- a/src/xine-engine/xine.c
+++ b/src/xine-engine/xine.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.c,v 1.72 2001/10/22 17:10:21 guenter Exp $
+ * $Id: xine.c,v 1.73 2001/11/15 23:18:04 guenter Exp $
*
* top-level xine functions
*
@@ -427,9 +427,9 @@ xine_t *xine_init (vo_driver_t *vo,
load_demux_plugins(this, config, DEMUXER_PLUGIN_IFACE_VERSION);
- this->audio_channel = 0;
- this->spu_channel = -1;
- this->cur_input_pos = 0;
+ this->spu_channel_auto = -1;
+ this->spu_channel_user = -1;
+ this->cur_input_pos = 0;
/*
* init and start decoder threads
@@ -451,14 +451,28 @@ xine_t *xine_init (vo_driver_t *vo,
int xine_get_spu_channel (xine_t *this) {
- return this->spu_channel;
+ return this->spu_channel_user;
}
void xine_select_spu_channel (xine_t *this, int channel) {
pthread_mutex_lock (&this->xine_lock);
- this->spu_channel = (channel >= -1 ? channel : -1);
+ this->spu_channel_user = (channel >= -2 ? channel : -2);
+
+ switch (this->spu_channel_user) {
+ case -2:
+ this->spu_channel = -1;
+ this->video_out->enable_ovl (this->video_out, 0);
+ break;
+ case -1:
+ this->spu_channel = this->spu_channel_auto;
+ this->video_out->enable_ovl (this->video_out, 1);
+ break;
+ default:
+ this->spu_channel = this->spu_channel_user;
+ this->video_out->enable_ovl (this->video_out, 1);
+ }
pthread_mutex_unlock (&this->xine_lock);
}
@@ -646,28 +660,55 @@ int xine_get_current_frame (xine_t *this, int *width, int *height,
void xine_get_spu_lang (xine_t *this, char *str) {
- if (this->cur_input_plugin) {
- if (this->cur_input_plugin->get_capabilities (this->cur_input_plugin) & INPUT_CAP_SPULANG) {
- this->cur_input_plugin->get_optional_data (this->cur_input_plugin, str,
- INPUT_OPTIONAL_DATA_SPULANG);
- return;
- }
- }
+ switch (this->spu_channel_user) {
+ case -2:
+ sprintf (str, "off");
+ break;
+ case -1:
+ if (this->cur_input_plugin) {
+ if (this->cur_input_plugin->get_capabilities (this->cur_input_plugin) & INPUT_CAP_SPULANG) {
+ this->cur_input_plugin->get_optional_data (this->cur_input_plugin, this->str,
+ INPUT_OPTIONAL_DATA_SPULANG);
+ sprintf (str, "*(%s)", this->str);
+ return;
+ }
+ }
+ if (this->spu_channel_auto == -1)
+ sprintf (str, "*(off)");
+ else
+ sprintf (str, "*(%3d)", this->spu_channel_auto);
+ break;
+ default:
+ sprintf (str, "%3d", this->spu_channel_user);
+ }
- sprintf (str, "%3d", this->spu_channel);
}
void xine_get_audio_lang (xine_t *this, char *str) {
- if (this->cur_input_plugin) {
- if (this->cur_input_plugin->get_capabilities (this->cur_input_plugin) & INPUT_CAP_AUDIOLANG) {
- this->cur_input_plugin->get_optional_data (this->cur_input_plugin, str,
- INPUT_OPTIONAL_DATA_AUDIOLANG);
- return;
- }
- }
+ switch (this->audio_channel_user) {
+ case -2:
+ sprintf (str, "off");
+ break;
+ case -1:
+ if (this->cur_input_plugin) {
+ if (this->cur_input_plugin->get_capabilities (this->cur_input_plugin) & INPUT_CAP_AUDIOLANG) {
+ this->cur_input_plugin->get_optional_data (this->cur_input_plugin, this->str,
+ INPUT_OPTIONAL_DATA_AUDIOLANG);
+
+ sprintf (str, "*(%s)", this->str);
- sprintf (str, "%3d", this->audio_channel);
+ return;
+ }
+ }
+ if (this->audio_channel_auto == -1)
+ sprintf (str, "*(off)");
+ else
+ sprintf (str, "*(%3d)", this->audio_channel_auto);
+ break;
+ default:
+ sprintf (str, "%3d", this->audio_channel_user);
+ }
}
diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h
index 99628c7e5..99e37b546 100644
--- a/src/xine-engine/xine_internal.h
+++ b/src/xine-engine/xine_internal.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: xine_internal.h,v 1.54 2001/11/13 21:47:59 heikos Exp $
+ * $Id: xine_internal.h,v 1.55 2001/11/15 23:18:04 guenter Exp $
*
*/
@@ -164,8 +164,15 @@ struct xine_s {
spu_decoder_t *cur_spu_decoder_plugin;
int spu_finished;
- int audio_channel;
- int audio_channel_suggested;
+ /* *_user: -2 => off
+ -1 => auto (use *_auto value)
+ >=0 => respect the user's choice
+ */
+
+ int audio_channel_user;
+ int audio_channel_auto;
+ int spu_channel_user;
+ int spu_channel_auto;
int spu_channel;
vo_instance_t *video_out;
@@ -198,6 +205,9 @@ struct xine_s {
xine_event_listener_t event_listeners[XINE_MAX_EVENT_LISTENERS];
void *event_listener_user_data[XINE_MAX_EVENT_LISTENERS];
uint16_t num_event_listeners;
+
+ /* scratch string buffer */
+ char str[1024];
};
/*