Changeset 67:9c8c096465ad in roaraudio


Ignore:
Timestamp:
07/12/08 13:49:47 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added basic most-time-it-should-work RIFF/WAVE support to sources.c

Location:
roard
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • roard/include/sources.h

    r65 r67  
    1515int sources_add (char * driver, char * device, char * container, char * options, int primary); 
    1616 
    17 int sources_add_raw (char * driver, char * device, char * container, char * options, int primary); 
     17int sources_add_raw  (char * driver, char * device, char * container, char * options, int primary); 
     18int sources_add_wav  (char * driver, char * device, char * container, char * options, int primary); 
    1819 
    1920#endif 
  • roard/sources.c

    r65 r67  
    2222 
    2323int sources_add (char * driver, char * device, char * container, char * options, int primary) { 
    24  if ( strcmp(driver, "raw") == 0 ) 
     24 if ( strcmp(driver, "raw") == 0 ) { 
    2525  return sources_add_raw(driver, device, container, options, primary); 
     26 } else if ( strcmp(driver, "wav") == 0 ) { 
     27  return sources_add_wav(driver, device, container, options, primary); 
     28 } 
    2629 
    2730 return -1; 
     
    5659} 
    5760 
     61int sources_add_wav (char * driver, char * device, char * container, char * options, int primary) { 
     62 int stream; 
     63 int fh; 
     64 char buf[44]; 
     65 struct roar_stream * s; 
     66 
     67 if ( (fh = open(device, O_RDONLY, 0644)) == -1 ) { 
     68  return -1; 
     69 } 
     70 
     71 if (read(fh, buf, 44) != 44) { 
     72  close(fh); 
     73  return -1; 
     74 } 
     75 
     76 if ( (stream = streams_new()) == -1 ) { 
     77  close(fh); 
     78  return -1; 
     79 } 
     80 
     81 streams_get(stream, (struct roar_stream_server **)&s); 
     82 
     83 memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info)); 
     84 
     85  memcpy(&(s->info.rate    ), buf+24, 4); 
     86  memcpy(&(s->info.channels), buf+22, 2); 
     87  memcpy(&(s->info.bits    ), buf+34, 2); 
     88 
     89 s->dir        = ROAR_DIR_PLAY; 
     90 s->pos_rel_id = -1; 
     91 
     92 streams_set_fh(stream, fh); 
     93 
     94 client_stream_add(g_source_client, stream); 
     95 
     96 return 0; 
     97} 
    5898//ll 
Note: See TracChangeset for help on using the changeset viewer.