Changeset 5056:b31e60545552 in roaraudio for roard/driver_pulsesimple.c


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 ) { 
Note: See TracChangeset for help on using the changeset viewer.