From 2f7bba0bd01b3814c7239a9907c4c652d7718cb8 Mon Sep 17 00:00:00 2001 From: Mike Lampard Date: Sun, 31 Mar 2002 14:33:12 +0000 Subject: dxr3 patches from Michael Roitzsch : make dxr3 work again by updating to current video_out interface, fix some problems when switching from non-mpeg content (e.g. the xine logo) to mpeg content & handle situations when video_out tells the dxr3 decoder to skip frames. CVS patchset: 1648 CVS date: 2002/03/31 14:33:12 --- src/dxr3/dxr3_decoder.c | 162 +++++++++++++++++++++++++--------------------- src/dxr3/dxr3_video_out.c | 30 +++++++-- src/dxr3/dxr3_video_out.h | 7 +- src/dxr3/dxr3_vo_core.c | 50 +++++++------- src/dxr3/mpeg_encoders.c | 25 +++---- 5 files changed, 156 insertions(+), 118 deletions(-) diff --git a/src/dxr3/dxr3_decoder.c b/src/dxr3/dxr3_decoder.c index ce8163120..a0f56a901 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.66 2002/03/14 13:56:49 richwareham Exp $ + * $Id: dxr3_decoder.c,v 1.67 2002/03/31 14:33:12 mlampard Exp $ * * dxr3 video and spu decoder plugin. Accepts the video and spu data * from XINE and sends it directly to the corresponding dxr3 devices. @@ -98,6 +98,9 @@ static char devnum[3]; #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 { video_decoder_t video_decoder; @@ -107,6 +110,7 @@ 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; @@ -247,14 +251,12 @@ static void dxr3scr_adjust (scr_plugin_t *scr, int64_t vpts) { dxr3scr_t *self = (dxr3scr_t*) scr; uint32_t cpts32; int32_t offset32; - int64_t cpts; pthread_mutex_lock(&self->mutex); if (ioctl(self->fd_control, EM8300_IOCTL_SCR_GET, &cpts32)) printf("dxr3scr: adjust get failed (%s)\n", strerror(errno)); - cpts = (int64_t)cpts32 << 1; self->last_pts = cpts32; - self->offset = vpts - cpts; + self->offset = vpts - ((int64_t)cpts32 << 1); offset32 = self->offset / 4; /* kernel driver ignores diffs < 7200, so abs(offset32) must be > 7200 / 4 */ if (offset32 < -7200/4 || offset32 > 7200/4) { @@ -296,6 +298,7 @@ static void dxr3scr_start (scr_plugin_t *scr, int64_t start_vpts) { static int64_t dxr3scr_get_current (scr_plugin_t *scr) { dxr3scr_t *self = (dxr3scr_t*) scr; uint32_t pts; + int64_t current; pthread_mutex_lock(&self->mutex); if (ioctl(self->fd_control, EM8300_IOCTL_SCR_GET, &pts)) @@ -303,9 +306,10 @@ static int64_t dxr3scr_get_current (scr_plugin_t *scr) { if (pts < self->last_pts) /* wrap around detected, compensate with offset */ self->offset += (int64_t)1 << 33; self->last_pts = pts; + current = ((int64_t)pts << 1) + self->offset; pthread_mutex_unlock(&self->mutex); - return ((int64_t)pts << 1) + self->offset; + return current; } /* *** dxr3scr_exit *** clean up for exit @@ -362,7 +366,10 @@ static int dxr3_can_handle (video_decoder_t *this_gen, int buf_type) 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; snprintf (tmpstr, sizeof(tmpstr), "%s%s", devname, devnum); printf("dxr3: Entering video init, devname=%s.\n",tmpstr); @@ -378,25 +385,19 @@ static void dxr3_init (video_decoder_t *this_gen, vo_instance_t *video_out) video_out->open(video_out); this->video_out = video_out; - this->last_pts = this->video_decoder.metronom-> - get_current_time(this->video_decoder.metronom); + time = metronom->get_current_time(metronom); + this->last_metronom_resync = this->last_pts = time; this->decoder_thread = pthread_self(); - - if (!this->scr) { - this->scr = dxr3scr_init(this); - /* dxr3_init is called while the master scr already runs. - therefore the scr must be started here */ - this->scr->start(this->scr, this->video_decoder.metronom-> - get_current_time(this->video_decoder.metronom)); - 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"); - } - } + + 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 */ } @@ -471,7 +472,7 @@ static void dxr3_flush (video_decoder_t *this_gen) * to need it anyway... */ printf("dxr3_decoder: flush requested, disabled for the moment.\n"); /* dxr3_mvcommand(this->fd_control, 0x11); - this->have_header_info = 0; */ + this->have_header_info = 0;*/ if (this->fd_video >= 0) fsync(this->fd_video); } @@ -487,37 +488,9 @@ static void dxr3_decode_data (video_decoder_t *this_gen, buf_element_t *buf) uint8_t *buffer, byte; uint32_t shift; - vpts = 0; + if (buf->decoder_flags & BUF_FLAG_PREVIEW) return; -#if 0 - /* if we're just coming from a BUF_VIDEO_FILL situation, - * do a flush for good riddance. (doesn't help much though) */ - if (this->in_buffer_fill && buf->type != BUF_VIDEO_FILL) - dxr3_flush(this_gen); - this->in_buffer_fill = (buf->type == BUF_VIDEO_FILL); - - /* FIXME What are we supposed to do with this? */ - if (buf->type == BUF_VIDEO_FILL && this->have_header_info) { - duration = get_duration(this->frame_rate_code, 0); - /* printf("dxr3enc: BUF_VIDEO_FILL\n"); */ - /* require have_header_info, otherwise width and height - * settings may be random */ - img = this->video_out->get_frame (this->video_out, - this->width, - this->height, - this->aspect, - IMGFMT_YV12, - duration, - DXR3_VO_UPDATE_FLAG); - img->PTS=0; - img->bad_frame = 0; - img->draw(img); - vpts = img->PTS; - img->free(img); - this->last_pts += duration; /* predict vpts */ - return; - } -#endif + vpts = 0; /* count the number of frame codes in this block of data * this code borrowed from libmpeg2. @@ -586,15 +559,26 @@ static void dxr3_decode_data (video_decoder_t *this_gen, buf_element_t *buf) and stores the return value in img->vpts Calling draw with buf->pts==0 is okay; metronome will extrapolate a value. */ - skip = img->draw(img) + (21600 / duration); + skip = img->draw(img); if (skip <= 0) { /* don't skip */ - vpts = img->vpts - 21600; /* copy so we can free img */ - /* 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 */ + vpts = img->vpts; /* copy so we can free img */ } - else { /* metronom says skip, so don't set pts */ + 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 */ @@ -630,14 +614,35 @@ static void dxr3_decode_data (video_decoder_t *this_gen, buf_element_t *buf) * FIXME: the exact conditions here are a bit uncertain... */ if (vpts) { - int64_t delay; - delay = vpts - this->video_decoder.metronom->get_current_time( - this->video_decoder.metronom); + int64_t delay, time; + time = 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) && @@ -647,6 +652,7 @@ 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 */ @@ -690,14 +696,24 @@ static void dxr3_decode_data (video_decoder_t *this_gen, buf_element_t *buf) 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) { - this->video_decoder.metronom->unregister_scr( - this->video_decoder.metronom, this->scr); + metronom->unregister_scr(metronom, this->scr); this->scr->exit(this->scr); this->scr = 0; } - + + /* revert av_offset change done in dxr3_init */ + 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; @@ -950,22 +966,19 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) /* just watch out for menus */ if (p[3] == 0xbf && p[6] == 0x00) { /* Private stream 2 */ - pci_t *pci; + pci_t pci; - pci = xine_xmalloc(sizeof(pci_t)); - nav_read_pci(pci, p + 7); + nav_read_pci(&pci, p + 7); - if (pci->hli.hl_gi.hli_ss == 1) + if (pci.hli.hl_gi.hli_ss == 1) /* menu ahead, remember pci for later evaluation */ - xine_fast_memcpy(&this->pci, pci, sizeof(pci_t)); + xine_fast_memcpy(&this->pci, &pci, sizeof(pci_t)); - if ((pci->hli.hl_gi.hli_ss == 0) && (this->pci.hli.hl_gi.hli_ss == 1)) { + if ((pci.hli.hl_gi.hli_ss == 0) && (this->pci.hli.hl_gi.hli_ss == 1)) { /* leaving menu */ - xine_fast_memcpy(&this->pci, pci, sizeof(pci_t)); + xine_fast_memcpy(&this->pci, &pci, sizeof(pci_t)); ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, NULL); } - - free(pci); } return; } @@ -1194,4 +1207,3 @@ spu_decoder_t *init_spu_decoder_plugin (int iface_version, xine_t *xine) return (spu_decoder_t *) this; } - diff --git a/src/dxr3/dxr3_video_out.c b/src/dxr3/dxr3_video_out.c index b36d49614..5cc561557 100644 --- a/src/dxr3/dxr3_video_out.c +++ b/src/dxr3/dxr3_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: dxr3_video_out.c,v 1.10 2002/03/08 00:24:40 jcdutton Exp $ + * $Id: dxr3_video_out.c,v 1.11 2002/03/31 14:33:12 mlampard Exp $ * * mpeg1 encoding video out plugin for the dxr3. * @@ -224,7 +224,7 @@ static void dxr3_update_frame_format (vo_driver_t *this_gen, * the dxr3 decoder plugin */ if (this->fd_video >= 0) { close(this->fd_video); - this->fd_video = -1; + this->fd_video = CLOSED_FOR_DECODER; } /* for mpeg source, we don't have to do much. */ this->video_width = width; @@ -253,6 +253,11 @@ static void dxr3_update_frame_format (vo_driver_t *this_gen, } /* the following is for the mpeg encoding part only */ + + if (this->fd_video == CLOSED_FOR_DECODER) { /* decoder should have released it */ + this->fd_video = CLOSED_FOR_ENCODER; /* allow encoder to reopen it */ + this->need_redraw = 1; + } if (this->add_bars == 0) { /* don't add black bars; assume source is in 4:3 */ @@ -296,6 +301,7 @@ static void dxr3_update_frame_format (vo_driver_t *this_gen, this->video_aspect = ratio_code; this->fps = 90000.0/frame->vo_frame.duration; this->format = format; + this->need_redraw = 1; if (! this->enc) { /* no encoder plugin! Let's bug the user! */ @@ -392,6 +398,17 @@ static void dxr3_update_frame_format (vo_driver_t *this_gen, } +static int dxr3_redraw_needed(vo_driver_t *this_gen) +{ + dxr3_driver_t *this = (dxr3_driver_t *) this_gen; + + if (this->need_redraw) { + this->need_redraw = 0; + return 1; + } + return 0; +} + static void dxr3_frame_copy(vo_frame_t *frame_gen, uint8_t **src) { dxr3_frame_t *frame = (dxr3_frame_t *) frame_gen; @@ -418,7 +435,8 @@ static void dxr3_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, { if ( frame_gen->format != IMGFMT_MPEG ) { - /* we have regular YUV frames, so in principle we can blend + /* FIXME: Do something useful here. + * we have regular YUV frames, so in principle we can blend * it just like the Xv driver does. Problem is that the * alphablend.c code file is not nearby */ } @@ -495,6 +513,7 @@ printf("dxr3_video_out:init_plugin\n"); this->vo_driver.set_property = dxr3_set_property; this->vo_driver.get_property_min_max = dxr3_get_property_min_max; this->vo_driver.gui_data_exchange = dxr3_gui_data_exchange; + this->vo_driver.redraw_needed = dxr3_redraw_needed; this->vo_driver.exit = dxr3_exit; this->config=config; @@ -545,7 +564,7 @@ printf("dxr3_video_out:init_plugin\n"); } /* close now and and let the encoders reopen if they want */ close(this->fd_video); - this->fd_video = -1; + this->fd_video = CLOSED_FOR_DECODER; } /* which encoder to use? Whadda we got? */ @@ -580,7 +599,6 @@ printf("dxr3_video_out:init_plugin\n"); printf( "dxr3: mpeg encoder \"%s\" not compiled in or not supported.\n" "dxr3: valid options are %s\n", encoder, available_encoders); - return 0; } } else { @@ -608,7 +626,7 @@ printf("dxr3_video_out:init_plugin\n"); } static vo_info_t vo_info_dxr3 = { - 4, /* api version */ + 5, /* api version */ "dxr3", "xine video output plugin for dxr3 cards", VISUAL_TYPE_X11, diff --git a/src/dxr3/dxr3_video_out.h b/src/dxr3/dxr3_video_out.h index 2f5964a94..db89d7a62 100644 --- a/src/dxr3/dxr3_video_out.h +++ b/src/dxr3/dxr3_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: dxr3_video_out.h,v 1.15 2002/03/08 00:24:40 jcdutton Exp $ + * $Id: dxr3_video_out.h,v 1.16 2002/03/31 14:33:12 mlampard Exp $ * */ @@ -57,6 +57,10 @@ /* image format used by dxr3_decoder to tag undecoded mpeg data */ #define IMGFMT_MPEG (('G'<<24)|('E'<<16)|('P'<<8)|'M') +/* values for fd_video indicating why it is closed */ +#define CLOSED_FOR_DECODER -1 +#define CLOSED_FOR_ENCODER -2 + struct coeff { float k,m; }; @@ -90,6 +94,7 @@ typedef struct dxr3_driver_s { int aspectratio; int tv_mode; int enhanced_mode; /* enhanced play mode */ + int need_redraw; em8300_bcs_t bcs; char devname[128]; char devnum[3]; diff --git a/src/dxr3/dxr3_vo_core.c b/src/dxr3/dxr3_vo_core.c index a22985479..a450bd7d2 100644 --- a/src/dxr3/dxr3_vo_core.c +++ b/src/dxr3/dxr3_vo_core.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_vo_core.c,v 1.17 2002/03/07 13:33:44 jcdutton Exp $ + * $Id: dxr3_vo_core.c,v 1.18 2002/03/31 14:33:12 mlampard Exp $ * ************************************************************************* * core functions common to both Standard and RT-Encoding vo plugins * @@ -105,7 +105,7 @@ void dxr3_read_config(dxr3_driver_t *this) config_values_t *config=this->config; if (ioctl(this->fd_control, EM8300_IOCTL_GETBCS, &this->bcs)) - fprintf(stderr, "dxr3_vo: cannot read bcs values (%s)\n", + printf("dxr3_vo: cannot read bcs values (%s)\n", strerror(errno)); this->bcs.contrast = config->register_range(config, "dxr3.contrast", this->bcs.contrast,100,900,"Dxr3: contrast control",NULL,NULL,NULL); @@ -124,7 +124,7 @@ void dxr3_read_config(dxr3_driver_t *this) this->tv_switchable=0; /* don't allow on-the-fly switching */ } else if (!strcasecmp(str, "overlay")) { this->tv_mode = EM8300_VIDEOMODE_DEFAULT; - fprintf(stderr, "dxr3_vo: setting up overlay mode\n"); + printf("dxr3_vo: setting up overlay mode\n"); if (dxr3_overlay_read_state(&this->overlay) == 0) { this->overlay_enabled = 1; this->tv_switchable=1; @@ -136,7 +136,7 @@ void dxr3_read_config(dxr3_driver_t *this) sscanf(str, "%f", &this->overlay.color_interval); } else { - fprintf(stderr, "dxr3_vo: please run autocal, overlay disabled\n"); + printf("dxr3_vo: please run autocal, overlay disabled\n"); this->overlay_enabled=0; this->tv_switchable=0; } @@ -145,13 +145,13 @@ void dxr3_read_config(dxr3_driver_t *this) if (!strcasecmp(str, "ntsc")) { this->tv_mode = EM8300_VIDEOMODE_NTSC; - fprintf(stderr, "dxr3_vo: setting tv_mode to NTSC\n"); + printf("dxr3_vo: setting tv_mode to NTSC\n"); } else if (!strcasecmp(str, "pal")) { this->tv_mode = EM8300_VIDEOMODE_PAL; - fprintf(stderr, "dxr3_vo: setting tv_mode to PAL 50Hz\n"); + printf("dxr3_vo: setting tv_mode to PAL 50Hz\n"); } else if (!strcasecmp(str, "pal60")) { this->tv_mode = EM8300_VIDEOMODE_PAL60; - fprintf(stderr, "dxr3_vo: setting tv_mode to PAL 60Hz\n"); + printf("dxr3_vo: setting tv_mode to PAL 60Hz\n"); } else { this->tv_mode = EM8300_VIDEOMODE_DEFAULT; } @@ -159,7 +159,7 @@ void dxr3_read_config(dxr3_driver_t *this) if (this->tv_mode != EM8300_VIDEOMODE_DEFAULT) if (ioctl(this->fd_control, EM8300_IOCTL_SET_VIDEOMODE, &this->tv_mode)) - fprintf(stderr, "dxr3_vo: setting video mode failed."); + printf("dxr3_vo: setting video mode failed."); } @@ -254,7 +254,7 @@ int dxr3_get_property (vo_driver_t *this_gen, int property) break; default: val = 0; - fprintf(stderr, "dxr3_vo: property %d not implemented!\n", property); + printf("dxr3_vo: property %d not implemented!\n", property); } return val; @@ -290,20 +290,20 @@ int dxr3_set_property (vo_driver_t *this_gen, fullscreen = this->overlay_enabled ? is_fullscreen(this) : 0; if (value == ASPECT_ANAMORPHIC) { - fprintf(stderr, "dxr3_vo: setting aspect ratio to anamorphic\n"); + printf("dxr3_vo: setting aspect ratio to anamorphic\n"); if (!this->overlay_enabled || fullscreen) val = EM8300_ASPECTRATIO_16_9; else /* The overlay window can adapt to the ratio */ val = EM8300_ASPECTRATIO_4_3; this->desired_ratio = 16.0/9.0; } else { - fprintf(stderr, "dxr3_vo: setting aspect ratio to full\n"); + printf("dxr3_vo: setting aspect ratio to full\n"); val = EM8300_ASPECTRATIO_4_3; this->desired_ratio = 4.0/3.0; } if (ioctl(this->fd_control, EM8300_IOCTL_SET_ASPECTRATIO, &val)) - fprintf(stderr, "dxr3_vo: failed to set aspect ratio (%s)\n", + printf("dxr3_vo: failed to set aspect ratio (%s)\n", strerror(errno)); if (this->overlay_enabled && !fullscreen){ @@ -313,22 +313,22 @@ int dxr3_set_property (vo_driver_t *this_gen, } break; case VO_PROP_COLORKEY: - fprintf(stderr, "dxr3_vo: VO_PROP_COLORKEY not implemented!"); + printf("dxr3_vo: VO_PROP_COLORKEY not implemented!"); this->overlay.colorkey = val; break; case VO_PROP_ZOOM_FACTOR: /* FIXME: Was ZOOM_X */ if(!this->overlay_enabled){ /* TV-out only */ if(value==1){ - fprintf(stderr, "dxr3_vo: enabling 16:9 zoom\n"); + printf("dxr3_vo: enabling 16:9 zoom\n"); val=EM8300_ASPECTRATIO_4_3; if (ioctl(this->fd_control, EM8300_IOCTL_SET_ASPECTRATIO, &val)) - fprintf(stderr, "dxr3_vo: failed to set aspect ratio (%s)\n", + printf("dxr3_vo: failed to set aspect ratio (%s)\n", strerror(errno)); dxr3_zoomTV(this); }else if (value==-1){ - fprintf(stderr, "dxr3_vo: disabling 16:9 zoom\n"); + printf("dxr3_vo: disabling 16:9 zoom\n"); if (ioctl(this->fd_control, EM8300_IOCTL_SET_ASPECTRATIO, &this->aspectratio)) - fprintf(stderr, "dxr3_vo: failed to set aspect ratio (%s)\n", + printf("dxr3_vo: failed to set aspect ratio (%s)\n", strerror(errno)); } } @@ -340,15 +340,15 @@ int dxr3_set_property (vo_driver_t *this_gen, newmode++; if (newmode>EM8300_VIDEOMODE_LAST) newmode=EM8300_VIDEOMODE_PAL; - fprintf(stderr, "dxr3_vo: Changing TVMode to "); + printf("dxr3_vo: Changing TVMode to "); if(newmode==EM8300_VIDEOMODE_PAL) - fprintf(stderr, "PAL\n"); + printf("PAL\n"); if(newmode==EM8300_VIDEOMODE_PAL60) - fprintf(stderr, "PAL60\n"); + printf("PAL60\n"); if(newmode==EM8300_VIDEOMODE_NTSC) - fprintf(stderr, "NTSC\n"); + printf("NTSC\n"); if (ioctl(this->fd_control, EM8300_IOCTL_SET_VIDEOMODE, &newmode)) - fprintf(stderr, "dxr3_vo: setting video mode failed."); + printf("dxr3_vo: setting video mode failed."); } break; default: @@ -357,7 +357,7 @@ int dxr3_set_property (vo_driver_t *this_gen, if (bcs_changed){ if (ioctl(this->fd_control, EM8300_IOCTL_SETBCS, &this->bcs)) - fprintf(stderr, "dxr3_vo: bcs set failed (%s)\n", + printf("dxr3_vo: bcs set failed (%s)\n", strerror(errno)); this->config->update_num(this->config, "dxr3.contrast", this->bcs.contrast); this->config->update_num(this->config, "dxr3.saturation", this->bcs.saturation); @@ -452,11 +452,11 @@ int dxr3_gui_data_exchange (vo_driver_t *this_gen, int window_showing; (int *)window_showing = (int *)data; if(!window_showing){ - fprintf(stderr, "dxr3_vo: Hiding VO window and diverting video to TV\n"); + printf("dxr3_vo: Hiding VO window and diverting video to TV\n"); dxr3_overlay_set_mode(&this->overlay, EM8300_OVERLAY_MODE_OFF ); this->overlay_enabled=0; }else{ - fprintf(stderr, "dxr3_vo: Using VO window for overlaying video\n"); + printf("dxr3_vo: Using VO window for overlaying video\n"); dxr3_overlay_set_mode(&this->overlay, EM8300_OVERLAY_MODE_OVERLAY ); this->overlay_enabled=1; } diff --git a/src/dxr3/mpeg_encoders.c b/src/dxr3/mpeg_encoders.c index 704e46d42..63bc3c729 100644 --- a/src/dxr3/mpeg_encoders.c +++ b/src/dxr3/mpeg_encoders.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: mpeg_encoders.c,v 1.5 2002/03/14 13:56:49 richwareham Exp $ + * $Id: mpeg_encoders.c,v 1.6 2002/03/31 14:33:12 mlampard Exp $ * * mpeg encoders for the dxr3 video out plugin. */ @@ -68,10 +68,12 @@ static void mp1e_callback(rte_context *context, void *data, ssize_t size, regs.val=6; /* Mike's mystery number :-) */ ioctl(this->fd_control, EM8300_IOCTL_WRITEREG, ®s); } - if (this->fd_video < 0) { - snprintf (tmpstr, sizeof(tmpstr), "%s_mv", this->devname); - this->fd_video = open(tmpstr, O_WRONLY); + if (this->fd_video == CLOSED_FOR_ENCODER) { + snprintf (tmpstr, sizeof(tmpstr), "%s_mv%s", this->devname, this->devnum); + this->fd_video = open(tmpstr, O_WRONLY | O_NONBLOCK); } + if (this->fd_video < 0) return; + /* FIXME: Is a SETPTS necessary here? */ if (write(this->fd_video, data, size) < 0) perror("dxr3: writing to video device"); } @@ -406,14 +408,15 @@ static int fame_on_display_frame( dxr3_driver_t* drv, dxr3_frame_t* frame) ioctl(drv->fd_control, EM8300_IOCTL_WRITEREG, ®s); } - if (drv->fd_video < 0) { - snprintf (tmpstr, sizeof(tmpstr), "%s_mv", drv->devname); - drv->fd_video = open(tmpstr, O_WRONLY); + if (drv->fd_video == CLOSED_FOR_ENCODER) { + snprintf (tmpstr, sizeof(tmpstr), "%s_mv%s", drv->devname, drv->devnum); + drv->fd_video = open(tmpstr, O_WRONLY | O_NONBLOCK); } - //if (write(drv->fd_video, frame->mpeg, frame->mpeg_size) < 0) - if (write(drv->fd_video, this->buffer, size) < 0) - perror("dxr3: writing to video device"); - frame->vo_frame.displayed(&frame->vo_frame); + if (drv->fd_video >= 0) + /* FIXME: Is a SETPTS necessary here? */ + if (write(drv->fd_video, this->buffer, size) < 0) + perror("dxr3: writing to video device"); + frame->vo_frame.displayed(&frame->vo_frame); return 0; } -- cgit v1.2.3