Changeset 3415:bf9a44f51723 in roaraudio for libroarpulse/sample.c


Ignore:
Timestamp:
02/11/10 17:55:21 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

start with those strange formating functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroarpulse/sample.c

    r3414 r3415  
    4343 
    4444/** Return the size of a frame with the specific sample type */ 
    45 size_t pa_frame_size(const pa_sample_spec *spec); 
     45size_t pa_frame_size(const pa_sample_spec *spec) { 
     46 if ( spec == NULL ) 
     47  return 0; 
     48 
     49 return pa_sample_size(spec) * spec->channels; 
     50} 
    4651 
    4752/** Return the size of a sample with the specific sample type */ 
    48 size_t pa_sample_size(const pa_sample_spec *spec); 
     53size_t pa_sample_size(const pa_sample_spec *spec) { 
     54 if ( spec == NULL ) 
     55  return -1; 
     56 
     57 switch (spec->format) { 
     58  case PA_SAMPLE_ALAW: 
     59  case PA_SAMPLE_ULAW: 
     60  case PA_SAMPLE_U8: 
     61    return 1; 
     62   break; 
     63  case PA_SAMPLE_S16LE: 
     64  case PA_SAMPLE_S16BE: 
     65    return 2; 
     66   break; 
     67  default: 
     68    return 0; 
     69   break; 
     70 } 
     71 
     72 return 0; 
     73} 
    4974 
    5075/** Calculate the time the specified bytes take to play with the specified sample type */ 
     
    5580 
    5681/** Return non-zero when the sample type specification is valid */ 
    57 int pa_sample_spec_valid(const pa_sample_spec *spec); 
     82int pa_sample_spec_valid(const pa_sample_spec *spec) { 
     83 if ( spec == NULL ) 
     84  return 0; 
     85 
     86 if ( spec->channels < 1 || spec->channels > ROAR_MAX_CHANNELS ) 
     87  return 0; 
     88 
     89 if ( spec->format < 0 || spec->format > PA_SAMPLE_MAX ) 
     90  return 0; 
     91 
     92 return 1; 
     93} 
    5894 
    5995/** Return non-zero when the two sample type specifications match */ 
    60 int pa_sample_spec_equal(const pa_sample_spec*a, const pa_sample_spec*b); 
     96int pa_sample_spec_equal(const pa_sample_spec*a, const pa_sample_spec*b) { 
     97 if ( a->rate != b->rate ) 
     98  return 0; 
     99 
     100 if ( a->channels != b->channels ) 
     101  return 0; 
     102 
     103 if ( a->format != b->format ) 
     104  return 0; 
     105 
     106 return 1; 
     107} 
    61108 
    62109/** Return a descriptive string for the specified sample format. \since 0.8 */ 
     110static struct { 
     111 pa_sample_format_t format; 
     112 const char * name; 
     113} _roar_pa_format[] = { 
     114 {PA_SAMPLE_INVALID, NULL} 
     115}; 
     116 
    63117const char *pa_sample_format_to_string(pa_sample_format_t f); 
    64118 
Note: See TracChangeset for help on using the changeset viewer.