decoder/flac: merged code into flac_decoder_new()
Convenience wrapper for FLAC__stream_decoder_new() and FLAC__stream_decoder_set_metadata_respond().
This commit is contained in:
parent
4a8cc87b4d
commit
a3f5284dc6
@ -371,6 +371,26 @@ flac_tag_dup(const char *file)
|
|||||||
return flac_tag_load(file, NULL);
|
return flac_tag_load(file, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some glue code around FLAC__stream_decoder_new().
|
||||||
|
*/
|
||||||
|
static FLAC__StreamDecoder *
|
||||||
|
flac_decoder_new(void)
|
||||||
|
{
|
||||||
|
FLAC__StreamDecoder *sd = FLAC__stream_decoder_new();
|
||||||
|
if (sd == NULL) {
|
||||||
|
g_warning("FLAC__stream_decoder_new() failed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
|
||||||
|
if(!FLAC__stream_decoder_set_metadata_respond(sd, FLAC__METADATA_TYPE_VORBIS_COMMENT))
|
||||||
|
g_debug("FLAC__stream_decoder_set_metadata_respond() has failed");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return sd;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
|
flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
|
||||||
FLAC__uint64 t_start, FLAC__uint64 t_end)
|
FLAC__uint64 t_start, FLAC__uint64 t_end)
|
||||||
@ -431,18 +451,13 @@ flac_decode_internal(struct decoder * decoder,
|
|||||||
struct flac_data data;
|
struct flac_data data;
|
||||||
const char *err = NULL;
|
const char *err = NULL;
|
||||||
|
|
||||||
if (!(flac_dec = FLAC__stream_decoder_new()))
|
flac_dec = flac_decoder_new();
|
||||||
|
if (flac_dec == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
flac_data_init(&data, decoder, input_stream);
|
flac_data_init(&data, decoder, input_stream);
|
||||||
data.tag = tag_new();
|
data.tag = tag_new();
|
||||||
|
|
||||||
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
|
|
||||||
if(!FLAC__stream_decoder_set_metadata_respond(flac_dec, FLAC__METADATA_TYPE_VORBIS_COMMENT))
|
|
||||||
{
|
|
||||||
g_debug("Failed to set metadata respond\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (is_ogg) {
|
if (is_ogg) {
|
||||||
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
|
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
|
||||||
FLAC__StreamDecoderInitStatus status =
|
FLAC__StreamDecoderInitStatus status =
|
||||||
@ -564,21 +579,12 @@ flac_container_decode(struct decoder* decoder,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(flac_dec = FLAC__stream_decoder_new()))
|
flac_dec = flac_decoder_new();
|
||||||
{
|
if (flac_dec == NULL)
|
||||||
g_free(pathname);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
flac_data_init(&data, decoder, NULL);
|
flac_data_init(&data, decoder, NULL);
|
||||||
|
|
||||||
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
|
|
||||||
if(!FLAC__stream_decoder_set_metadata_respond(flac_dec, FLAC__METADATA_TYPE_VORBIS_COMMENT))
|
|
||||||
{
|
|
||||||
g_debug("Failed to set metadata respond\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
init_status = is_ogg
|
init_status = is_ogg
|
||||||
? FLAC__stream_decoder_init_ogg_file(flac_dec, pathname,
|
? FLAC__stream_decoder_init_ogg_file(flac_dec, pathname,
|
||||||
flac_write_cb,
|
flac_write_cb,
|
||||||
@ -645,19 +651,12 @@ flac_filedecode_internal(struct decoder* decoder,
|
|||||||
const char *err = NULL;
|
const char *err = NULL;
|
||||||
unsigned int flac_err_state = 0;
|
unsigned int flac_err_state = 0;
|
||||||
|
|
||||||
if (!(flac_dec = FLAC__stream_decoder_new()))
|
flac_dec = flac_decoder_new();
|
||||||
|
if (flac_dec == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
flac_data_init(&data, decoder, NULL);
|
flac_data_init(&data, decoder, NULL);
|
||||||
|
|
||||||
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
|
|
||||||
if(!FLAC__stream_decoder_set_metadata_respond(flac_dec, FLAC__METADATA_TYPE_VORBIS_COMMENT))
|
|
||||||
{
|
|
||||||
g_debug("Failed to set metadata respond\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
if (is_ogg)
|
if (is_ogg)
|
||||||
{
|
{
|
||||||
if ( (flac_err_state = FLAC__stream_decoder_init_ogg_file( flac_dec,
|
if ( (flac_err_state = FLAC__stream_decoder_init_ogg_file( flac_dec,
|
||||||
|
Loading…
Reference in New Issue
Block a user