Changeset 3929:4663575733dd in roaraudio


Ignore:
Timestamp:
06/10/10 17:18:56 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

implemneted rsoudn support

Location:
roarclients
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • roarclients/Makefile

    r3830 r3929  
    5555        $L 
    5656roarinterconnect: roarinterconnect.o 
    57         $L $(lib_esd) $(LIBROAREIO) 
     57        $L $(lib_esd) $(LIBROAREIO) $(lib_rsound) 
    5858roarbidir: roarbidir.o 
    5959        $L 
  • roarclients/roarinterconnect.c

    r3842 r3929  
    3535#endif 
    3636 
     37#ifdef ROAR_HAVE_LIBRSOUND 
     38#include <rsound.h> 
     39#ifdef RSD_EXEC 
     40#define _HAVE_RSOUND 
     41#endif 
     42#endif 
     43 
    3744#if defined(ROAR_HAVE_OSS_BSD) || defined(ROAR_HAVE_OSS) 
    3845#define _HAVE_OSS 
     
    4552#define MT_SIMPLE   0x30 
    4653#define MT_OSS      0x40 
     54#define MT_RSOUND   0x50 
    4755#define MT_DEFAULT  MT_ROAR 
    4856 
     
    7987#ifdef _HAVE_OSS 
    8088        "  oss                - Open Sound System (OSS) device\n" 
     89#endif 
     90#ifdef _HAVE_RSOUND 
     91        "  rsound             - RSound server\n" 
    8192#endif 
    8293        "\n" 
     
    112123    ret -= ret & MT_MASK; 
    113124    ret += MT_OSS; 
     125   } else if ( !strcmp(type, "rsound") ) { 
     126    ret -= ret & MT_MASK; 
     127    ret += MT_RSOUND; 
    114128   } else if ( !strcmp(type, "bidir") ) { 
    115129    ret -= ret & ST_MASK; 
     
    142156                                              // very unlike to be configured at the server side. 
    143157   case MT_OSS:    ret |= ST_BIDIR;    break; 
     158   case MT_RSOUND: ret |= ST_TRANSMIT; break; // RSound does only handle playback streams. 
    144159   default: 
    145160     return MT_NONE|ST_NONE; // error case 
     
    150165 return ret; 
    151166} 
     167 
     168#ifdef _HAVE_RSOUND 
     169// RSound format helper function: 
     170enum rsd_format para2rsdfmt (int bits, int codec) { 
     171 switch (codec) { 
     172/* 
     173      RSD_S16_LE = 0x0001, 
     174      RSD_S16_BE = 0x0002, 
     175      RSD_U16_LE = 0x0004, 
     176      RSD_U16_BE = 0x0008, 
     177      RSD_U8     = 0x0010, 
     178      RSD_S8     = 0x0020, 
     179      RSD_S16_NE = 0x0040, 
     180      RSD_U16_NE = 0x0080, 
     181*/ 
     182  case ROAR_CODEC_PCM_S_LE: 
     183    switch (bits) { 
     184#ifdef RSD_S8 
     185     case  8: return RSD_S8;     break; 
     186#endif 
     187#ifdef RSD_S16_LE 
     188     case 16: return RSD_S16_LE; break; 
     189#endif 
     190    } 
     191   break; 
     192  case ROAR_CODEC_PCM_S_BE: 
     193    switch (bits) { 
     194#ifdef RSD_S8 
     195     case  8: return RSD_S8;     break; 
     196#endif 
     197#ifdef RSD_S16_BE 
     198     case 16: return RSD_S16_BE; break; 
     199#endif 
     200    } 
     201   break; 
     202  case ROAR_CODEC_PCM_U_LE: 
     203    switch (bits) { 
     204#ifdef RSD_U8 
     205     case  8: return RSD_U8;     break; 
     206#endif 
     207#ifdef RSD_U16_LE 
     208     case 16: return RSD_U16_LE; break; 
     209#endif 
     210    } 
     211   break; 
     212  case ROAR_CODEC_PCM_U_BE: 
     213    switch (bits) { 
     214#ifdef RSD_U8 
     215     case  8: return RSD_U8;     break; 
     216#endif 
     217#ifdef RSD_U16_BE 
     218     case 16: return RSD_U16_BE; break; 
     219#endif 
     220    } 
     221   break; 
     222#ifdef RSD_ALAW 
     223  case ROAR_CODEC_ALAW: 
     224    return RSD_ALAW; 
     225   break; 
     226#endif 
     227#ifdef RSD_MULAW 
     228  case ROAR_CODEC_MULAW: 
     229    return RSD_MULAW; 
     230   break; 
     231#endif 
     232 } 
     233 return 0; 
     234} 
     235#endif 
    152236 
    153237int main (int argc, char * argv[]) { 
     
    157241 struct roar_vio_calls  vio; 
    158242 struct roar_audio_info info; 
     243#endif 
     244#ifdef _HAVE_RSOUND 
     245 rsound_t *rd; 
     246 enum rsd_format fmt = 0; 
    159247#endif 
    160248 int    rate     = 44100; 
     
    303391   break; 
    304392#endif 
     393#ifdef _HAVE_RSOUND 
     394  case MT_RSOUND: 
     395    fmt = para2rsdfmt(bits, codec); 
     396 
     397    if ( fmt == 0 ) { 
     398     fprintf(stderr, "Error: Bits/Codec not supported by RSound\n"); 
     399     return 2; 
     400    } 
     401 
     402    switch (type & ST_MASK) { 
     403     case ST_TRANSMIT: 
     404       localdir = ROAR_DIR_MONITOR; 
     405 
     406       rsd_init(&rd); 
     407       rsd_set_param(rd, RSD_HOST,       remote); 
     408       rsd_set_param(rd, RSD_CHANNELS,   &channels); 
     409       rsd_set_param(rd, RSD_SAMPLERATE, &rate); 
     410       rsd_set_param(rd, RSD_FORMAT,     &fmt); 
     411       rfh = rsd_exec(rd); 
     412       if ( rfh == -1 ) { 
     413        rsd_stop(rd); 
     414        rsd_free(rd); 
     415       } 
     416      break; 
     417     default: 
     418       fprintf(stderr, "Error: this type is not supported by RSound\n"); 
     419       return 2; 
     420      break; 
     421    } 
     422   break; 
     423#endif 
    305424  case MT_SIMPLE: 
    306425    switch (type & ST_MASK) { 
Note: See TracChangeset for help on using the changeset viewer.