Changeset 5a6f362 in mainline
- Timestamp:
- 2013-04-04T15:39:00Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5029c788
- Parents:
- 76ea1b7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/pcm/src/format.c
r76ea1b7 r5a6f362 90 90 unsigned frame, unsigned channel, const pcm_format_t *f); 91 91 92 /** 93 * Compare PCM format attribtues. 94 * @param a Format description. 95 * @param b Format description. 96 * @return True if a and b describe the same format, false otherwise. 97 */ 92 98 bool pcm_format_same(const pcm_format_t *a, const pcm_format_t* b) 93 99 { … … 100 106 } 101 107 108 /** 109 * Fill audio buffer with silence in the specified format. 110 * @param dst Destination audio buffer. 111 * @param size Size of the destination audio buffer. 112 * @param f Pointer to the format description. 113 */ 102 114 void pcm_format_silence(void *dst, size_t size, const pcm_format_t *f) 103 115 { … … 146 158 } 147 159 160 /** 161 * Mix audio data of the same format and size. 162 * @param dst Destination buffer 163 * @param src Source buffer 164 * @param size Size of both the destination and the source buffer 165 * @param f Pointer to the format descriptor. 166 * @return Error code. 167 */ 148 168 int pcm_format_mix(void *dst, const void *src, size_t size, const pcm_format_t *f) 149 169 { 150 170 return pcm_format_convert_and_mix(dst, size, src, size, f, f); 151 171 } 172 173 /** 174 * Add and mix audio data. 175 * @param dst Destination audio buffer 176 * @param dst_size Size of the destination buffer 177 * @param src Source audio buffer 178 * @param src_size Size of the source buffer. 179 * @param sf Pointer to the source format descriptor. 180 * @param df Pointer to the destination format descriptor. 181 * @return Error code. 182 * 183 * Buffers must contain entire frames. Destination buffer is always filled. 184 * If there are not enough data in the source buffer silent data is assumed. 185 */ 152 186 int pcm_format_convert_and_mix(void *dst, size_t dst_size, const void *src, 153 187 size_t src_size, const pcm_format_t *sf, const pcm_format_t *df) … … 160 194 161 195 const size_t dst_frame_size = pcm_format_frame_size(df); 162 if (( src_size % dst_frame_size) != 0)196 if ((dst_size % dst_frame_size) != 0) 163 197 return EINVAL; 164 198 … … 226 260 } 227 261 228 /** Converts all sample formats to float <-1,1> */ 262 /** 263 * Converts all sample formats to float <-1,1> 264 * @param buffer Audio data 265 * @param size Size of the buffer 266 * @param frame Index of the frame to read 267 * @param channel Channel within the frame 268 * @param f Pointer to a format descriptor 269 * @return Normalized sample <-1,1>, 0.0 if the data could not be read 270 */ 229 271 static float get_normalized_sample(const void *buffer, size_t size, 230 272 unsigned frame, unsigned channel, const pcm_format_t *f)
Note:
See TracChangeset
for help on using the changeset viewer.