Changeset 8de7ef2 in mainline
- Timestamp:
- 2012-07-05T19:31:39Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7ca22e5
- Parents:
- f8608f2
- Location:
- uspace/lib/drv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_audio_pcm_buffer.c
rf8608f2 r8de7ef2 83 83 /*----------------------------------------------------------------------------*/ 84 84 int audio_pcm_buffer_get_buffer(async_exch_t *exch, void **buffer, size_t *size, 85 unsigned *id )85 unsigned *id, async_client_conn_t event_rec, void* arg) 86 86 { 87 87 if (!exch || !buffer || !size || !id) … … 95 95 void *dst = NULL; 96 96 // FIXME Do we need to know the flags? 97 constint ret = async_share_in_start_0_0(exch, buffer_size, &dst);97 int ret = async_share_in_start_0_0(exch, buffer_size, &dst); 98 98 if (ret != EOK) { 99 99 return ret; 100 100 } 101 ret = async_connect_to_me(exch, 0, 0, 0, event_rec, arg); 102 if (ret != EOK) { 103 return ret; 104 } 105 101 106 *buffer = dst; 102 107 *size = buffer_size; … … 115 120 /*----------------------------------------------------------------------------*/ 116 121 int audio_pcm_buffer_start_playback(async_exch_t *exch, unsigned id, 117 unsigned sample_rate, uint16_t sample_size, uint8_t channels, bool sign) 122 unsigned parts, unsigned sample_rate, uint16_t sample_size, 123 uint8_t channels, bool sign) 118 124 { 119 125 if (!exch) 120 126 return EINVAL; 121 sysarg_t packed = 122 (sample_size << 16) | (channels << 8) | (sign ? 1 : 0); 127 const sysarg_t packed = 128 (sample_size << 16) | (channels << 8) | 129 (parts & 0x7f << 1) | (sign ? 1 : 0); 123 130 return async_req_4_0(exch, DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE), 124 131 IPC_M_AUDIO_PCM_START_PLAYBACK, id, sample_rate, packed); … … 214 221 const audio_pcm_buffer_iface_t *pcm_iface = iface; 215 222 216 if (!pcm_iface->get_buffer) { 223 if (!pcm_iface->get_buffer || 224 !pcm_iface->release_buffer || 225 !pcm_iface->set_event_session) { 217 226 async_answer_0(callid, ENOTSUP); 218 227 return; … … 221 230 size_t size = DEV_IPC_GET_ARG1(*call); 222 231 unsigned id = 0; 223 constint ret = pcm_iface->get_buffer(fun, &buffer, &size, &id);232 int ret = pcm_iface->get_buffer(fun, &buffer, &size, &id); 224 233 async_answer_2(callid, ret, size, id); 234 if (ret != EOK || size == 0) 235 return; 236 225 237 /* Share the buffer. */ 226 if (ret == EOK && size > 0) { 227 size_t share_size = 0; 228 ipc_callid_t share_id = 0; 229 ddf_msg(LVL_DEBUG2, "Calling share receive."); 230 if (!async_share_in_receive(&share_id, &share_size)) { 231 ddf_msg(LVL_DEBUG, "Failed to share pcm buffer."); 232 if (pcm_iface->release_buffer) 233 pcm_iface->release_buffer(fun, id); 234 async_answer_0(share_id, EPARTY); 235 return; 236 } 237 ddf_msg(LVL_DEBUG2, "Checking requested share size"); 238 if (share_size != size) { 239 ddf_msg(LVL_DEBUG, "Incorrect pcm buffer size requested."); 240 if (pcm_iface->release_buffer) 241 pcm_iface->release_buffer(fun, id); 242 async_answer_0(share_id, ELIMIT); 243 return; 244 } 245 ddf_msg(LVL_DEBUG2, "Calling share finalize"); 246 const int ret = async_share_in_finalize(share_id, buffer, 0); 238 size_t share_size = 0; 239 ipc_callid_t share_id = 0; 240 ddf_msg(LVL_DEBUG2, "Calling share receive."); 241 if (!async_share_in_receive(&share_id, &share_size)) { 242 ddf_msg(LVL_DEBUG, "Failed to share pcm buffer."); 243 if (pcm_iface->release_buffer) 244 pcm_iface->release_buffer(fun, id); 245 async_answer_0(share_id, EPARTY); 246 return; 247 } 248 ddf_msg(LVL_DEBUG2, "Checking requested share size"); 249 if (share_size != size) { 250 ddf_msg(LVL_DEBUG, "Incorrect pcm buffer size requested."); 251 if (pcm_iface->release_buffer) 252 pcm_iface->release_buffer(fun, id); 253 async_answer_0(share_id, ELIMIT); 254 return; 255 } 256 ddf_msg(LVL_DEBUG2, "Calling share finalize"); 257 ret = async_share_in_finalize(share_id, buffer, 0); 258 if (ret != EOK) { 259 ddf_msg(LVL_DEBUG, "Failed to share buffer"); 260 if (pcm_iface->release_buffer) 261 pcm_iface->release_buffer(fun, id); 262 return; 263 264 } 265 ddf_msg(LVL_DEBUG2, "Buffer shared with size %zu, creating callback.", 266 share_size); 267 { 268 ipc_call_t call; 269 ipc_callid_t callid = async_get_call(&call); 270 async_sess_t *sess = 271 async_callback_receive_start(EXCHANGE_ATOMIC, &call); 272 if (sess == NULL) { 273 ddf_msg(LVL_DEBUG, "Failed to create event callback"); 274 pcm_iface->release_buffer(fun, id); 275 async_answer_0(callid, EAGAIN); 276 return; 277 } 278 ret = pcm_iface->set_event_session(fun, id, sess); 247 279 if (ret != EOK) { 248 ddf_msg(LVL_DEBUG, "Failed to share buffer"); 249 if (pcm_iface->release_buffer) 250 pcm_iface->release_buffer(fun, id); 251 return; 252 253 } 254 ddf_msg(LVL_DEBUG2, "Buffer shared ok with size %zu.", 255 share_size); 280 ddf_msg(LVL_DEBUG, "Failed to set event callback."); 281 pcm_iface->release_buffer(fun, id); 282 } 283 async_answer_0(callid, ret); 256 284 } 257 285 } … … 276 304 const unsigned rate = DEV_IPC_GET_ARG2(*call); 277 305 const unsigned size = DEV_IPC_GET_ARG3(*call) >> 16; 278 const unsigned channels = (DEV_IPC_GET_ARG3(*call) >> 8) && UINT8_MAX; 306 const unsigned channels = (DEV_IPC_GET_ARG3(*call) >> 8) & UINT8_MAX; 307 const unsigned parts = (DEV_IPC_GET_ARG3(*call) >> 1) & 0x7f; 279 308 const bool sign = (bool)(DEV_IPC_GET_ARG3(*call) & 1); 280 309 281 310 const int ret = pcm_iface->start_playback 282 ? pcm_iface->start_playback(fun, id, rate, size, channels, sign)311 ? pcm_iface->start_playback(fun, id, parts, rate, size, channels, sign) 283 312 : ENOTSUP; 284 313 async_answer_0(callid, ret); -
uspace/lib/drv/include/audio_pcm_buffer_iface.h
rf8608f2 r8de7ef2 43 43 44 44 int audio_pcm_buffer_get_info_str(async_exch_t *, const char **); 45 int audio_pcm_buffer_get_buffer(async_exch_t *, void **, size_t *, unsigned *); 45 int audio_pcm_buffer_get_buffer(async_exch_t *, void **, size_t *, unsigned *, 46 async_client_conn_t, void *); 46 47 int audio_pcm_buffer_release_buffer(async_exch_t *, unsigned); 47 48 48 int audio_pcm_buffer_start_playback(async_exch_t *, unsigned, 49 int audio_pcm_buffer_start_playback(async_exch_t *, unsigned, unsigned, 49 50 unsigned, uint16_t, uint8_t, bool); 50 51 int audio_pcm_buffer_stop_playback(async_exch_t *, unsigned); … … 59 60 int (*get_buffer)(ddf_fun_t *, void **, size_t *, unsigned *); 60 61 int (*release_buffer)(ddf_fun_t *, unsigned); 61 int (*start_playback)(ddf_fun_t *, unsigned, 62 int (*set_event_session)(ddf_fun_t *, unsigned, async_sess_t *); 63 int (*start_playback)(ddf_fun_t *, unsigned, unsigned, 62 64 unsigned, unsigned, unsigned, bool); 63 65 int (*stop_playback)(ddf_fun_t *, unsigned);
Note:
See TracChangeset
for help on using the changeset viewer.