mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 01:26:58 +00:00
FS-4657 --resolve update libsndfile to its latest master
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -54,12 +54,12 @@ int
|
||||
nist_open (SF_PRIVATE *psf)
|
||||
{ int error ;
|
||||
|
||||
if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
|
||||
if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0))
|
||||
{ if ((error = nist_read_header (psf)))
|
||||
return error ;
|
||||
} ;
|
||||
|
||||
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
|
||||
if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
|
||||
{ if (psf->is_pipe)
|
||||
return SFE_NO_PIPE_WRITE ;
|
||||
|
||||
@@ -118,15 +118,12 @@ static char bad_header [] =
|
||||
|
||||
static int
|
||||
nist_read_header (SF_PRIVATE *psf)
|
||||
{ char *psf_header ;
|
||||
int bitwidth = 0, bytes = 0, count, encoding ;
|
||||
{ char psf_header [NIST_HEADER_LENGTH + 2] ;
|
||||
int bitwidth = 0, count, encoding ;
|
||||
unsigned bytes = 0 ;
|
||||
char str [64], *cptr ;
|
||||
long samples ;
|
||||
|
||||
psf->sf.format = SF_FORMAT_NIST ;
|
||||
|
||||
psf_header = psf->u.cbuf ;
|
||||
|
||||
if (sizeof (psf->header) <= NIST_HEADER_LENGTH)
|
||||
return SFE_INTERNAL ;
|
||||
|
||||
@@ -164,7 +161,9 @@ nist_read_header (SF_PRIVATE *psf)
|
||||
{ sscanf (cptr, "sample_coding -s%d %63s", &count, str) ;
|
||||
|
||||
if (strcmp (str, "pcm") == 0)
|
||||
{ /* Correct this later when we find out the bitwidth. */
|
||||
encoding = SF_FORMAT_PCM_U8 ;
|
||||
}
|
||||
else if (strcmp (str, "alaw") == 0)
|
||||
encoding = SF_FORMAT_ALAW ;
|
||||
else if ((strcmp (str, "ulaw") == 0) || (strcmp (str, "mu-law") == 0))
|
||||
@@ -193,19 +192,23 @@ nist_read_header (SF_PRIVATE *psf)
|
||||
psf->endian = (CPU_IS_BIG_ENDIAN) ? SF_ENDIAN_BIG : SF_ENDIAN_LITTLE ;
|
||||
|
||||
/* This is where we figure out endian-ness. */
|
||||
if ((cptr = strstr (psf_header, "sample_byte_format -s")))
|
||||
{ sscanf (cptr, "sample_byte_format -s%d %8s", &bytes, str) ;
|
||||
if ((cptr = strstr (psf_header, "sample_byte_format -s"))
|
||||
&& sscanf (cptr, "sample_byte_format -s%u %8s", &bytes, str) == 2)
|
||||
{
|
||||
if (bytes != strlen (str))
|
||||
psf_log_printf (psf, "Weird sample_byte_format : strlen '%s' != %d\n", str, bytes) ;
|
||||
|
||||
if (bytes > 1)
|
||||
{ if (psf->bytewidth == 0)
|
||||
psf->bytewidth = bytes ;
|
||||
else if (psf->bytewidth != bytes)
|
||||
else if (psf->bytewidth - bytes != 0)
|
||||
{ psf_log_printf (psf, "psf->bytewidth (%d) != bytes (%d)\n", psf->bytewidth, bytes) ;
|
||||
return SFE_NIST_BAD_ENCODING ;
|
||||
} ;
|
||||
|
||||
if (strstr (str, "01") == str)
|
||||
if (strcmp (str, "01") == 0)
|
||||
psf->endian = SF_ENDIAN_LITTLE ;
|
||||
else if (strstr (str, "10"))
|
||||
else if (strcmp (str, "10") == 0)
|
||||
psf->endian = SF_ENDIAN_BIG ;
|
||||
else
|
||||
{ psf_log_printf (psf, "Weird endian-ness : %s\n", str) ;
|
||||
@@ -255,13 +258,26 @@ nist_read_header (SF_PRIVATE *psf)
|
||||
else
|
||||
return SFE_UNIMPLEMENTED ;
|
||||
|
||||
/* Sanitize psf->sf.format. */
|
||||
switch (SF_CODEC (psf->sf.format))
|
||||
{ case SF_FORMAT_ULAW :
|
||||
case SF_FORMAT_ALAW :
|
||||
case SF_FORMAT_PCM_U8 :
|
||||
/* Blank out endian bits. */
|
||||
psf->sf.format = SF_FORMAT_NIST | SF_CODEC (psf->sf.format) ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
break ;
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
} /* nist_read_header */
|
||||
|
||||
static int
|
||||
nist_close (SF_PRIVATE *psf)
|
||||
{
|
||||
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
|
||||
if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
|
||||
nist_write_header (psf, SF_TRUE) ;
|
||||
|
||||
return 0 ;
|
||||
|
Reference in New Issue
Block a user