Changeset eca79ff in mainline
- Timestamp:
- 2013-04-06T14:14:20Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7e706a3
- Parents:
- 599034e
- Location:
- uspace/srv/audio/hound
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/audio/hound/audio_device.c
r599034e reca79ff 54 54 static int get_buffer(audio_device_t *dev); 55 55 static int release_buffer(audio_device_t *dev); 56 static void fill_buffer(audio_device_t *dev, size_t size); 56 57 57 58 … … 74 75 75 76 /* Init buffer members */ 76 fibril_mutex_initialize(&dev->buffer.guard);77 fibril_condvar_initialize(&dev->buffer.wc);78 77 dev->buffer.base = NULL; 79 78 dev->buffer.position = NULL; … … 108 107 // TODO set formats 109 108 110 /* Fill the buffer first */111 audio_sink_mix_inputs(&dev->sink,112 dev->buffer.base, dev->buffer.size);109 /* Fill the buffer first. Fill the first two fragments, 110 * so that we stay one fragment ahead */ 111 fill_buffer(dev, dev->buffer.fragment_size * 2); 113 112 114 113 const unsigned frames = dev->buffer.fragment_size / … … 204 203 struct timeval time1; 205 204 getuptime(&time1); 206 //TODO add underrun protection. 207 if (dev->buffer.position) { 208 dev->buffer.position += 209 dev->buffer.fragment_size; 210 } 211 if ((!dev->buffer.position) || 212 (dev->buffer.position >= 213 (dev->buffer.base + dev->buffer.size))) 214 { 215 dev->buffer.position = dev->buffer.base; 216 } 217 audio_sink_mix_inputs(&dev->sink, dev->buffer.position, 218 dev->buffer.fragment_size); 205 fill_buffer(dev, dev->buffer.fragment_size); 219 206 struct timeval time2; 220 207 getuptime(&time2); … … 236 223 } 237 224 } 225 238 226 static int device_check_format(audio_sink_t* sink) 239 227 { … … 258 246 } 259 247 260 dev->buffer.size = 0; 248 /* Ask for largest buffer possible */ 249 size_t preferred_size = 0; 261 250 262 251 const int ret = audio_pcm_get_buffer(dev->sess, &dev->buffer.base, 263 &dev->buffer.size); 264 if (ret == EOK) 252 &preferred_size); 253 if (ret == EOK) { 254 dev->buffer.size = preferred_size; 265 255 dev->buffer.fragment_size = dev->buffer.size / BUFFER_PARTS; 256 dev->buffer.position = dev->buffer.base; 257 } 266 258 return ret; 267 259 … … 283 275 return ret; 284 276 } 277 278 static void fill_buffer(audio_device_t *dev, size_t size) 279 { 280 assert(dev); 281 assert(dev->buffer.position >= dev->buffer.base); 282 assert(dev->buffer.position < (dev->buffer.base + dev->buffer.size)); 283 284 //TODO add underrun detection. 285 audio_sink_mix_inputs(&dev->sink, dev->buffer.position, size); 286 dev->buffer.position += size; 287 if (dev->buffer.position == (dev->buffer.base + dev->buffer.size)) 288 dev->buffer.position = dev->buffer.base; 289 } 285 290 /** 286 291 * @} -
uspace/srv/audio/hound/audio_device.h
r599034e reca79ff 53 53 char *name; 54 54 struct { 55 fibril_mutex_t guard;56 fibril_condvar_t wc;57 55 void *base; 58 56 size_t size;
Note:
See TracChangeset
for help on using the changeset viewer.