Changeset b1dfe13 in mainline for uspace/lib/pcm/include/pcm/sample_format.h
- Timestamp:
- 2013-04-10T19:08:09Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8a7d78cc
- Parents:
- a8e87da
- File:
-
- 1 edited
-
uspace/lib/pcm/include/pcm/sample_format.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/pcm/include/pcm/sample_format.h
ra8e87da rb1dfe13 40 40 #include <time.h> 41 41 42 /** Known and supported PCM sample formats */ 42 43 typedef enum { 43 44 PCM_SAMPLE_UINT8, … … 63 64 } pcm_sample_format_t; 64 65 66 /** 67 * Query if the format uses signed values. 68 * @param format PCM sample format. 69 * @return True if the format uses signed values, false otherwise. 70 */ 65 71 static inline bool pcm_sample_format_is_signed(pcm_sample_format_t format) 66 72 { … … 91 97 } 92 98 99 /** 100 * Query byte-size of samples. 101 * @param format PCM sample format. 102 * @return Size in bytes of a single sample. 103 */ 93 104 static inline size_t pcm_sample_format_size(pcm_sample_format_t format) 94 105 { … … 122 133 } 123 134 135 /** 136 * Query sie of the entire frame. 137 * @param channels Number of samples in every frame. 138 * @param format PCM sample format. 139 * @return Size in bytes. 140 */ 124 141 static inline size_t pcm_sample_format_frame_size(unsigned channels, 125 142 pcm_sample_format_t format) … … 128 145 } 129 146 147 /** 148 * Count number of frames that fit into a buffer (even incomplete frames). 149 * @param size Size of the buffer. 150 * @param channels Number of samples in every frame. 151 * @param format PCM sample format. 152 * @return Number of frames (even incomplete). 153 */ 130 154 static inline size_t pcm_sample_format_size_to_frames(size_t size, 131 155 unsigned channels, pcm_sample_format_t format) … … 135 159 } 136 160 161 /** 162 * Convert byte size to time. 163 * @param size Size of the buffer. 164 * @param sample_rate Samples per second. 165 * @param channels Number of samples in every frame. 166 * @param format PCM sample format. 167 * @return Number of useconds of audio data. 168 */ 137 169 static inline useconds_t pcm_sample_format_size_to_usec(size_t size, 138 170 unsigned sample_rate, unsigned channels, pcm_sample_format_t format) 139 171 { 140 const long long frames =172 const unsigned long long frames = 141 173 pcm_sample_format_size_to_frames(size, channels, format); 142 174 return (frames * 1000000ULL) / sample_rate; 143 175 } 144 176 177 /** 178 * Get readable name of a sample format. 179 * @param format PCM sample format. 180 * @return Valid string representation. 181 */ 145 182 static inline const char * pcm_sample_format_str(pcm_sample_format_t format) 146 183 {
Note:
See TracChangeset
for help on using the changeset viewer.
