Lines Matching full:chain
899 * This is the length of the chain initially read from the FLAC file.
910 FLAC__Metadata_Chain *chain; member
947 static void chain_init_(FLAC__Metadata_Chain *chain) in chain_init_() argument
949 FLAC__ASSERT(0 != chain); in chain_init_()
951 chain->filename = 0; in chain_init_()
952 chain->is_ogg = false; in chain_init_()
953 chain->head = chain->tail = 0; in chain_init_()
954 chain->nodes = 0; in chain_init_()
955 chain->status = FLAC__METADATA_CHAIN_STATUS_OK; in chain_init_()
956 chain->initial_length = 0; in chain_init_()
957 chain->read_cb = 0; in chain_init_()
960 static void chain_clear_(FLAC__Metadata_Chain *chain) in chain_clear_() argument
964 FLAC__ASSERT(0 != chain); in chain_clear_()
966 for(node = chain->head; node; ) { in chain_clear_()
972 if(0 != chain->filename) in chain_clear_()
973 free(chain->filename); in chain_clear_()
975 chain_init_(chain); in chain_clear_()
978 static void chain_append_node_(FLAC__Metadata_Chain *chain, FLAC__Metadata_Node *node) in chain_append_node_() argument
980 FLAC__ASSERT(0 != chain); in chain_append_node_()
986 if(0 != chain->tail) in chain_append_node_()
987 chain->tail->data->is_last = false; in chain_append_node_()
989 if(0 == chain->head) in chain_append_node_()
990 chain->head = node; in chain_append_node_()
992 FLAC__ASSERT(0 != chain->tail); in chain_append_node_()
993 chain->tail->next = node; in chain_append_node_()
994 node->prev = chain->tail; in chain_append_node_()
996 chain->tail = node; in chain_append_node_()
997 chain->nodes++; in chain_append_node_()
1000 static void chain_remove_node_(FLAC__Metadata_Chain *chain, FLAC__Metadata_Node *node) in chain_remove_node_() argument
1002 FLAC__ASSERT(0 != chain); in chain_remove_node_()
1005 if(node == chain->head) in chain_remove_node_()
1006 chain->head = node->next; in chain_remove_node_()
1010 if(node == chain->tail) in chain_remove_node_()
1011 chain->tail = node->prev; in chain_remove_node_()
1015 if(0 != chain->tail) in chain_remove_node_()
1016 chain->tail->data->is_last = true; in chain_remove_node_()
1018 chain->nodes--; in chain_remove_node_()
1021 static void chain_delete_node_(FLAC__Metadata_Chain *chain, FLAC__Metadata_Node *node) in chain_delete_node_() argument
1023 chain_remove_node_(chain, node); in chain_delete_node_()
1027 static FLAC__off_t chain_calculate_length_(FLAC__Metadata_Chain *chain) in chain_calculate_length_() argument
1031 for(node = chain->head; node; node = node->next) in chain_calculate_length_()
1042 FLAC__ASSERT(0 != iterator->chain); in iterator_insert_node_()
1043 FLAC__ASSERT(0 != iterator->chain->head); in iterator_insert_node_()
1044 FLAC__ASSERT(0 != iterator->chain->tail); in iterator_insert_node_()
1052 iterator->chain->head = node; in iterator_insert_node_()
1058 iterator->chain->nodes++; in iterator_insert_node_()
1067 FLAC__ASSERT(0 != iterator->chain); in iterator_insert_node_after_()
1068 FLAC__ASSERT(0 != iterator->chain->head); in iterator_insert_node_after_()
1069 FLAC__ASSERT(0 != iterator->chain->tail); in iterator_insert_node_after_()
1077 iterator->chain->tail = node; in iterator_insert_node_after_()
1083 iterator->chain->tail->data->is_last = true; in iterator_insert_node_after_()
1085 iterator->chain->nodes++; in iterator_insert_node_after_()
1089 static FLAC__bool chain_merge_adjacent_padding_(FLAC__Metadata_Chain *chain, FLAC__Metadata_Node *n… in chain_merge_adjacent_padding_() argument
1095 chain_delete_node_(chain, node->next); in chain_merge_adjacent_padding_()
1102 /* Returns the new length of the chain, or 0 if there was an error. */
1109 static FLAC__off_t chain_prepare_for_write_(FLAC__Metadata_Chain *chain, FLAC__bool use_padding) in chain_prepare_for_write_() argument
1111 FLAC__off_t current_length = chain_calculate_length_(chain); in chain_prepare_for_write_()
1115 …if(current_length < chain->initial_length && chain->tail->data->type == FLAC__METADATA_TYPE_PADDIN… in chain_prepare_for_write_()
1116 const FLAC__off_t delta = chain->initial_length - current_length; in chain_prepare_for_write_()
1117 chain->tail->data->length += delta; in chain_prepare_for_write_()
1119 FLAC__ASSERT(current_length == chain->initial_length); in chain_prepare_for_write_()
1122 …else if(current_length + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH <= chain->initial_length… in chain_prepare_for_write_()
1126 chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; in chain_prepare_for_write_()
1129 padding->length = chain->initial_length - (FLAC__STREAM_METADATA_HEADER_LENGTH + current_length); in chain_prepare_for_write_()
1132 chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; in chain_prepare_for_write_()
1136 chain_append_node_(chain, node); in chain_prepare_for_write_()
1137 current_length = chain_calculate_length_(chain); in chain_prepare_for_write_()
1138 FLAC__ASSERT(current_length == chain->initial_length); in chain_prepare_for_write_()
1141 else if(current_length > chain->initial_length) { in chain_prepare_for_write_()
1142 const FLAC__off_t delta = current_length - chain->initial_length; in chain_prepare_for_write_()
1143 if(chain->tail->data->type == FLAC__METADATA_TYPE_PADDING) { in chain_prepare_for_write_()
1145 …if((FLAC__off_t)chain->tail->data->length + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH == de… in chain_prepare_for_write_()
1146 chain_delete_node_(chain, chain->tail); in chain_prepare_for_write_()
1147 current_length = chain_calculate_length_(chain); in chain_prepare_for_write_()
1148 FLAC__ASSERT(current_length == chain->initial_length); in chain_prepare_for_write_()
1151 else if((FLAC__off_t)chain->tail->data->length >= delta) { in chain_prepare_for_write_()
1152 chain->tail->data->length -= delta; in chain_prepare_for_write_()
1154 FLAC__ASSERT(current_length == chain->initial_length); in chain_prepare_for_write_()
1163 for (node = chain->head; node; node = node->next) { in chain_prepare_for_write_()
1167 current_length = chain_calculate_length_(chain); in chain_prepare_for_write_()
1169 chain->status = FLAC__METADATA_CHAIN_STATUS_BAD_METADATA; in chain_prepare_for_write_()
1179 static FLAC__bool chain_read_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallba… in chain_read_cb_() argument
1183 FLAC__ASSERT(0 != chain); in chain_read_cb_()
1191 chain->status = FLAC__METADATA_CHAIN_STATUS_READ_ERROR; in chain_read_cb_()
1194 chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR; in chain_read_cb_()
1197 chain->status = FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE; in chain_read_cb_()
1207 chain->status = FLAC__METADATA_CHAIN_STATUS_READ_ERROR; in chain_read_cb_()
1210 chain->first_offset = (FLAC__off_t)pos; in chain_read_cb_()
1221 chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; in chain_read_cb_()
1227 chain->status = FLAC__METADATA_CHAIN_STATUS_READ_ERROR; in chain_read_cb_()
1234 chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; in chain_read_cb_()
1241 …chain->status = get_equivalent_status_(read_metadata_block_data_cb_(handle, read_cb, seek_cb, node… in chain_read_cb_()
1242 if(chain->status != FLAC__METADATA_CHAIN_STATUS_OK) { in chain_read_cb_()
1246 chain_append_node_(chain, node); in chain_read_cb_()
1253 chain->status = FLAC__METADATA_CHAIN_STATUS_READ_ERROR; in chain_read_cb_()
1256 chain->last_offset = (FLAC__off_t)pos; in chain_read_cb_()
1259 chain->initial_length = chain_calculate_length_(chain); in chain_read_cb_()
1266 FLAC__Metadata_Chain *chain = (FLAC__Metadata_Chain*)client_data; in chain_read_ogg_read_cb_() local
1268 if(*bytes > 0 && chain->status == FLAC__METADATA_CHAIN_STATUS_OK) { in chain_read_ogg_read_cb_()
1269 *bytes = chain->read_cb(buffer, sizeof(FLAC__byte), *bytes, chain->handle); in chain_read_ogg_read_cb_()
1287 FLAC__Metadata_Chain *chain = (FLAC__Metadata_Chain*)client_data; in chain_read_ogg_metadata_cb_() local
1294 chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; in chain_read_ogg_metadata_cb_()
1301 chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; in chain_read_ogg_metadata_cb_()
1305 chain_append_node_(chain, node); in chain_read_ogg_metadata_cb_()
1310 FLAC__Metadata_Chain *chain = (FLAC__Metadata_Chain*)client_data; in chain_read_ogg_error_cb_() local
1312 chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR; /*@@@ maybe needs better error code */ in chain_read_ogg_error_cb_()
1315 static FLAC__bool chain_read_ogg_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCa… in chain_read_ogg_cb_() argument
1319 FLAC__ASSERT(0 != chain); in chain_read_ogg_cb_()
1323 chain->handle = handle; in chain_read_ogg_cb_()
1324 chain->read_cb = read_cb; in chain_read_ogg_cb_()
1326 chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; in chain_read_ogg_cb_()
1330 …ead_ogg_write_cb_, chain_read_ogg_metadata_cb_, chain_read_ogg_error_cb_, chain) != FLAC__STREAM_D… in chain_read_ogg_cb_()
1332 chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR; /*@@@ maybe needs better error code */ in chain_read_ogg_cb_()
1336 …chain->first_offset = 0; /*@@@ wrong; will need to be set correctly to implement metadata writing … in chain_read_ogg_cb_()
1339 chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR; /*@@@ maybe needs better error code */ in chain_read_ogg_cb_()
1340 if(chain->status != FLAC__METADATA_CHAIN_STATUS_OK) { in chain_read_ogg_cb_()
1347 …chain->last_offset = 0; /*@@@ wrong; will need to be set correctly to implement metadata writing f… in chain_read_ogg_cb_()
1349 chain->initial_length = chain_calculate_length_(chain); in chain_read_ogg_cb_()
1354 static FLAC__bool chain_rewrite_metadata_in_place_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle h… in chain_rewrite_metadata_in_place_cb_() argument
1358 FLAC__ASSERT(0 != chain); in chain_rewrite_metadata_in_place_cb_()
1359 FLAC__ASSERT(0 != chain->head); in chain_rewrite_metadata_in_place_cb_()
1361 if(0 != seek_cb(handle, chain->first_offset, SEEK_SET)) { in chain_rewrite_metadata_in_place_cb_()
1362 chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR; in chain_rewrite_metadata_in_place_cb_()
1366 for(node = chain->head; node; node = node->next) { in chain_rewrite_metadata_in_place_cb_()
1368 chain->status = FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR; in chain_rewrite_metadata_in_place_cb_()
1372 chain->status = FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR; in chain_rewrite_metadata_in_place_cb_()
1377 /*FLAC__ASSERT(fflush(), ftello() == chain->last_offset);*/ in chain_rewrite_metadata_in_place_cb_()
1379 chain->status = FLAC__METADATA_CHAIN_STATUS_OK; in chain_rewrite_metadata_in_place_cb_()
1383 static FLAC__bool chain_rewrite_metadata_in_place_(FLAC__Metadata_Chain *chain) in chain_rewrite_metadata_in_place_() argument
1388 FLAC__ASSERT(0 != chain->filename); in chain_rewrite_metadata_in_place_()
1390 if(0 == (file = flac_fopen(chain->filename, "r+b"))) { in chain_rewrite_metadata_in_place_()
1391 chain->status = FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE; in chain_rewrite_metadata_in_place_()
1395 /* chain_rewrite_metadata_in_place_cb_() sets chain->status for us */ in chain_rewrite_metadata_in_place_()
1396 …ret = chain_rewrite_metadata_in_place_cb_(chain, (FLAC__IOHandle)file, (FLAC__IOCallback_Write)fwr… in chain_rewrite_metadata_in_place_()
1403 static FLAC__bool chain_rewrite_file_(FLAC__Metadata_Chain *chain, const char *tempfile_path_prefix) in chain_rewrite_file_() argument
1410 FLAC__ASSERT(0 != chain); in chain_rewrite_file_()
1411 FLAC__ASSERT(0 != chain->filename); in chain_rewrite_file_()
1412 FLAC__ASSERT(0 != chain->head); in chain_rewrite_file_()
1415 if(0 == (f = flac_fopen(chain->filename, "rb"))) { in chain_rewrite_file_()
1416 chain->status = FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE; in chain_rewrite_file_()
1419 if(!open_tempfile_(chain->filename, tempfile_path_prefix, &tempfile, &tempfilename, &status)) { in chain_rewrite_file_()
1420 chain->status = get_equivalent_status_(status); in chain_rewrite_file_()
1423 if(!copy_n_bytes_from_file_(f, tempfile, chain->first_offset, &status)) { in chain_rewrite_file_()
1424 chain->status = get_equivalent_status_(status); in chain_rewrite_file_()
1429 for(node = chain->head; node; node = node->next) { in chain_rewrite_file_()
1431 chain->status = get_equivalent_status_(status); in chain_rewrite_file_()
1435 chain->status = get_equivalent_status_(status); in chain_rewrite_file_()
1439 /*FLAC__ASSERT(fflush(), ftello() == chain->last_offset);*/ in chain_rewrite_file_()
1442 if(0 != fseeko(f, chain->last_offset, SEEK_SET)) { in chain_rewrite_file_()
1443 chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR; in chain_rewrite_file_()
1447 chain->status = get_equivalent_status_(status); in chain_rewrite_file_()
1453 if(!transport_tempfile_(chain->filename, &tempfile, &tempfilename, &status)) in chain_rewrite_file_()
1465 static FLAC__bool chain_rewrite_file_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__… in chain_rewrite_file_cb_() argument
1470 FLAC__ASSERT(0 != chain); in chain_rewrite_file_cb_()
1471 FLAC__ASSERT(0 == chain->filename); in chain_rewrite_file_cb_()
1472 FLAC__ASSERT(0 != chain->head); in chain_rewrite_file_cb_()
1475 …if(!copy_n_bytes_from_file_cb_(handle, read_cb, temp_handle, temp_write_cb, chain->first_offset, &… in chain_rewrite_file_cb_()
1476 chain->status = get_equivalent_status_(status); in chain_rewrite_file_cb_()
1481 for(node = chain->head; node; node = node->next) { in chain_rewrite_file_cb_()
1483 chain->status = FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR; in chain_rewrite_file_cb_()
1487 chain->status = FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR; in chain_rewrite_file_cb_()
1491 /*FLAC__ASSERT(fflush(), ftello() == chain->last_offset);*/ in chain_rewrite_file_cb_()
1494 if(0 != seek_cb(handle, chain->last_offset, SEEK_SET)) { in chain_rewrite_file_cb_()
1495 chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR; in chain_rewrite_file_cb_()
1499 chain->status = get_equivalent_status_(status); in chain_rewrite_file_cb_()
1508 FLAC__Metadata_Chain *chain = calloc(1, sizeof(FLAC__Metadata_Chain)); in FLAC__metadata_chain_new() local
1510 if(0 != chain) in FLAC__metadata_chain_new()
1511 chain_init_(chain); in FLAC__metadata_chain_new()
1513 return chain; in FLAC__metadata_chain_new()
1516 FLAC_API void FLAC__metadata_chain_delete(FLAC__Metadata_Chain *chain) in FLAC__metadata_chain_delete() argument
1518 FLAC__ASSERT(0 != chain); in FLAC__metadata_chain_delete()
1520 chain_clear_(chain); in FLAC__metadata_chain_delete()
1522 free(chain); in FLAC__metadata_chain_delete()
1525 FLAC_API FLAC__Metadata_ChainStatus FLAC__metadata_chain_status(FLAC__Metadata_Chain *chain) in FLAC__metadata_chain_status() argument
1529 FLAC__ASSERT(0 != chain); in FLAC__metadata_chain_status()
1531 status = chain->status; in FLAC__metadata_chain_status()
1532 chain->status = FLAC__METADATA_CHAIN_STATUS_OK; in FLAC__metadata_chain_status()
1536 static FLAC__bool chain_read_(FLAC__Metadata_Chain *chain, const char *filename, FLAC__bool is_ogg) in chain_read_() argument
1541 FLAC__ASSERT(0 != chain); in chain_read_()
1544 chain_clear_(chain); in chain_read_()
1546 if(0 == (chain->filename = strdup(filename))) { in chain_read_()
1547 chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; in chain_read_()
1551 chain->is_ogg = is_ogg; in chain_read_()
1554 chain->status = FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE; in chain_read_()
1558 /* the function also sets chain->status for us */ in chain_read_()
1560 chain_read_ogg_cb_(chain, file, (FLAC__IOCallback_Read)fread) : in chain_read_()
1561 chain_read_cb_(chain, file, (FLAC__IOCallback_Read)fread, fseek_wrapper_, ftell_wrapper_) in chain_read_()
1569 FLAC_API FLAC__bool FLAC__metadata_chain_read(FLAC__Metadata_Chain *chain, const char *filename) in FLAC__metadata_chain_read() argument
1571 return chain_read_(chain, filename, /*is_ogg=*/false); in FLAC__metadata_chain_read()
1575 FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg(FLAC__Metadata_Chain *chain, const char *filename) in FLAC__metadata_chain_read_ogg() argument
1577 return chain_read_(chain, filename, /*is_ogg=*/true); in FLAC__metadata_chain_read_ogg()
1580 static FLAC__bool chain_read_with_callbacks_(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FL… in chain_read_with_callbacks_() argument
1584 FLAC__ASSERT(0 != chain); in chain_read_with_callbacks_()
1586 chain_clear_(chain); in chain_read_with_callbacks_()
1589 chain->status = FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS; in chain_read_with_callbacks_()
1593 chain->is_ogg = is_ogg; in chain_read_with_callbacks_()
1597 chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR; in chain_read_with_callbacks_()
1601 /* the function also sets chain->status for us */ in chain_read_with_callbacks_()
1603 chain_read_ogg_cb_(chain, handle, callbacks.read) : in chain_read_with_callbacks_()
1604 chain_read_cb_(chain, handle, callbacks.read, callbacks.seek, callbacks.tell) in chain_read_with_callbacks_()
1610 FLAC_API FLAC__bool FLAC__metadata_chain_read_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOH… in FLAC__metadata_chain_read_with_callbacks() argument
1612 return chain_read_with_callbacks_(chain, handle, callbacks, /*is_ogg=*/false); in FLAC__metadata_chain_read_with_callbacks()
1616 FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg_with_callbacks(FLAC__Metadata_Chain *chain, FLAC_… in FLAC__metadata_chain_read_ogg_with_callbacks() argument
1618 return chain_read_with_callbacks_(chain, handle, callbacks, /*is_ogg=*/true); in FLAC__metadata_chain_read_ogg_with_callbacks()
1628 FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata_Chain *chain, FLAC… in FLAC__metadata_chain_check_if_tempfile_needed() argument
1631 * but doesn't actually alter the chain. Make sure to update the logic in FLAC__metadata_chain_check_if_tempfile_needed()
1638 FLAC__ASSERT(0 != chain); in FLAC__metadata_chain_check_if_tempfile_needed()
1640 current_length = chain_calculate_length_(chain); in FLAC__metadata_chain_check_if_tempfile_needed()
1643 const FLAC__Metadata_Node * const node = chain->tail; in FLAC__metadata_chain_check_if_tempfile_needed()
1645 if(current_length < chain->initial_length && node->data->type == FLAC__METADATA_TYPE_PADDING) { in FLAC__metadata_chain_check_if_tempfile_needed()
1647 lbs_size = node->data->length + (chain->initial_length - current_length); in FLAC__metadata_chain_check_if_tempfile_needed()
1650 …else if(current_length + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH <= chain->initial_length… in FLAC__metadata_chain_check_if_tempfile_needed()
1652 …lbs_size = chain->initial_length - (current_length + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LEN… in FLAC__metadata_chain_check_if_tempfile_needed()
1655 else if(current_length > chain->initial_length) { in FLAC__metadata_chain_check_if_tempfile_needed()
1656 const FLAC__off_t delta = current_length - chain->initial_length; in FLAC__metadata_chain_check_if_tempfile_needed()
1676 for(node = chain->head; node; node = node->next) { in FLAC__metadata_chain_check_if_tempfile_needed()
1678 if(node == chain->tail) { in FLAC__metadata_chain_check_if_tempfile_needed()
1702 return (current_length != chain->initial_length); in FLAC__metadata_chain_check_if_tempfile_needed()
1705 FLAC_API FLAC__bool FLAC__metadata_chain_write(FLAC__Metadata_Chain *chain, FLAC__bool use_padding,… in FLAC__metadata_chain_write() argument
1711 FLAC__ASSERT(0 != chain); in FLAC__metadata_chain_write()
1713 if (chain->is_ogg) { /* cannot write back to Ogg FLAC yet */ in FLAC__metadata_chain_write()
1714 chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR; in FLAC__metadata_chain_write()
1718 if (0 == chain->filename) { in FLAC__metadata_chain_write()
1719 chain->status = FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH; in FLAC__metadata_chain_write()
1723 current_length = chain_prepare_for_write_(chain, use_padding); in FLAC__metadata_chain_write()
1725 /* a return value of 0 means there was an error; chain->status is already set */ in FLAC__metadata_chain_write()
1730 get_file_stats_(chain->filename, &stats); in FLAC__metadata_chain_write()
1732 if(current_length == chain->initial_length) { in FLAC__metadata_chain_write()
1733 if(!chain_rewrite_metadata_in_place_(chain)) in FLAC__metadata_chain_write()
1737 if(!chain_rewrite_file_(chain, tempfile_path_prefix)) in FLAC__metadata_chain_write()
1743 chain->initial_length = current_length; in FLAC__metadata_chain_write()
1744 chain->last_offset = chain->first_offset; in FLAC__metadata_chain_write()
1745 for(node = chain->head; node; node = node->next) in FLAC__metadata_chain_write()
1746 chain->last_offset += (FLAC__STREAM_METADATA_HEADER_LENGTH + node->data->length); in FLAC__metadata_chain_write()
1751 set_file_stats_(chain->filename, &stats); in FLAC__metadata_chain_write()
1756 FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__bo… in FLAC__metadata_chain_write_with_callbacks() argument
1760 FLAC__ASSERT(0 != chain); in FLAC__metadata_chain_write_with_callbacks()
1762 if (chain->is_ogg) { /* cannot write back to Ogg FLAC yet */ in FLAC__metadata_chain_write_with_callbacks()
1763 chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR; in FLAC__metadata_chain_write_with_callbacks()
1767 if (0 != chain->filename) { in FLAC__metadata_chain_write_with_callbacks()
1768 chain->status = FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH; in FLAC__metadata_chain_write_with_callbacks()
1773 chain->status = FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS; in FLAC__metadata_chain_write_with_callbacks()
1777 if (FLAC__metadata_chain_check_if_tempfile_needed(chain, use_padding)) { in FLAC__metadata_chain_write_with_callbacks()
1778 chain->status = FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL; in FLAC__metadata_chain_write_with_callbacks()
1782 current_length = chain_prepare_for_write_(chain, use_padding); in FLAC__metadata_chain_write_with_callbacks()
1784 /* a return value of 0 means there was an error; chain->status is already set */ in FLAC__metadata_chain_write_with_callbacks()
1788 FLAC__ASSERT(current_length == chain->initial_length); in FLAC__metadata_chain_write_with_callbacks()
1790 return chain_rewrite_metadata_in_place_cb_(chain, handle, callbacks.write, callbacks.seek); in FLAC__metadata_chain_write_with_callbacks()
1793 …C__metadata_chain_write_with_callbacks_and_tempfile(FLAC__Metadata_Chain *chain, FLAC__bool use_pa… in FLAC__metadata_chain_write_with_callbacks_and_tempfile() argument
1797 FLAC__ASSERT(0 != chain); in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1799 if (chain->is_ogg) { /* cannot write back to Ogg FLAC yet */ in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1800 chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR; in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1804 if (0 != chain->filename) { in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1805 chain->status = FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH; in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1810 chain->status = FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS; in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1814 chain->status = FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS; in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1818 if (!FLAC__metadata_chain_check_if_tempfile_needed(chain, use_padding)) { in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1819 chain->status = FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL; in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1823 current_length = chain_prepare_for_write_(chain, use_padding); in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1825 /* a return value of 0 means there was an error; chain->status is already set */ in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1829 FLAC__ASSERT(current_length != chain->initial_length); in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1833 chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR; in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1837 …if(!chain_rewrite_file_cb_(chain, handle, callbacks.read, callbacks.seek, callbacks.eof, temp_hand… in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1843 chain->initial_length = current_length; in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1844 chain->last_offset = chain->first_offset; in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1845 for(node = chain->head; node; node = node->next) in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1846 chain->last_offset += (FLAC__STREAM_METADATA_HEADER_LENGTH + node->data->length); in FLAC__metadata_chain_write_with_callbacks_and_tempfile()
1852 FLAC_API void FLAC__metadata_chain_merge_padding(FLAC__Metadata_Chain *chain) in FLAC__metadata_chain_merge_padding() argument
1856 FLAC__ASSERT(0 != chain); in FLAC__metadata_chain_merge_padding()
1858 for(node = chain->head; node; ) { in FLAC__metadata_chain_merge_padding()
1859 if(!chain_merge_adjacent_padding_(chain, node)) in FLAC__metadata_chain_merge_padding()
1864 FLAC_API void FLAC__metadata_chain_sort_padding(FLAC__Metadata_Chain *chain) in FLAC__metadata_chain_sort_padding() argument
1869 FLAC__ASSERT(0 != chain); in FLAC__metadata_chain_sort_padding()
1875 for(i = 0, node = chain->head; i < chain->nodes; i++) { in FLAC__metadata_chain_sort_padding()
1878 chain_remove_node_(chain, node); in FLAC__metadata_chain_sort_padding()
1879 chain_append_node_(chain, node); in FLAC__metadata_chain_sort_padding()
1887 FLAC__metadata_chain_merge_padding(chain); in FLAC__metadata_chain_sort_padding()
1897 iterator->chain = 0; in FLAC__metadata_iterator_new()
1910 …I void FLAC__metadata_iterator_init(FLAC__Metadata_Iterator *iterator, FLAC__Metadata_Chain *chain) in FLAC__metadata_iterator_init() argument
1913 FLAC__ASSERT(0 != chain); in FLAC__metadata_iterator_init()
1914 FLAC__ASSERT(0 != chain->head); in FLAC__metadata_iterator_init()
1916 iterator->chain = chain; in FLAC__metadata_iterator_init()
1917 iterator->current = chain->head; in FLAC__metadata_iterator_init()
1985 chain_delete_node_(iterator->chain, iterator->current); in FLAC__metadata_iterator_delete_block()