Lines Matching defs:psf

305 static int 	format_from_extension (SF_PRIVATE *psf) ;
306 static int guess_file_type (SF_PRIVATE *psf) ;
308 static int validate_psf (SF_PRIVATE *psf) ;
309 static void save_header_info (SF_PRIVATE *psf) ;
310 static int psf_close (SF_PRIVATE *psf) ;
312 static int try_resource_fork (SF_PRIVATE * psf) ;
349 { SF_PRIVATE *psf ;
362 if ((psf = psf_allocate ()) == NULL)
367 psf_init_files (psf) ;
369 psf_log_printf (psf, "File : %s\n", path) ;
375 psf_close (psf) ;
383 psf_close (psf) ;
391 psf_close (psf) ;
400 psf_close (psf) ;
415 psf_close (psf) ;
424 if (psf_copy_filename (psf, utf8path_ptr) != 0)
425 { sf_errno = psf->error ;
426 psf_close (psf) ;
430 psf->file.mode = mode ;
432 psf->error = psf_set_stdio (psf) ;
434 psf->error = psf_fopen (psf) ;
436 return psf_open_file (psf, sfinfo) ;
441 { SF_PRIVATE *psf ;
452 if ((psf = psf_allocate ()) == NULL)
460 psf_init_files (psf) ;
461 psf_copy_filename (psf, "") ;
463 psf->file.mode = mode ;
464 psf_set_file (psf, fd) ;
465 psf->is_pipe = psf_is_pipe (psf) ;
466 psf->fileoffset = psf_ftell (psf) ;
468 result = psf_open_file (psf, sfinfo) ;
470 psf->file.do_not_close_descriptor = SF_TRUE ;
477 { SF_PRIVATE *psf ;
504 if ((psf = psf_allocate ()) == NULL)
509 psf_init_files (psf) ;
511 psf->virtual_io = SF_TRUE ;
512 psf->vio = *sfvirtual ;
513 psf->vio_user_data = user_data ;
515 psf->file.mode = mode ;
517 return psf_open_file (psf, sfinfo) ;
522 { SF_PRIVATE *psf ;
524 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
526 return psf_close (psf) ;
531 { SF_PRIVATE *psf ;
533 if ((psf = (SF_PRIVATE *) sndfile) == NULL)
536 psf_fsync (psf) ;
568 { SF_PRIVATE *psf = NULL ;
577 { psf = (SF_PRIVATE *) sndfile ;
579 if (psf->Magick != SNDFILE_MAGICK)
582 errnum = psf->error ;
584 if (errnum == SFE_SYSTEM && psf->syserr [0])
585 return psf->syserr ;
596 { SF_PRIVATE *psf ;
601 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 0) ;
603 if (psf->error)
604 return psf->error ;
614 { SF_PRIVATE *psf ;
621 { VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 0) ;
622 errnum = psf->error ;
635 { SF_PRIVATE *psf ;
644 { VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 0) ;
645 errnum = psf->error ;
1000 { SF_PRIVATE *psf = (SF_PRIVATE *) sndfile ;
1009 { if (psf)
1010 psf->error = SFE_BAD_COMMAND_PARAM ;
1062 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
1066 old_value = psf->norm_float ;
1067 psf->norm_float = (datasize) ? SF_TRUE : SF_FALSE ;
1073 memcpy (data, &psf->sf, sizeof (SF_INFO)) ;
1077 old_value = psf->norm_double ;
1078 psf->norm_double = (datasize) ? SF_TRUE : SF_FALSE ;
1082 return psf->norm_float ;
1085 return psf->norm_double ;
1088 old_value = psf->float_int_mult ;
1090 psf->float_int_mult = (datasize != 0) ? SF_TRUE : SF_FALSE ;
1091 if (psf->float_int_mult && psf->float_max < 0.0)
1093 psf->float_max = (32768.0 / 32767.0) * psf_calc_signal_max (psf, SF_FALSE) ;
1097 old_value = psf->scale_int_float ;
1098 psf->scale_int_float = (datasize != 0) ? SF_TRUE : SF_FALSE ;
1102 { int format = SF_CONTAINER (psf->sf.format) ;
1117 format = SF_CODEC (psf->sf.format) ;
1125 if (psf->file.mode != SFM_WRITE && psf->file.mode != SFM_RDWR)
1128 if (psf->have_written)
1129 { psf->error = SFE_CMD_HAS_DATA ;
1132 /* Everything seems OK, so set psf->has_peak and re-write header. */
1133 if (datasize == SF_FALSE && psf->peak_info != NULL)
1134 { free (psf->peak_info) ;
1135 psf->peak_info = NULL ;
1137 else if (psf->peak_info == NULL)
1138 { psf->peak_info = peak_info_calloc (psf->sf.channels) ;
1139 if (psf->peak_info != NULL)
1140 psf->peak_info->peak_loc = SF_PEAK_START ;
1143 if (psf->write_header)
1144 psf->write_header (psf, SF_TRUE) ;
1153 snprintf (data, datasize, "%s", psf->parselog.buf) ;
1158 return (psf->error = SFE_BAD_COMMAND_PARAM) ;
1159 *((double*) data) = psf_calc_signal_max (psf, SF_FALSE) ;
1164 return (psf->error = SFE_BAD_COMMAND_PARAM) ;
1165 *((double*) data) = psf_calc_signal_max (psf, SF_TRUE) ;
1169 if (data == NULL || datasize != SIGNED_SIZEOF (double) * psf->sf.channels)
1170 return (psf->error = SFE_BAD_COMMAND_PARAM) ;
1171 return psf_calc_max_all_channels (psf, (double*) data, SF_FALSE) ;
1174 if (data == NULL || datasize != SIGNED_SIZEOF (double) * psf->sf.channels)
1175 return (psf->error = SFE_BAD_COMMAND_PARAM) ;
1176 return psf_calc_max_all_channels (psf, (double*) data, SF_TRUE) ;
1180 { psf->error = SFE_BAD_COMMAND_PARAM ;
1183 return psf_get_signal_max (psf, (double *) data) ;
1186 if (data == NULL || datasize != SIGNED_SIZEOF (double) * psf->sf.channels)
1187 { psf->error = SFE_BAD_COMMAND_PARAM ;
1190 return psf_get_max_all_channels (psf, (double*) data) ;
1193 if (psf->write_header)
1194 psf->write_header (psf, SF_TRUE) ;
1198 psf->auto_header = datasize ? SF_TRUE : SF_FALSE ;
1199 return psf->auto_header ;
1213 return (psf->error = SFE_BAD_COMMAND_PARAM) ;
1214 memcpy (&psf->write_dither, data, sizeof (psf->write_dither)) ;
1215 if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
1216 dither_init (psf, SFM_WRITE) ;
1221 return (psf->error = SFE_BAD_COMMAND_PARAM) ;
1222 memcpy (&psf->read_dither, data, sizeof (psf->read_dither)) ;
1223 if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR)
1224 dither_init (psf, SFM_READ) ;
1228 if (psf->file.mode != SFM_WRITE && psf->file.mode != SFM_RDWR)
1233 { psf->error = SFE_BAD_COMMAND_PARAM ;
1244 psf->sf.frames = position ;
1246 position = psf_fseek (psf, 0, SEEK_CUR) ;
1248 return psf_ftruncate (psf, position) ;
1254 return (psf->error = SFE_BAD_COMMAND_PARAM) ;
1256 if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_RAW)
1257 return (psf->error = SFE_BAD_COMMAND_PARAM) ;
1259 psf->dataoffset = *((sf_count_t*) data) ;
1265 return (psf->error = SFE_BAD_COMMAND_PARAM) ;
1267 ((SF_EMBED_FILE_INFO*) data)->offset = psf->fileoffset ;
1268 ((SF_EMBED_FILE_INFO*) data)->length = psf->filelength ;
1273 psf->ieee_replace = (datasize) ? SF_TRUE : SF_FALSE ;
1274 if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_FLOAT)
1275 float32_init (psf) ;
1276 else if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_DOUBLE)
1277 double64_init (psf) ;
1279 return (psf->error = SFE_BAD_COMMAND_PARAM) ;
1284 psf->add_clipping = (datasize) ? SF_TRUE : SF_FALSE ;
1285 return psf->add_clipping ;
1288 return psf->add_clipping ;
1292 { psf->error = SFE_BAD_COMMAND_PARAM ;
1295 if (psf->loop_info == NULL)
1297 memcpy (data, psf->loop_info, sizeof (SF_LOOP_INFO)) ;
1301 { int format = SF_CONTAINER (psf->sf.format) ;
1309 if ((psf->file.mode != SFM_WRITE) && (psf->file.mode != SFM_RDWR))
1312 if (psf->broadcast_16k == NULL && psf->have_written)
1313 { psf->error = SFE_CMD_HAS_DATA ;
1317 if (!broadcast_var_set (psf, data, datasize))
1320 if (psf->write_header)
1321 psf->write_header (psf, SF_TRUE) ;
1326 { psf->error = SFE_BAD_COMMAND_PARAM ;
1329 return broadcast_var_get (psf, data, datasize) ;
1332 { int format = SF_CONTAINER (psf->sf.format) ;
1339 if ((psf->file.mode != SFM_WRITE) && (psf->file.mode != SFM_RDWR))
1342 if (psf->cart_16k == NULL && psf->have_written)
1343 { psf->error = SFE_CMD_HAS_DATA ;
1346 if (!cart_var_set (psf, data, datasize))
1348 if (psf->write_header)
1349 psf->write_header (psf, SF_TRUE) ;
1354 { psf->error = SFE_BAD_COMMAND_PARAM ;
1357 return cart_var_get (psf, data, datasize) ;
1361 { psf->error = SFE_BAD_COMMAND_PARAM ;
1364 if (psf->cues != NULL)
1365 { *((uint32_t *) data) = psf->cues->cue_count ;
1372 { psf->error = SFE_BAD_COMMAND_PARAM ;
1375 if (psf->cues == NULL)
1377 psf_get_cues (psf, data, datasize) ;
1381 if (psf->have_written)
1382 { psf->error = SFE_CMD_HAS_DATA ;
1386 { psf->error = SFE_BAD_COMMAND_PARAM ;
1389 if (psf->cues == NULL && (psf->cues = psf_cues_dup (data, datasize)) == NULL)
1390 { psf->error = SFE_MALLOC_FAILED ;
1397 { psf->error = SFE_BAD_COMMAND_PARAM ;
1400 if (psf->instrument == NULL)
1402 memcpy (data, psf->instrument, sizeof (SF_INSTRUMENT)) ;
1407 if (psf->have_written)
1408 { psf->error = SFE_CMD_HAS_DATA ;
1412 { psf->error = SFE_BAD_COMMAND_PARAM ;
1416 if (psf->instrument == NULL && (psf->instrument = psf_instrument_alloc ()) == NULL)
1417 { psf->error = SFE_MALLOC_FAILED ;
1420 memcpy (psf->instrument, data, sizeof (SF_INSTRUMENT)) ;
1424 return psf->data_endswap ;
1427 if (psf->channel_map == NULL)
1430 if (data == NULL || datasize != SIGNED_SIZEOF (psf->channel_map [0]) * psf->sf.channels)
1431 { psf->error = SFE_BAD_COMMAND_PARAM ;
1435 memcpy (data, psf->channel_map, datasize) ;
1439 if (psf->have_written)
1440 { psf->error = SFE_CMD_HAS_DATA ;
1443 if (data == NULL || datasize != SIGNED_SIZEOF (psf->channel_map [0]) * psf->sf.channels)
1444 { psf->error = SFE_BAD_COMMAND_PARAM ;
1450 for (iptr = data ; iptr < (int*) data + psf->sf.channels ; iptr++)
1452 { psf->error = SFE_BAD_COMMAND_PARAM ;
1458 free (psf->channel_map) ;
1459 if ((psf->channel_map = malloc (datasize)) == NULL)
1460 { psf->error = SFE_MALLOC_FAILED ;
1464 memcpy (psf->channel_map, data, datasize) ;
1468 ** Don't pass user data, use validated psf->channel_map data instead.
1470 if (psf->command)
1471 return psf->command (psf, command, NULL, 0) ;
1491 if (psf->command)
1492 return psf->command (psf, command, data, datasize) ;
1494 psf_log_printf (psf, "*** sf_command : cmd = 0x%X\n", command) ;
1495 return (psf->error = SFE_BAD_COMMAND_PARAM) ;
1506 { SF_PRIVATE *psf ;
1509 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
1511 if (! psf->sf.seekable)
1512 { psf->error = SFE_NOT_SEEKABLE ;
1519 if (((whence & SFM_MASK) == SFM_WRITE && psf->file.mode == SFM_READ) ||
1520 ((whence & SFM_MASK) == SFM_READ && psf->file.mode == SFM_WRITE))
1521 { psf->error = SFE_WRONG_SEEK ;
1540 { if (psf->file.mode == SFM_READ)
1541 return psf->read_current ;
1542 if (psf->file.mode == SFM_WRITE)
1543 return psf->write_current ;
1545 if (psf->file.mode == SFM_READ)
1546 seek_from_start = psf->read_current + offset ;
1547 else if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
1548 seek_from_start = psf->write_current + offset ;
1550 psf->error = SFE_AMBIGUOUS_SEEK ;
1555 return psf->read_current ;
1556 seek_from_start = psf->read_current + offset ;
1561 return psf->write_current ;
1562 seek_from_start = psf->write_current + offset ;
1569 seek_from_start = psf->sf.frames + offset ;
1573 psf->error = SFE_BAD_SEEK ;
1577 if (psf->error)
1580 if (psf->file.mode == SFM_RDWR || psf->file.mode == SFM_WRITE)
1582 { psf->error = SFE_BAD_SEEK ;
1586 else if (seek_from_start < 0 || seek_from_start > psf->sf.frames)
1587 { psf->error = SFE_BAD_SEEK ;
1591 if (psf->seek)
1592 { int new_mode = (whence & SFM_MASK) ? (whence & SFM_MASK) : psf->file.mode ;
1594 retval = psf->seek (psf, new_mode, seek_from_start) ;
1598 psf->read_current = retval ;
1601 psf->write_current = retval ;
1604 psf->read_current = retval ;
1605 psf->write_current = retval ;
1610 psf->last_op = new_mode ;
1615 psf->error = SFE_AMBIGUOUS_SEEK ;
1624 { SF_PRIVATE *psf ;
1626 if ((psf = (SF_PRIVATE*) sndfile) == NULL)
1628 if (psf->Magick != SNDFILE_MAGICK)
1631 return psf_get_string (psf, str_type) ;
1636 { SF_PRIVATE *psf ;
1638 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
1640 return psf_set_string (psf, str_type, str) ;
1648 { SF_PRIVATE *psf ;
1650 if ((psf = (SF_PRIVATE*) sndfile) == NULL)
1652 if (psf->Magick != SNDFILE_MAGICK)
1656 if (psf->bytewidth)
1657 return psf->sf.samplerate * psf->sf.channels * psf->bytewidth ;
1659 if (psf->byterate)
1660 return psf->byterate (psf) ;
1662 switch (SF_CODEC (psf->sf.format))
1666 return (psf->sf.samplerate * psf->sf.channels) / 2 ;
1669 return (psf->sf.samplerate * psf->sf.channels * 13000) / 8000 ;
1672 return psf->sf.samplerate / 4 + 10 ;
1675 return psf->sf.samplerate * 3 / 8 + 10 ;
1678 return psf->sf.samplerate / 2 + 10 ;
1681 return (psf->sf.samplerate * psf->sf.channels) / 2 ;
1684 return (psf->sf.samplerate * psf->sf.channels * 3) / 8 ;
1687 return (psf->sf.samplerate * psf->sf.channels * 5) / 8 ;
1701 { SF_PRIVATE *psf ;
1708 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
1710 bytewidth = (psf->bytewidth > 0) ? psf->bytewidth : 1 ;
1711 blockwidth = (psf->blockwidth > 0) ? psf->blockwidth : 1 ;
1713 if (psf->file.mode == SFM_WRITE)
1714 { psf->error = SFE_NOT_READMODE ;
1718 if (bytes < 0 || psf->read_current >= psf->sf.frames)
1723 if (bytes % (psf->sf.channels * bytewidth))
1724 { psf->error = SFE_BAD_READ_ALIGN ;
1728 if (psf->last_op != SFM_READ)
1729 if (psf->seek (psf, SFM_READ, psf->read_current) < 0)
1732 count = psf_fread (ptr, 1, bytes, psf) ;
1734 if (psf->read_current + count / blockwidth <= psf->sf.frames)
1735 psf->read_current += count / blockwidth ;
1737 { count = (psf->sf.frames - psf->read_current) * blockwidth ;
1740 psf->read_current = psf->sf.frames ;
1743 psf->last_op = SFM_READ ;
1753 { SF_PRIVATE *psf ;
1759 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
1762 { psf->error = SFE_NEGATIVE_RW_LEN ;
1766 if (psf->file.mode == SFM_WRITE)
1767 { psf->error = SFE_NOT_READMODE ;
1771 if (len % psf->sf.channels)
1772 { psf->error = SFE_BAD_READ_ALIGN ;
1776 if (psf->read_current >= psf->sf.frames)
1781 if (psf->read_short == NULL || psf->seek == NULL)
1782 { psf->error = SFE_UNIMPLEMENTED ;
1786 if (psf->last_op != SFM_READ)
1787 if (psf->seek (psf, SFM_READ, psf->read_current) < 0)
1790 count = psf->read_short (psf, ptr, len) ;
1792 if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
1793 psf->read_current += count / psf->sf.channels ;
1795 { count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
1798 psf->read_current = psf->sf.frames ;
1801 psf->last_op = SFM_READ ;
1808 { SF_PRIVATE *psf ;
1814 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
1817 { psf->error = SFE_NEGATIVE_RW_LEN ;
1821 if (psf->file.mode == SFM_WRITE)
1822 { psf->error = SFE_NOT_READMODE ;
1826 if (psf->read_current >= psf->sf.frames)
1827 { psf_memset (ptr, 0, frames * psf->sf.channels * sizeof (short)) ;
1831 if (psf->read_short == NULL || psf->seek == NULL)
1832 { psf->error = SFE_UNIMPLEMENTED ;
1836 if (psf->last_op != SFM_READ)
1837 if (psf->seek (psf, SFM_READ, psf->read_current) < 0)
1840 count = psf->read_short (psf, ptr, frames * psf->sf.channels) ;
1842 if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
1843 psf->read_current += count / psf->sf.channels ;
1845 { count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
1846 extra = frames * psf->sf.channels - count ;
1848 psf->read_current = psf->sf.frames ;
1851 psf->last_op = SFM_READ ;
1853 return count / psf->sf.channels ;
1861 { SF_PRIVATE *psf ;
1867 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
1870 { psf->error = SFE_NEGATIVE_RW_LEN ;
1874 if (psf->file.mode == SFM_WRITE)
1875 { psf->error = SFE_NOT_READMODE ;
1879 if (len % psf->sf.channels)
1880 { psf->error = SFE_BAD_READ_ALIGN ;
1884 if (psf->read_current >= psf->sf.frames)
1889 if (psf->read_int == NULL || psf->seek == NULL)
1890 { psf->error = SFE_UNIMPLEMENTED ;
1894 if (psf->last_op != SFM_READ)
1895 if (psf->seek (psf, SFM_READ, psf->read_current) < 0)
1898 count = psf->read_int (psf, ptr, len) ;
1900 if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
1901 psf->read_current += count / psf->sf.channels ;
1903 { count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
1906 psf->read_current = psf->sf.frames ;
1909 psf->last_op = SFM_READ ;
1916 { SF_PRIVATE *psf ;
1922 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
1925 { psf->error = SFE_NEGATIVE_RW_LEN ;
1929 if (psf->file.mode == SFM_WRITE)
1930 { psf->error = SFE_NOT_READMODE ;
1934 if (psf->read_current >= psf->sf.frames)
1935 { psf_memset (ptr, 0, frames * psf->sf.channels * sizeof (int)) ;
1939 if (psf->read_int == NULL || psf->seek == NULL)
1940 { psf->error = SFE_UNIMPLEMENTED ;
1944 if (psf->last_op != SFM_READ)
1945 if (psf->seek (psf, SFM_READ, psf->read_current) < 0)
1948 count = psf->read_int (psf, ptr, frames * psf->sf.channels) ;
1950 if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
1951 psf->read_current += count / psf->sf.channels ;
1953 { count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
1954 extra = frames * psf->sf.channels - count ;
1956 psf->read_current = psf->sf.frames ;
1959 psf->last_op = SFM_READ ;
1961 return count / psf->sf.channels ;
1969 { SF_PRIVATE *psf ;
1975 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
1978 { psf->error = SFE_NEGATIVE_RW_LEN ;
1982 if (psf->file.mode == SFM_WRITE)
1983 { psf->error = SFE_NOT_READMODE ;
1987 if (len % psf->sf.channels)
1988 { psf->error = SFE_BAD_READ_ALIGN ;
1992 if (psf->read_current >= psf->sf.frames)
1997 if (psf->read_float == NULL || psf->seek == NULL)
1998 { psf->error = SFE_UNIMPLEMENTED ;
2002 if (psf->last_op != SFM_READ)
2003 if (psf->seek (psf, SFM_READ, psf->read_current) < 0)
2006 count = psf->read_float (psf, ptr, len) ;
2008 if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
2009 psf->read_current += count / psf->sf.channels ;
2011 { count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
2014 psf->read_current = psf->sf.frames ;
2017 psf->last_op = SFM_READ ;
2024 { SF_PRIVATE *psf ;
2030 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
2033 { psf->error = SFE_NEGATIVE_RW_LEN ;
2037 if (psf->file.mode == SFM_WRITE)
2038 { psf->error = SFE_NOT_READMODE ;
2042 if (psf->read_current >= psf->sf.frames)
2043 { psf_memset (ptr, 0, frames * psf->sf.channels * sizeof (float)) ;
2047 if (psf->read_float == NULL || psf->seek == NULL)
2048 { psf->error = SFE_UNIMPLEMENTED ;
2052 if (psf->last_op != SFM_READ)
2053 if (psf->seek (psf, SFM_READ, psf->read_current) < 0)
2056 count = psf->read_float (psf, ptr, frames * psf->sf.channels) ;
2058 if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
2059 psf->read_current += count / psf->sf.channels ;
2061 { count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
2062 extra = frames * psf->sf.channels - count ;
2064 psf->read_current = psf->sf.frames ;
2067 psf->last_op = SFM_READ ;
2069 return count / psf->sf.channels ;
2077 { SF_PRIVATE *psf ;
2083 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
2086 { psf->error = SFE_NEGATIVE_RW_LEN ;
2090 if (psf->file.mode == SFM_WRITE)
2091 { psf->error = SFE_NOT_READMODE ;
2095 if (len % psf->sf.channels)
2096 { psf->error = SFE_BAD_READ_ALIGN ;
2100 if (psf->read_current >= psf->sf.frames)
2105 if (psf->read_double == NULL || psf->seek == NULL)
2106 { psf->error = SFE_UNIMPLEMENTED ;
2110 if (psf->last_op != SFM_READ)
2111 if (psf->seek (psf, SFM_READ, psf->read_current) < 0)
2114 count = psf->read_double (psf, ptr, len) ;
2116 if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
2117 psf->read_current += count / psf->sf.channels ;
2119 { count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
2122 psf->read_current = psf->sf.frames ;
2125 psf->last_op = SFM_READ ;
2132 { SF_PRIVATE *psf ;
2138 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
2141 { psf->error = SFE_NEGATIVE_RW_LEN ;
2145 if (psf->file.mode == SFM_WRITE)
2146 { psf->error = SFE_NOT_READMODE ;
2150 if (psf->read_current >= psf->sf.frames)
2151 { psf_memset (ptr, 0, frames * psf->sf.channels * sizeof (double)) ;
2155 if (psf->read_double == NULL || psf->seek == NULL)
2156 { psf->error = SFE_UNIMPLEMENTED ;
2160 if (psf->last_op != SFM_READ)
2161 if (psf->seek (psf, SFM_READ, psf->read_current) < 0)
2164 count = psf->read_double (psf, ptr, frames * psf->sf.channels) ;
2166 if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
2167 psf->read_current += count / psf->sf.channels ;
2169 { count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
2170 extra = frames * psf->sf.channels - count ;
2172 psf->read_current = psf->sf.frames ;
2175 psf->last_op = SFM_READ ;
2177 return count / psf->sf.channels ;
2185 { SF_PRIVATE *psf ;
2192 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
2195 { psf->error = SFE_NEGATIVE_RW_LEN ;
2199 bytewidth = (psf->bytewidth > 0) ? psf->bytewidth : 1 ;
2200 blockwidth = (psf->blockwidth > 0) ? psf->blockwidth : 1 ;
2202 if (psf->file.mode == SFM_READ)
2203 { psf->error = SFE_NOT_WRITEMODE ;
2207 if (len % (psf->sf.channels * bytewidth))
2208 { psf->error = SFE_BAD_WRITE_ALIGN ;
2212 if (psf->last_op != SFM_WRITE)
2213 if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0)
2216 if (psf->have_written == SF_FALSE && psf->write_header != NULL)
2217 { if ((psf->error = psf->write_header (psf, SF_FALSE)))
2220 psf->have_written = SF_TRUE ;
2222 count = psf_fwrite (ptr, 1, len, psf) ;
2224 psf->write_current += count / blockwidth ;
2226 psf->last_op = SFM_WRITE ;
2228 if (psf->write_current > psf->sf.frames)
2229 { psf->sf.frames = psf->write_current ;
2230 psf->dataend = 0 ;
2233 if (psf->auto_header && psf->write_header != NULL)
2234 psf->write_header (psf, SF_TRUE) ;
2244 { SF_PRIVATE *psf ;
2250 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
2253 { psf->error = SFE_NEGATIVE_RW_LEN ;
2257 if (psf->file.mode == SFM_READ)
2258 { psf->error = SFE_NOT_WRITEMODE ;
2262 if (len % psf->sf.channels)
2263 { psf->error = SFE_BAD_WRITE_ALIGN ;
2267 if (psf->write_short == NULL || psf->seek == NULL)
2268 { psf->error = SFE_UNIMPLEMENTED ;
2272 if (psf->last_op != SFM_WRITE)
2273 if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0)
2276 if (psf->have_written == SF_FALSE && psf->write_header != NULL)
2277 { if ((psf->error = psf->write_header (psf, SF_FALSE)))
2280 psf->have_written = SF_TRUE ;
2282 count = psf->write_short (psf, ptr, len) ;
2284 psf->write_current += count / psf->sf.channels ;
2286 psf->last_op = SFM_WRITE ;
2288 if (psf->write_current > psf->sf.frames)
2289 { psf->sf.frames = psf->write_current ;
2290 psf->dataend = 0 ;
2293 if (psf->auto_header && psf->write_header != NULL)
2294 psf->write_header (psf, SF_TRUE) ;
2301 { SF_PRIVATE *psf ;
2307 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
2310 { psf->error = SFE_NEGATIVE_RW_LEN ;
2314 if (psf->file.mode == SFM_READ)
2315 { psf->error = SFE_NOT_WRITEMODE ;
2319 if (psf->write_short == NULL || psf->seek == NULL)
2320 { psf->error = SFE_UNIMPLEMENTED ;
2324 if (psf->last_op != SFM_WRITE)
2325 if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0)
2328 if (psf->have_written == SF_FALSE && psf->write_header != NULL)
2329 { if ((psf->error = psf->write_header (psf, SF_FALSE)))
2332 psf->have_written = SF_TRUE ;
2334 count = psf->write_short (psf, ptr, frames * psf->sf.channels) ;
2336 psf->write_current += count / psf->sf.channels ;
2338 psf->last_op = SFM_WRITE ;
2340 if (psf->write_current > psf->sf.frames)
2341 { psf->sf.frames = psf->write_current ;
2342 psf->dataend = 0 ;
2345 if (psf->auto_header && psf->write_header != NULL)
2346 psf->write_header (psf, SF_TRUE) ;
2348 return count / psf->sf.channels ;
2356 { SF_PRIVATE *psf ;
2362 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
2365 { psf->error = SFE_NEGATIVE_RW_LEN ;
2369 if (psf->file.mode == SFM_READ)
2370 { psf->error = SFE_NOT_WRITEMODE ;
2374 if (len % psf->sf.channels)
2375 { psf->error = SFE_BAD_WRITE_ALIGN ;
2379 if (psf->write_int == NULL || psf->seek == NULL)
2380 { psf->error = SFE_UNIMPLEMENTED ;
2384 if (psf->last_op != SFM_WRITE)
2385 if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0)
2388 if (psf->have_written == SF_FALSE && psf->write_header != NULL)
2389 { if ((psf->error = psf->write_header (psf, SF_FALSE)))
2392 psf->have_written = SF_TRUE ;
2394 count = psf->write_int (psf, ptr, len) ;
2396 psf->write_current += count / psf->sf.channels ;
2398 psf->last_op = SFM_WRITE ;
2400 if (psf->write_current > psf->sf.frames)
2401 { psf->sf.frames = psf->write_current ;
2402 psf->dataend = 0 ;
2405 if (psf->auto_header && psf->write_header != NULL)
2406 psf->write_header (psf, SF_TRUE) ;
2413 { SF_PRIVATE *psf ;
2419 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
2422 { psf->error = SFE_NEGATIVE_RW_LEN ;
2426 if (psf->file.mode == SFM_READ)
2427 { psf->error = SFE_NOT_WRITEMODE ;
2431 if (psf->write_int == NULL || psf->seek == NULL)
2432 { psf->error = SFE_UNIMPLEMENTED ;
2436 if (psf->last_op != SFM_WRITE)
2437 if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0)
2440 if (psf->have_written == SF_FALSE && psf->write_header != NULL)
2441 { if ((psf->error = psf->write_header (psf, SF_FALSE)))
2444 psf->have_written = SF_TRUE ;
2446 count = psf->write_int (psf, ptr, frames * psf->sf.channels) ;
2448 psf->write_current += count / psf->sf.channels ;
2450 psf->last_op = SFM_WRITE ;
2452 if (psf->write_current > psf->sf.frames)
2453 { psf->sf.frames = psf->write_current ;
2454 psf->dataend = 0 ;
2457 if (psf->auto_header && psf->write_header != NULL)
2458 psf->write_header (psf, SF_TRUE) ;
2460 return count / psf->sf.channels ;
2468 { SF_PRIVATE *psf ;
2474 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
2477 { psf->error = SFE_NEGATIVE_RW_LEN ;
2481 if (psf->file.mode == SFM_READ)
2482 { psf->error = SFE_NOT_WRITEMODE ;
2486 if (len % psf->sf.channels)
2487 { psf->error = SFE_BAD_WRITE_ALIGN ;
2491 if (psf->write_float == NULL || psf->seek == NULL)
2492 { psf->error = SFE_UNIMPLEMENTED ;
2496 if (psf->last_op != SFM_WRITE)
2497 if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0)
2500 if (psf->have_written == SF_FALSE && psf->write_header != NULL)
2501 { if ((psf->error = psf->write_header (psf, SF_FALSE)))
2504 psf->have_written = SF_TRUE ;
2506 count = psf->write_float (psf, ptr, len) ;
2508 psf->write_current += count / psf->sf.channels ;
2510 psf->last_op = SFM_WRITE ;
2512 if (psf->write_current > psf->sf.frames)
2513 { psf->sf.frames = psf->write_current ;
2514 psf->dataend = 0 ;
2517 if (psf->auto_header && psf->write_header != NULL)
2518 psf->write_header (psf, SF_TRUE) ;
2525 { SF_PRIVATE *psf ;
2531 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
2534 { psf->error = SFE_NEGATIVE_RW_LEN ;
2538 if (psf->file.mode == SFM_READ)
2539 { psf->error = SFE_NOT_WRITEMODE ;
2543 if (psf->write_float == NULL || psf->seek == NULL)
2544 { psf->error = SFE_UNIMPLEMENTED ;
2548 if (psf->last_op != SFM_WRITE)
2549 if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0)
2552 if (psf->have_written == SF_FALSE && psf->write_header != NULL)
2553 { if ((psf->error = psf->write_header (psf, SF_FALSE)))
2556 psf->have_written = SF_TRUE ;
2558 count = psf->write_float (psf, ptr, frames * psf->sf.channels) ;
2560 psf->write_current += count / psf->sf.channels ;
2562 psf->last_op = SFM_WRITE ;
2564 if (psf->write_current > psf->sf.frames)
2565 { psf->sf.frames = psf->write_current ;
2566 psf->dataend = 0 ;
2569 if (psf->auto_header && psf->write_header != NULL)
2570 psf->write_header (psf, SF_TRUE) ;
2572 return count / psf->sf.channels ;
2580 { SF_PRIVATE *psf ;
2586 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
2589 { psf->error = SFE_NEGATIVE_RW_LEN ;
2593 if (psf->file.mode == SFM_READ)
2594 { psf->error = SFE_NOT_WRITEMODE ;
2598 if (len % psf->sf.channels)
2599 { psf->error = SFE_BAD_WRITE_ALIGN ;
2603 if (psf->write_double == NULL || psf->seek == NULL)
2604 { psf->error = SFE_UNIMPLEMENTED ;
2608 if (psf->last_op != SFM_WRITE)
2609 if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0)
2612 if (psf->have_written == SF_FALSE && psf->write_header != NULL)
2613 { if ((psf->error = psf->write_header (psf, SF_FALSE)))
2616 psf->have_written = SF_TRUE ;
2618 count = psf->write_double (psf, ptr, len) ;
2620 psf->write_current += count / psf->sf.channels ;
2622 psf->last_op = SFM_WRITE ;
2624 if (psf->write_current > psf->sf.frames)
2625 { psf->sf.frames = psf->write_current ;
2626 psf->dataend = 0 ;
2629 if (psf->auto_header && psf->write_header != NULL)
2630 psf->write_header (psf, SF_TRUE) ;
2637 { SF_PRIVATE *psf ;
2643 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
2646 { psf->error = SFE_NEGATIVE_RW_LEN ;
2650 if (psf->file.mode == SFM_READ)
2651 { psf->error = SFE_NOT_WRITEMODE ;
2655 if (psf->write_double == NULL || psf->seek == NULL)
2656 { psf->error = SFE_UNIMPLEMENTED ;
2660 if (psf->last_op != SFM_WRITE)
2661 if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0)
2664 if (psf->have_written == SF_FALSE && psf->write_header != NULL)
2665 { if ((psf->error = psf->write_header (psf, SF_FALSE)))
2668 psf->have_written = SF_TRUE ;
2670 count = psf->write_double (psf, ptr, frames * psf->sf.channels) ;
2672 psf->write_current += count / psf->sf.channels ;
2674 psf->last_op = SFM_WRITE ;
2676 if (psf->write_current > psf->sf.frames)
2677 { psf->sf.frames = psf->write_current ;
2678 psf->dataend = 0 ;
2681 if (psf->auto_header && psf->write_header != NULL)
2682 psf->write_header (psf, SF_TRUE) ;
2684 return count / psf->sf.channels ;
2692 try_resource_fork (SF_PRIVATE * psf)
2693 { int old_error = psf->error ;
2696 psf->rsrc.mode = SFM_READ ;
2697 if (psf_open_rsrc (psf) != 0)
2698 { psf->error = old_error ;
2703 psf_log_printf (psf, "Resource fork : %s\n", psf->rsrc.path) ;
2709 format_from_extension (SF_PRIVATE *psf)
2714 if ((cptr = strrchr (psf->file.name, '.')) == NULL)
2734 { psf->sf.channels = 1 ;
2735 psf->sf.samplerate = 8000 ;
2739 { psf->sf.channels = 1 ;
2740 psf->sf.samplerate = 8000 ;
2745 { psf->sf.channels = 1 ;
2746 psf->sf.samplerate = 8000 ;
2750 { psf->sf.channels = 1 ;
2751 psf->sf.samplerate = 6000 ;
2755 { psf->sf.channels = 1 ;
2756 psf->sf.samplerate = 8000 ;
2769 psf->dataoffset = 0 ;
2786 guess_file_type (SF_PRIVATE *psf)
2790 if (psf_binheader_readf (psf, "b", &buffer, SIGNED_SIZEOF (buffer)) != SIGNED_SIZEOF (buffer))
2791 { psf->error = SFE_BAD_FILE_READ ;
2874 if (buffer [2] == MAKE_MARKER (0, 2, 0, 0) && 2 * ((int64_t) BE2H_32 (buffer [0])) + 12 == psf->filelength)
2888 { psf_log_printf (psf, "Found 'ID3' marker.\n") ;
2889 if (id3_skip (psf))
2895 if (psf->id3_header.len > 0 && (format = identify_mpeg (buffer [0])) != 0)
2910 if (psf->filelength > 0 && (format = try_resource_fork (psf)) != 0)
2916 if (psf->id3_header.len == 0 && (format = identify_mpeg (buffer [0])) != 0)
2941 validate_psf (SF_PRIVATE *psf)
2943 if (psf->datalength < 0)
2944 { psf_log_printf (psf, "Invalid SF_PRIVATE field : datalength == %D.\n", psf->datalength) ;
2947 if (psf->dataoffset < 0)
2948 { psf_log_printf (psf, "Invalid SF_PRIVATE field : dataoffset == %D.\n", psf->dataoffset) ;
2951 if (psf->blockwidth && psf->blockwidth != psf->sf.channels * psf->bytewidth)
2952 { psf_log_printf (psf, "Invalid SF_PRIVATE field : channels * bytewidth == %d.\n",
2953 psf->sf.channels * psf->bytewidth) ;
2960 save_header_info (SF_PRIVATE *psf)
2961 { snprintf (sf_parselog, sizeof (sf_parselog), "%s", psf->parselog.buf) ;
2968 psf_close (SF_PRIVATE *psf)
2972 if (psf->codec_close)
2973 { error = psf->codec_close (psf) ;
2974 /* To prevent it being called in psf->container_close(). */
2975 psf->codec_close = NULL ;
2978 if (psf->container_close)
2979 error = psf->container_close (psf) ;
2981 error = psf_fclose (psf) ;
2982 psf_close_rsrc (psf) ;
2985 free (psf->header.ptr) ;
2986 free (psf->container_data) ;
2987 free (psf->codec_data) ;
2988 free (psf->interleave) ;
2989 free (psf->dither) ;
2990 free (psf->peak_info) ;
2991 free (psf->broadcast_16k) ;
2992 free (psf->loop_info) ;
2993 free (psf->instrument) ;
2994 free (psf->cues) ;
2995 free (psf->channel_map) ;
2996 free (psf->format_desc) ;
2997 free (psf->strings.storage) ;
2999 if (psf->wchunks.chunks)
3000 for (k = 0 ; k < psf->wchunks.used ; k++)
3001 free (psf->wchunks.chunks [k].data) ;
3002 free (psf->rchunks.chunks) ;
3003 free (psf->wchunks.chunks) ;
3004 free (psf->iterator) ;
3005 free (psf->cart_16k) ;
3007 free (psf) ;
3013 psf_open_file (SF_PRIVATE *psf, SF_INFO *sfinfo)
3019 if (psf->error)
3020 { error = psf->error ;
3024 if (psf->file.mode != SFM_READ && psf->file.mode != SFM_WRITE && psf->file.mode != SFM_RDWR)
3034 if (psf->file.mode == SFM_READ)
3045 memcpy (&psf->sf, sfinfo, sizeof (SF_INFO)) ;
3047 psf->Magick = SNDFILE_MAGICK ;
3048 psf->norm_float = SF_TRUE ;
3049 psf->norm_double = SF_TRUE ;
3050 psf->dataoffset = -1 ;
3051 psf->datalength = -1 ;
3052 psf->read_current = -1 ;
3053 psf->write_current = -1 ;
3054 psf->auto_header = SF_FALSE ;
3055 psf->rwf_endian = SF_ENDIAN_LITTLE ;
3056 psf->seek = psf_default_seek ;
3057 psf->float_int_mult = 0 ;
3058 psf->float_max = -1.0 ;
3061 psf->unique_id = psf_rand_int32 () ;
3063 psf->sf.sections = 1 ;
3065 psf->is_pipe = psf_is_pipe (psf) ;
3067 if (psf->is_pipe)
3068 { psf->sf.seekable = SF_FALSE ;
3069 psf->filelength = SF_COUNT_MAX ;
3072 { psf->sf.seekable = SF_TRUE ;
3075 psf->filelength = psf_get_filelen (psf) ;
3078 if (psf->fileoffset > 0)
3079 { switch (psf->file.mode)
3081 if (psf->filelength < 44)
3082 { psf_log_printf (psf, "Short filelength: %D (fileoffset: %D)\n", psf->filelength, psf->fileoffset) ;
3089 psf->fileoffset = 0 ;
3090 psf_fseek (psf, 0, SEEK_END) ;
3091 psf->fileoffset = psf_ftell (psf) ;
3099 psf_log_printf (psf, "Embedded file offset : %D\n", psf->fileoffset) ;
3102 if (psf->filelength == SF_COUNT_MAX)
3103 psf_log_printf (psf, "Length : unknown\n") ;
3105 psf_log_printf (psf, "Length : %D\n", psf->filelength) ;
3107 if (psf->file.mode == SFM_WRITE || (psf->file.mode == SFM_RDWR && psf->filelength == 0))
3111 if ((SF_CONTAINER (psf->sf.format)) == 0)
3115 if ((SF_CODEC (psf->sf.format)) == 0)
3120 if (sf_format_check (&psf->sf) == 0)
3125 else if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_RAW)
3127 psf->sf.format = guess_file_type (psf) ;
3129 if (psf->sf.format == 0)
3130 psf->sf.format = format_from_extension (psf) ;
3134 psf->last_op = psf->file.mode ;
3137 switch (SF_CODEC (psf->sf.format))
3143 psf->bytewidth = 1 ;
3148 psf->bytewidth = 2 ;
3152 psf->bytewidth = 3 ;
3157 psf->bytewidth = 4 ;
3161 psf->bytewidth = 8 ;
3166 switch (SF_CONTAINER (psf->sf.format))
3169 error = wav_open (psf) ;
3173 error = aiff_open (psf) ;
3177 error = au_open (psf) ;
3181 error = raw_open (psf) ;
3185 error = w64_open (psf) ;
3189 error = rf64_open (psf) ;
3194 error = paf_open (psf) ;
3198 error = svx_open (psf) ;
3202 error = nist_open (psf) ;
3206 error = ircam_open (psf) ;
3210 error = voc_open (psf) ;
3214 error = sds_open (psf) ;
3218 error = ogg_open (psf) ;
3222 error = txw_open (psf) ;
3226 error = wve_open (psf) ;
3230 error = dwd_open (psf) ;
3234 error = mat4_open (psf) ;
3238 error = mat5_open (psf) ;
3242 error = pvf_open (psf) ;
3246 error = xi_open (psf) ;
3250 error = htk_open (psf) ;
3254 error = sd2_open (psf) ;
3258 error = rx2_open (psf) ;
3262 error = avr_open (psf) ;
3266 error = flac_open (psf) ;
3270 error = caf_open (psf) ;
3274 error = mpc2k_open (psf) ;
3278 error = mpeg_open (psf) ;
3291 format = SF_CONTAINER (psf->sf.format) ;
3292 if (psf->fileoffset > 0)
3312 if (psf->fileoffset > 0)
3313 psf_log_printf (psf, "Embedded file length : %D\n", psf->filelength) ;
3315 if (psf->file.mode == SFM_RDWR && sf_format_check (&psf->sf) == 0)
3320 if (validate_sfinfo (&psf->sf) == 0)
3321 { psf_log_SF_INFO (psf) ;
3322 save_header_info (psf) ;
3327 if (validate_psf (psf) == 0)
3328 { save_header_info (psf) ;
3333 psf->read_current = 0 ;
3334 psf->write_current = 0 ;
3335 if (psf->file.mode == SFM_RDWR)
3336 { psf->write_current = psf->sf.frames ;
3337 psf->have_written = psf->sf.frames > 0 ? SF_TRUE : SF_FALSE ;
3340 memcpy (sfinfo, &psf->sf, sizeof (SF_INFO)) ;
3342 if (psf->file.mode == SFM_WRITE)
3349 return (SNDFILE *) psf ;
3355 snprintf (sf_syserr, sizeof (sf_syserr), "%s", psf->syserr) ;
3356 snprintf (sf_parselog, sizeof (sf_parselog), "%s", psf->parselog.buf) ;
3368 if (psf->file.mode == SFM_READ)
3369 { psf_log_printf (psf, "Parse error : %s\n", sf_error_number (error)) ;
3374 psf_close (psf) ;
3386 { SF_PRIVATE *psf ;
3388 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
3393 if (psf->set_chunk)
3394 return psf->set_chunk (psf, chunk_info) ;
3401 { SF_PRIVATE *psf ;
3403 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
3406 return psf_get_chunk_iterator (psf, chunk_info->id) ;
3408 return psf_get_chunk_iterator (psf, NULL) ;
3413 { SF_PRIVATE *psf ;
3416 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
3418 if (psf->next_chunk_iterator)
3419 return psf->next_chunk_iterator (psf, iterator) ;
3426 { SF_PRIVATE *psf ;
3429 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
3434 if (psf->get_chunk_size)
3435 return psf->get_chunk_size (psf, iterator, chunk_info) ;
3442 { SF_PRIVATE *psf ;
3445 VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
3450 if (psf->get_chunk_data)
3451 return psf->get_chunk_data (psf, iterator, chunk_info) ;