| 1138 | } |
| 1139 | |
| 1140 | static int try_menu( |
| 1141 | hb_dvdnav_t * d, |
| 1142 | hb_list_t * list_title, |
| 1143 | DVDMenuID_t menu, |
| 1144 | uint64_t fallback_duration ) |
| 1145 | { |
| 1146 | int result, event, len; |
| 1147 | uint8_t buf[HB_DVD_READ_BUFFER_SIZE]; |
| 1148 | int ii, jj; |
| 1149 | int32_t cur_title, title, part; |
| 1150 | uint64_t longest_duration = 0; |
| 1151 | int longest = -1; |
| 1152 | |
| 1153 | // A bit of a hack here. Abusing Escape menu to mean use whatever |
| 1154 | // current menu is already set. |
| 1155 | if ( menu != DVD_MENU_Escape ) |
| 1156 | { |
| 1157 | result = dvdnav_menu_call( d->dvdnav, menu ); |
| 1158 | if ( result != DVDNAV_STATUS_OK ) |
| 1159 | { |
| 1160 | // Sometimes the "first play" item doesn't initialize the |
| 1161 | // initial VTS. So do it here. |
| 1162 | dvdnav_title_play( d->dvdnav, 1 ); |
| 1163 | result = dvdnav_menu_call( d->dvdnav, menu ); |
| 1164 | if ( result != DVDNAV_STATUS_OK ) |
| 1165 | { |
| 1166 | hb_error("dvdnav: Can not set dvd menu, %s", dvdnav_err_to_string(d->dvdnav)); |
| 1167 | goto done; |
| 1168 | } |
| 1169 | } |
| 1170 | } |
| 1171 | |
| 1172 | result = dvdnav_current_title_info( d->dvdnav, &title, &part ); |
| 1173 | if (result != DVDNAV_STATUS_OK) |
| 1174 | hb_log("dvdnav title info: %s", dvdnav_err_to_string(d->dvdnav)); |
| 1175 | |
| 1176 | cur_title = title; |
| 1177 | |
| 1178 | for (jj = 0; jj < 4; jj++) |
| 1179 | { |
| 1180 | for (ii = 0; ii < 4000; ii++) |
| 1181 | { |
| 1182 | result = dvdnav_get_next_block( d->dvdnav, buf, &event, &len ); |
| 1183 | if ( result == DVDNAV_STATUS_ERR ) |
| 1184 | { |
| 1185 | hb_error("dvdnav: Read Error, %s", dvdnav_err_to_string(d->dvdnav)); |
| 1186 | goto done; |
| 1187 | } |
| 1188 | switch ( event ) |
| 1189 | { |
| 1190 | case DVDNAV_BLOCK_OK: |
| 1191 | break; |
| 1192 | |
| 1193 | case DVDNAV_CELL_CHANGE: |
| 1194 | { |
| 1195 | result = dvdnav_current_title_info( d->dvdnav, &title, &part ); |
| 1196 | if (result != DVDNAV_STATUS_OK) |
| 1197 | hb_log("dvdnav title info: %s", dvdnav_err_to_string(d->dvdnav)); |
no test coverage detected