Added cues to sndfile

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
This commit is contained in:
Lars Palo 2016-04-01 12:58:49 +02:00 committed by Erik de Castro Lopo
parent 0dae66a5e3
commit 3500ad97a9
2 changed files with 49 additions and 0 deletions

View File

@ -1235,6 +1235,33 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
} ;
return cart_var_get (psf, data, datasize) ;
case SFC_GET_CUE :
if (datasize != sizeof (SF_CUES) || data == NULL)
{ psf->error = SFE_BAD_COMMAND_PARAM ;
return SF_FALSE ;
} ;
if (psf->cues == NULL)
return SF_FALSE ;
memcpy (data, psf->cues, sizeof (SF_CUES)) ;
return SF_TRUE ;
case SFC_SET_CUE :
if (psf->have_written)
{ psf->error = SFE_CMD_HAS_DATA ;
return SF_FALSE ;
} ;
if (datasize != sizeof (SF_CUES) || data == NULL)
{ psf->error = SFE_BAD_COMMAND_PARAM ;
return SF_FALSE ;
} ;
if (psf->cues == NULL && (psf->cues = psf_cues_alloc ()) == NULL)
{ psf->error = SFE_MALLOC_FAILED ;
return SF_FALSE ;
} ;
memcpy (psf->cues, data, sizeof (SF_CUES)) ;
return SF_TRUE ;
case SFC_GET_INSTRUMENT :
if (datasize != sizeof (SF_INSTRUMENT) || data == NULL)
{ psf->error = SFE_BAD_COMMAND_PARAM ;
@ -2659,6 +2686,7 @@ psf_close (SF_PRIVATE *psf)
free (psf->broadcast_16k) ;
free (psf->loop_info) ;
free (psf->instrument) ;
free (psf->cues) ;
free (psf->channel_map) ;
free (psf->format_desc) ;
free (psf->strings.storage) ;

View File

@ -180,6 +180,9 @@ enum
SFC_SET_CLIPPING = 0x10C0,
SFC_GET_CLIPPING = 0x10C1,
SFC_GET_CUE = 0x10CE,
SFC_SET_CUE = 0x10CF,
SFC_GET_INSTRUMENT = 0x10D0,
SFC_SET_INSTRUMENT = 0x10D1,
@ -401,6 +404,24 @@ typedef struct
sf_count_t length ;
} SF_EMBED_FILE_INFO ;
/*
** Struct used to retrieve cue marker information from a file
*/
typedef struct
{ int cue_count;
struct
{ int dwName;
unsigned int dwPosition;
int fccChunk;
int dwChunkStart;
int dwBlockStart;
unsigned int dwSampleOffset;
char name[256];
} cue_points[100];
} SF_CUES ;
/*
** Structs used to retrieve music sample information from a file.
*/