Changeset 5056:b31e60545552 in roaraudio


Ignore:
Timestamp:
06/02/11 23:13:11 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

support auto reconf bits=32->16 in case not supported (See: #48)

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • configure

    r5052 r5056  
    15851585test_func_defmake ROAR_HAVE_GETVERSIONEX     GetVersionEx     'OSVERSIONINFO osinfo; osinfo.dwOSVersionInfoSize = sizeof(osinfo);GetVersionEx(&osinfo);'                -- windows.h 
    15861586 
     1587test_func_defmake ROAR_HAVE_AO_APPEND_GLOBAL_OPTION ao_append_global_option 'ao_append_global_option("","")' ao -- ao/ao.h 
     1588 
    15871589 
    15881590echo -n 'checking for basic IO calls... ' 
  • roard/driver_ao.c

    r5012 r5056  
    3232 if ( _driver_ao_usage_counter++ == 0 ) 
    3333  ao_initialize(); 
     34 
     35#ifdef ROAR_HAVE_AO_APPEND_GLOBAL_OPTION 
     36 ao_append_global_option("client_name", "roard"); 
     37#endif 
    3438} 
    3539 
     
    4448 ao_sample_format     format; 
    4549 int driver; 
     50 int autoconfig = 0; 
    4651 
    4752 ROAR_WARN("The libao driver is obsolete, use another!"); 
     
    4954 if ( fh != -1 ) 
    5055  return -1; 
     56 
     57 if ( sstream != NULL ) { 
     58  autoconfig = streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_AUTOCONF); 
     59 } 
    5160 
    5261 driver_ao_init(); 
     
    94103   break; 
    95104  default: 
    96    ROAR_ERR("Can not open audio device via libao: codec not supported. You may want to try -oO codec=pcm"); 
    97    driver_ao_uninit(); 
    98    return -1; 
    99   break; 
     105    if ( autoconfig ) { 
     106     format.byte_format = AO_FMT_NATIVE; 
     107     info->codec = ROAR_CODEC_DEFAULT; 
     108    } else { 
     109     ROAR_ERR("Can not open audio device via libao: codec not supported. You may want to try -oO codec=pcm"); 
     110     driver_ao_uninit(); 
     111     return -1; 
     112    } 
     113   break; 
    100114 } 
    101115 
    102116 aodevice = ao_open_live(driver, &format, NULL /* no options */); 
     117 
     118 if ( aodevice == NULL && autoconfig ) { 
     119  format.byte_format = AO_FMT_NATIVE; 
     120  format.bits        = 16; 
     121  info->codec        = ROAR_CODEC_DEFAULT; 
     122  info->bits         = 16; 
     123  aodevice = ao_open_live(driver, &format, NULL /* no options */); 
     124 } 
    103125 
    104126 if ( aodevice == NULL ) { 
  • roard/driver_artsc.c

    r4809 r5056  
    5151int     driver_artsc_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) { 
    5252 struct roar_artsc * self = NULL; 
     53 int autoconfig           = 0; 
    5354 
    5455 (void)sstream; 
     
    5657 if ( fh != -1 || device != NULL ) 
    5758  return -1; 
     59 
     60 if ( sstream != NULL ) { 
     61  autoconfig = streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_AUTOCONF); 
     62 } 
    5863 
    5964 self = roar_mm_malloc(sizeof(struct roar_artsc)); 
     
    7378 self->info   = info; 
    7479 self->stream = arts_play_stream(info->rate, info->bits, info->channels, "roard"); 
     80 
     81 if ( self->stream == NULL && autoconfig ) { 
     82  info->bits   = 16; 
     83  self->stream = arts_play_stream(info->rate, info->bits, info->channels, "roard"); 
     84 } 
    7585 
    7686 if ( self->stream == NULL ) { 
  • roard/driver_portaudio.c

    r5012 r5056  
    3535 long flags = PABLIO_WRITE; 
    3636#elif defined(ROAR_HAVE_PA19_VERSION_19) 
     37 PaStreamParameters params; 
     38#endif 
    3739 PaError err; 
    38  PaStreamParameters params; 
    39 #endif 
     40 int autoconfig = 0; 
    4041 
    4142 if ( fh != -1 ) 
    4243  return -1; 
     44 
     45 if ( sstream != NULL ) { 
     46  autoconfig = streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_AUTOCONF); 
     47 } 
    4348 
    4449 switch (info->bits) { 
     
    5661      break; 
    5762     default: 
    58        return -1; 
     63       if ( autoconfig ) { 
     64        info->codec = ROAR_CODEC_DEFAULT; 
     65        fmt = paInt8; 
     66       } else { 
     67        return -1; 
     68       } 
    5969      break; 
    6070    } 
    6171   break; 
    6272  case 16: 
    63     if ( info->codec != ROAR_CODEC_DEFAULT ) 
    64      return -1; 
     73    if ( info->codec != ROAR_CODEC_DEFAULT ) { 
     74     if ( autoconfig ) { 
     75      info->codec = ROAR_CODEC_DEFAULT; 
     76     } else { 
     77      return -1; 
     78     } 
     79    } 
    6580    fmt = paInt16; 
    6681   break; 
    6782#ifdef paPackedInt24 
    6883  case 24: 
    69     if ( info->codec != ROAR_CODEC_DEFAULT ) 
     84    if ( info->codec != ROAR_CODEC_DEFAULT ) { 
     85     if ( autoconfig ) { 
     86      info->codec = ROAR_CODEC_DEFAULT; 
     87     } else { 
     88      return -1; 
     89     } 
     90    } 
     91    fmt = paPackedInt24; 
     92   break; 
     93#endif 
     94  case 32: 
     95    if ( info->codec != ROAR_CODEC_DEFAULT ) { 
     96     if ( autoconfig ) { 
     97      info->codec = ROAR_CODEC_DEFAULT; 
     98     } else { 
     99      return -1; 
     100     } 
     101    } 
     102    fmt = paInt32; 
     103   break; 
     104  default: 
     105    if ( autoconfig ) { 
     106     info->codec = ROAR_CODEC_DEFAULT; 
     107     info->bits  = 16; 
     108     fmt = paInt16; 
     109    } else { 
    70110     return -1; 
    71     fmt = paPackedInt24; 
    72    break; 
    73 #endif 
    74   case 32: 
    75     if ( info->codec != ROAR_CODEC_DEFAULT ) 
    76      return -1; 
    77     fmt = paInt32; 
    78    break; 
    79   default: 
    80     return -1; 
     111    } 
     112   break; 
    81113 } 
    82114 
     
    100132  case 2: flags |= PABLIO_STEREO; break; 
    101133  default: 
    102     roar_mm_free(self); 
    103     Pa_Terminate(); 
    104     return -1; 
    105  } 
    106  
    107  if ( OpenAudioStream(&(self->ostream), info->rate, fmt, flags) != paNoError ) { 
     134    if ( autoconfig ) { 
     135     info->channels = 2; 
     136     flags |= PABLIO_STEREO; 
     137    } else { 
     138     roar_mm_free(self); 
     139     Pa_Terminate(); 
     140     return -1; 
     141    } 
     142 } 
     143 
     144 err = OpenAudioStream(&(self->ostream), info->rate, fmt, flags); 
     145 
     146 if ( err != paNoError && autoconfig ) { 
     147  if ( (flags & PABLIO_MONO) == PABLIO_MONO ) { 
     148   flags -= PABLIO_MONO; 
     149   flags |= PABLIO_STEREO; 
     150   info->channels = 2; 
     151  } 
     152  fmt         = paInt16; 
     153  info->codec = ROAR_CODEC_DEFAULT; 
     154  info->bits  = 16; 
     155 
     156  err = OpenAudioStream(&(self->ostream), info->rate, fmt, flags); 
     157 } 
     158 
     159 if ( err != paNoError ) { 
    108160  roar_mm_free(self); 
    109161  Pa_Terminate(); 
     
    133185                    ); 
    134186 
     187 if ( err != paNoError && autoconfig ) { 
     188  params.sampleFormat = paInt16; 
     189  params.channelCount = 2; 
     190  info->codec         = ROAR_CODEC_DEFAULT; 
     191  info->bits          = 16; 
     192  info->channels      = 2; 
     193 
     194  err = Pa_OpenStream(&(self->stream), 
     195                      NULL, 
     196                      &params, 
     197                      info->rate, 
     198                      128 /*FIXME:frames*/, 
     199                      paClipOff, 
     200                      NULL, 
     201                      NULL 
     202                     ); 
     203 } 
     204 
    135205 if ( err != paNoError ) { 
    136206  ROAR_ERR("driver_portaudio_open(*): Could not open PortAudio device: \"%s\".", Pa_GetErrorText(err)); 
  • roard/driver_pulsesimple.c

    r5012 r5056  
    3434 pa_stream_direction_t dir = PA_STREAM_PLAYBACK; 
    3535 pa_sample_spec        ss; 
     36 int autoconfig = 0; 
     37 int needauto   = 0; 
    3638 
    3739//    pa_sample_format_t format;     /**< The sample format */ 
     40 
     41 if ( fh != -1 ) 
     42  return -1; 
     43 
     44 if ( sstream != NULL ) { 
     45  autoconfig = streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_AUTOCONF); 
     46 } 
    3847 
    3948 switch (info->codec) { 
     
    5059      break; 
    5160     default: 
    52        return -1; 
     61       needauto = 1; 
    5362      break; 
    5463    } 
     
    6069      break; 
    6170     default: 
    62        return -1; 
     71       needauto = 1; 
    6372      break; 
    6473    } 
     
    7079     ss.format = PA_SAMPLE_U8; 
    7180    } else { 
    72      return -1; 
     81     needauto = 1; 
    7382    } 
    7483   break; 
    7584  default: 
    76     return -1; 
     85    needauto = 1; 
    7786   break; 
     87 } 
     88 
     89 if ( needauto ) { 
     90  if ( !autoconfig ) { 
     91   return -1; 
     92  } 
     93 
     94  info->bits = 16; 
     95  info->codec = ROAR_CODEC_DEFAULT; 
     96  ss.format = PA_SAMPLE_S16NE; 
    7897 } 
    7998 
     
    85104 
    86105 self->handle = pa_simple_new(device, "roard", dir, subdev, "RoarAudio Sound Server", &ss, NULL, NULL, &pulseerror); 
     106 
     107 if ( self->handle == NULL && autoconfig ) { 
     108  info->bits = 16; 
     109  info->codec = ROAR_CODEC_DEFAULT; 
     110  ss.format = PA_SAMPLE_S16NE; 
     111 
     112  self->handle = pa_simple_new(device, "roard", dir, subdev, "RoarAudio Sound Server", &ss, NULL, NULL, &pulseerror); 
     113 } 
    87114 
    88115 if ( self->handle == NULL ) { 
  • roard/driver_roar.c

    r4708 r5056  
    4747 
    4848 if ( roar_vio_simple_stream(inst, info->rate, info->channels, info->bits, info->codec, device, dir, "roard") == -1 ) { 
     49  if ( streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_AUTOCONF) ) { 
     50   roar_profile2info(info, "default"); 
     51   if ( roar_vio_simple_stream(inst, info->rate, info->channels, info->bits, info->codec, device, dir, "roard") == -1 ) { 
     52    return -1; 
     53   } 
     54  } 
    4955  return -1; 
    5056 } 
  • roard/driver_rsound.c

    r5012 r5056  
    7575 tmp = -1; // unknown by RSound 
    7676 
     77 if ( info->bits > 16 && streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_AUTOCONF) ) { 
     78  info->bits = 32; 
     79 } 
     80 
    7781 switch (info->codec) { 
    7882  case ROAR_CODEC_PCM_S_LE: 
     
    8084     case  8: tmp = RSD_S8;     break; 
    8185     case 16: tmp = RSD_S16_LE; break; 
     86#ifdef RSD_S32_LE 
     87     case 32: tmp = RSD_S32_LE; break; 
     88#endif 
    8289    } 
    8390   break; 
     
    8693     case  8: tmp = RSD_S8;     break; 
    8794     case 16: tmp = RSD_S16_BE; break; 
     95#ifdef RSD_S32_BE 
     96     case 32: tmp = RSD_S32_BE; break; 
     97#endif 
    8898    } 
    8999   break; 
     
    97107     case  8: tmp = RSD_U8;     break; 
    98108     case 16: tmp = RSD_U16_LE; break; 
     109#ifdef RSD_U32_LE 
     110     case 32: tmp = RSD_U32_LE; break; 
     111#endif 
    99112    } 
    100113   break; 
     
    103116     case  8: tmp = RSD_U8;     break; 
    104117     case 16: tmp = RSD_U16_BE; break; 
     118#ifdef RSD_U32_BE 
     119     case 32: tmp = RSD_U32_BE; break; 
     120#endif 
    105121    } 
    106122   break; 
     
    111127   break; 
    112128 } 
     129 
     130#ifdef RSD_S16_NE 
     131 if ( tmp == -1 && streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_AUTOCONF) ) { 
     132  info->bits  = 16; 
     133  info->codec = ROAR_CODEC_DEFAULT; 
     134  tmp         = RSD_S16_NE; 
     135 } 
     136#endif 
    113137 
    114138 if ( tmp == -1 ) { 
  • roard/driver_wmm.c

    r5012 r5056  
    215215 
    216216  mmres = 
    217     waveOutOpen(&self->hwo, 
     217    waveOutOpen(&(self->hwo), 
    218218                self->id, 
    219                 &self->wavefmt, 
     219                &(self->wavefmt), 
    220220                (DWORD_PTR)0/* waveOutProc */, 
    221221                (DWORD_PTR)self, 
Note: See TracChangeset for help on using the changeset viewer.