Changeset 3119:9632a77b5f46 in roaraudio for libroar/vio_tantalos.c


Ignore:
Timestamp:
01/12/10 11:57:50 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

cache slp matches for tantalos

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/vio_tantalos.c

    r3117 r3119  
    3737#define _LEN 1024 
    3838 
     39static struct roar_slp_cookie * roar_vio_open_get_cookie (int reinit) { 
     40 static struct roar_slp_cookie   cookie; 
     41 static int inited = 0; 
     42 
     43 if ( !inited ) { 
     44  if ( roar_slp_cookie_init(&cookie, NULL) == -1 ) 
     45   return NULL; 
     46  inited++; 
     47 } 
     48 
     49 return &cookie; 
     50} 
     51 
    3952int     roar_vio_open_tantalos    (struct roar_vio_calls * calls, struct roar_vio_calls * dst, 
    4053                                   char * key, struct roar_vio_defaults * odef) { 
    4154#ifdef ROAR_HAVE_LIBSLP 
    42  struct roar_slp_cookie   cookie; 
     55 struct roar_slp_cookie * cookie; 
    4356 char url[_LEN]; 
    4457 int i; 
     58 int need_search = 0; 
     59 time_t now = time(NULL); 
    4560 
    46  if ( roar_slp_cookie_init(&cookie, NULL) == -1 ) 
     61 if ( (cookie = roar_vio_open_get_cookie(0)) == NULL ) 
    4762  return -1; 
    4863 
    49  if ( roar_slp_search(&cookie, ROAR_SLP_URL_TYPE_DOWNLOAD_HTTP) == -1 ) 
    50   return -1; 
     64 if ( cookie->matchcount == 0 ) { 
     65  need_search++; 
     66 } else { 
     67  for (i = 0; i < cookie->matchcount; i++) { 
     68   if ( cookie->match[i].tod < now ) { 
     69    need_search++; 
     70   } 
     71  } 
     72 } 
    5173 
    52  for (i = 0; i < cookie.matchcount; i++) { 
    53   strncpy(url, cookie.match[i].url + ROAR_SLP_URL_TYPE_DOWNLOAD_HTTP_LEN - 4, _LEN); 
     74 if ( need_search ) { 
     75  if ( (cookie = roar_vio_open_get_cookie(1)) == NULL ) 
     76   return -1; 
     77  if ( roar_slp_search(cookie, ROAR_SLP_URL_TYPE_DOWNLOAD_HTTP) == -1 ) 
     78   return -1; 
     79 } 
     80 
     81 for (i = 0; i < cookie->matchcount; i++) { 
     82  strncpy(url, cookie->match[i].url + ROAR_SLP_URL_TYPE_DOWNLOAD_HTTP_LEN - 4, _LEN); 
    5483  strcat(url, key); 
    5584 
Note: See TracChangeset for help on using the changeset viewer.