Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 63c34d7 in mainline


Ignore:
Timestamp:
2012-07-15T18:35:41Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial
Children:
b7c080c
Parents:
5cd5079
Message:

libdrv/audio: Add 'test_format' call.

Location:
uspace/lib/drv
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_audio_pcm.c

    r5cd5079 r63c34d7  
    4545typedef enum {
    4646        IPC_M_AUDIO_PCM_GET_INFO_STR,
     47        IPC_M_AUDIO_PCM_TEST_FORMAT,
    4748        IPC_M_AUDIO_PCM_GET_BUFFER,
    4849        IPC_M_AUDIO_PCM_RELEASE_BUFFER,
     
    106107}
    107108
     109int audio_pcm_test_format(audio_pcm_sess_t *sess, unsigned *channels,
     110    unsigned *rate, pcm_sample_format_t *format)
     111{
     112        async_exch_t *exch = async_exchange_begin(sess);
     113        sysarg_t channels_arg = channels ? *channels : 0;
     114        sysarg_t rate_arg = rate ? *rate : 0;
     115        sysarg_t format_arg = format ? *format : 0;
     116        const int ret = async_req_4_3(exch,
     117            DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
     118            IPC_M_AUDIO_PCM_TEST_FORMAT, channels_arg, rate_arg, format_arg,
     119            &channels_arg, &rate_arg, &format_arg);
     120        async_exchange_end(exch);
     121
     122        /* All OK or something has changed. Verify that it was not one of the
     123         * params we care about */
     124        if ((ret == EOK || ret == ELIMIT)
     125            && (!channels || *channels == channels_arg)
     126            && (!rate || *rate == rate_arg)
     127            && (!format || *format == format_arg))
     128                return EOK;
     129        if (channels)
     130                *channels = channels_arg;
     131        if (rate)
     132                *rate = rate_arg;
     133        if (format)
     134                *format = format_arg;
     135        return ret;
     136}
     137
    108138int audio_pcm_get_buffer(audio_pcm_sess_t *sess, void **buffer, size_t *size,
    109139    async_client_conn_t event_rec, void* arg)
     
    202232 */
    203233static void remote_audio_pcm_get_info_str(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     234static void remote_audio_pcm_test_format(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    204235static void remote_audio_pcm_get_buffer(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    205236static void remote_audio_pcm_release_buffer(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     
    212243static remote_iface_func_ptr_t remote_audio_pcm_iface_ops[] = {
    213244        [IPC_M_AUDIO_PCM_GET_INFO_STR] = remote_audio_pcm_get_info_str,
     245        [IPC_M_AUDIO_PCM_TEST_FORMAT] = remote_audio_pcm_test_format,
    214246        [IPC_M_AUDIO_PCM_GET_BUFFER] = remote_audio_pcm_get_buffer,
    215247        [IPC_M_AUDIO_PCM_RELEASE_BUFFER] = remote_audio_pcm_release_buffer,
     
    254286                async_data_read_finalize(name_id, name, name_size);
    255287        }
     288}
     289
     290static void remote_audio_pcm_test_format(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     291{
     292        const audio_pcm_iface_t *pcm_iface = iface;
     293        unsigned channels = DEV_IPC_GET_ARG1(*call);
     294        unsigned rate = DEV_IPC_GET_ARG2(*call);
     295        pcm_sample_format_t format = DEV_IPC_GET_ARG3(*call);
     296        const int ret = pcm_iface->test_format ?
     297            pcm_iface->test_format(fun, &channels, &rate, &format) : ENOTSUP;
     298        async_answer_3(callid, ret, channels, rate, format);
    256299}
    257300
  • uspace/lib/drv/include/audio_pcm_iface.h

    r5cd5079 r63c34d7  
    5858
    5959int audio_pcm_get_info_str(audio_pcm_sess_t *, const char **);
     60int audio_pcm_test_format(audio_pcm_sess_t *, unsigned *, unsigned *,
     61    pcm_sample_format_t *);
     62
    6063int audio_pcm_get_buffer(audio_pcm_sess_t *, void **, size_t *,
    6164    async_client_conn_t, void *);
     
    7376typedef struct {
    7477        int (*get_info_str)(ddf_fun_t *, const char **);
     78        int (*test_format)(ddf_fun_t *, unsigned *, unsigned *,
     79            pcm_sample_format_t *);
    7580        int (*get_buffer)(ddf_fun_t *, void **, size_t *);
    7681        int (*release_buffer)(ddf_fun_t *);
Note: See TracChangeset for help on using the changeset viewer.