Changeset 20ce2ad


Ignore:
Timestamp:
Dec 18, 2018, 1:07:13 AM (12 months ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink
Children:
0da5208
Parents:
d286fe4
Message:

[utils] move string routines to strutils.c

Location:
src
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/sink.c

    rd286fe4 r20ce2ad  
    5454};
    5555
     56extern uint_t aubio_str_path_has_extension(const char_t *filename,
     57    const char_t *pattern);
     58
    5659#ifdef HAVE_VORBISENC
    5760typedef struct _aubio_sink_vorbis_t aubio_sink_vorbis_t;
     
    9295#endif /* HAVE_FLAC */
    9396
    94 static const char_t *aubio_get_extension(const char_t *filename)
    95 {
    96   if (!filename) return NULL;
    97   // find last occurence of dot character
    98   const char_t *ext = strrchr(filename, '.');
    99   if (!ext || ext == filename) return "";
    100   else return ext + 1;
    101 }
    102 
    10397aubio_sink_t * new_aubio_sink(const char_t * uri, uint_t samplerate) {
    10498  aubio_sink_t * s = AUBIO_NEW(aubio_sink_t);
    105 #if defined(HAVE_VORBISENC) || defined(HAVE_FLAC)
    106   const char_t * uri_ext = aubio_get_extension(uri);
    107 #endif /* defined(HAVE_VORBISENC) || defined(HAVE_FLAC) */
    10899
    109100#ifdef HAVE_VORBISENC
    110101  // check if this uri could be for us
    111   uint_t match_oggstream = 0;
    112   if (uri_ext && strcmp (uri_ext, "ogg") == 0) match_oggstream = 1;
    113   if (match_oggstream) {
     102  if (aubio_str_path_has_extension(uri, "ogg")) {
    114103    s->sink = (void *)new_aubio_sink_vorbis(uri, samplerate);
    115104    if (s->sink) {
     
    129118#ifdef HAVE_FLAC
    130119  // check if this uri could be for us
    131   uint_t match_flacstream = 0;
    132   if (uri_ext && strcmp (uri_ext, "flac") == 0) match_flacstream = 1;
    133   if (match_flacstream) {
     120  if (aubio_str_path_has_extension(uri, "flac")) {
    134121    s->sink = (void *)new_aubio_sink_flac(uri, samplerate);
    135122    if (s->sink) {
Note: See TracChangeset for help on using the changeset viewer.