Changeset 1240bb9 in mainline
- Timestamp:
- 2012-07-12T18:20:45Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d01e635
- Parents:
- 992ef56
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/dplay/dplay.c
r992ef56 r1240bb9 91 91 ipc_call_t call; 92 92 ipc_callid_t callid = async_get_call(&call); 93 if (IPC_GET_IMETHOD(call) != IPC_FIRST_USER_METHOD) { 94 printf("Unknown event.\n"); 93 switch(IPC_GET_IMETHOD(call)) { 94 case PCM_EVENT_PLAYBACK_DONE: 95 printf("+"); 96 async_answer_0(callid, EOK); 95 97 break; 98 case PCM_EVENT_PLAYBACK_TERMINATED: 99 printf("\nPlayback terminated\n"); 100 fibril_mutex_lock(&pb->mutex); 101 pb->playing = false; 102 fibril_condvar_signal(&pb->cv); 103 async_answer_0(callid, EOK); 104 fibril_mutex_unlock(&pb->mutex); 105 return; 106 default: 107 printf("Unknown event %d.\n", IPC_GET_IMETHOD(call)); 108 async_answer_0(callid, ENOTSUP); 109 continue; 110 96 111 } 97 printf("+");98 112 const size_t bytes = fread(pb->buffer.position, sizeof(uint8_t), 99 113 buffer_part, pb->source); … … 103 117 if (pb->buffer.position >= (pb->buffer.base + pb->buffer.size)) 104 118 pb->buffer.position = pb->buffer.base; 105 async_answer_0(callid, EOK);106 119 if (bytes == 0) { 120 fibril_mutex_lock(&pb->mutex); 107 121 pb->playing = false; 108 122 fibril_condvar_signal(&pb->cv); 123 fibril_mutex_unlock(&pb->mutex); 109 124 } 110 125 } … … 138 153 139 154 audio_pcm_stop_playback(pb->device, pb->buffer.id); 140 fibril_condvar_wait(&pb->cv, &pb->mutex); 155 for (pb->playing = true; pb->playing; 156 fibril_condvar_wait(&pb->cv, &pb->mutex)); 157 fibril_mutex_unlock(&pb->mutex); 141 158 printf("\n"); 142 159 } -
uspace/app/drec/drec.c
r992ef56 r1240bb9 89 89 ipc_call_t call; 90 90 ipc_callid_t callid = async_get_call(&call); 91 if (IPC_GET_IMETHOD(call) != IPC_FIRST_USER_METHOD) { 92 printf("Unknown event.\n"); 91 switch(IPC_GET_IMETHOD(call)) { 92 case PCM_EVENT_RECORDING_DONE: 93 printf("+"); 94 async_answer_0(callid, EOK); 93 95 break; 96 case PCM_EVENT_RECORDING_TERMINATED: 97 printf("\nRecording terminated\n"); 98 return; 99 default: 100 printf("Unknown event %d.\n", IPC_GET_IMETHOD(call)); 101 async_answer_0(callid, ENOTSUP); 102 continue; 103 94 104 } 95 105 const size_t bytes = fwrite(rec->buffer.position, … … 207 217 }; 208 218 fwrite(&header, sizeof(header), 1, rec.file); 209 record(&rec, sampling_rate, channels, format);219 record(&rec, channels, sampling_rate, format); 210 220 fclose(rec.file); 211 221 -
uspace/drv/audio/sb16/dsp.c
r992ef56 r1240bb9 33 33 */ 34 34 35 #include <bool.h> 35 36 #include <devman.h> 36 37 #include <device/hw_res.h> … … 38 39 #include <libarch/barrier.h> 39 40 #include <str_error.h> 40 #include < bool.h>41 #include <audio_pcm_iface.h> 41 42 42 43 #include "dma.h" … … 162 163 dsp->event_exchange = NULL; 163 164 dsp->sb_dev = dev; 165 dsp->status = DSP_STOPPED; 164 166 sb_dsp_reset(dsp); 165 167 /* "DSP takes about 100 microseconds to initialize itself" */ … … 188 190 assert(dsp); 189 191 if (dsp->event_exchange) { 190 async_msg_0(dsp->event_exchange, IPC_FIRST_USER_METHOD); 192 switch (dsp->status) { 193 case DSP_PLAYBACK: 194 async_msg_0(dsp->event_exchange, 195 PCM_EVENT_PLAYBACK_DONE); 196 break; 197 case DSP_RECORDING: 198 async_msg_0(dsp->event_exchange, 199 PCM_EVENT_RECORDING_DONE); 200 break; 201 default: 202 case DSP_STOPPED: 203 ddf_log_warning("Interrupt while DSP stopped and " 204 "event exchange present. Terminating exchange"); 205 async_exchange_end(dsp->event_exchange); 206 dsp->event_exchange = NULL; 207 } 191 208 } else { 192 209 ddf_log_warning("Interrupt with no event consumer."); … … 316 333 sampling_rate / (dsp->active.samples * channels)); 317 334 318 dsp-> active.playing = true;335 dsp->status = DSP_PLAYBACK; 319 336 320 337 return EOK; … … 326 343 if (id != BUFFER_ID) 327 344 return ENOENT; 345 sb_dsp_write(dsp, DMA_16B_EXIT); 346 ddf_log_debug("Stopping playback on buffer %u.", id); 347 async_msg_0(dsp->event_exchange, PCM_EVENT_PLAYBACK_TERMINATED); 328 348 async_exchange_end(dsp->event_exchange); 329 sb_dsp_write(dsp, DMA_16B_EXIT);349 dsp->event_exchange = NULL; 330 350 return EOK; 331 351 } … … 389 409 "(~1/%u sec)", dsp->active.samples, 390 410 sampling_rate / (dsp->active.samples * channels)); 391 dsp-> active.playing = false;411 dsp->status = DSP_RECORDING; 392 412 393 413 return EOK; … … 399 419 if (id != BUFFER_ID) 400 420 return ENOENT; 421 sb_dsp_write(dsp, DMA_16B_EXIT); 422 ddf_log_debug("Stopping playback on buffer %u.", id); 423 async_msg_0(dsp->event_exchange, PCM_EVENT_RECORDING_TERMINATED); 401 424 async_exchange_end(dsp->event_exchange); 402 sb_dsp_write(dsp, DMA_16B_EXIT);425 dsp->event_exchange = NULL; 403 426 return EOK; 404 427 } -
uspace/drv/audio/sb16/dsp.h
r992ef56 r1240bb9 57 57 uint8_t mode; 58 58 uint16_t samples; 59 bool playing;60 59 } active; 60 enum { 61 DSP_PLAYBACK, 62 DSP_RECORDING, 63 DSP_STOPPED, 64 } status; 61 65 async_sess_t *event_session; 62 66 async_exch_t *event_exchange; -
uspace/lib/drv/include/audio_pcm_iface.h
r992ef56 r1240bb9 43 43 #include "ddf/driver.h" 44 44 45 enum { 46 PCM_EVENT_PLAYBACK_DONE = IPC_FIRST_USER_METHOD, 47 PCM_EVENT_RECORDING_DONE, 48 PCM_EVENT_PLAYBACK_TERMINATED, 49 PCM_EVENT_RECORDING_TERMINATED 50 }; 51 52 45 53 int audio_pcm_get_info_str(async_exch_t *, const char **); 46 54 int audio_pcm_get_buffer(async_exch_t *, void **, size_t *, unsigned *,
Note:
See TracChangeset
for help on using the changeset viewer.