comparison dvdnav.c @ 4:99bed5d6db2f src

Added reset patch from Kees Cook <kees@outflux.net>
author richwareham
date Tue, 02 Apr 2002 18:22:27 +0000
parents 328eadb3f37e
children 5f319e02e333
comparison
equal deleted inserted replaced
3:328eadb3f37e 4:99bed5d6db2f
33 #include <dvdread/nav_read.h> 33 #include <dvdread/nav_read.h>
34 34
35 #include <stdlib.h> 35 #include <stdlib.h>
36 #include <stdio.h> 36 #include <stdio.h>
37 37
38 dvdnav_status_t dvdnav_clear(dvdnav_t * self) {
39 if (!self) {
40 printerr("Passed a NULL pointer");
41 return S_ERR;
42 }
43 /* clear everything except path, file, vm, mutex, readahead */
44
45 // path
46 if (self->file) DVDCloseFile(self->file);
47 self->file = NULL;
48 self->open_vtsN = -1;
49 self->open_domain = -1;
50 self->vobu_start=0;
51 self->vobu_length=0;
52 self->blockN=0;
53 self->next_vobu=0;
54 self->cell = NULL;
55 self->jmp_blockN=0;
56 self->jmp_vobu_start=0;
57 self->seekto_block=0;
58
59 memset(&self->pci,0,sizeof(self->pci));
60 memset(&self->dsi,0,sizeof(self->dsi));
61
62 /* Set initial values of flags */
63 self->expecting_nav_packet = 1;
64 self->at_soc = 1;
65 self->still_frame = -1;
66 self->jumping = 0;
67 self->seeking = 0;
68 self->stop = 0;
69 self->highlight_changed = 0;
70 self->spu_clut_changed = 0;
71 self->spu_stream_changed = 0;
72 self->audio_stream_changed = 0;
73 self->started=0;
74 // self->use_read_ahead
75
76 self->hli_state=0;
77
78 self->cache_start_sector = -1;
79 self->cache_block_count = 0;
80 self->cache_valid = 0;
81
82 return S_OK;
83 }
84
38 dvdnav_status_t dvdnav_open(dvdnav_t** dest, char *path) { 85 dvdnav_status_t dvdnav_open(dvdnav_t** dest, char *path) {
39 dvdnav_t *self; 86 dvdnav_t *self;
40 87
41 /* Create a new structure */ 88 /* Create a new structure */
42 (*dest) = NULL; 89 (*dest) = NULL;
61 } 108 }
62 109
63 /* Set the path. FIXME: Is a deep copy 'right' */ 110 /* Set the path. FIXME: Is a deep copy 'right' */
64 strncpy(self->path, path, MAX_PATH_LEN); 111 strncpy(self->path, path, MAX_PATH_LEN);
65 112
66 /* Set initial values of flags */ 113 dvdnav_clear(self);
67 self->expecting_nav_packet = 1;
68 self->started = 0;
69
70 self->open_vtsN = -1;
71 self->open_domain = -1;
72 self->file = NULL;
73 self->cell = NULL;
74 self->at_soc = 1;
75 self->jumping = 0;
76 self->seeking = 0;
77 self->still_frame = -1;
78 self->cache_buffer = NULL;
79 self->cache_start_sector = -1;
80 self->cache_block_count = 0;
81 self->cache_valid = 0;
82 self->use_read_ahead = 1;
83 self->stop = 0;
84 self->highlight_changed = 0;
85 self->spu_clut_changed = 0;
86
87 self->vobu_start = self->vobu_length = 0;
88 114
89 /* Pre-open and close a file so that the CSS-keys are cached. */ 115 /* Pre-open and close a file so that the CSS-keys are cached. */
90 self->file = DVDOpenFile(vm_get_dvd_reader(self->vm), 0, DVD_READ_MENU_VOBS); 116 self->file = DVDOpenFile(vm_get_dvd_reader(self->vm), 0, DVD_READ_MENU_VOBS);
91 if (self->file) DVDCloseFile(self->file); 117 if (self->file) DVDCloseFile(self->file);
92 self->file = NULL; 118 self->file = NULL;
125 pthread_mutex_destroy(&self->vm_lock); 151 pthread_mutex_destroy(&self->vm_lock);
126 /* Finally free the entire structure */ 152 /* Finally free the entire structure */
127 free(self); 153 free(self);
128 154
129 return S_OK; 155 return S_OK;
156 }
157
158 dvdnav_status_t dvdnav_reset(dvdnav_t *self) {
159 dvdnav_status_t result;
160
161 printf("dvdnav:reset:called\n");
162 if(!self) {
163 printerr("Passed a NULL pointer");
164 return S_ERR;
165 }
166 printf("getting lock\n");
167 pthread_mutex_lock(&self->vm_lock);
168 printf("reseting vm\n");
169 if(vm_reset(self->vm, NULL) == -1) {
170 printerr("Error restarting the VM");
171 pthread_mutex_unlock(&self->vm_lock);
172 return S_ERR;
173 }
174 printf("clearing dvdnav\n");
175 result=dvdnav_clear(self);
176 printf("starting vm\n");
177 if(!self->started) {
178 /* Start the VM */
179 vm_start(self->vm);
180 self->started = 1;
181 }
182 printf("unlocking\n");
183 pthread_mutex_unlock(&self->vm_lock);
184 return result;
130 } 185 }
131 186
132 dvdnav_status_t dvdnav_path(dvdnav_t *self, char** path) { 187 dvdnav_status_t dvdnav_path(dvdnav_t *self, char** path) {
133 if(!self || !path || !(*path)) { 188 if(!self || !path || !(*path)) {
134 return S_ERR; 189 return S_ERR;
929 } 984 }
930 985
931 986
932 /* 987 /*
933 * $Log$ 988 * $Log$
989 * Revision 1.3 2002/04/02 18:22:27 richwareham
990 * Added reset patch from Kees Cook <kees@outflux.net>
991 *
934 * Revision 1.2 2002/04/01 18:56:28 richwareham 992 * Revision 1.2 2002/04/01 18:56:28 richwareham
935 * Added initial example programs directory and make sure all debug/error output goes to stderr. 993 * Added initial example programs directory and make sure all debug/error output goes to stderr.
936 * 994 *
937 * Revision 1.1.1.1 2002/03/12 19:45:57 richwareham 995 * Revision 1.1.1.1 2002/03/12 19:45:57 richwareham
938 * Initial import 996 * Initial import