summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-04-01 12:09:08 +0000
committerMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-04-01 12:09:08 +0000
commitea913a96287487006e871aaada963dad44d20a3e (patch)
treeb34ae062270657d0f9a8261273ff13682de487ac
parent5cd3cd24d98bf43115d0181f762bb62e5dd21880 (diff)
downloadxine-lib-ea913a96287487006e871aaada963dad44d20a3e.tar.gz
xine-lib-ea913a96287487006e871aaada963dad44d20a3e.tar.bz2
latest dxr3 fixes from Michael Roitzsch.
removed METRONOM_DENY_BACKWARD_ADJUST hack. CVS patchset: 1653 CVS date: 2002/04/01 12:09:08
-rw-r--r--src/dxr3/dxr3_decoder.c110
-rw-r--r--src/xine-engine/audio_out.c11
-rw-r--r--src/xine-engine/metronom.c11
-rw-r--r--src/xine-engine/metronom.h11
4 files changed, 50 insertions, 93 deletions
diff --git a/src/dxr3/dxr3_decoder.c b/src/dxr3/dxr3_decoder.c
index a0f56a901..da8305a5b 100644
--- a/src/dxr3/dxr3_decoder.c
+++ b/src/dxr3/dxr3_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: dxr3_decoder.c,v 1.67 2002/03/31 14:33:12 mlampard Exp $
+ * $Id: dxr3_decoder.c,v 1.68 2002/04/01 12:09:08 miguelfreitas Exp $
*
* dxr3 video and spu decoder plugin. Accepts the video and spu data
* from XINE and sends it directly to the corresponding dxr3 devices.
@@ -94,12 +94,6 @@ static char devnum[3];
#define LOG_SPU 0
#define MV_COMMAND 0
-#ifndef MVCOMMAND_SCAN
- #define MVCOMMAND_SCAN 4
-#endif
-
-/* we give metronom two seconds to recover from our resyncing */
-#define SYNC_RECOVER_TIME (2 * 90000)
typedef struct dxr3_decoder_s {
@@ -110,7 +104,6 @@ typedef struct dxr3_decoder_s {
int fd_control;
int fd_video;
int64_t last_pts;
- int64_t last_metronom_resync;
scr_plugin_t *scr;
int scr_prio;
int width;
@@ -199,38 +192,38 @@ static int dxr3scr_set_speed (scr_plugin_t *scr, int speed) {
switch(speed){
case SPEED_PAUSE:
em_speed = 0;
- playmode=MVCOMMAND_PAUSE;
+ playmode=EM8300_PLAYMODE_PAUSED;
break;
case SPEED_SLOW_4:
em_speed = 0x900/4;
- playmode=MVCOMMAND_START;
+ playmode=EM8300_PLAYMODE_PLAY;
break;
case SPEED_SLOW_2:
em_speed = 0x900/2;
- playmode=MVCOMMAND_START;
+ playmode=EM8300_PLAYMODE_PLAY;
break;
case SPEED_NORMAL:
em_speed = 0x900;
- playmode=MVCOMMAND_START;
+ playmode=EM8300_PLAYMODE_PLAY;
break;
case SPEED_FAST_2:
em_speed = 0x900*2;
- playmode=MVCOMMAND_SCAN;
+ playmode=EM8300_PLAYMODE_SCAN;
break;
case SPEED_FAST_4:
em_speed = 0x900*4;
- playmode=MVCOMMAND_SCAN;
+ playmode=EM8300_PLAYMODE_SCAN;
break;
default:
em_speed = 0;
- playmode = MVCOMMAND_PAUSE;
+ playmode = EM8300_PLAYMODE_PAUSED;
}
if(em_speed>0x900)
scanning_mode=1;
else
scanning_mode=0;
- if(dxr3_mvcommand(self->fd_control,playmode))
+ if (ioctl(self->fd_control, EM8300_IOCTL_SET_PLAYMODE, &playmode))
printf("dxr3scr: failed to playmode (%s)\n", strerror(errno));
if (ioctl(self->fd_control, EM8300_IOCTL_SCR_SETSPEED, &em_speed))
@@ -368,8 +361,7 @@ static void dxr3_init (video_decoder_t *this_gen, vo_instance_t *video_out)
dxr3_decoder_t *this = (dxr3_decoder_t *) this_gen;
metronom_t *metronom = this->video_decoder.metronom;
char tmpstr[128];
- int64_t time, cur_offset;
- int cur_deny_back_adj;
+ int64_t cur_offset;
snprintf (tmpstr, sizeof(tmpstr), "%s%s", devname, devnum);
printf("dxr3: Entering video init, devname=%s.\n",tmpstr);
@@ -385,19 +377,13 @@ static void dxr3_init (video_decoder_t *this_gen, vo_instance_t *video_out)
video_out->open(video_out);
this->video_out = video_out;
- time = metronom->get_current_time(metronom);
- this->last_metronom_resync = this->last_pts = time;
+ this->last_pts = metronom->get_current_time(metronom);
this->decoder_thread = pthread_self();
cur_offset = metronom->get_option(metronom, METRONOM_AV_OFFSET);
metronom->set_option(metronom, METRONOM_AV_OFFSET, cur_offset - 21600);
/* a note on the 21600: this seems to be a necessary offset,
maybe the dxr3 needs some internal time, however it improves sync a lot */
-
- cur_deny_back_adj = metronom->get_option(metronom, METRONOM_DENY_BACKWARD_ADJUST);
- metronom->set_option(metronom, METRONOM_DENY_BACKWARD_ADJUST, ++cur_deny_back_adj);
- /* this is a boolean metronom option, but we increase it, so that we can
- easily revert our change when the decoder exits */
}
@@ -564,21 +550,8 @@ static void dxr3_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
vpts = img->vpts; /* copy so we can free img */
}
else { /* metronom says skip, so don't set vpts */
- metronom_t *metronom = this->video_decoder.metronom;
- int64_t time;
-
printf("dxr3: skip = %d\n", skip);
vpts = 0;
-
- /* Adjust metronom's vpts_offset to make it think, the
- stream started later, so that it no longer gives us too old
- vpts values and therefore makes skipping unnecessary. */
- time = metronom->get_current_time(metronom);
- if (time > this->last_metronom_resync + SYNC_RECOVER_TIME) {
- metronom->set_option(metronom, METRONOM_ADJ_VPTS_OFFSET,
- skip * duration);
- this->last_metronom_resync = time;
- }
}
img->free(img);
this->last_pts += duration; /* predict vpts */
@@ -610,39 +583,47 @@ static void dxr3_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
}
}
+ /* We may want to issue a SETPTS, so make sure the scr plugin
+ is running and registered. Unfortuantely wa cannot do this
+ earlier, because the dxr3's internal scr gets confused
+ when started with a closed video device. Maybe this is a
+ driver bug and gets fixed somewhen. FIXME: We might then
+ want to move this code to dxr3_init. */
+ if (!this->scr) {
+ int64_t time;
+
+ /* if the dxr3_alt_play option is used, change the dxr3 playmode */
+ if(this->enhanced_mode)
+ dxr3_mvcommand(this->fd_control, MVCOMMAND_SYNC);
+
+ time = this->video_decoder.metronom->get_current_time(
+ this->video_decoder.metronom);
+
+ this->scr = dxr3scr_init(this);
+ this->scr->start(this->scr, time);
+ this->video_decoder.metronom->register_scr(
+ this->video_decoder.metronom, this->scr);
+ if (this->video_decoder.metronom->scr_master == this->scr) {
+ printf("dxr3: dxr3scr plugin is master\n");
+ } else {
+ printf("dxr3: dxr3scr plugin is NOT master\n");
+ }
+ }
+
/* From time to time, update the pts value
* FIXME: the exact conditions here are a bit uncertain... */
if (vpts)
{
- int64_t delay, time;
- time = this->video_decoder.metronom->get_current_time(
+ int64_t delay;
+
+ delay = vpts - this->video_decoder.metronom->get_current_time(
this->video_decoder.metronom);
- delay = vpts - time;
#if LOG_PTS
printf("dxr3: SETPTS got %lld expected = %lld (delta %lld) delay = %lld\n",
vpts, this->last_pts, vpts-this->last_pts, delay);
#endif
this->last_pts = vpts;
- /* We are going to issue a SETPTS, so make sure the scr plugin
- is running and registered. Unfortuantely wa cannot do this
- earlier, because the dxr3's internal scr gets confused
- when started with a closed video device. Maybe this is a
- driver bug and gets fixed somewhen. FIXME: We might then
- want to move this code to dxr3_init. */
- if (!this->scr) {
- this->scr = dxr3scr_init(this);
- this->scr->start(this->scr, time);
- this->video_decoder.metronom->register_scr(
- this->video_decoder.metronom, this->scr);
-
- if (this->video_decoder.metronom->scr_master == this->scr) {
- printf("dxr3: dxr3scr plugin is master\n");
- } else {
- printf("dxr3: dxr3scr plugin is NOT master\n");
- }
- }
-
/* SETPTS only if less then one second in the future and
* either buffer has pts or sync_every_frame is set */
if ((delay > 0) && (delay < 90000) &&
@@ -652,7 +633,6 @@ static void dxr3_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
if (ioctl(this->fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vpts32))
printf("dxr3: set video pts failed (%s)\n",
strerror(errno));
- this->last_metronom_resync = time;
}
if (delay >= 90000) {
/* frame more than 1 sec ahead */
@@ -669,9 +649,6 @@ static void dxr3_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
buf->pts, this->last_pts);
}
#endif
- /* if the dxr3_alt_play option is used, change the dxr3 playmode */
- if(this->enhanced_mode && !scanning_mode)
- dxr3_mvcommand(this->fd_control, 6);
/* now write the content to the dxr3 mpeg device and, in a dramatic
break with open source tradition, check the return value */
@@ -698,7 +675,6 @@ static void dxr3_close (video_decoder_t *this_gen)
dxr3_decoder_t *this = (dxr3_decoder_t *) this_gen;
metronom_t *metronom = this->video_decoder.metronom;
int64_t cur_offset;
- int cur_deny_back_adj;
if (this->scr) {
metronom->unregister_scr(metronom, this->scr);
@@ -710,10 +686,6 @@ static void dxr3_close (video_decoder_t *this_gen)
cur_offset = metronom->get_option(metronom, METRONOM_AV_OFFSET);
metronom->set_option(metronom, METRONOM_AV_OFFSET, cur_offset + 21600);
- /* revert deny_backward_adjust change done in dxr3_init */
- cur_deny_back_adj = metronom->get_option(metronom, METRONOM_DENY_BACKWARD_ADJUST);
- metronom->set_option(metronom, METRONOM_DENY_BACKWARD_ADJUST, --cur_deny_back_adj);
-
if (this->fd_video >= 0)
close(this->fd_video);
this->fd_video = -1;
diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c
index 52d5c46f3..4326d598e 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.50 2002/03/31 14:36:42 mlampard Exp $
+ * $Id: audio_out.c,v 1.51 2002/04/01 12:09:09 miguelfreitas Exp $
*
* 22-8-2001 James imported some useful AC3 sections from the previous alsa driver.
* (c) 2001 Andy Lo A Foe <andy@alsaplayer.org>
@@ -344,13 +344,8 @@ static void *ao_loop (void *this_gen) {
cur_time > (last_sync_time + SYNC_TIME_INVERVAL) &&
bufs_since_sync >= SYNC_BUF_INTERVAL ) {
- if (!this->metronom->get_option(this->metronom, METRONOM_DENY_BACKWARD_ADJUST) ||
- gap < 0) {
- this->metronom->set_option(this->metronom, METRONOM_ADJ_VPTS_OFFSET,
- -gap/SYNC_GAP_RATE );
- } else {
- ao_fill_gap(this, gap);
- }
+ this->metronom->set_option(this->metronom, METRONOM_ADJ_VPTS_OFFSET,
+ -gap/SYNC_GAP_RATE );
last_sync_time = cur_time;
bufs_since_sync = 0;
}
diff --git a/src/xine-engine/metronom.c b/src/xine-engine/metronom.c
index 4f5b2b87d..e660815e6 100644
--- a/src/xine-engine/metronom.c
+++ b/src/xine-engine/metronom.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: metronom.c,v 1.77 2002/03/31 14:36:42 mlampard Exp $
+ * $Id: metronom.c,v 1.78 2002/04/01 12:09:10 miguelfreitas Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -521,15 +521,11 @@ static void metronom_set_option (metronom_t *this, int option, int64_t value) {
this->scr_adjustable = value;
break;
case METRONOM_ADJ_VPTS_OFFSET:
- if (!this->deny_backward_adjust || value > 0)
- this->vpts_offset += value;
+ this->vpts_offset += value;
/*#ifdef LOG*/
printf ("metronom: adjusting vpts_offset by %lld\n", value );
/*#endif*/
break;
- case METRONOM_DENY_BACKWARD_ADJUST:
- this->deny_backward_adjust = value;
- break;
default:
printf ("metronom: unknown option in set_option: %d\n",
option);
@@ -544,8 +540,6 @@ static int64_t metronom_get_option (metronom_t *this, int option) {
return this->av_offset;
case METRONOM_SCR_ADJUSTABLE:
return this->scr_adjustable;
- case METRONOM_DENY_BACKWARD_ADJUST:
- return this->deny_backward_adjust;
}
printf ("metronom: unknown option in get_option: %d\n",
option);
@@ -698,7 +692,6 @@ metronom_t * metronom_init (int have_audio, void *xine) {
this->in_discontinuity = 0;
this->vpts_offset = 0;
this->next_vpts_offset = 0;
- this->deny_backward_adjust = 0;
/* initialize video stuff */
diff --git a/src/xine-engine/metronom.h b/src/xine-engine/metronom.h
index 924efd5c3..f470eb00e 100644
--- a/src/xine-engine/metronom.h
+++ b/src/xine-engine/metronom.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: metronom.h,v 1.27 2002/03/31 14:36:42 mlampard Exp $
+ * $Id: metronom.h,v 1.28 2002/04/01 12:09:10 miguelfreitas Exp $
*
* metronom: general pts => virtual calculation/assoc
*
@@ -226,8 +226,6 @@ struct metronom_s {
scr_plugin_t** scr_list;
pthread_t sync_thread;
int scr_adjustable;
-
- int deny_backward_adjust;
pthread_mutex_t lock;
@@ -246,10 +244,9 @@ metronom_t *metronom_init (int have_audio, void *xine);
* metronom options
*/
-#define METRONOM_SCR_ADJUSTABLE 1
-#define METRONOM_AV_OFFSET 2
-#define METRONOM_ADJ_VPTS_OFFSET 3
-#define METRONOM_DENY_BACKWARD_ADJUST 4
+#define METRONOM_SCR_ADJUSTABLE 1
+#define METRONOM_AV_OFFSET 2
+#define METRONOM_ADJ_VPTS_OFFSET 3
/*
* SCR (system clock reference) plugins