From 4129c169b15f8af03c04f436a6bb2a8bd7c0645e Mon Sep 17 00:00:00 2001 From: Michael Roitzsch Date: Tue, 27 Aug 2002 19:24:33 +0000 Subject: sync to libdvdnav cvs, this should now conform to the way xine outputs its console messages (write to stdout, "libdvdnav: " in front each line) CVS patchset: 2531 CVS date: 2002/08/27 19:24:33 --- src/input/libdvdnav/decoder.c | 89 ++++++------- src/input/libdvdnav/diff_against_cvs.patch | 13 +- src/input/libdvdnav/dvdnav.c | 58 +++++---- src/input/libdvdnav/dvdnav_internal.h | 5 +- src/input/libdvdnav/highlight.c | 15 +-- src/input/libdvdnav/read_cache.c | 10 +- src/input/libdvdnav/searching.c | 42 +++--- src/input/libdvdnav/vm.c | 203 ++++++++++++++++------------- src/input/libdvdnav/vmcmd.c | 151 ++++++++++----------- 9 files changed, 311 insertions(+), 275 deletions(-) (limited to 'src') diff --git a/src/input/libdvdnav/decoder.c b/src/input/libdvdnav/decoder.c index 7d01a62f2..6fb771ef1 100644 --- a/src/input/libdvdnav/decoder.c +++ b/src/input/libdvdnav/decoder.c @@ -18,7 +18,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: decoder.c,v 1.3 2002/08/09 22:52:14 mroi Exp $ + * $Id: decoder.c,v 1.4 2002/08/27 19:24:33 mroi Exp $ * */ @@ -34,6 +34,7 @@ #include #include "vmcmd.h" #include "decoder.h" +#include "dvdnav_internal.h" uint32_t vm_getbits(command_t *command, int start, int count) { uint64_t result = 0; @@ -47,7 +48,7 @@ uint32_t vm_getbits(command_t *command, int start, int count) { (start > 63) || (count < 0) || (start < 0) ){ - fprintf(stderr, "Bad call to vm_getbits. Parameter out of range\n"); + fprintf(MSG_OUT, "libdvdnav: Bad call to vm_getbits. Parameter out of range\n"); assert(0); } bit_mask >>= start; @@ -63,7 +64,7 @@ static uint16_t get_GPRM(registers_t* registers, uint8_t reg) { struct timeval current_time, time_offset; uint16_t result; /* Counter mode */ - /* fprintf(stderr, "Getting counter %d\n",reg);*/ + /* fprintf(MSG_OUT, "libdvdnav: Getting counter %d\n",reg);*/ gettimeofday(¤t_time, NULL); time_offset.tv_sec = current_time.tv_sec - registers->GPRM_time[reg].tv_sec; time_offset.tv_usec = current_time.tv_usec - registers->GPRM_time[reg].tv_usec; @@ -86,7 +87,7 @@ static void set_GPRM(registers_t* registers, uint8_t reg, uint16_t value) { if (registers->GPRM_mode[reg] & 0x01) { struct timeval current_time; /* Counter mode */ - /* fprintf(stderr, "Setting counter %d\n",reg); */ + /* fprintf(MSG_OUT, "libdvdnav: Setting counter %d\n",reg); */ gettimeofday(¤t_time, NULL); registers->GPRM_time[reg] = current_time; registers->GPRM_time[reg].tv_sec -= value; @@ -99,7 +100,7 @@ static void set_GPRM(registers_t* registers, uint8_t reg, uint16_t value) { static uint16_t eval_reg(command_t* command, uint8_t reg) { if(reg & 0x80) { if ((reg & 0x1f) == 20) { - fprintf(stderr, "Suspected RCE Region Protection!!!"); + fprintf(MSG_OUT, "libdvdnav: Suspected RCE Region Protection!!!"); } return command->registers->SPRM[reg & 0x1f]; /* FIXME max 24 not 32 */ } else { @@ -149,7 +150,7 @@ static int32_t eval_compare(uint8_t operation, uint16_t data1, uint16_t data2) { case 7: return data1 < data2; } - fprintf(stderr,"eval_compare: Invalid comparison code\n"); + fprintf(MSG_OUT, "libdvdnav: eval_compare: Invalid comparison code\n"); return 0; } @@ -503,7 +504,7 @@ static int32_t eval_command(uint8_t *bytes, registers_t* registers, link_t *retu cond = eval_if_version_1(&command); res = eval_special_instruction(&command, cond); if(res == -1) { - fprintf(stderr, "Unknown Instruction!\n"); + fprintf(MSG_OUT, "libdvdnav: Unknown Instruction!\n"); assert(0); } break; @@ -555,15 +556,15 @@ static int32_t eval_command(uint8_t *bytes, registers_t* registers, link_t *retu res = -1; break; default: /* Unknown command */ - fprintf(stderr, "WARNING: Unknown Command=%x\n", vm_getbits(&command, 0, 3)); + fprintf(MSG_OUT, "libdvdnav: WARNING: Unknown Command=%x\n", vm_getbits(&command, 0, 3)); assert(0); } /* Check if there are bits not yet examined */ if(command.instruction & ~ command.examined) { - fprintf(stderr, " libdvdnav: decoder.c: [WARNING, unknown bits:"); - fprintf(stderr, " %08llx", (command.instruction & ~ command.examined) ); - fprintf(stderr, "]"); + fprintf(MSG_OUT, "libdvdnav: decoder.c: [WARNING, unknown bits:"); + fprintf(MSG_OUT, " %08llx", (command.instruction & ~ command.examined) ); + fprintf(MSG_OUT, "]\n"); } return res; @@ -578,33 +579,29 @@ int32_t vmEval_CMD(vm_cmd_t commands[], int32_t num_commands, #ifdef TRACE /* DEBUG */ - fprintf(stderr, "libdvdnav: Registers before transaction\n"); + fprintf(MSG_OUT, "libdvdnav: Registers before transaction\n"); vmPrint_registers( registers ); - if(1) { - int32_t i; - fprintf(stderr, "libdvdnav: Full list of commands to execute\n"); - for(i = 0; i < num_commands; i++) - vmPrint_CMD(i, &commands[i]); - fprintf(stderr, "--------------------------------------------\n"); - } /* end DEBUG */ - if (1) { - fprintf(stderr, "libdvdnav: Single stepping commands\n"); - } + int32_t i; + fprintf(MSG_OUT, "libdvdnav: Full list of commands to execute\n"); + for(i = 0; i < num_commands; i++) + vmPrint_CMD(i, &commands[i]); + fprintf(MSG_OUT, "libdvdnav: --------------------------------------------\n"); + fprintf(MSG_OUT, "libdvdnav: Single stepping commands\n"); #endif while(i < num_commands && total < 100000) { int32_t line; #ifdef TRACE - if(1) vmPrint_CMD(i, &commands[i]); + vmPrint_CMD(i, &commands[i]); #endif line = eval_command(&commands[i].bytes[0], registers, return_values); if (line < 0) { /* Link command */ #ifdef TRACE - fprintf(stderr, "libdvdnav: Registers after transaction\n"); + fprintf(MSG_OUT, "libdvdnav: Registers after transaction\n"); vmPrint_registers( registers ); - fprintf(stderr, "eval: Doing Link/Jump/Call\n"); + fprintf(MSG_OUT, "libdvdnav: eval: Doing Link/Jump/Call\n"); #endif return 1; } @@ -619,7 +616,7 @@ int32_t vmEval_CMD(vm_cmd_t commands[], int32_t num_commands, memset(return_values, 0, sizeof(link_t)); #ifdef TRACE - fprintf(stderr, "libdvdnav: Registers after transaction\n"); + fprintf(MSG_OUT, "libdvdnav: Registers after transaction\n"); vmPrint_registers( registers ); #endif return 0; @@ -708,61 +705,61 @@ void vmPrint_LINK(link_t value) { case LinkGoUpPGC: case LinkTailPGC: case LinkRSM: - fprintf(stderr, "%s (button %d)\n", cmd, value.data1); + fprintf(MSG_OUT, "libdvdnav: %s (button %d)\n", cmd, value.data1); break; case LinkPGCN: case JumpTT: case JumpVTS_TT: case JumpSS_VMGM_MENU: /* == 2 -> Title Menu */ case JumpSS_VMGM_PGC: - fprintf(stderr, "%s %d\n", cmd, value.data1); + fprintf(MSG_OUT, "libdvdnav: %s %d\n", cmd, value.data1); break; case LinkPTTN: case LinkPGN: case LinkCN: - fprintf(stderr, "%s %d (button %d)\n", cmd, value.data1, value.data2); + fprintf(MSG_OUT, "libdvdnav: %s %d (button %d)\n", cmd, value.data1, value.data2); break; case Exit: case JumpSS_FP: case PlayThis: /* Humm.. should we have this at all.. */ - fprintf(stderr, "%s\n", cmd); + fprintf(MSG_OUT, "libdvdnav: %s\n", cmd); break; case JumpVTS_PTT: - fprintf(stderr, "%s %d:%d\n", cmd, value.data1, value.data2); + fprintf(MSG_OUT, "libdvdnav: %s %d:%d\n", cmd, value.data1, value.data2); break; case JumpSS_VTSM: - fprintf(stderr, "%s vts %d title %d menu %d\n", + fprintf(MSG_OUT, "libdvdnav: %s vts %d title %d menu %d\n", cmd, value.data1, value.data2, value.data3); break; case CallSS_FP: - fprintf(stderr, "%s resume cell %d\n", cmd, value.data1); + fprintf(MSG_OUT, "libdvdnav: %s resume cell %d\n", cmd, value.data1); break; case CallSS_VMGM_MENU: /* == 2 -> Title Menu */ case CallSS_VTSM: - fprintf(stderr, "%s %d resume cell %d\n", cmd, value.data1, value.data2); + fprintf(MSG_OUT, "libdvdnav: %s %d resume cell %d\n", cmd, value.data1, value.data2); break; case CallSS_VMGM_PGC: - fprintf(stderr, "%s %d resume cell %d\n", cmd, value.data1, value.data2); + fprintf(MSG_OUT, "libdvdnav: %s %d resume cell %d\n", cmd, value.data1, value.data2); break; } } void vmPrint_registers( registers_t *registers ) { int32_t i; - fprintf(stderr, " # "); + fprintf(MSG_OUT, "libdvdnav: # "); for(i = 0; i < 24; i++) - fprintf(stderr, " %2d |", i); - fprintf(stderr, "\nSRPMS: "); + fprintf(MSG_OUT, " %2d |", i); + fprintf(MSG_OUT, "\nlibdvdnav: SRPMS: "); for(i = 0; i < 24; i++) - fprintf(stderr, "%04x|", registers->SPRM[i]); - fprintf(stderr, "\nGRPMS: "); + fprintf(MSG_OUT, "%04x|", registers->SPRM[i]); + fprintf(MSG_OUT, "\nlibdvdnav: GRPMS: "); for(i = 0; i < 16; i++) - fprintf(stderr, "%04x|", get_GPRM(registers, i) ); - fprintf(stderr, "\nGmode: "); + fprintf(MSG_OUT, "%04x|", get_GPRM(registers, i) ); + fprintf(MSG_OUT, "\nlibdvdnav: Gmode: "); for(i = 0; i < 16; i++) - fprintf(stderr, "%04x|", registers->GPRM_mode[i]); - fprintf(stderr, "\nGtime: "); + fprintf(MSG_OUT, "%04x|", registers->GPRM_mode[i]); + fprintf(MSG_OUT, "\nlibdvdnav: Gtime: "); for(i = 0; i < 16; i++) - fprintf(stderr, "%04lx|", registers->GPRM_time[i].tv_sec & 0xffff); - fprintf(stderr, "\n"); + fprintf(MSG_OUT, "%04lx|", registers->GPRM_time[i].tv_sec & 0xffff); + fprintf(MSG_OUT, "\n"); } diff --git a/src/input/libdvdnav/diff_against_cvs.patch b/src/input/libdvdnav/diff_against_cvs.patch index 1bb5c976b..25876c5d6 100644 --- a/src/input/libdvdnav/diff_against_cvs.patch +++ b/src/input/libdvdnav/diff_against_cvs.patch @@ -82,12 +82,21 @@ /* Maximum length of an error string */ +@@ -60,7 +61,7 @@ + #endif + + /* where should libdvdnav write its messages (stdout/stderr) */ +-#define MSG_OUT stderr ++#define MSG_OUT stdout + + typedef struct read_cache_s read_cache_t; + --- src/input/libdvdnav/highlight.c Fri Jul 26 12:58:10 2002 +++ src/input/libdvdnav/highlight.c Fri Aug 9 22:02:46 2002 -@@ -35,10 +35,10 @@ +@@ -34,10 +34,10 @@ + #include "dvdnav_internal.h" #include "vm.h" - # -#include +#include "nav_types.h" diff --git a/src/input/libdvdnav/dvdnav.c b/src/input/libdvdnav/dvdnav.c index 206420653..8412c519e 100644 --- a/src/input/libdvdnav/dvdnav.c +++ b/src/input/libdvdnav/dvdnav.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: dvdnav.c,v 1.4 2002/08/19 17:17:00 mroi Exp $ + * $Id: dvdnav.c,v 1.5 2002/08/27 19:24:33 mroi Exp $ * */ @@ -227,13 +227,13 @@ dvdnav_status_t dvdnav_close(dvdnav_t *this) { return S_ERR; } #ifdef LOG_DEBUG - fprintf(stderr,"dvdnav:close:called\n"); + fprintf(MSG_OUT, "libdvdnav: close:called\n"); #endif if (this->file) { DVDCloseFile(this->file); #ifdef LOG_DEBUG - fprintf(stderr,"dvdnav:close:file closing\n"); + fprintf(MSG_OUT, "libdvdnav: close:file closing\n"); #endif this->file = NULL; } @@ -245,7 +245,7 @@ dvdnav_status_t dvdnav_close(dvdnav_t *this) { if (this->file) { DVDCloseFile(this->file); #ifdef LOG_DEBUG - fprintf(stderr,"dvdnav:close2:file closing\n"); + fprintf(MSG_OUT, "libdvdnav: close2:file closing\n"); #endif this->file = NULL; } @@ -265,18 +265,18 @@ dvdnav_status_t dvdnav_reset(dvdnav_t *this) { dvdnav_status_t result; #ifdef LOG_DEBUG - printf("dvdnav:reset:called\n"); + fprintf(MSG_OUT, "libdvdnav: reset:called\n"); #endif if(!this) { printerr("Passed a NULL pointer"); return S_ERR; } #ifdef LOG_DEBUG - printf("getting lock\n"); + fprintf(MSG_OUT, "libdvdnav: getting lock\n"); #endif pthread_mutex_lock(&this->vm_lock); #ifdef LOG_DEBUG - printf("reseting vm\n"); + fprintf(MSG_OUT, "libdvdnav: reseting vm\n"); #endif if(vm_reset(this->vm, NULL) == -1) { printerr("Error restarting the VM"); @@ -284,11 +284,11 @@ dvdnav_status_t dvdnav_reset(dvdnav_t *this) { return S_ERR; } #ifdef LOG_DEBUG - printf("clearing dvdnav\n"); + fprintf(MSG_OUT, "libdvdnav: clearing dvdnav\n"); #endif result=dvdnav_clear(this); #ifdef LOG_DEBUG - printf("starting vm\n"); + fprintf(MSG_OUT, "libdvdnav: starting vm\n"); #endif // if(!this->started) { // /* Start the VM */ @@ -296,7 +296,7 @@ dvdnav_status_t dvdnav_reset(dvdnav_t *this) { // this->started = 1; // } #ifdef LOG_DEBUG - printf("unlocking\n"); + fprintf(MSG_OUT, "libdvdnav: unlocking\n"); #endif pthread_mutex_unlock(&this->vm_lock); return result; @@ -338,7 +338,7 @@ int dvdnav_decode_packet(dvdnav_t *this, uint8_t *p, dsi_t* nav_dsi, pci_t* nav_ if (p==NULL) { - fprintf(stderr,"Passed a NULL pointer.\n"); + fprintf(MSG_OUT, "libdvdnav: Passed a NULL pointer.\n"); return 0; } @@ -371,7 +371,7 @@ int dvdnav_decode_packet(dvdnav_t *this, uint8_t *p, dsi_t* nav_dsi, pci_t* nav_ /* we should now have a PES packet here */ if (p[0] || p[1] || (p[2] != 1)) { - fprintf(stderr,"demux error! %02x %02x %02x (should be 0x000001) \n",p[0],p[1],p[2]); + fprintf(MSG_OUT, "libdvdnav: demux error! %02x %02x %02x (should be 0x000001) \n",p[0],p[1],p[2]); return 0; } @@ -384,11 +384,11 @@ int dvdnav_decode_packet(dvdnav_t *this, uint8_t *p, dsi_t* nav_dsi, pci_t* nav_ if (nStreamID == 0xbf) { /* Private stream 2 */ /* * int i; - * printf("dvdnav:nav packet=%u\n",p-p_start-6); + * fprintf(MSG_OUT, "libdvdnav: nav packet=%u\n",p-p_start-6); * for(i=0;i<80;i++) { - * printf("%02x ",p[i-6]); + * fprintf(MSG_OUT, "%02x ",p[i-6]); * } - * printf("\n"); + * fprintf(MSG_OUT, "\n"); */ if(p[0] == 0x00) { navRead_PCI(nav_pci, p+1); @@ -546,9 +546,9 @@ dvdnav_status_t dvdnav_get_next_cache_block(dvdnav_t *this, unsigned char **buf, vm_position_get(this->vm,&this->position_next); /********** - fprintf(stderr, "POS-NEXT "); + fprintf(MSG_OUT, "libdvdnav: POS-NEXT "); vm_position_print(this->vm, &this->position_next); - fprintf(stderr, "POS-CUR "); + fprintf(MSG_OUT, "libdvdnav: POS-CUR "); vm_position_print(this->vm, &this->position_current); **********/ @@ -565,13 +565,13 @@ dvdnav_status_t dvdnav_get_next_cache_block(dvdnav_t *this, unsigned char **buf, if(this->spu_clut_changed) { (*event) = DVDNAV_SPU_CLUT_CHANGE; #ifdef LOG_DEBUG - fprintf(stderr,"libdvdnav:SPU_CLUT_CHANGE\n"); + fprintf(MSG_OUT, "libdvdnav: SPU_CLUT_CHANGE\n"); #endif (*len) = 16 * sizeof(uint32_t); memcpy(*buf, &(state->pgc->palette), 16 * sizeof(uint32_t)); this->spu_clut_changed = 0; #ifdef LOG_DEBUG - fprintf(stderr,"libdvdnav:SPU_CLUT_CHANGE returning S_OK\n"); + fprintf(MSG_OUT, "libdvdnav: SPU_CLUT_CHANGE returning S_OK\n"); #endif pthread_mutex_unlock(&this->vm_lock); return S_OK; @@ -581,7 +581,7 @@ dvdnav_status_t dvdnav_get_next_cache_block(dvdnav_t *this, unsigned char **buf, dvdnav_spu_stream_change_event_t stream_change; (*event) = DVDNAV_SPU_STREAM_CHANGE; #ifdef LOG_DEBUG - fprintf(stderr,"libdvdnav:SPU_STREAM_CHANGE\n"); + fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE\n"); #endif (*len) = sizeof(dvdnav_spu_stream_change_event_t); stream_change.physical_wide = vm_get_subp_active_stream(this->vm, 0); @@ -590,16 +590,16 @@ dvdnav_status_t dvdnav_get_next_cache_block(dvdnav_t *this, unsigned char **buf, memcpy(*buf, &(stream_change), sizeof( dvdnav_spu_stream_change_event_t)); this->position_current.spu_channel = this->position_next.spu_channel; #ifdef LOG_DEBUG - fprintf(stderr,"libdvdnav:SPU_STREAM_CHANGE stream_id_wide=%d\n",stream_change.physical_wide); - fprintf(stderr,"libdvdnav:SPU_STREAM_CHANGE stream_id_letterbox=%d\n",stream_change.physical_letterbox); - fprintf(stderr,"libdvdnav:SPU_STREAM_CHANGE stream_id_pan_scan=%d\n",stream_change.physical_pan_scan); + fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_wide=%d\n",stream_change.physical_wide); + fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_letterbox=%d\n",stream_change.physical_letterbox); + fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_pan_scan=%d\n",stream_change.physical_pan_scan); #endif pthread_mutex_unlock(&this->vm_lock); if (stream_change.physical_wide != -1 && stream_change.physical_letterbox != -1 && stream_change.physical_pan_scan != -1) { #ifdef LOG_DEBUG - fprintf(stderr,"libdvdnav:SPU_STREAM_CHANGE returning S_OK\n"); + fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE returning S_OK\n"); #endif return S_OK; } @@ -609,14 +609,14 @@ dvdnav_status_t dvdnav_get_next_cache_block(dvdnav_t *this, unsigned char **buf, dvdnav_audio_stream_change_event_t stream_change; (*event) = DVDNAV_AUDIO_STREAM_CHANGE; #ifdef LOG_DEBUG - fprintf(stderr,"libdvdnav:AUDIO_STREAM_CHANGE\n"); + fprintf(MSG_OUT, "libdvdnav: AUDIO_STREAM_CHANGE\n"); #endif (*len) = sizeof(dvdnav_audio_stream_change_event_t); stream_change.physical= vm_get_audio_active_stream( this->vm ); memcpy(*buf, &(stream_change), sizeof( dvdnav_audio_stream_change_event_t)); this->position_current.audio_channel = this->position_next.audio_channel; #ifdef LOG_DEBUG - fprintf(stderr,"libdvdnav:AUDIO_STREAM_CHANGE stream_id=%d returning S_OK\n",stream_change.physical); + fprintf(MSG_OUT, "libdvdnav: AUDIO_STREAM_CHANGE stream_id=%d returning S_OK\n",stream_change.physical); #endif pthread_mutex_unlock(&this->vm_lock); return S_OK; @@ -735,7 +735,7 @@ dvdnav_status_t dvdnav_get_next_cache_block(dvdnav_t *this, unsigned char **buf, if(this->vobu.vobu_next == SRI_END_OF_CELL) { /* End of Cell from NAV DSI info */ #ifdef LOG_DEBUG - fprintf(stderr, "Still set to %x\n", this->position_next.still); + fprintf(MSG_OUT, "libdvdnav: Still set to %x\n", this->position_next.still); #endif this->position_current.still = this->position_next.still; @@ -999,6 +999,10 @@ uint32_t dvdnav_get_next_still_flag(dvdnav_t *this) { /* * $Log: dvdnav.c,v $ + * Revision 1.5 2002/08/27 19:24:33 mroi + * sync to libdvdnav cvs, this should now conform to the way xine outputs + * its console messages (write to stdout, "libdvdnav: " in front each line) + * * Revision 1.4 2002/08/19 17:17:00 mroi * sync to libdvdnav cvs * - update clut and spu/audio channel more often diff --git a/src/input/libdvdnav/dvdnav_internal.h b/src/input/libdvdnav/dvdnav_internal.h index 7ec745b42..d3c48a276 100644 --- a/src/input/libdvdnav/dvdnav_internal.h +++ b/src/input/libdvdnav/dvdnav_internal.h @@ -18,7 +18,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: dvdnav_internal.h,v 1.3 2002/08/09 22:52:14 mroi Exp $ + * $Id: dvdnav_internal.h,v 1.4 2002/08/27 19:24:33 mroi Exp $ * */ @@ -60,6 +60,9 @@ #define DVD_VIDEO_LB_LEN 2048 #endif +/* where should libdvdnav write its messages (stdout/stderr) */ +#define MSG_OUT stdout + typedef struct read_cache_s read_cache_t; /* diff --git a/src/input/libdvdnav/highlight.c b/src/input/libdvdnav/highlight.c index ee5eb163c..2863f2441 100644 --- a/src/input/libdvdnav/highlight.c +++ b/src/input/libdvdnav/highlight.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: highlight.c,v 1.3 2002/08/09 22:52:14 mroi Exp $ + * $Id: highlight.c,v 1.4 2002/08/27 19:24:33 mroi Exp $ * */ @@ -34,7 +34,6 @@ #include "dvdnav_internal.h" #include "vm.h" -# #include "nav_types.h" #ifdef BUTTON_TESTING @@ -57,7 +56,7 @@ btni_t *__get_current_button(dvdnav_t *this) { int button = 0; if(dvdnav_get_current_highlight(this, &button) != S_OK) { - printerrf("Unable to get information on current highlight."); + printerr("Unable to get information on current highlight."); return NULL; } #ifdef BUTTON_TESTING @@ -160,12 +159,12 @@ dvdnav_status_t dvdnav_get_highlight_area(pci_t* nav_pci , int32_t button, int32 dvdnav_highlight_area_t* highlight) { btni_t *button_ptr; #ifdef BUTTON_TESTING - fprintf(stderr,"Button get_highlight_area %i\n", button); + fprintf(MSG_OUT, "libdvdnav: Button get_highlight_area %i\n", button); #endif /* Set the highlight SPRM if the passed button was valid*/ if((button <= 0) || (button > nav_pci->hli.hl_gi.btn_ns)) { - fprintf(stderr,"Unable to select button number %i as it doesn't exist\n", + fprintf(MSG_OUT, "libdvdnav: Unable to select button number %i as it doesn't exist\n", button); return S_ERR; } @@ -183,7 +182,7 @@ dvdnav_status_t dvdnav_get_highlight_area(pci_t* nav_pci , int32_t button, int32 highlight->pts = nav_pci->hli.hl_gi.hli_s_ptm; highlight->buttonN = button; #ifdef BUTTON_TESTING - fprintf(stderr,"highlight.c:Highlight area is (%u,%u)-(%u,%u), display = %i, button = %u\n", + fprintf(MSG_OUT, "libdvdnav: highlight.c:Highlight area is (%u,%u)-(%u,%u), display = %i, button = %u\n", button_ptr->x_start, button_ptr->y_start, button_ptr->x_end, button_ptr->y_end, 1, @@ -235,7 +234,7 @@ dvdnav_status_t dvdnav_button_activate(dvdnav_t *this) { /* Finally, make the VM execute the appropriate code and * scedule a jump */ #ifdef BUTTON_TESTING - fprintf(stderr, "libdvdnav: Evaluating Button Activation commands.\n"); + fprintf(MSG_OUT, "libdvdnav: Evaluating Button Activation commands.\n"); #endif if(vm_eval_cmd(this->vm, &(button_ptr->cmd)) == 1) { /* Command caused a jump */ @@ -255,7 +254,7 @@ dvdnav_status_t dvdnav_button_select(dvdnav_t *this, int button) { } #ifdef BUTTON_TESTING - fprintf(stderr,"libdvdnav: Button select %i\n", button); + fprintf(MSG_OUT, "libdvdnav: Button select %i\n", button); #endif /* Set the highlight SPRM if the passed button was valid*/ diff --git a/src/input/libdvdnav/read_cache.c b/src/input/libdvdnav/read_cache.c index 72ff2d801..6d3a2e8f1 100644 --- a/src/input/libdvdnav/read_cache.c +++ b/src/input/libdvdnav/read_cache.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: read_cache.c,v 1.2 2002/08/19 17:17:00 mroi Exp $ + * $Id: read_cache.c,v 1.3 2002/08/27 19:24:33 mroi Exp $ * */ @@ -93,10 +93,10 @@ struct read_cache_s { }; #endif -#define _MT_TRACE 0 +#define READ_CACHE_TRACE 0 -#if _MT_TRACE -#define dprintf(fmt, args...) fprintf(stderr, "%s: "fmt, __func__ , ## args); +#if READ_CACHE_TRACE +#define dprintf(fmt, args...) fprintf(MSG_OUT, "libdvdnav: %s: "fmt, __func__ , ## args); #else #define dprintf(fmt, args...) /* Nowt */ #endif @@ -312,7 +312,7 @@ int dvdnav_read_cache_block( read_cache_t *self, int sector, size_t block_count, } else { /* Miss */ - fprintf(stderr, "DVD read cache miss! (not bad but a performance hit) sector=%d\n", sector); + fprintf(MSG_OUT, "libdvdnav: DVD read cache miss! (not bad but a performance hit) sector=%d\n", sector); result = DVDReadBlocks( self->dvd_self->file, sector, block_count, *buf); self->read_point = sector+block_count; if(self->read_point > self->pos + self->size) { diff --git a/src/input/libdvdnav/searching.c b/src/input/libdvdnav/searching.c index d4a4b4280..b1c1141f7 100644 --- a/src/input/libdvdnav/searching.c +++ b/src/input/libdvdnav/searching.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: searching.c,v 1.3 2002/08/09 22:52:14 mroi Exp $ + * $Id: searching.c,v 1.4 2002/08/27 19:24:33 mroi Exp $ * */ @@ -47,7 +47,7 @@ dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, int32_t seekto /* FIXME:Need to handle seeking outside current cell. */ vobu_admap_t *admap = NULL; *vobu = -1; - fprintf(stderr,"Seeking to target %u ...\n", + fprintf(MSG_OUT, "libdvdnav: Seeking to target %u ...\n", seekto_block); /* Search through the VOBU_ADMAP for the nearest VOBU @@ -64,7 +64,7 @@ dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, int32_t seekto admap = this->vm->vtsi->vts_vobu_admap; break; default: - fprintf(stderr,"Error: Unknown domain for seeking seek.\n"); + fprintf(MSG_OUT, "libdvdnav: Error: Unknown domain for seeking seek.\n"); } if(admap) { int32_t address = 0; @@ -77,7 +77,7 @@ dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, int32_t seekto while((!found) && ((address<<2) < admap->last_byte)) { next_vobu = admap->vobu_start_sectors[address]; - /* printf("Found block %u\n", next_vobu); */ + /* fprintf(MSG_OUT, "libdvdnav: Found block %u\n", next_vobu); */ if(vobu_start <= seekto_block && next_vobu > seekto_block) { @@ -92,11 +92,11 @@ dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, int32_t seekto *vobu = vobu_start; return S_OK; } else { - fprintf(stderr,"Could not locate block\n"); + fprintf(MSG_OUT, "libdvdnav: Could not locate block\n"); return S_ERR; } } - fprintf(stderr,"admap not located\n"); + fprintf(MSG_OUT, "libdvdnav: admap not located\n"); return S_ERR; } @@ -128,8 +128,8 @@ dvdnav_status_t dvdnav_sector_search(dvdnav_t *this, pthread_mutex_lock(&this->vm_lock); result = dvdnav_get_position(this, &target, &length); - fprintf(stderr,"FIXME: seeking to offset=%lu pos=%u length=%u\n", offset, target, length); - fprintf(stderr,"FIXME: Before cellN=%u blockN=%u\n" , + fprintf(MSG_OUT, "libdvdnav: FIXME: seeking to offset=%lu pos=%u length=%u\n", offset, target, length); + fprintf(MSG_OUT, "libdvdnav: FIXME: Before cellN=%u blockN=%u\n" , state->cellN, state->blockN); if(!result) { @@ -188,7 +188,7 @@ dvdnav_status_t dvdnav_sector_search(dvdnav_t *this, if(fnd_cell_nr <= last_cell_nr) { int32_t vobu, start; dvdnav_status_t status; - fprintf(stderr,"Seeking to cell %i from choice of %i to %i\n", + fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n", fnd_cell_nr, first_cell_nr, last_cell_nr); status = dvdnav_scan_admap(this, state->domain, target, &vobu); /* @@ -197,24 +197,24 @@ dvdnav_status_t dvdnav_sector_search(dvdnav_t *this, * A new clut has to be sent. */ start =(state->pgc->cell_playback[state->cellN - 1].first_sector); - fprintf(stderr,"FIXME: After cellN=%u blockN=%u target=%x vobu=%x start=%x\n" , + fprintf(MSG_OUT, "libdvdnav: FIXME: After cellN=%u blockN=%u target=%x vobu=%x start=%x\n" , state->cellN, state->blockN, target, vobu, start); state->blockN = vobu - start; - fprintf(stderr,"FIXME: After vobu=%x start=%x blockN=%x\n" , + fprintf(MSG_OUT, "libdvdnav: FIXME: After vobu=%x start=%x blockN=%x\n" , vobu, start, state->blockN); pthread_mutex_unlock(&this->vm_lock); return target; } else { - fprintf(stderr, "Error when seeking, asked to seek outside program\n"); + fprintf(MSG_OUT, "libdvdnav: Error when seeking, asked to seek outside program\n"); } - fprintf(stderr,"FIXME: Implement seeking to location %u\n", target); + fprintf(MSG_OUT, "libdvdnav: FIXME: Implement seeking to location %u\n", target); pthread_mutex_unlock(&this->vm_lock); return -1; @@ -240,13 +240,13 @@ dvdnav_status_t dvdnav_prev_pg_search(dvdnav_t *this) { /* Make sure this is not the first chapter */ if(state->pgN <= 1 ) { - fprintf(stderr,"dvdnav: at first chapter. prev chapter failed.\n"); + fprintf(MSG_OUT, "libdvdnav: at first chapter. prev chapter failed.\n"); return S_ERR; } - fprintf(stderr,"dvdnav: previous chapter\n"); + fprintf(MSG_OUT, "libdvdnav: previous chapter\n"); vm_jump_prog(this->vm, state->pgN - 1); this->vm->hop_channel++; - fprintf(stderr,"dvdnav: previous chapter done\n"); + fprintf(MSG_OUT, "libdvdnav: previous chapter done\n"); return S_OK; } @@ -256,7 +256,7 @@ dvdnav_status_t dvdnav_top_pg_search(dvdnav_t *this) { if((!this) || (!this->vm) ) return S_ERR; - fprintf(stderr,"dvdnav: top chapter. NOP.\n"); + fprintf(MSG_OUT, "libdvdnav: top chapter. NOP.\n"); return S_OK; } @@ -273,13 +273,13 @@ dvdnav_status_t dvdnav_next_pg_search(dvdnav_t *this) { /* Make sure this is not the last chapter */ if(state->pgN >= state->pgc->nr_of_programs) { - fprintf(stderr,"dvdnav: at last chapter. next chapter failed.\n"); + fprintf(MSG_OUT, "libdvdnav: at last chapter. next chapter failed.\n"); return S_ERR; } - fprintf(stderr,"dvdnav: next chapter\n"); + fprintf(MSG_OUT, "libdvdnav: next chapter\n"); vm_jump_prog(this->vm, state->pgN + 1); this->vm->hop_channel++; - fprintf(stderr,"dvdnav: next chapter done\n"); + fprintf(MSG_OUT, "libdvdnav: next chapter done\n"); return S_OK; } @@ -398,7 +398,7 @@ dvdnav_status_t dvdnav_get_position(dvdnav_t *this, unsigned int* pos, *pos= cur_sector - first_cell->first_sector; *len= last_cell->last_sector - first_cell->first_sector; - /* printf("dvdnav:searching:current pos=%u length=%u\n",*pos,*len); */ + /* fprintf(MSG_OUT, "libdvdnav: searching:current pos=%u length=%u\n",*pos,*len); */ return S_OK; diff --git a/src/input/libdvdnav/vm.c b/src/input/libdvdnav/vm.c index 1001ac395..21f976ef8 100644 --- a/src/input/libdvdnav/vm.c +++ b/src/input/libdvdnav/vm.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: vm.c,v 1.3 2002/08/09 22:52:14 mroi Exp $ + * $Id: vm.c,v 1.4 2002/08/27 19:24:33 mroi Exp $ * */ @@ -42,6 +42,10 @@ #include "vm.h" #include "dvdnav_internal.h" +/* +#define STRICT +*/ + /* Local prototypes */ static void saveRSMinfo(vm_t *vm,int cellN, int blockN); @@ -87,26 +91,26 @@ vm_t* vm_new_vm() { static void vm_print_current_domain_state(vm_t *vm) { switch((vm->state).domain) { case VTS_DOMAIN: - fprintf(stderr, "Video Title Domain: -\n"); + fprintf(MSG_OUT, "libdvdnav: Video Title Domain: -\n"); break; case VTSM_DOMAIN: - fprintf(stderr, "Video Title Menu Domain: -\n"); + fprintf(MSG_OUT, "libdvdnav: Video Title Menu Domain: -\n"); break; case VMGM_DOMAIN: - fprintf(stderr, "Video Manager Menu Domain: -\n"); + fprintf(MSG_OUT, "libdvdnav: Video Manager Menu Domain: -\n"); break; case FP_DOMAIN: - fprintf(stderr, "First Play Domain: -\n"); + fprintf(MSG_OUT, "libdvdnav: First Play Domain: -\n"); break; default: - fprintf(stderr, "Unknown Domain: -\n"); + fprintf(MSG_OUT, "libdvdnav: Unknown Domain: -\n"); break; } - fprintf(stderr, "VTS:%d PG:%u CELL:%u BLOCK:%u VTS_TTN:%u TTN:%u TT_PGCN:%u\n", + fprintf(MSG_OUT, "libdvdnav: VTS:%d PG:%u CELL:%u BLOCK:%u VTS_TTN:%u TTN:%u TT_PGCN:%u\n", (vm->state).vtsN, (vm->state).pgN, (vm->state).cellN, @@ -214,44 +218,44 @@ int vm_reset(vm_t *vm, char *dvdroot) /* , register_t regs) */ { if (!vm->dvd) { vm->dvd = DVDOpen(dvdroot); if(!vm->dvd) { - fprintf(stderr, "vm: faild to open/read the DVD\n"); + fprintf(MSG_OUT, "libdvdnav: vm: faild to open/read the DVD\n"); return -1; } vm->vmgi = ifoOpenVMGI(vm->dvd); if(!vm->vmgi) { - fprintf(stderr, "vm: faild to read VIDEO_TS.IFO\n"); + fprintf(MSG_OUT, "libdvdnav: vm: faild to read VIDEO_TS.IFO\n"); return -1; } if(!ifoRead_FP_PGC(vm->vmgi)) { - fprintf(stderr, "vm: ifoRead_FP_PGC failed\n"); + fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_FP_PGC failed\n"); return -1; } if(!ifoRead_TT_SRPT(vm->vmgi)) { - fprintf(stderr, "vm: ifoRead_TT_SRPT failed\n"); + fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_TT_SRPT failed\n"); return -1; } if(!ifoRead_PGCI_UT(vm->vmgi)) { - fprintf(stderr, "vm: ifoRead_PGCI_UT failed\n"); + fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_PGCI_UT failed\n"); return -1; } if(!ifoRead_PTL_MAIT(vm->vmgi)) { - fprintf(stderr, "vm: ifoRead_PTL_MAIT failed\n"); + fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_PTL_MAIT failed\n"); ; /* return -1; Not really used for now.. */ } if(!ifoRead_VTS_ATRT(vm->vmgi)) { - fprintf(stderr, "vm: ifoRead_VTS_ATRT failed\n"); + fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_VTS_ATRT failed\n"); ; /* return -1; Not really used for now.. */ } if(!ifoRead_VOBU_ADMAP(vm->vmgi)) { - fprintf(stderr, "vm: ifoRead_VOBU_ADMAP vgmi failed\n"); + fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_VOBU_ADMAP vgmi failed\n"); ; /* return -1; Not really used for now.. */ } /* ifoRead_TXTDT_MGI(vmgi); Not implemented yet */ } - else fprintf(stderr, "vm: reset\n"); + else fprintf(MSG_OUT, "libdvdnav: vm: reset\n"); if (vm->vmgi) { - fprintf(stderr, "DVD disk reports itself with Region mask 0x%08x. Maybe region %u.\n", + fprintf(MSG_OUT, "libdvdnav: DVD disk reports itself with Region mask 0x%08x. Maybe region %u.\n", vm->vmgi->vmgi_mat->vmg_category, (((vm->vmgi->vmgi_mat->vmg_category >> 16) ^ 0xff) & 0xff) ); } @@ -270,7 +274,7 @@ int vm_start(vm_t *vm) assert(link_values.command == PlayThis); (vm->state).blockN = link_values.data1; #ifdef TRACE - fprintf(stderr, "vm_start: blockN set to 0x%x\n", (vm->state).blockN); + fprintf(MSG_OUT, "libdvdnav: vm_start: blockN set to 0x%x\n", (vm->state).blockN); #endif assert( (vm->state).blockN == 0 ); @@ -296,7 +300,7 @@ int vm_position_get(vm_t *vm, vm_position_t *position) { } int vm_position_print(vm_t *vm, vm_position_t *position) { - fprintf(stderr, "But=%x Spu=%x Aud=%x Ang=%x Hop=%x vts=%x dom=%x cell=%x cell_restart=%x still=%x start=%x next=%x\n", + fprintf(MSG_OUT, "libdvdnav: But=%x Spu=%x Aud=%x Ang=%x Hop=%x vts=%x dom=%x cell=%x cell_restart=%x still=%x start=%x next=%x\n", position->button, position->spu_channel, position->audio_channel, @@ -322,7 +326,7 @@ int vm_start_title(vm_t *vm, int tt) { assert(link_values.command == PlayThis); (vm->state).blockN = link_values.data1; #ifdef TRACE - fprintf(stderr, "vm_start_title: blockN set to 0x%x\n", (vm->state).blockN); + fprintf(MSG_OUT, "libdvdnav: vm_start_title: blockN set to 0x%x\n", (vm->state).blockN); #endif assert( (vm->state).blockN == 0 ); @@ -340,7 +344,7 @@ int vm_jump_prog(vm_t *vm, int pr) { assert(link_values.command == PlayThis); (vm->state).blockN = link_values.data1; #ifdef TRACE - fprintf(stderr, "vm_jump_prog: blockN set to 0x%x\n", (vm->state).blockN); + fprintf(MSG_OUT, "libdvdnav: vm_jump_prog: blockN set to 0x%x\n", (vm->state).blockN); #endif assert( (vm->state).blockN == 0 ); @@ -356,7 +360,7 @@ int vm_eval_cmd(vm_t *vm, vm_cmd_t *cmd) assert(link_values.command == PlayThis); (vm->state).blockN = link_values.data1; #ifdef TRACE - fprintf(stderr, "vm_eval_cmd: blockN set to 0x%x\n", (vm->state).blockN); + fprintf(MSG_OUT, "libdvdnav: vm_eval_cmd: blockN set to 0x%x\n", (vm->state).blockN); #endif assert( (vm->state).blockN == 0 ); return 1; /* Something changed, Jump */ @@ -373,7 +377,7 @@ int vm_get_next_cell(vm_t *vm) assert(link_values.command == PlayThis); (vm->state).blockN = link_values.data1; #ifdef TRACE - fprintf(stderr, "vm_get_next_cell: blockN set to 0x%x\n", (vm->state).blockN); + fprintf(MSG_OUT, "libdvdnav: vm_get_next_cell: blockN set to 0x%x\n", (vm->state).blockN); #endif assert( (vm->state).blockN == 0 ); @@ -388,7 +392,7 @@ int vm_top_pg(vm_t *vm) assert(link_values.command == PlayThis); (vm->state).blockN = link_values.data1; #ifdef TRACE - fprintf(stderr, "vm_top_pg: blockN set to 0x%x\n", (vm->state).blockN); + fprintf(MSG_OUT, "libdvdnav: vm_top_pg: blockN set to 0x%x\n", (vm->state).blockN); #endif assert( (vm->state).blockN == 0 ); @@ -407,7 +411,7 @@ int vm_go_up(vm_t *vm) assert(link_values.command == PlayThis); (vm->state).blockN = link_values.data1; #ifdef TRACE - fprintf(stderr, "vm_go_up: blockN set to 0x%x\n", (vm->state).blockN); + fprintf(MSG_OUT, "libdvdnav: vm_go_up: blockN set to 0x%x\n", (vm->state).blockN); #endif assert( (vm->state).blockN == 0 ); @@ -480,7 +484,7 @@ int vm_menu_call(vm_t *vm, DVDMenuID_t menuid, int block) assert(link_values.command == PlayThis); (vm->state).blockN = link_values.data1; #ifdef TRACE - fprintf(stderr, "vm_menu_call: blockN set to 0x%x\n", (vm->state).blockN); + fprintf(MSG_OUT, "libdvdnav: vm_menu_call: blockN set to 0x%x\n", (vm->state).blockN); #endif assert( (vm->state).blockN == 0 ); return 1; /* Jump */ @@ -526,14 +530,14 @@ int vm_resume(vm_t *vm) assert(link_values.command == PlayThis); (vm->state).blockN = link_values.data1; #ifdef TRACE - fprintf(stderr, "vm_resume1: blockN set to 0x%x\n", (vm->state).blockN); + fprintf(MSG_OUT, "libdvdnav: vm_resume1: blockN set to 0x%x\n", (vm->state).blockN); #endif assert( (vm->state).blockN == 0 ); } else { (vm->state).cellN = (vm->state).rsm_cellN; (vm->state).blockN = (vm->state).rsm_blockN; #ifdef TRACE - fprintf(stderr, "vm_resume2: blockN set to 0x%x\n", (vm->state).blockN); + fprintf(MSG_OUT, "libdvdnav: vm_resume2: blockN set to 0x%x\n", (vm->state).blockN); #endif /* (vm->state).pgN = ?? does this gets the righ value in play_Cell, no! */ if(set_PGN(vm)) { @@ -554,7 +558,7 @@ int vm_get_audio_stream(vm_t *vm, int audioN) { int streamN = -1; #ifdef TRACE - fprintf(stderr,"dvdnav:vm.c:get_audio_stream audioN=%d\n",audioN); + fprintf(MSG_OUT, "libdvdnav: vm.c:get_audio_stream audioN=%d\n",audioN); #endif if((vm->state).domain == VTSM_DOMAIN || (vm->state).domain == VMGM_DOMAIN @@ -861,11 +865,11 @@ static link_t play_PGC(vm_t *vm) link_t link_values; #ifdef TRACE - fprintf(stderr, "vm: play_PGC:"); + fprintf(MSG_OUT, "libdvdnav: vm: play_PGC:"); if((vm->state).domain != FP_DOMAIN) { - fprintf(stderr, " (vm->state).pgcN (%i)\n", get_PGCN(vm)); + fprintf(MSG_OUT, " (vm->state).pgcN (%i)\n", get_PGCN(vm)); } else { - fprintf(stderr, " first_play_pgc\n"); + fprintf(MSG_OUT, " first_play_pgc\n"); } #endif @@ -889,7 +893,7 @@ static link_t play_PGC(vm_t *vm) return link_values; } else { #ifdef TRACE - fprintf(stderr, "PGC pre commands didn't do a Jump, Link or Call\n"); + fprintf(MSG_OUT, "libdvdnav: PGC pre commands didn't do a Jump, Link or Call\n"); #endif } } @@ -901,11 +905,11 @@ static link_t play_PGC_PG(vm_t *vm, int pgN) link_t link_values; #ifdef TRACE - fprintf(stderr, "vm: play_PGC:"); + fprintf(MSG_OUT, "libdvdnav: vm: play_PGC:"); if((vm->state).domain != FP_DOMAIN) { - fprintf(stderr, " (vm->state).pgcN (%i)\n", get_PGCN(vm)); + fprintf(MSG_OUT, " (vm->state).pgcN (%i)\n", get_PGCN(vm)); } else { - fprintf(stderr, " first_play_pgc\n"); + fprintf(MSG_OUT, " first_play_pgc\n"); } #endif @@ -929,7 +933,7 @@ static link_t play_PGC_PG(vm_t *vm, int pgN) return link_values; } else { #ifdef TRACE - fprintf(stderr, "PGC pre commands didn't do a Jump, Link or Call\n"); + fprintf(MSG_OUT, "libdvdnav: PGC pre commands didn't do a Jump, Link or Call\n"); #endif } } @@ -939,13 +943,13 @@ static link_t play_PGC_PG(vm_t *vm, int pgN) static link_t play_PG(vm_t *vm) { #ifdef TRACE - fprintf(stderr, "play_PG: (vm->state).pgN (%i)\n", (vm->state).pgN); + fprintf(MSG_OUT, "libdvdnav: play_PG: (vm->state).pgN (%i)\n", (vm->state).pgN); #endif assert((vm->state).pgN > 0); if((vm->state).pgN > (vm->state).pgc->nr_of_programs) { #ifdef TRACE - fprintf(stderr, "(vm->state).pgN (%i) == pgc->nr_of_programs + 1 (%i)\n", + fprintf(MSG_OUT, "libdvdnav: (vm->state).pgN (%i) == pgc->nr_of_programs + 1 (%i)\n", (vm->state).pgN, (vm->state).pgc->nr_of_programs + 1); #endif /*assert((vm->state).pgN == (vm->state).pgc->nr_of_programs + 1);*/ @@ -961,13 +965,13 @@ static link_t play_PG(vm_t *vm) static link_t play_Cell(vm_t *vm) { #ifdef TRACE - fprintf(stderr, "play_Cell: (vm->state).cellN (%i)\n", (vm->state).cellN); + fprintf(MSG_OUT, "libdvdnav: play_Cell: (vm->state).cellN (%i)\n", (vm->state).cellN); #endif assert((vm->state).cellN > 0); if((vm->state).cellN > (vm->state).pgc->nr_of_cells) { #ifdef TRACE - fprintf(stderr, "(vm->state).cellN (%i) == pgc->nr_of_cells + 1 (%i)\n", + fprintf(MSG_OUT, "libdvdnav: (vm->state).cellN (%i) == pgc->nr_of_cells + 1 (%i)\n", (vm->state).cellN, (vm->state).pgc->nr_of_cells + 1); #endif assert((vm->state).cellN == (vm->state).pgc->nr_of_cells + 1); @@ -987,14 +991,22 @@ static link_t play_Cell(vm_t *vm) case 1: /* Angle block */ /* Loop and check each cell instead? So we don't get outsid the block. */ (vm->state).cellN += (vm->state).AGL_REG - 1; +#ifdef STRICT assert((vm->state).cellN <= (vm->state).pgc->nr_of_cells); assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode != 0); assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 1); +#endif + if (!((vm->state).cellN <= (vm->state).pgc->nr_of_cells) || + !((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode != 0) || + !((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 1)) { + fprintf(MSG_OUT, "libdvdnav: Invalid angle block\n"); + (vm->state).cellN -= (vm->state).AGL_REG - 1; + } break; case 2: /* ?? */ case 3: /* ?? */ default: - fprintf(stderr, "Invalid? Cell block_mode (%d), block_type (%d)\n", + fprintf(MSG_OUT, "libdvdnav: Invalid? Cell block_mode (%d), block_type (%d)\n", (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode, (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type); } @@ -1003,7 +1015,7 @@ static link_t play_Cell(vm_t *vm) case 3: /* Last cell in the block */ /* These might perhaps happen for RSM or LinkC commands? */ default: - fprintf(stderr, "Cell is in block but did not enter at first cell!\n"); + fprintf(MSG_OUT, "libdvdnav: Cell is in block but did not enter at first cell!\n"); } /* Updates (vm->state).pgN and PTTN_REG */ @@ -1014,7 +1026,7 @@ static link_t play_Cell(vm_t *vm) return tmp; } (vm->state).cell_restart++; - fprintf(stderr, "libdvdnav: Cell should restart here\n"); + fprintf(MSG_OUT, "libdvdnav: Cell should restart here\n"); { link_t tmp = {PlayThis, /* Block in Cell */ 0, 0, 0}; return tmp; @@ -1027,7 +1039,7 @@ static link_t play_Cell_post(vm_t *vm) cell_playback_t *cell; #ifdef TRACE - fprintf(stderr, "play_Cell_post: (vm->state).cellN (%i)\n", (vm->state).cellN); + fprintf(MSG_OUT, "libdvdnav: play_Cell_post: (vm->state).cellN (%i)\n", (vm->state).cellN); #endif cell = &(vm->state).pgc->cell_playback[(vm->state).cellN - 1]; @@ -1038,17 +1050,24 @@ static link_t play_Cell_post(vm_t *vm) if(cell->cell_cmd_nr != 0) { link_t link_values; +#ifdef STRICT assert((vm->state).pgc->command_tbl != NULL); assert((vm->state).pgc->command_tbl->nr_of_cell >= cell->cell_cmd_nr); +#endif + if ((vm->state).pgc->command_tbl != NULL && + (vm->state).pgc->command_tbl->nr_of_cell >= cell->cell_cmd_nr) { #ifdef TRACE - fprintf(stderr, "Cell command pressent, executing\n"); + fprintf(MSG_OUT, "libdvdnav: Cell command present, executing\n"); #endif - if(vmEval_CMD(&(vm->state).pgc->command_tbl->cell_cmds[cell->cell_cmd_nr - 1], 1, - &(vm->state).registers, &link_values)) { - return link_values; + if(vmEval_CMD(&(vm->state).pgc->command_tbl->cell_cmds[cell->cell_cmd_nr - 1], 1, + &(vm->state).registers, &link_values)) { + return link_values; + } else { + fprintf(MSG_OUT, "libdvdnav: Cell command didn't do a Jump, Link or Call\n"); + /* Error ?? goto tail? goto next PG? or what? just continue? */ + } } else { - fprintf(stderr, "Cell command didn't do a Jump, Link or Call\n"); - /* Error ?? goto tail? goto next PG? or what? just continue? */ + fprintf(MSG_OUT, "libdvdnav: Invalid Cell command\n"); } } @@ -1078,7 +1097,7 @@ static link_t play_Cell_post(vm_t *vm) case 2: /* ?? */ case 3: /* ?? */ default: - fprintf(stderr, "Invalid? Cell block_mode (%d), block_type (%d)\n", + fprintf(MSG_OUT, "libdvdnav: Invalid? Cell block_mode (%d), block_type (%d)\n", (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode, (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type); } @@ -1089,7 +1108,7 @@ static link_t play_Cell_post(vm_t *vm) /* Figure out the correct pgN for the new cell */ if(set_PGN(vm)) { #ifdef TRACE - fprintf(stderr, "last cell in this PGC\n"); + fprintf(MSG_OUT, "libdvdnav: last cell in this PGC\n"); #endif return play_PGC_post(vm); } @@ -1103,7 +1122,7 @@ static link_t play_PGC_post(vm_t *vm) link_t link_values; #ifdef TRACE - fprintf(stderr, "play_PGC_post:\n"); + fprintf(MSG_OUT, "libdvdnav: play_PGC_post:\n"); #endif assert((vm->state).pgc->still_time == 0); /* FIXME $$$ */ @@ -1122,7 +1141,7 @@ static link_t play_PGC_post(vm_t *vm) /* Or perhaps handle it here? */ { link_t link_next_pgc = {LinkNextPGC, 0, 0, 0}; - fprintf(stderr, "** Fell of the end of the pgc, continuing in NextPGC\n"); + fprintf(MSG_OUT, "libdvdnav: ** Fell of the end of the pgc, continuing in NextPGC\n"); assert((vm->state).pgc->next_pgc_nr != 0); /* Should end up in the STOP_DOMAIN if next_pgc is 0. */ return link_next_pgc; @@ -1134,16 +1153,16 @@ static link_t process_command(vm_t *vm, link_t link_values) { /* FIXME $$$ Move this to a separate function? */ vm->badness_counter++; - if (vm->badness_counter > 1) fprintf(stderr, "**** process_command re-entered %d*****\n",vm->badness_counter); + if (vm->badness_counter > 1) fprintf(MSG_OUT, "libdvdnav: **** process_command re-entered %d*****\n",vm->badness_counter); while(link_values.command != PlayThis) { #ifdef TRACE vmPrint_LINK(link_values); - fprintf(stderr, "Link values %i %i %i %i\n", link_values.command, + fprintf(MSG_OUT, "libdvdnav: Link values %i %i %i %i\n", link_values.command, link_values.data1, link_values.data2, link_values.data3); - fprintf(stderr, "Before:"); + fprintf(MSG_OUT, "libdvdnav: Before:"); vm_print_current_domain_state(vm); #endif @@ -1153,13 +1172,13 @@ static link_t process_command(vm_t *vm, link_t link_values) /* BUTTON number:data1 */ if(link_values.data1 != 0) (vm->state).HL_BTNN_REG = link_values.data1 << 10; - fprintf(stderr, "libdvdnav: FIXME: in trouble...LinkNoLink - CRASHING!!!\n"); + fprintf(MSG_OUT, "libdvdnav: FIXME: in trouble...LinkNoLink - CRASHING!!!\n"); assert(0); case LinkTopC: /* Restart playing from the beginning of the current Cell. */ /* BUTTON number:data1 */ - fprintf(stderr, "libdvdnav: FIXME: LinkTopC. Replay current Cell\n"); + fprintf(MSG_OUT, "libdvdnav: FIXME: LinkTopC. Replay current Cell\n"); if(link_values.data1 != 0) (vm->state).HL_BTNN_REG = link_values.data1 << 10; link_values = play_Cell(vm); @@ -1184,7 +1203,7 @@ static link_t process_command(vm_t *vm, link_t link_values) case LinkTopPG: /* Link to Top Program */ /* BUTTON number:data1 */ - fprintf(stderr, "libdvdnav: FIXME: LinkTopPG. This should start the current PG again.\n"); + fprintf(MSG_OUT, "libdvdnav: FIXME: LinkTopPG. This should start the current PG again.\n"); if(link_values.data1 != 0) (vm->state).HL_BTNN_REG = link_values.data1 << 10; /* Does pgN always contain the current value? */ @@ -1213,7 +1232,7 @@ static link_t process_command(vm_t *vm, link_t link_values) case LinkTopPGC: /* Restart playing from beginning of current Program Chain */ /* BUTTON number:data1 */ - fprintf(stderr, "libdvdnav: FIXME: LinkTopPGC. Restart from beginning of current Program Chain\n"); + fprintf(MSG_OUT, "libdvdnav: FIXME: LinkTopPGC. Restart from beginning of current Program Chain\n"); if(link_values.data1 != 0) (vm->state).HL_BTNN_REG = link_values.data1 << 10; link_values = play_PGC(vm); @@ -1251,7 +1270,7 @@ static link_t process_command(vm_t *vm, link_t link_values) case LinkTailPGC: /* Link to Tail??? Program Chain */ /* BUTTON number:data1 */ - /* fprintf(stderr, "libdvdnav: FIXME: LinkTailPGC. What is LinkTailPGC?\n"); */ + /* fprintf(MSG_OUT, "libdvdnav: FIXME: LinkTailPGC. What is LinkTailPGC?\n"); */ if(link_values.data1 != 0) (vm->state).HL_BTNN_REG = link_values.data1 << 10; link_values = play_PGC_post(vm); @@ -1333,7 +1352,7 @@ static link_t process_command(vm_t *vm, link_t link_values) break; case Exit: - fprintf(stderr, "libdvdnav: FIXME:in trouble...Link Exit - CRASHING!!!\n"); + fprintf(MSG_OUT, "libdvdnav: FIXME:in trouble...Link Exit - CRASHING!!!\n"); assert(0); /* What should we do here?? */ case JumpTT: @@ -1350,7 +1369,7 @@ static link_t process_command(vm_t *vm, link_t link_values) /* Only allowed from the VTS Menu Domain(VTSM) */ /* or the Video Title Set Domain(VTS) */ assert((vm->state).domain == VTSM_DOMAIN || (vm->state).domain == VTS_DOMAIN); /* ?? */ - fprintf(stderr, "libdvdnav: FIXME: Should be able to use get_VTS_PTT here.\n"); + fprintf(MSG_OUT, "libdvdnav: FIXME: Should be able to use get_VTS_PTT here.\n"); if(set_VTS_TT(vm,(vm->state).vtsN, link_values.data1) == -1) assert(0); link_values = play_PGC(vm); @@ -1393,12 +1412,12 @@ static link_t process_command(vm_t *vm, link_t link_values) /* VTS_TTN_REG:data2 */ /* get_MENU:data3 */ #ifdef TRACE - fprintf(stderr, "dvdnav: BUG TRACKING *******************************************************************\n"); - fprintf(stderr, " data1=%u data2=%u data3=%u\n", + fprintf(MSG_OUT, "libdvdnav: BUG TRACKING *******************************************************************\n"); + fprintf(MSG_OUT, "libdvdnav: data1=%u data2=%u data3=%u\n", link_values.data1, link_values.data2, link_values.data3); - fprintf(stderr, "dvdnav: *******************************************************************\n"); + fprintf(MSG_OUT, "libdvdnav: *******************************************************************\n"); #endif if(link_values.data1 !=0) { @@ -1476,7 +1495,7 @@ static link_t process_command(vm_t *vm, link_t link_values) } #ifdef TRACE - fprintf(stderr, "After:"); + fprintf(MSG_OUT, "libdvdnav: After:"); vm_print_current_domain_state(vm); #endif @@ -1515,7 +1534,7 @@ static int set_TT(vm_t *vm, int tt) static int set_VTS_TT(vm_t *vm, int vtsN, int vts_ttn) { - fprintf(stderr, "get_VTS_TT called, testing!!! vtsN=%d, vts_ttn=%d\n", vtsN, vts_ttn); + fprintf(MSG_OUT, "libdvdnav: get_VTS_TT called, testing!!! vtsN=%d, vts_ttn=%d\n", vtsN, vts_ttn); return set_VTS_PTT(vm, vtsN, vts_ttn, 1); /* pgcN = get_ID(vm, vts_ttn); This might return -1 */ /* @@ -1588,7 +1607,7 @@ static int get_ID(vm_t *vm, int id) /* Relies on state to get the correct pgcit. */ pgcit = get_PGCIT(vm); assert(pgcit != NULL); - fprintf(stderr, "** Searching for menu (0x%x) entry PGC\n", id); + fprintf(MSG_OUT, "libdvdnav: ** Searching for menu (0x%x) entry PGC\n", id); /* Get menu/title */ for(i = 0; i < pgcit->nr_of_pgci_srp; i++) { @@ -1598,9 +1617,9 @@ static int get_ID(vm_t *vm, int id) return pgcN; } } - fprintf(stderr, "** No such id/menu (%d) entry PGC\n", id); + fprintf(MSG_OUT, "libdvdnav: ** No such id/menu (%d) entry PGC\n", id); for(i = 0; i < pgcit->nr_of_pgci_srp; i++) { - fprintf(stderr, "Available menus: 0x%x\n", + fprintf(MSG_OUT, "libdvdnav: Available menus: 0x%x\n", pgcit->pgci_srp[i].entry_id); } assert(0); /* Use assert for now, until the error is handled. */ @@ -1619,7 +1638,7 @@ static int set_PGC(vm_t *vm, int pgcN) assert(pgcit != NULL); /* ?? Make this return -1 instead */ if(pgcN < 1 || pgcN > pgcit->nr_of_pgci_srp) { - fprintf(stderr, "** No such pgcN = %d\n", pgcN); + fprintf(MSG_OUT, "libdvdnav: ** No such pgcN = %d\n", pgcN); assert(0); return -1; /* error */ } @@ -1648,7 +1667,7 @@ static int get_PGCN(vm_t *vm) return pgcN; pgcN++; } - fprintf(stderr, "libdvdnav: get_PGCN failed. Trying to find pgcN in domain %d \n", + fprintf(MSG_OUT, "libdvdnav: get_PGCN failed. Trying to find pgcN in domain %d \n", (vm->state).domain); assert(0); return -1; /* error */ @@ -1669,13 +1688,13 @@ int vm_get_video_aspect(vm_t *vm) aspect = vm->vmgi->vmgi_mat->vmgm_video_attr.display_aspect_ratio; break; default: - fprintf(stderr, "libdvdnav: vm_get_video_aspect failed. Unknown domain %d\n", + fprintf(MSG_OUT, "libdvdnav: vm_get_video_aspect failed. Unknown domain %d\n", (vm->state).domain); assert(0); break; } #ifdef TRACE - fprintf(stderr, "dvdnav:get_video_aspect:aspect=%d\n",aspect); + fprintf(MSG_OUT, "libdvdnav: get_video_aspect:aspect=%d\n",aspect); #endif assert(aspect == 0 || aspect == 3); (vm->state).registers.SPRM[14] &= ~(0x3 << 10); @@ -1696,7 +1715,7 @@ int vm_get_video_scale_permission(vm_t *vm) permission = vm->vmgi->vmgi_mat->vmgm_video_attr.permitted_df; } #ifdef TRACE - fprintf(stderr, "dvdnav:get_video_scale_permission:permission=%d\n",permission); + fprintf(MSG_OUT, "libdvdnav: get_video_scale_permission:permission=%d\n",permission); #endif return permission; @@ -1713,27 +1732,27 @@ static void ifoOpenNewVTSI(vm_t *vm, dvd_reader_t *dvd, int vtsN) vm->vtsi = ifoOpenVTSI(dvd, vtsN); if(vm->vtsi == NULL) { - fprintf(stderr, "ifoOpenVTSI failed - CRASHING!!!\n"); + fprintf(MSG_OUT, "libdvdnav: ifoOpenVTSI failed - CRASHING!!!\n"); assert(0); } if(!ifoRead_VTS_PTT_SRPT(vm->vtsi)) { - fprintf(stderr, "ifoRead_VTS_PTT_SRPT failed - CRASHING!!!\n"); + fprintf(MSG_OUT, "libdvdnav: ifoRead_VTS_PTT_SRPT failed - CRASHING!!!\n"); assert(0); } if(!ifoRead_PGCIT(vm->vtsi)) { - fprintf(stderr, "ifoRead_PGCIT failed - CRASHING!!!\n"); + fprintf(MSG_OUT, "libdvdnav: ifoRead_PGCIT failed - CRASHING!!!\n"); assert(0); } if(!ifoRead_PGCI_UT(vm->vtsi)) { - fprintf(stderr, "ifoRead_PGCI_UT failed - CRASHING!!!\n"); + fprintf(MSG_OUT, "libdvdnav: ifoRead_PGCI_UT failed - CRASHING!!!\n"); assert(0); } if(!ifoRead_VOBU_ADMAP(vm->vtsi)) { - fprintf(stderr, "ifoRead_VOBU_ADMAP vtsi failed - CRASHING\n"); + fprintf(MSG_OUT, "libdvdnav: ifoRead_VOBU_ADMAP vtsi failed - CRASHING\n"); assert(0); } if(!ifoRead_TITLE_VOBU_ADMAP(vm->vtsi)) { - fprintf(stderr, "ifoRead_TITLE_VOBU_ADMAP vtsi failed - CRASHING\n"); + fprintf(MSG_OUT, "libdvdnav: ifoRead_TITLE_VOBU_ADMAP vtsi failed - CRASHING\n"); assert(0); } (vm->state).vtsN = vtsN; @@ -1744,7 +1763,7 @@ static pgcit_t* get_MENU_PGCIT(vm_t *vm, ifo_handle_t *h, uint16_t lang) int i; if(h == NULL || h->pgci_ut == NULL) { - fprintf(stderr, "*** pgci_ut handle is NULL ***\n"); + fprintf(MSG_OUT, "libdvdnav: *** pgci_ut handle is NULL ***\n"); return NULL; /* error? */ } @@ -1753,17 +1772,17 @@ static pgcit_t* get_MENU_PGCIT(vm_t *vm, ifo_handle_t *h, uint16_t lang) && h->pgci_ut->lu[i].lang_code != lang) i++; if(i == h->pgci_ut->nr_of_lus) { - fprintf(stderr, "Language '%c%c' not found, using '%c%c' instead\n", + fprintf(MSG_OUT, "libdvdnav: Language '%c%c' not found, using '%c%c' instead\n", (char)(lang >> 8), (char)(lang & 0xff), (char)(h->pgci_ut->lu[0].lang_code >> 8), (char)(h->pgci_ut->lu[0].lang_code & 0xff)); - fprintf(stderr, "Menu Languages available: "); + fprintf(MSG_OUT, "libdvdnav: Menu Languages available: "); for(i=0;i< h->pgci_ut->nr_of_lus;i++) { - fprintf(stderr, "%c%c ", + fprintf(MSG_OUT, "%c%c ", (char)(h->pgci_ut->lu[0].lang_code >> 8), (char)(h->pgci_ut->lu[0].lang_code & 0xff)); } - fprintf(stderr, "\n"); + fprintf(MSG_OUT, "\n"); i = 0; /* error? */ } @@ -1787,7 +1806,7 @@ static pgcit_t* get_PGCIT(vm_t *vm) { break; default: pgcit = NULL; /* Should never hapen */ - fprintf(stderr, "libdvdnav: get_PGCIT: Unknown domain:%d\n", + fprintf(MSG_OUT, "libdvdnav: get_PGCIT: Unknown domain:%d\n", (vm->state).domain); assert(0); break; @@ -1798,6 +1817,10 @@ static pgcit_t* get_PGCIT(vm_t *vm) { /* * $Log: vm.c,v $ + * Revision 1.4 2002/08/27 19:24:33 mroi + * sync to libdvdnav cvs, this should now conform to the way xine outputs + * its console messages (write to stdout, "libdvdnav: " in front each line) + * * Revision 1.3 2002/08/09 22:52:14 mroi * change includes from system include to local include where the file is in * our tree now to avoid version clashes diff --git a/src/input/libdvdnav/vmcmd.c b/src/input/libdvdnav/vmcmd.c index 4ae8f92ba..28b2c5ab3 100644 --- a/src/input/libdvdnav/vmcmd.c +++ b/src/input/libdvdnav/vmcmd.c @@ -18,7 +18,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: vmcmd.c,v 1.1 2002/08/08 17:49:21 richwareham Exp $ + * $Id: vmcmd.c,v 1.2 2002/08/27 19:24:33 mroi Exp $ * */ @@ -32,6 +32,7 @@ #include #include "vmcmd.h" +#include "dvdnav_internal.h" /* freebsd compatibility */ @@ -115,9 +116,9 @@ static const char *system_reg_abbr_table[] = { static void print_system_reg(uint16_t reg) { if(reg < sizeof(system_reg_abbr_table) / sizeof(char *)) - fprintf(stderr, "%s (SRPM:%d)", system_reg_table[reg], reg); + fprintf(MSG_OUT, " %s (SRPM:%d)", system_reg_table[reg], reg); else - fprintf(stderr, " WARNING: Unknown system register ( reg=%d ) ", reg); + fprintf(MSG_OUT, " WARNING: Unknown system register ( reg=%d ) ", reg); } static void print_reg(uint8_t reg) { @@ -125,32 +126,32 @@ static void print_reg(uint8_t reg) { print_system_reg(reg & 0x7f); else if(reg < 16) - fprintf(stderr, "g[%" PRIu8 "]", reg); + fprintf(MSG_OUT, " g[%" PRIu8 "]", reg); else - fprintf(stderr, " WARNING: Unknown general register "); + fprintf(MSG_OUT, " WARNING: Unknown general register "); } static void print_cmp_op(uint8_t op) { if(op < sizeof(cmp_op_table) / sizeof(char *) && cmp_op_table[op] != NULL) - fprintf(stderr, " %s ", cmp_op_table[op]); + fprintf(MSG_OUT, " %s ", cmp_op_table[op]); else - fprintf(stderr, " WARNING: Unknown compare op "); + fprintf(MSG_OUT, " WARNING: Unknown compare op "); } static void print_set_op(uint8_t op) { if(op < sizeof(set_op_table) / sizeof(char *) && set_op_table[op] != NULL) - fprintf(stderr, " %s ", set_op_table[op]); + fprintf(MSG_OUT, " %s ", set_op_table[op]); else - fprintf(stderr, " WARNING: Unknown set op "); + fprintf(MSG_OUT, " WARNING: Unknown set op "); } static void print_reg_or_data(command_t* command, int immediate, int byte) { if(immediate) { int i = vm_getbits(command, (byte*8), 16); - fprintf(stderr, "0x%x", i); + fprintf(MSG_OUT, "0x%x", i); if(isprint(i & 0xff) && isprint((i>>8) & 0xff)) - fprintf(stderr, " (\"%c%c\")", (char)((i>>8) & 0xff), (char)(i & 0xff)); + fprintf(MSG_OUT, " (\"%c%c\")", (char)((i>>8) & 0xff), (char)(i & 0xff)); } else { print_reg(vm_getbits(command, ((byte + 1)*8), 8)); } @@ -158,20 +159,20 @@ static void print_reg_or_data(command_t* command, int immediate, int byte) { static void print_reg_or_data_2(command_t* command, int immediate, int byte) { if(immediate) - fprintf(stderr, "0x%x", vm_getbits(command, ((byte*8)+1), 7)); + fprintf(MSG_OUT, "0x%x", vm_getbits(command, ((byte*8)+1), 7)); else - fprintf(stderr, "g[%" PRIu8 "]", vm_getbits(command, ((byte*8)+4), 4)); + fprintf(MSG_OUT, "g[%" PRIu8 "]", vm_getbits(command, ((byte*8)+4), 4)); } static void print_if_version_1(command_t* command) { uint8_t op = vm_getbits(command, 9, 3); if(op) { - fprintf(stderr, "if ("); + fprintf(MSG_OUT, "if ("); print_reg(vm_getbits(command,24,8)); print_cmp_op(op); print_reg_or_data(command, vm_getbits(command, 8,1), 4); - fprintf(stderr, ") "); + fprintf(MSG_OUT, ") "); } } @@ -179,11 +180,11 @@ static void print_if_version_2(command_t* command) { uint8_t op = vm_getbits(command, 9, 3); if(op) { - fprintf(stderr, "if ("); + fprintf(MSG_OUT, "if ("); print_reg(vm_getbits(command, 48, 8)); print_cmp_op(op); print_reg(vm_getbits(command, 56, 8)); - fprintf(stderr, ") "); + fprintf(MSG_OUT, ") "); } } @@ -191,11 +192,11 @@ static void print_if_version_3(command_t* command) { uint8_t op = vm_getbits(command, 9, 3); if(op) { - fprintf(stderr, "if ("); + fprintf(MSG_OUT, "if ("); print_reg(vm_getbits(command, 20, 4)); print_cmp_op(op); print_reg_or_data(command, vm_getbits(command, 8, 1), 6); - fprintf(stderr, ") "); + fprintf(MSG_OUT, ") "); } } @@ -203,11 +204,11 @@ static void print_if_version_4(command_t* command) { uint8_t op = vm_getbits(command, 9, 3); if(op) { - fprintf(stderr, "if ("); + fprintf(MSG_OUT, "if ("); print_reg(vm_getbits(command, 12, 4)); print_cmp_op(op); print_reg_or_data(command, vm_getbits(command, 8, 1), 4); - fprintf(stderr, ") "); + fprintf(MSG_OUT, ") "); } } @@ -216,20 +217,20 @@ static void print_special_instruction(command_t* command) { switch(op) { case 0: /* NOP */ - fprintf(stderr, "Nop"); + fprintf(MSG_OUT, "Nop"); break; case 1: /* Goto line */ - fprintf(stderr, "Goto %" PRIu8, vm_getbits(command, 56, 8)); + fprintf(MSG_OUT, "Goto %" PRIu8, vm_getbits(command, 56, 8)); break; case 2: /* Break */ - fprintf(stderr, "Break"); + fprintf(MSG_OUT, "Break"); break; case 3: /* Parental level */ - fprintf(stderr, "SetTmpPML %" PRIu8 ", Goto %" PRIu8, + fprintf(MSG_OUT, "SetTmpPML %" PRIu8 ", Goto %" PRIu8, vm_getbits(command, 52, 4), vm_getbits(command, 56, 8)); break; default: - fprintf(stderr, "WARNING: Unknown special instruction (%i)", + fprintf(MSG_OUT, "WARNING: Unknown special instruction (%i)", vm_getbits(command, 12, 4)); } } @@ -239,99 +240,99 @@ static void print_linksub_instruction(command_t* command) { int button = vm_getbits(command, 48, 6); if(linkop < sizeof(link_table)/sizeof(char *) && link_table[linkop] != NULL) - fprintf(stderr, "%s (button %" PRIu8 ")", link_table[linkop], button); + fprintf(MSG_OUT, "%s (button %" PRIu8 ")", link_table[linkop], button); else - fprintf(stderr, "WARNING: Unknown linksub instruction (%i)", linkop); + fprintf(MSG_OUT, "WARNING: Unknown linksub instruction (%i)", linkop); } static void print_link_instruction(command_t* command, int optional) { uint8_t op = vm_getbits(command, 12, 4); if(optional && op) - fprintf(stderr, ", "); + fprintf(MSG_OUT, ", "); switch(op) { case 0: if(!optional) - fprintf(stderr, "WARNING: NOP (link)!"); + fprintf(MSG_OUT, "WARNING: NOP (link)!"); break; case 1: print_linksub_instruction(command); break; case 4: - fprintf(stderr, "LinkPGCN %" PRIu16, vm_getbits(command, 49, 15)); + fprintf(MSG_OUT, "LinkPGCN %" PRIu16, vm_getbits(command, 49, 15)); break; case 5: - fprintf(stderr, "LinkPTT %" PRIu16 " (button %" PRIu8 ")", + fprintf(MSG_OUT, "LinkPTT %" PRIu16 " (button %" PRIu8 ")", vm_getbits(command, 54, 10), vm_getbits(command, 48, 6)); break; case 6: - fprintf(stderr, "LinkPGN %" PRIu8 " (button %" PRIu8 ")", + fprintf(MSG_OUT, "LinkPGN %" PRIu8 " (button %" PRIu8 ")", vm_getbits(command, 57, 7), vm_getbits(command, 48, 6)); break; case 7: - fprintf(stderr, "LinkCN %" PRIu8 " (button %" PRIu8 ")", + fprintf(MSG_OUT, "LinkCN %" PRIu8 " (button %" PRIu8 ")", vm_getbits(command, 56, 8), vm_getbits(command, 48, 6)); break; default: - fprintf(stderr, "WARNING: Unknown link instruction"); + fprintf(MSG_OUT, "WARNING: Unknown link instruction"); } } static void print_jump_instruction(command_t* command) { switch(vm_getbits(command, 12, 4)) { case 1: - fprintf(stderr, "Exit"); + fprintf(MSG_OUT, "Exit"); break; case 2: - fprintf(stderr, "JumpTT %" PRIu8, vm_getbits(command, 41, 7)); + fprintf(MSG_OUT, "JumpTT %" PRIu8, vm_getbits(command, 41, 7)); break; case 3: - fprintf(stderr, "JumpVTS_TT %" PRIu8, vm_getbits(command, 41, 7)); + fprintf(MSG_OUT, "JumpVTS_TT %" PRIu8, vm_getbits(command, 41, 7)); break; case 5: - fprintf(stderr, "JumpVTS_PTT %" PRIu8 ":%" PRIu16, + fprintf(MSG_OUT, "JumpVTS_PTT %" PRIu8 ":%" PRIu16, vm_getbits(command, 41, 7), vm_getbits(command, 22, 10)); break; case 6: switch(vm_getbits(command, 40, 2)) { case 0: - fprintf(stderr, "JumpSS FP"); + fprintf(MSG_OUT, "JumpSS FP"); break; case 1: - fprintf(stderr, "JumpSS VMGM (menu %" PRIu8 ")", vm_getbits(command, 44, 4)); + fprintf(MSG_OUT, "JumpSS VMGM (menu %" PRIu8 ")", vm_getbits(command, 44, 4)); break; case 2: - fprintf(stderr, "JumpSS VTSM (vts %" PRIu8 ", title %" PRIu8 + fprintf(MSG_OUT, "JumpSS VTSM (vts %" PRIu8 ", title %" PRIu8 ", menu %" PRIu8 ")", vm_getbits(command, 32, 8), vm_getbits(command, 24, 8), vm_getbits(command, 44, 4)); break; case 3: - fprintf(stderr, "JumpSS VMGM (pgc %" PRIu8 ")", vm_getbits(command, 17, 15)); + fprintf(MSG_OUT, "JumpSS VMGM (pgc %" PRIu8 ")", vm_getbits(command, 17, 15)); break; } break; case 8: switch(vm_getbits(command, 40, 2)) { case 0: - fprintf(stderr, "CallSS FP (rsm_cell %" PRIu8 ")", + fprintf(MSG_OUT, "CallSS FP (rsm_cell %" PRIu8 ")", vm_getbits(command, 32, 8)); break; case 1: - fprintf(stderr, "CallSS VMGM (menu %" PRIu8 + fprintf(MSG_OUT, "CallSS VMGM (menu %" PRIu8 ", rsm_cell %" PRIu8 ")", vm_getbits(command, 44, 4), vm_getbits(command, 32, 8)); break; case 2: - fprintf(stderr, "CallSS VTSM (menu %" PRIu8 + fprintf(MSG_OUT, "CallSS VTSM (menu %" PRIu8 ", rsm_cell %" PRIu8 ")", vm_getbits(command, 44, 4), vm_getbits(command, 32, 8)); break; case 3: - fprintf(stderr, "CallSS VMGM (pgc %" PRIu8 ", rsm_cell %" PRIu8 ")", + fprintf(MSG_OUT, "CallSS VMGM (pgc %" PRIu8 ", rsm_cell %" PRIu8 ")", vm_getbits(command, 17, 15), vm_getbits(command, 32, 8)); break; } break; default: - fprintf(stderr, "WARNING: Unknown Jump/Call instruction"); + fprintf(MSG_OUT, "WARNING: Unknown Jump/Call instruction"); } } @@ -343,26 +344,26 @@ static void print_system_set(command_t* command) { for(i = 1; i <= 3; i++) { if(vm_getbits(command, ((2+i)*8), 1)) { print_system_reg(i); - fprintf(stderr, " = "); + fprintf(MSG_OUT, " = "); print_reg_or_data_2(command, vm_getbits(command, 3, 1), 2 + i); - fprintf(stderr, " "); + fprintf(MSG_OUT, " "); } } break; case 2: /* Set system reg 9 & 10 (Navigation timer, Title PGC number) */ print_system_reg(9); - fprintf(stderr, " = "); + fprintf(MSG_OUT, " = "); print_reg_or_data(command, vm_getbits(command, 3, 1), 2); - fprintf(stderr, " "); + fprintf(MSG_OUT, " "); print_system_reg(10); - fprintf(stderr, " = %" PRIu8, vm_getbits(command, 40, 8)); /* ?? */ + fprintf(MSG_OUT, " = %" PRIu8, vm_getbits(command, 40, 8)); /* ?? */ break; case 3: /* Mode: Counter / Register + Set */ - fprintf(stderr, "SetMode "); + fprintf(MSG_OUT, "SetMode "); if(vm_getbits(command, 40, 1)) - fprintf(stderr, "Counter "); + fprintf(MSG_OUT, "Counter "); else - fprintf(stderr, "Register "); + fprintf(MSG_OUT, "Register "); print_reg(vm_getbits(command, 44, 4)); print_set_op(0x1); /* '=' */ print_reg_or_data(command, vm_getbits(command, 3, 1), 2); @@ -370,12 +371,12 @@ static void print_system_set(command_t* command) { case 6: /* Set system reg 8 (Highlighted button) */ print_system_reg(8); if(vm_getbits(command, 3, 1)) /* immediate */ - fprintf(stderr, " = 0x%x (button no %d)", vm_getbits(command, 32, 16), vm_getbits(command, 32, 6)); + fprintf(MSG_OUT, " = 0x%x (button no %d)", vm_getbits(command, 32, 16), vm_getbits(command, 32, 6)); else - fprintf(stderr, " = g[%" PRIu8 "]", vm_getbits(command, 44, 4)); + fprintf(MSG_OUT, " = g[%" PRIu8 "]", vm_getbits(command, 44, 4)); break; default: - fprintf(stderr, "WARNING: Unknown system set instruction (%i)", + fprintf(MSG_OUT, "WARNING: Unknown system set instruction (%i)", vm_getbits(command, 4, 4)); } } @@ -388,7 +389,7 @@ static void print_set_version_1(command_t* command) { print_set_op(set_op); print_reg_or_data(command, vm_getbits(command, 3, 1), 4); } else { - fprintf(stderr, "NOP"); + fprintf(MSG_OUT, "NOP"); } } @@ -400,7 +401,7 @@ static void print_set_version_2(command_t* command) { print_set_op(set_op); print_reg_or_data(command, vm_getbits(command, 3, 1), 2); } else { - fprintf(stderr, "NOP"); + fprintf(MSG_OUT, "NOP"); } } @@ -442,47 +443,47 @@ void vmPrint_mnemonic(vm_cmd_t *vm_command) { break; case 4: /* Set, Compare -> LinkSub instructions */ print_set_version_2(&command); - fprintf(stderr, ", "); + fprintf(MSG_OUT, ", "); print_if_version_4(&command); print_linksub_instruction(&command); break; case 5: /* Compare -> (Set and LinkSub) instructions */ print_if_version_4(&command); - fprintf(stderr, "{ "); + fprintf(MSG_OUT, "{ "); print_set_version_2(&command); - fprintf(stderr, ", "); + fprintf(MSG_OUT, ", "); print_linksub_instruction(&command); - fprintf(stderr, " }"); + fprintf(MSG_OUT, " }"); break; case 6: /* Compare -> Set, always LinkSub instructions */ print_if_version_4(&command); - fprintf(stderr, "{ "); + fprintf(MSG_OUT, "{ "); print_set_version_2(&command); - fprintf(stderr, " } "); + fprintf(MSG_OUT, " } "); print_linksub_instruction(&command); break; default: - fprintf(stderr, "WARNING: Unknown instruction type (%i)", vm_getbits(&command, 0, 3)); + fprintf(MSG_OUT, "WARNING: Unknown instruction type (%i)", vm_getbits(&command, 0, 3)); } /* Check if there still are bits set that were not examined */ if(command.instruction & ~ command.examined) { - fprintf(stderr, " libdvdnav: vmcmd.c: [WARNING, unknown bits:"); - fprintf(stderr, " %08llx", (command.instruction & ~ command.examined) ); - fprintf(stderr, "]"); + fprintf(MSG_OUT, " libdvdnav: vmcmd.c: [WARNING, unknown bits:"); + fprintf(MSG_OUT, " %08llx", (command.instruction & ~ command.examined) ); + fprintf(MSG_OUT, "]"); } } void vmPrint_CMD(int row, vm_cmd_t *vm_command) { int i; - fprintf(stderr, "(%03d) ", row + 1); + fprintf(MSG_OUT, "(%03d) ", row + 1); for(i = 0; i < 8; i++) - fprintf(stderr, "%02x ", vm_command->bytes[i]); - fprintf(stderr, "| "); + fprintf(MSG_OUT, "%02x ", vm_command->bytes[i]); + fprintf(MSG_OUT, "| "); vmPrint_mnemonic(vm_command); - fprintf(stderr, "\n"); + fprintf(MSG_OUT, "\n"); } -- cgit v1.2.3