Changeset 57e8b3b in mainline for uspace/drv/audio/sb16/dsp.c
- Timestamp:
- 2012-07-15T15:25:43Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5cd5079
- Parents:
- 2cc5c835
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/dsp.c
r2cc5c835 r57e8b3b 188 188 { 189 189 assert(dsp); 190 dsp->active.frame_count += 191 dsp->active.samples / ((dsp->active.mode & DSP_MODE_STEREO) ? 2 : 1); 192 190 193 if (dsp->event_exchange) { 191 194 switch (dsp->status) { 192 195 case DSP_PLAYBACK: 193 async_msg_ 0(dsp->event_exchange,194 PCM_EVENT_ PLAYBACK_DONE);196 async_msg_1(dsp->event_exchange, 197 PCM_EVENT_FRAMES_PLAYED, dsp->active.frame_count); 195 198 break; 196 199 case DSP_RECORDING: 197 async_msg_ 0(dsp->event_exchange,198 PCM_EVENT_ RECORDING_DONE);200 async_msg_1(dsp->event_exchange, 201 PCM_EVENT_FRAMES_RECORDED, dsp->active.frame_count); 199 202 break; 200 203 default: … … 267 270 } 268 271 269 int sb_dsp_start_playback(sb_dsp_t *dsp, unsigned parts,272 int sb_dsp_start_playback(sb_dsp_t *dsp, unsigned frames, 270 273 unsigned channels, unsigned sampling_rate, pcm_sample_format_t format) 271 274 { … … 275 278 return EINVAL; 276 279 277 /* Play block size must be even number (we use DMA 16)*/278 if (dsp->buffer.size % (parts * 2))279 return EINVAL;280 281 const unsigned play_block_size = dsp->buffer.size / parts;282 283 280 /* Check supported parameters */ 284 ddf_log_debug("Requested playback (%u parts):%uHz, %s, %u channel(s).",285 parts, sampling_rate, pcm_sample_format_str(format), channels);281 ddf_log_debug("Requested playback: %u frames, %uHz, %s, %u channel(s).", 282 frames, sampling_rate, pcm_sample_format_str(format), channels); 286 283 if (channels != 1 && channels != 2) 287 284 return ENOTSUP; … … 311 308 #endif 312 309 313 dsp->active.mode = 0 | 314 (sign ? DSP_MODE_SIGNED : 0) | (channels == 2 ? DSP_MODE_STEREO : 0); 310 dsp->active.mode = 0 311 | (sign ? DSP_MODE_SIGNED : 0) 312 | (channels == 2 ? DSP_MODE_STEREO : 0); 313 dsp->active.samples = frames * channels; 314 dsp->active.frame_count = 0; 315 315 316 sb_dsp_write(dsp, dsp->active.mode); 316 317 dsp->active.samples = sample_count(format, play_block_size);318 317 sb_dsp_write(dsp, (dsp->active.samples - 1) & 0xff); 319 318 sb_dsp_write(dsp, (dsp->active.samples - 1) >> 8); … … 339 338 } 340 339 341 int sb_dsp_start_record(sb_dsp_t *dsp, unsigned parts,340 int sb_dsp_start_record(sb_dsp_t *dsp, unsigned frames, 342 341 unsigned channels, unsigned sampling_rate, pcm_sample_format_t format) 343 342 { … … 347 346 return EINVAL; 348 347 349 /* Play block size must be even number (we use DMA 16)*/350 if (dsp->buffer.size % (parts * 2))351 return EINVAL;352 353 const unsigned play_block_size = dsp->buffer.size / parts;354 355 348 /* Check supported parameters */ 356 ddf_log_debug("Requested record (%u parts):%uHz, %s, %u channel(s).",357 parts, sampling_rate, pcm_sample_format_str(format), channels);349 ddf_log_debug("Requested record: %u frames, %uHz, %s, %u channel(s).", 350 frames, sampling_rate, pcm_sample_format_str(format), channels); 358 351 if (channels != 1 && channels != 2) 359 352 return ENOTSUP; … … 384 377 385 378 dsp->active.mode = 0 | 386 (sign ? DSP_MODE_SIGNED : 0) | (channels == 2 ? DSP_MODE_STEREO : 0); 379 (sign ? DSP_MODE_SIGNED : 0) | 380 (channels == 2 ? DSP_MODE_STEREO : 0); 381 dsp->active.samples = frames * channels; 382 dsp->active.frame_count = 0; 383 387 384 sb_dsp_write(dsp, dsp->active.mode); 388 389 dsp->active.samples = sample_count(format, play_block_size);390 385 sb_dsp_write(dsp, (dsp->active.samples - 1) & 0xff); 391 386 sb_dsp_write(dsp, (dsp->active.samples - 1) >> 8);
Note:
See TracChangeset
for help on using the changeset viewer.