Changeset 4656:5a99c25bbb0d in roaraudio
- Timestamp:
- 12/12/10 20:49:45 (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roarclients/roarvorbis.c
r4014 r4656 55 55 56 56 #ifdef ROAR_HAVE_LIBVORBISFILE 57 FILE * open_http (char * file) { 58 #ifdef ROAR_HAVE_BIN_WGET 59 char cmd[1024]; 60 61 snprintf(cmd, 1023, ROAR_HAVE_BIN_WGET " -qO - '%s'", file); 62 63 return popen(cmd, "r"); 64 #else 65 return NULL; 66 #endif 67 } 57 int _g_cf_vorbis_vfvio_return_err (void) { 58 return -1; 59 } 60 61 size_t cf_vorbis_vfvio_read (void *ptr, size_t size, size_t nmemb, void *datasource) { 62 ssize_t r; 63 64 r = roar_vio_read(datasource, ptr, size*nmemb); 65 66 ROAR_DBG("cf_vorbis_vfvio_read(ptr=%p, size=%lu, nmemb=%lu, datasource=%p): r=%i", ptr, size, nmemb, datasource, r); 67 68 if ( r == -1 ) 69 return 0; 70 71 if ( r > 0 ) 72 errno = 0; 73 74 r /= size; 75 76 ROAR_DBG("cf_vorbis_vfvio_read(ptr=%p, size=%lu, nmemb=%lu, datasource=%p) = %i", ptr, size, nmemb, datasource, r); 77 return r; 78 } 79 80 81 ov_callbacks _g_cf_vorbis_vfvio = { 82 .read_func = cf_vorbis_vfvio_read, 83 .seek_func = (int (*)(void *, ogg_int64_t, int )) _g_cf_vorbis_vfvio_return_err, 84 .close_func = (int (*)(void * )) _g_cf_vorbis_vfvio_return_err, 85 .tell_func = (long (*)(void * )) _g_cf_vorbis_vfvio_return_err 86 }; 87 68 88 69 89 int update_stream (struct roar_connection * con, … … 193 213 return 1; 194 214 #else 195 struct roar_vio_calls vclt ;215 struct roar_vio_calls vclt, in; 196 216 struct roar_vio_defaults def; 197 217 char * server = NULL; … … 200 220 char * k; 201 221 int i; 202 FILE * in;203 222 struct roar_connection con; 204 223 struct roar_stream s; … … 238 257 } 239 258 259 if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_RDONLY, 0644) == -1 ) 260 return 1; 261 262 if ( roar_vio_open_dstr(&in, file, &def, 1) == -1 ) { 263 fprintf(stderr, "Error: can not open file: %s: %s\n", file, strerror(errno)); 264 return 1; 265 } 266 240 267 if ( roar_simple_connect(&con, server, "roarvorbis") == -1 ) { 241 268 ROAR_DBG("roar_simple_play(*): roar_simple_connect() faild!"); 242 return 1; 243 } 244 245 if ( strncmp(file, "http:", 5) == 0 ) { 246 in = open_http(file); 247 } else { 248 in = fopen(file, "rb"); 249 } 250 251 if ( in == NULL ) { 252 roar_disconnect(&con); 253 fclose(in); 254 return 1; 255 } 256 257 #ifdef _WIN32 258 _setmode(_fileno(in), _O_BINARY); 259 #endif 260 261 if( ov_open(in, &vf, NULL, 0) < 0 ) { 269 roar_vio_close(&in); 270 return 1; 271 } 272 273 if ( ov_open_callbacks((void*)&in, &vf, NULL, 0, _g_cf_vorbis_vfvio) < 0 ) { 274 // if( ov_open(in, &vf, NULL, 0) < 0 ) { 262 275 fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n"); 263 276 roar_disconnect(&con); 264 fclose(in);277 roar_vio_close(&in); 265 278 return 1; 266 279 } … … 271 284 if ( roar_vio_open_dstr(&vclt, vcltfile, &def, 1) == -1 ) { 272 285 fprintf(stderr, "Error: can not open file: %s: %s\n", k, strerror(errno)); 273 fclose(in); 286 roar_disconnect(&con); 287 roar_vio_close(&in); 274 288 return 1; 275 289 } … … 284 298 if ( last_section != current_section ) 285 299 if ( update_stream(&con, &s, &vio, &vf, file, &info, vcltfile == NULL ? NULL : &vclt) == -1 ) { 286 fclose(in); 300 roar_vio_close(&in); 301 if ( vcltfile != NULL ) 302 roar_vio_close(&vclt); 287 303 return 1; 288 304 } … … 307 323 roar_disconnect(&con); 308 324 309 if ( vcltfile != NULL ) {325 if ( vcltfile != NULL ) 310 326 roar_vio_close(&vclt); 311 } 312 313 fclose(in); 327 328 roar_vio_close(&in); 314 329 315 330 return 0;
Note: See TracChangeset
for help on using the changeset viewer.