Ignore:
Timestamp:
Mar 12, 2017, 2:23:33 PM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
sampler
Children:
618ebd5
Parents:
4ac4ebc
Message:

src/io/source_avcodec.c: set a longer timeout when opening urls

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/source_avcodec.c

    r4ac4ebc r91ad284  
    7676  uint_t eof;
    7777  uint_t multi;
     78  uint_t has_network_url;
    7879};
    7980
     
    9091  av_url_split(proto, proto_size, authorization, authorization_size, hostname,
    9192      hostname_size, port_ptr, uripath, path_size, s->path);
     93  s->has_network_url = 0;
    9294  if (strlen(proto)) {
    93     return 1;
    94   }
    95   return 0;
     95    s->has_network_url = 1;
     96  }
     97  return s->has_network_url;
    9698}
    9799
     
    129131  // try opening the file and get some info about it
    130132  AVFormatContext *avFormatCtx = s->avFormatCtx;
     133  AVDictionary *streamopts = 0;
     134  if (s->has_network_url) {
     135    if (av_dict_set(&streamopts, "timeout", "1000000", 0)) { // in microseconds
     136      AUBIO_WRN("source_avcodec: Failed setting timeout to 1000000 for %s\n", s->path);
     137    } else {
     138      AUBIO_WRN("source_avcodec: Setting timeout to 1000000 for %s\n", s->path);
     139    }
     140  }
    131141  avFormatCtx = NULL;
    132   if ( (err = avformat_open_input(&avFormatCtx, s->path, NULL, NULL) ) < 0 ) {
     142  if ( (err = avformat_open_input(&avFormatCtx, s->path, NULL, &streamopts) ) < 0 ) {
    133143    char errorstr[256];
    134144    av_strerror (err, errorstr, sizeof(errorstr));
    135145    AUBIO_ERR("source_avcodec: Failed opening %s (%s)\n", s->path, errorstr);
    136     goto beach;
     146    goto beach_streamopts;
    137147  }
    138148
     
    262272  //av_log_set_level(AV_LOG_QUIET);
    263273
     274  av_dict_free(&streamopts);
    264275  return s;
    265276
     277beach_streamopts:
     278  av_dict_free(&streamopts);
    266279beach:
    267280  //AUBIO_ERR("can not read %s at samplerate %dHz with a hop_size of %d\n",
Note: See TracChangeset for help on using the changeset viewer.