Changeset 3415:bf9a44f51723 in roaraudio for libroarpulse
- Timestamp:
- 02/11/10 17:55:21 (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroarpulse/sample.c
r3414 r3415 43 43 44 44 /** Return the size of a frame with the specific sample type */ 45 size_t pa_frame_size(const pa_sample_spec *spec); 45 size_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 } 46 51 47 52 /** Return the size of a sample with the specific sample type */ 48 size_t pa_sample_size(const pa_sample_spec *spec); 53 size_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 } 49 74 50 75 /** Calculate the time the specified bytes take to play with the specified sample type */ … … 55 80 56 81 /** Return non-zero when the sample type specification is valid */ 57 int pa_sample_spec_valid(const pa_sample_spec *spec); 82 int 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 } 58 94 59 95 /** 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); 96 int 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 } 61 108 62 109 /** Return a descriptive string for the specified sample format. \since 0.8 */ 110 static struct { 111 pa_sample_format_t format; 112 const char * name; 113 } _roar_pa_format[] = { 114 {PA_SAMPLE_INVALID, NULL} 115 }; 116 63 117 const char *pa_sample_format_to_string(pa_sample_format_t f); 64 118
Note: See TracChangeset
for help on using the changeset viewer.