| [c09ad29e] | 1 | /*
|
|---|
| [90f05b0f] | 2 | * Copyright (c) 2012 Jan Vesely
|
|---|
| [c09ad29e] | 3 | * All rights reserved.
|
|---|
| 4 | *
|
|---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 6 | * modification, are permitted provided that the following conditions
|
|---|
| 7 | * are met:
|
|---|
| 8 | *
|
|---|
| 9 | * - Redistributions of source code must retain the above copyright
|
|---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
|---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 13 | * documentation and/or other materials provided with the distribution.
|
|---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
|---|
| 15 | * derived from this software without specific prior written permission.
|
|---|
| 16 | *
|
|---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 27 | */
|
|---|
| 28 | /** @addtogroup libdrv
|
|---|
| 29 | * @{
|
|---|
| 30 | */
|
|---|
| 31 | /** @file
|
|---|
| 32 | */
|
|---|
| 33 |
|
|---|
| 34 | #include <async.h>
|
|---|
| [2cc5c835] | 35 | #include <devman.h>
|
|---|
| [f8608f2] | 36 | #include <ddf/log.h>
|
|---|
| [c09ad29e] | 37 | #include <errno.h>
|
|---|
| 38 | #include <str.h>
|
|---|
| 39 | #include <as.h>
|
|---|
| 40 | #include <sys/mman.h>
|
|---|
| 41 |
|
|---|
| [90f05b0f] | 42 | #include "audio_pcm_iface.h"
|
|---|
| [c09ad29e] | 43 | #include "ddf/driver.h"
|
|---|
| 44 |
|
|---|
| 45 | typedef enum {
|
|---|
| 46 | IPC_M_AUDIO_PCM_GET_INFO_STR,
|
|---|
| [2e01b3f] | 47 | IPC_M_AUDIO_PCM_QUERY_CAPS,
|
|---|
| [63c34d7] | 48 | IPC_M_AUDIO_PCM_TEST_FORMAT,
|
|---|
| [c09ad29e] | 49 | IPC_M_AUDIO_PCM_GET_BUFFER,
|
|---|
| 50 | IPC_M_AUDIO_PCM_RELEASE_BUFFER,
|
|---|
| [fa91c0f] | 51 | IPC_M_AUDIO_PCM_GET_BUFFER_POS,
|
|---|
| [c09ad29e] | 52 | IPC_M_AUDIO_PCM_START_PLAYBACK,
|
|---|
| 53 | IPC_M_AUDIO_PCM_STOP_PLAYBACK,
|
|---|
| [d86c9736] | 54 | IPC_M_AUDIO_PCM_START_CAPTURE,
|
|---|
| 55 | IPC_M_AUDIO_PCM_STOP_CAPTURE,
|
|---|
| [c09ad29e] | 56 | } audio_pcm_iface_funcs_t;
|
|---|
| 57 |
|
|---|
| 58 | /*
|
|---|
| 59 | * CLIENT SIDE
|
|---|
| 60 | */
|
|---|
| [ad1aedc] | 61 |
|
|---|
| 62 | /**
|
|---|
| 63 | * Open audio session with device identified by location service string.
|
|---|
| 64 | *
|
|---|
| 65 | * @param name Location service string.
|
|---|
| 66 | * @return Pointer to a new audio device session, NULL on failure.
|
|---|
| 67 | */
|
|---|
| [2cc5c835] | 68 | audio_pcm_sess_t *audio_pcm_open(const char *name)
|
|---|
| [c09ad29e] | 69 | {
|
|---|
| [2cc5c835] | 70 | devman_handle_t device_handle = 0;
|
|---|
| 71 | const int ret = devman_fun_get_handle(name, &device_handle, 0);
|
|---|
| 72 | if (ret != EOK)
|
|---|
| 73 | return NULL;
|
|---|
| 74 | return devman_device_connect(EXCHANGE_SERIALIZE, device_handle,
|
|---|
| 75 | IPC_FLAG_BLOCKING);
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| [ad1aedc] | 78 | /**
|
|---|
| 79 | * Open audio session with device identified by location service id
|
|---|
| 80 | *
|
|---|
| 81 | * @param name Location service id.
|
|---|
| 82 | * @return Pointer to a new audio device session, NULL on failure.
|
|---|
| 83 | */
|
|---|
| [2cc5c835] | 84 | audio_pcm_sess_t *audio_pcm_open_service(service_id_t id)
|
|---|
| 85 | {
|
|---|
| 86 | return loc_service_connect(EXCHANGE_SERIALIZE, id, IPC_FLAG_BLOCKING);
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| [ad1aedc] | 89 | /**
|
|---|
| 90 | * Close open audio device session.
|
|---|
| 91 | *
|
|---|
| 92 | * @param name Open audio device session.
|
|---|
| 93 | *
|
|---|
| 94 | * @note Calling this function on already closed or invalid session results
|
|---|
| 95 | * in undefined behavior.
|
|---|
| 96 | */
|
|---|
| [2cc5c835] | 97 | void audio_pcm_close(audio_pcm_sess_t *sess)
|
|---|
| 98 | {
|
|---|
| 99 | if (sess)
|
|---|
| 100 | async_hangup(sess);
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| [ad1aedc] | 103 | /**
|
|---|
| 104 | * Get a short description string.
|
|---|
| 105 | *
|
|---|
| 106 | * @param sess Audio device session.
|
|---|
| 107 | * @param name Place to store newly allocated string.
|
|---|
| 108 | *
|
|---|
| 109 | * @return Error code.
|
|---|
| 110 | *
|
|---|
| 111 | * @note Caller is responsible for freeing newly allocated memory.
|
|---|
| 112 | */
|
|---|
| [2cc5c835] | 113 | int audio_pcm_get_info_str(audio_pcm_sess_t *sess, const char **name)
|
|---|
| 114 | {
|
|---|
| 115 | async_exch_t *exch = async_exchange_begin(sess);
|
|---|
| [c09ad29e] | 116 | sysarg_t name_size;
|
|---|
| 117 | const int ret = async_req_1_1(exch,
|
|---|
| 118 | DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
|
|---|
| 119 | IPC_M_AUDIO_PCM_GET_INFO_STR, &name_size);
|
|---|
| 120 | if (ret == EOK && name) {
|
|---|
| 121 | char *name_place = calloc(1, name_size);
|
|---|
| 122 | if (!name_place) {
|
|---|
| 123 | /* Make the other side fail
|
|---|
| 124 | * as it waits for read request */
|
|---|
| 125 | async_data_read_start(exch, (void*)-1, 0);
|
|---|
| [2cc5c835] | 126 | async_exchange_end(exch);
|
|---|
| [c09ad29e] | 127 | return ENOMEM;
|
|---|
| 128 | }
|
|---|
| 129 | const int ret =
|
|---|
| 130 | async_data_read_start(exch, name_place, name_size);
|
|---|
| 131 | if (ret != EOK) {
|
|---|
| 132 | free(name_place);
|
|---|
| [2cc5c835] | 133 | async_exchange_end(exch);
|
|---|
| [c09ad29e] | 134 | return ret;
|
|---|
| 135 | }
|
|---|
| 136 | *name = name_place;
|
|---|
| 137 | }
|
|---|
| [2cc5c835] | 138 | async_exchange_end(exch);
|
|---|
| [c09ad29e] | 139 | return ret;
|
|---|
| 140 | }
|
|---|
| [4bbfb93] | 141 |
|
|---|
| [ad1aedc] | 142 |
|
|---|
| 143 | /**
|
|---|
| 144 | * Query value of specified capability.
|
|---|
| 145 | *
|
|---|
| 146 | * @param sess Audio device session.
|
|---|
| 147 | * @param cap Audio device capability.
|
|---|
| 148 | * @param val Place to store queried value.
|
|---|
| 149 | *
|
|---|
| 150 | * @return Error code.
|
|---|
| 151 | */
|
|---|
| [2e01b3f] | 152 | int audio_pcm_query_cap(audio_pcm_sess_t *sess, audio_cap_t cap, unsigned *val)
|
|---|
| 153 | {
|
|---|
| 154 | if (!val)
|
|---|
| 155 | return EINVAL;
|
|---|
| 156 | async_exch_t *exch = async_exchange_begin(sess);
|
|---|
| [fa91c0f] | 157 | sysarg_t value = 0;
|
|---|
| [2e01b3f] | 158 | const int ret = async_req_2_1(exch,
|
|---|
| 159 | DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE), IPC_M_AUDIO_PCM_QUERY_CAPS,
|
|---|
| [fa91c0f] | 160 | cap, &value);
|
|---|
| [2e01b3f] | 161 | if (ret == EOK)
|
|---|
| 162 | *val = value;
|
|---|
| [fa91c0f] | 163 | async_exchange_end(exch);
|
|---|
| 164 | return ret;
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| [ad1aedc] | 167 | /**
|
|---|
| 168 | * Query current position in device buffer.
|
|---|
| 169 | *
|
|---|
| 170 | * @param sess Audio device session.
|
|---|
| 171 | * @param pos Place to store the result.
|
|---|
| 172 | *
|
|---|
| 173 | * @return Error code.
|
|---|
| 174 | *
|
|---|
| 175 | * Works for both playback and capture.
|
|---|
| 176 | */
|
|---|
| [fa91c0f] | 177 | int audio_pcm_get_buffer_pos(audio_pcm_sess_t *sess, size_t *pos)
|
|---|
| 178 | {
|
|---|
| 179 | if (!pos)
|
|---|
| 180 | return EINVAL;
|
|---|
| 181 | async_exch_t *exch = async_exchange_begin(sess);
|
|---|
| 182 | sysarg_t value = 0;;
|
|---|
| 183 | const int ret = async_req_1_1(exch,
|
|---|
| 184 | DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
|
|---|
| 185 | IPC_M_AUDIO_PCM_GET_BUFFER_POS, &value);
|
|---|
| 186 | if (ret == EOK)
|
|---|
| 187 | *pos = value;
|
|---|
| 188 | async_exchange_end(exch);
|
|---|
| [2e01b3f] | 189 | return ret;
|
|---|
| 190 | }
|
|---|
| 191 |
|
|---|
| [ad1aedc] | 192 | /**
|
|---|
| 193 | * Test format parameters for device support.
|
|---|
| 194 | *
|
|---|
| 195 | * @param sess Audio device session.
|
|---|
| 196 | * @param channels Number of channels
|
|---|
| 197 | * @param rate Sampling rate.
|
|---|
| 198 | * @format Sample format.
|
|---|
| 199 | *
|
|---|
| 200 | * @return Error code.
|
|---|
| 201 | *
|
|---|
| 202 | * Works for both playback and capture. This function modifies provided
|
|---|
| 203 | * parameters to the nearest values supported by the device.
|
|---|
| 204 | */
|
|---|
| [63c34d7] | 205 | int audio_pcm_test_format(audio_pcm_sess_t *sess, unsigned *channels,
|
|---|
| 206 | unsigned *rate, pcm_sample_format_t *format)
|
|---|
| 207 | {
|
|---|
| 208 | async_exch_t *exch = async_exchange_begin(sess);
|
|---|
| 209 | sysarg_t channels_arg = channels ? *channels : 0;
|
|---|
| 210 | sysarg_t rate_arg = rate ? *rate : 0;
|
|---|
| 211 | sysarg_t format_arg = format ? *format : 0;
|
|---|
| 212 | const int ret = async_req_4_3(exch,
|
|---|
| 213 | DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
|
|---|
| 214 | IPC_M_AUDIO_PCM_TEST_FORMAT, channels_arg, rate_arg, format_arg,
|
|---|
| 215 | &channels_arg, &rate_arg, &format_arg);
|
|---|
| 216 | async_exchange_end(exch);
|
|---|
| 217 |
|
|---|
| 218 | /* All OK or something has changed. Verify that it was not one of the
|
|---|
| 219 | * params we care about */
|
|---|
| 220 | if ((ret == EOK || ret == ELIMIT)
|
|---|
| 221 | && (!channels || *channels == channels_arg)
|
|---|
| 222 | && (!rate || *rate == rate_arg)
|
|---|
| 223 | && (!format || *format == format_arg))
|
|---|
| 224 | return EOK;
|
|---|
| 225 | if (channels)
|
|---|
| 226 | *channels = channels_arg;
|
|---|
| 227 | if (rate)
|
|---|
| 228 | *rate = rate_arg;
|
|---|
| 229 | if (format)
|
|---|
| 230 | *format = format_arg;
|
|---|
| 231 | return ret;
|
|---|
| 232 | }
|
|---|
| 233 |
|
|---|
| [ad1aedc] | 234 | /**
|
|---|
| 235 | * Get device accessible playback/capture buffer.
|
|---|
| 236 | *
|
|---|
| 237 | * @param sess Audio device session.
|
|---|
| 238 | * @param buffer Place to store pointer to the buffer.
|
|---|
| 239 | * @param size Place to store buffer size (bytes).
|
|---|
| 240 | * @param event_rec Event callback function.
|
|---|
| 241 | * @param arg Event callback custom parameter.
|
|---|
| 242 | *
|
|---|
| 243 | * @return Error code.
|
|---|
| 244 | */
|
|---|
| [2cc5c835] | 245 | int audio_pcm_get_buffer(audio_pcm_sess_t *sess, void **buffer, size_t *size,
|
|---|
| [b497018] | 246 | async_client_conn_t event_rec, void* arg)
|
|---|
| [c09ad29e] | 247 | {
|
|---|
| [2cc5c835] | 248 | if (!buffer || !size)
|
|---|
| [c09ad29e] | 249 | return EINVAL;
|
|---|
| [00006e0] | 250 |
|
|---|
| [2cc5c835] | 251 | async_exch_t *exch = async_exchange_begin(sess);
|
|---|
| 252 |
|
|---|
| [b497018] | 253 | sysarg_t buffer_size = *size;
|
|---|
| 254 | const int ret = async_req_2_1(exch,
|
|---|
| [c09ad29e] | 255 | DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE), IPC_M_AUDIO_PCM_GET_BUFFER,
|
|---|
| [b497018] | 256 | (sysarg_t)buffer_size, &buffer_size);
|
|---|
| [c09ad29e] | 257 | if (ret == EOK) {
|
|---|
| [722912e] | 258 | void *dst = NULL;
|
|---|
| [8de7ef2] | 259 | int ret = async_share_in_start_0_0(exch, buffer_size, &dst);
|
|---|
| [c09ad29e] | 260 | if (ret != EOK) {
|
|---|
| [2cc5c835] | 261 | async_exchange_end(exch);
|
|---|
| [c09ad29e] | 262 | return ret;
|
|---|
| 263 | }
|
|---|
| [8de7ef2] | 264 | ret = async_connect_to_me(exch, 0, 0, 0, event_rec, arg);
|
|---|
| 265 | if (ret != EOK) {
|
|---|
| [2cc5c835] | 266 | async_exchange_end(exch);
|
|---|
| [8de7ef2] | 267 | return ret;
|
|---|
| 268 | }
|
|---|
| 269 |
|
|---|
| [c09ad29e] | 270 | *buffer = dst;
|
|---|
| 271 | *size = buffer_size;
|
|---|
| [00006e0] | 272 | }
|
|---|
| [2cc5c835] | 273 | async_exchange_end(exch);
|
|---|
| [c09ad29e] | 274 | return ret;
|
|---|
| 275 | }
|
|---|
| [4bbfb93] | 276 |
|
|---|
| [ad1aedc] | 277 | /**
|
|---|
| 278 | * Release device accessible playback/capture buffer.
|
|---|
| 279 | *
|
|---|
| 280 | * @param sess Audio device session.
|
|---|
| 281 | *
|
|---|
| 282 | * @return Error code.
|
|---|
| 283 | */
|
|---|
| [2cc5c835] | 284 | int audio_pcm_release_buffer(audio_pcm_sess_t *sess)
|
|---|
| [c09ad29e] | 285 | {
|
|---|
| [2cc5c835] | 286 | async_exch_t *exch = async_exchange_begin(sess);
|
|---|
| 287 | const int ret = async_req_1_0(exch,
|
|---|
| 288 | DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
|
|---|
| [b497018] | 289 | IPC_M_AUDIO_PCM_RELEASE_BUFFER);
|
|---|
| [2cc5c835] | 290 | async_exchange_end(exch);
|
|---|
| 291 | return ret;
|
|---|
| [c09ad29e] | 292 | }
|
|---|
| [4bbfb93] | 293 |
|
|---|
| [ad1aedc] | 294 | /**
|
|---|
| 295 | * Start playback on buffer from position 0.
|
|---|
| 296 | *
|
|---|
| 297 | * @param sess Audio device session.
|
|---|
| 298 | * @param frames Size of fragment (in frames).
|
|---|
| 299 | * @param channels Number of channels.
|
|---|
| 300 | * @param sample_rate Sampling rate (for one channel).
|
|---|
| 301 | * @param format Sample format.
|
|---|
| 302 | *
|
|---|
| 303 | * @return Error code.
|
|---|
| 304 | *
|
|---|
| 305 | * Event will be generated after every fragment. Set fragment size to
|
|---|
| 306 | * 0 to turn off event generation.
|
|---|
| 307 | */
|
|---|
| [57e8b3b] | 308 | int audio_pcm_start_playback(audio_pcm_sess_t *sess, unsigned frames,
|
|---|
| [346643c] | 309 | unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
|
|---|
| [c09ad29e] | 310 | {
|
|---|
| [57e8b3b] | 311 | if (channels > UINT16_MAX)
|
|---|
| [346643c] | 312 | return EINVAL;
|
|---|
| 313 | assert((format & UINT16_MAX) == format);
|
|---|
| [57e8b3b] | 314 | const sysarg_t packed = (channels << 16) | (format & UINT16_MAX);
|
|---|
| [2cc5c835] | 315 | async_exch_t *exch = async_exchange_begin(sess);
|
|---|
| [57e8b3b] | 316 | const int ret = async_req_4_0(exch,
|
|---|
| [2cc5c835] | 317 | DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
|
|---|
| 318 | IPC_M_AUDIO_PCM_START_PLAYBACK,
|
|---|
| [57e8b3b] | 319 | frames, sample_rate, packed);
|
|---|
| [2cc5c835] | 320 | async_exchange_end(exch);
|
|---|
| 321 | return ret;
|
|---|
| [c09ad29e] | 322 | }
|
|---|
| [4bbfb93] | 323 |
|
|---|
| [ad1aedc] | 324 | /**
|
|---|
| 325 | * Stop current playback.
|
|---|
| 326 | *
|
|---|
| 327 | * @param sess Audio device session.
|
|---|
| 328 | *
|
|---|
| 329 | * @return Error code.
|
|---|
| 330 | */
|
|---|
| [2cc5c835] | 331 | int audio_pcm_stop_playback(audio_pcm_sess_t *sess)
|
|---|
| [c09ad29e] | 332 | {
|
|---|
| [2cc5c835] | 333 | async_exch_t *exch = async_exchange_begin(sess);
|
|---|
| 334 | const int ret = async_req_1_0(exch,
|
|---|
| 335 | DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
|
|---|
| [b497018] | 336 | IPC_M_AUDIO_PCM_STOP_PLAYBACK);
|
|---|
| [2cc5c835] | 337 | async_exchange_end(exch);
|
|---|
| 338 | return ret;
|
|---|
| [c09ad29e] | 339 | }
|
|---|
| [4bbfb93] | 340 |
|
|---|
| [ad1aedc] | 341 | /**
|
|---|
| 342 | * Start capture on buffer from position 0.
|
|---|
| 343 | *
|
|---|
| 344 | * @param sess Audio device session.
|
|---|
| 345 | * @param frames Size of fragment (in frames).
|
|---|
| 346 | * @param channels Number of channels.
|
|---|
| 347 | * @param sample_rate Sampling rate (for one channel).
|
|---|
| 348 | * @param format Sample format.
|
|---|
| 349 | *
|
|---|
| 350 | * @return Error code.
|
|---|
| 351 | *
|
|---|
| 352 | * Event will be generated after every fragment. Set fragment size to
|
|---|
| 353 | * 0 to turn off event generation.
|
|---|
| 354 | */
|
|---|
| [d86c9736] | 355 | int audio_pcm_start_capture(audio_pcm_sess_t *sess, unsigned frames,
|
|---|
| [346643c] | 356 | unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
|
|---|
| [c09ad29e] | 357 | {
|
|---|
| [57e8b3b] | 358 | if (channels > UINT16_MAX)
|
|---|
| [346643c] | 359 | return EINVAL;
|
|---|
| 360 | assert((format & UINT16_MAX) == format);
|
|---|
| [57e8b3b] | 361 | const sysarg_t packed = (channels << 16) | (format & UINT16_MAX);
|
|---|
| [2cc5c835] | 362 | async_exch_t *exch = async_exchange_begin(sess);
|
|---|
| [57e8b3b] | 363 | const int ret = async_req_4_0(exch,
|
|---|
| [d86c9736] | 364 | DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE), IPC_M_AUDIO_PCM_START_CAPTURE,
|
|---|
| [57e8b3b] | 365 | frames, sample_rate, packed);
|
|---|
| [2cc5c835] | 366 | async_exchange_end(exch);
|
|---|
| 367 | return ret;
|
|---|
| [c09ad29e] | 368 | }
|
|---|
| [4bbfb93] | 369 |
|
|---|
| [ad1aedc] | 370 | /**
|
|---|
| 371 | * Stop current playback.
|
|---|
| 372 | *
|
|---|
| 373 | * @param sess Audio device session.
|
|---|
| 374 | *
|
|---|
| 375 | * @return Error code.
|
|---|
| 376 | */
|
|---|
| [d86c9736] | 377 | int audio_pcm_stop_capture(audio_pcm_sess_t *sess)
|
|---|
| [c09ad29e] | 378 | {
|
|---|
| [2cc5c835] | 379 | async_exch_t *exch = async_exchange_begin(sess);
|
|---|
| 380 | const int ret = async_req_1_0(exch,
|
|---|
| [d86c9736] | 381 | DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE), IPC_M_AUDIO_PCM_STOP_CAPTURE);
|
|---|
| [2cc5c835] | 382 | async_exchange_end(exch);
|
|---|
| 383 | return ret;
|
|---|
| [c09ad29e] | 384 | }
|
|---|
| 385 |
|
|---|
| 386 | /*
|
|---|
| 387 | * SERVER SIDE
|
|---|
| 388 | */
|
|---|
| 389 | static void remote_audio_pcm_get_info_str(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
|
|---|
| [2e01b3f] | 390 | static void remote_audio_pcm_query_caps(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
|
|---|
| [fa91c0f] | 391 | static void remote_audio_pcm_get_buffer_pos(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
|
|---|
| [63c34d7] | 392 | static void remote_audio_pcm_test_format(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
|
|---|
| [c09ad29e] | 393 | static void remote_audio_pcm_get_buffer(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
|
|---|
| 394 | static void remote_audio_pcm_release_buffer(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
|
|---|
| 395 | static void remote_audio_pcm_start_playback(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
|
|---|
| 396 | static void remote_audio_pcm_stop_playback(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
|
|---|
| [d86c9736] | 397 | static void remote_audio_pcm_start_capture(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
|
|---|
| 398 | static void remote_audio_pcm_stop_capture(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
|
|---|
| [c09ad29e] | 399 |
|
|---|
| 400 | /** Remote audio pcm buffer interface operations. */
|
|---|
| 401 | static remote_iface_func_ptr_t remote_audio_pcm_iface_ops[] = {
|
|---|
| 402 | [IPC_M_AUDIO_PCM_GET_INFO_STR] = remote_audio_pcm_get_info_str,
|
|---|
| [2e01b3f] | 403 | [IPC_M_AUDIO_PCM_QUERY_CAPS] = remote_audio_pcm_query_caps,
|
|---|
| [fa91c0f] | 404 | [IPC_M_AUDIO_PCM_GET_BUFFER_POS] = remote_audio_pcm_get_buffer_pos,
|
|---|
| [63c34d7] | 405 | [IPC_M_AUDIO_PCM_TEST_FORMAT] = remote_audio_pcm_test_format,
|
|---|
| [c09ad29e] | 406 | [IPC_M_AUDIO_PCM_GET_BUFFER] = remote_audio_pcm_get_buffer,
|
|---|
| 407 | [IPC_M_AUDIO_PCM_RELEASE_BUFFER] = remote_audio_pcm_release_buffer,
|
|---|
| 408 | [IPC_M_AUDIO_PCM_START_PLAYBACK] = remote_audio_pcm_start_playback,
|
|---|
| 409 | [IPC_M_AUDIO_PCM_STOP_PLAYBACK] = remote_audio_pcm_stop_playback,
|
|---|
| [d86c9736] | 410 | [IPC_M_AUDIO_PCM_START_CAPTURE] = remote_audio_pcm_start_capture,
|
|---|
| 411 | [IPC_M_AUDIO_PCM_STOP_CAPTURE] = remote_audio_pcm_stop_capture,
|
|---|
| [c09ad29e] | 412 | };
|
|---|
| 413 |
|
|---|
| 414 | /** Remote audio mixer interface structure. */
|
|---|
| [90f05b0f] | 415 | remote_iface_t remote_audio_pcm_iface = {
|
|---|
| [c09ad29e] | 416 | .method_count = sizeof(remote_audio_pcm_iface_ops) /
|
|---|
| 417 | sizeof(remote_audio_pcm_iface_ops[0]),
|
|---|
| 418 | .methods = remote_audio_pcm_iface_ops
|
|---|
| 419 | };
|
|---|
| [4bbfb93] | 420 |
|
|---|
| [c09ad29e] | 421 | void remote_audio_pcm_get_info_str(ddf_fun_t *fun, void *iface,
|
|---|
| 422 | ipc_callid_t callid, ipc_call_t *call)
|
|---|
| 423 | {
|
|---|
| [90f05b0f] | 424 | const audio_pcm_iface_t *pcm_iface = iface;
|
|---|
| [c09ad29e] | 425 |
|
|---|
| 426 | if (!pcm_iface->get_info_str) {
|
|---|
| 427 | async_answer_0(callid, ENOTSUP);
|
|---|
| 428 | return;
|
|---|
| 429 | }
|
|---|
| 430 | const char *name = NULL;
|
|---|
| 431 | const int ret = pcm_iface->get_info_str(fun, &name);
|
|---|
| 432 | const size_t name_size = name ? str_size(name) + 1 : 0;
|
|---|
| 433 | async_answer_1(callid, ret, name_size);
|
|---|
| 434 | /* Send the string. */
|
|---|
| 435 | if (ret == EOK && name_size > 0) {
|
|---|
| 436 | size_t size;
|
|---|
| 437 | ipc_callid_t name_id;
|
|---|
| 438 | if (!async_data_read_receive(&name_id, &size)) {
|
|---|
| 439 | async_answer_0(name_id, EPARTY);
|
|---|
| 440 | return;
|
|---|
| 441 | }
|
|---|
| 442 | if (size != name_size) {
|
|---|
| 443 | async_answer_0(name_id, ELIMIT);
|
|---|
| 444 | return;
|
|---|
| 445 | }
|
|---|
| 446 | async_data_read_finalize(name_id, name, name_size);
|
|---|
| 447 | }
|
|---|
| 448 | }
|
|---|
| [4bbfb93] | 449 |
|
|---|
| [2e01b3f] | 450 | void remote_audio_pcm_query_caps(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
|
|---|
| 451 | {
|
|---|
| 452 | const audio_pcm_iface_t *pcm_iface = iface;
|
|---|
| 453 | const audio_cap_t cap = DEV_IPC_GET_ARG1(*call);
|
|---|
| 454 | if (pcm_iface->query_cap) {
|
|---|
| 455 | const unsigned value = pcm_iface->query_cap(fun, cap);
|
|---|
| 456 | async_answer_1(callid, EOK, value);
|
|---|
| 457 | } else {
|
|---|
| 458 | async_answer_0(callid, ENOTSUP);
|
|---|
| 459 | }
|
|---|
| 460 | }
|
|---|
| [fa91c0f] | 461 | void remote_audio_pcm_get_buffer_pos(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
|
|---|
| 462 | {
|
|---|
| 463 | const audio_pcm_iface_t *pcm_iface = iface;
|
|---|
| 464 | size_t pos = 0;
|
|---|
| 465 | const int ret = pcm_iface->get_buffer_pos ?
|
|---|
| 466 | pcm_iface->get_buffer_pos(fun, &pos) : ENOTSUP;
|
|---|
| 467 | async_answer_1(callid, ret, pos);
|
|---|
| 468 | }
|
|---|
| [2e01b3f] | 469 |
|
|---|
| 470 | void remote_audio_pcm_test_format(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
|
|---|
| [63c34d7] | 471 | {
|
|---|
| 472 | const audio_pcm_iface_t *pcm_iface = iface;
|
|---|
| 473 | unsigned channels = DEV_IPC_GET_ARG1(*call);
|
|---|
| 474 | unsigned rate = DEV_IPC_GET_ARG2(*call);
|
|---|
| 475 | pcm_sample_format_t format = DEV_IPC_GET_ARG3(*call);
|
|---|
| 476 | const int ret = pcm_iface->test_format ?
|
|---|
| 477 | pcm_iface->test_format(fun, &channels, &rate, &format) : ENOTSUP;
|
|---|
| 478 | async_answer_3(callid, ret, channels, rate, format);
|
|---|
| 479 | }
|
|---|
| 480 |
|
|---|
| [c09ad29e] | 481 | void remote_audio_pcm_get_buffer(ddf_fun_t *fun, void *iface,
|
|---|
| 482 | ipc_callid_t callid, ipc_call_t *call)
|
|---|
| 483 | {
|
|---|
| [90f05b0f] | 484 | const audio_pcm_iface_t *pcm_iface = iface;
|
|---|
| [c09ad29e] | 485 |
|
|---|
| [8de7ef2] | 486 | if (!pcm_iface->get_buffer ||
|
|---|
| 487 | !pcm_iface->release_buffer ||
|
|---|
| 488 | !pcm_iface->set_event_session) {
|
|---|
| [c09ad29e] | 489 | async_answer_0(callid, ENOTSUP);
|
|---|
| 490 | return;
|
|---|
| 491 | }
|
|---|
| 492 | void *buffer = NULL;
|
|---|
| [00006e0] | 493 | size_t size = DEV_IPC_GET_ARG1(*call);
|
|---|
| [b497018] | 494 | int ret = pcm_iface->get_buffer(fun, &buffer, &size);
|
|---|
| 495 | async_answer_1(callid, ret, size);
|
|---|
| [8de7ef2] | 496 | if (ret != EOK || size == 0)
|
|---|
| 497 | return;
|
|---|
| 498 |
|
|---|
| [c09ad29e] | 499 | /* Share the buffer. */
|
|---|
| [8de7ef2] | 500 | size_t share_size = 0;
|
|---|
| 501 | ipc_callid_t share_id = 0;
|
|---|
| [7364c6ee] | 502 |
|
|---|
| 503 | ddf_msg(LVL_DEBUG2, "Receiving share request.");
|
|---|
| [8de7ef2] | 504 | if (!async_share_in_receive(&share_id, &share_size)) {
|
|---|
| 505 | ddf_msg(LVL_DEBUG, "Failed to share pcm buffer.");
|
|---|
| [b497018] | 506 | pcm_iface->release_buffer(fun);
|
|---|
| [8de7ef2] | 507 | async_answer_0(share_id, EPARTY);
|
|---|
| 508 | return;
|
|---|
| 509 | }
|
|---|
| [7364c6ee] | 510 |
|
|---|
| 511 | ddf_msg(LVL_DEBUG2, "Checking requested share size.");
|
|---|
| [8de7ef2] | 512 | if (share_size != size) {
|
|---|
| 513 | ddf_msg(LVL_DEBUG, "Incorrect pcm buffer size requested.");
|
|---|
| [b497018] | 514 | pcm_iface->release_buffer(fun);
|
|---|
| [8de7ef2] | 515 | async_answer_0(share_id, ELIMIT);
|
|---|
| 516 | return;
|
|---|
| 517 | }
|
|---|
| [7364c6ee] | 518 |
|
|---|
| 519 | ddf_msg(LVL_DEBUG2, "Calling share finalize.");
|
|---|
| 520 | ret = async_share_in_finalize(share_id, buffer, AS_AREA_WRITE
|
|---|
| 521 | | AS_AREA_READ);
|
|---|
| [8de7ef2] | 522 | if (ret != EOK) {
|
|---|
| [7364c6ee] | 523 | ddf_msg(LVL_DEBUG, "Failed to share buffer.");
|
|---|
| [b497018] | 524 | pcm_iface->release_buffer(fun);
|
|---|
| [8de7ef2] | 525 | return;
|
|---|
| 526 | }
|
|---|
| [7364c6ee] | 527 |
|
|---|
| [8de7ef2] | 528 | ddf_msg(LVL_DEBUG2, "Buffer shared with size %zu, creating callback.",
|
|---|
| 529 | share_size);
|
|---|
| 530 | {
|
|---|
| 531 | ipc_call_t call;
|
|---|
| 532 | ipc_callid_t callid = async_get_call(&call);
|
|---|
| 533 | async_sess_t *sess =
|
|---|
| 534 | async_callback_receive_start(EXCHANGE_ATOMIC, &call);
|
|---|
| 535 | if (sess == NULL) {
|
|---|
| 536 | ddf_msg(LVL_DEBUG, "Failed to create event callback");
|
|---|
| [b497018] | 537 | pcm_iface->release_buffer(fun);
|
|---|
| [8de7ef2] | 538 | async_answer_0(callid, EAGAIN);
|
|---|
| [c09ad29e] | 539 | return;
|
|---|
| 540 | }
|
|---|
| [b497018] | 541 | ret = pcm_iface->set_event_session(fun, sess);
|
|---|
| [f8608f2] | 542 | if (ret != EOK) {
|
|---|
| [8de7ef2] | 543 | ddf_msg(LVL_DEBUG, "Failed to set event callback.");
|
|---|
| [b497018] | 544 | pcm_iface->release_buffer(fun);
|
|---|
| [7364c6ee] | 545 | async_answer_0(callid, ret);
|
|---|
| 546 | return;
|
|---|
| [f8608f2] | 547 | }
|
|---|
| [7364c6ee] | 548 | ddf_msg(LVL_DEBUG2, "Buffer and event session setup OK.");
|
|---|
| 549 | async_answer_0(callid, EOK);
|
|---|
| [c09ad29e] | 550 | }
|
|---|
| 551 | }
|
|---|
| [4bbfb93] | 552 |
|
|---|
| [c09ad29e] | 553 | void remote_audio_pcm_release_buffer(ddf_fun_t *fun, void *iface,
|
|---|
| 554 | ipc_callid_t callid, ipc_call_t *call)
|
|---|
| 555 | {
|
|---|
| [90f05b0f] | 556 | const audio_pcm_iface_t *pcm_iface = iface;
|
|---|
| [c09ad29e] | 557 |
|
|---|
| 558 | const int ret = pcm_iface->release_buffer ?
|
|---|
| [b497018] | 559 | pcm_iface->release_buffer(fun) : ENOTSUP;
|
|---|
| [c09ad29e] | 560 | async_answer_0(callid, ret);
|
|---|
| 561 | }
|
|---|
| [4bbfb93] | 562 |
|
|---|
| [c09ad29e] | 563 | void remote_audio_pcm_start_playback(ddf_fun_t *fun, void *iface,
|
|---|
| 564 | ipc_callid_t callid, ipc_call_t *call)
|
|---|
| 565 | {
|
|---|
| [90f05b0f] | 566 | const audio_pcm_iface_t *pcm_iface = iface;
|
|---|
| [c09ad29e] | 567 |
|
|---|
| [57e8b3b] | 568 | const unsigned frames = DEV_IPC_GET_ARG1(*call);
|
|---|
| 569 | const unsigned rate = DEV_IPC_GET_ARG2(*call);
|
|---|
| 570 | const unsigned channels = (DEV_IPC_GET_ARG3(*call) >> 16) & UINT8_MAX;
|
|---|
| 571 | const pcm_sample_format_t format = DEV_IPC_GET_ARG3(*call) & UINT16_MAX;
|
|---|
| [c09ad29e] | 572 |
|
|---|
| 573 | const int ret = pcm_iface->start_playback
|
|---|
| [57e8b3b] | 574 | ? pcm_iface->start_playback(fun, frames, channels, rate, format)
|
|---|
| [c09ad29e] | 575 | : ENOTSUP;
|
|---|
| 576 | async_answer_0(callid, ret);
|
|---|
| 577 | }
|
|---|
| [4bbfb93] | 578 |
|
|---|
| [c09ad29e] | 579 | void remote_audio_pcm_stop_playback(ddf_fun_t *fun, void *iface,
|
|---|
| 580 | ipc_callid_t callid, ipc_call_t *call)
|
|---|
| 581 | {
|
|---|
| [90f05b0f] | 582 | const audio_pcm_iface_t *pcm_iface = iface;
|
|---|
| [c09ad29e] | 583 |
|
|---|
| 584 | const int ret = pcm_iface->stop_playback ?
|
|---|
| [b497018] | 585 | pcm_iface->stop_playback(fun) : ENOTSUP;
|
|---|
| [c09ad29e] | 586 | async_answer_0(callid, ret);
|
|---|
| 587 | }
|
|---|
| [4bbfb93] | 588 |
|
|---|
| [d86c9736] | 589 | void remote_audio_pcm_start_capture(ddf_fun_t *fun, void *iface,
|
|---|
| [c09ad29e] | 590 | ipc_callid_t callid, ipc_call_t *call)
|
|---|
| 591 | {
|
|---|
| [90f05b0f] | 592 | const audio_pcm_iface_t *pcm_iface = iface;
|
|---|
| [c09ad29e] | 593 |
|
|---|
| [57e8b3b] | 594 | const unsigned frames = DEV_IPC_GET_ARG1(*call);
|
|---|
| 595 | const unsigned rate = DEV_IPC_GET_ARG2(*call);
|
|---|
| 596 | const unsigned channels = (DEV_IPC_GET_ARG3(*call) >> 16) & UINT16_MAX;
|
|---|
| 597 | const pcm_sample_format_t format = DEV_IPC_GET_ARG3(*call) & UINT16_MAX;
|
|---|
| [c09ad29e] | 598 |
|
|---|
| [d86c9736] | 599 | const int ret = pcm_iface->start_capture
|
|---|
| 600 | ? pcm_iface->start_capture(fun, frames, channels, rate, format)
|
|---|
| [c09ad29e] | 601 | : ENOTSUP;
|
|---|
| 602 | async_answer_0(callid, ret);
|
|---|
| 603 | }
|
|---|
| [4bbfb93] | 604 |
|
|---|
| [d86c9736] | 605 | void remote_audio_pcm_stop_capture(ddf_fun_t *fun, void *iface,
|
|---|
| [c09ad29e] | 606 | ipc_callid_t callid, ipc_call_t *call)
|
|---|
| 607 | {
|
|---|
| [90f05b0f] | 608 | const audio_pcm_iface_t *pcm_iface = iface;
|
|---|
| [c09ad29e] | 609 |
|
|---|
| [d86c9736] | 610 | const int ret = pcm_iface->stop_capture ?
|
|---|
| 611 | pcm_iface->stop_capture(fun) : ENOTSUP;
|
|---|
| [c09ad29e] | 612 | async_answer_0(callid, ret);
|
|---|
| 613 | }
|
|---|
| 614 |
|
|---|
| 615 | #if 0
|
|---|
| [4bbfb93] | 616 |
|
|---|
| [c09ad29e] | 617 | void remote_audio_mixer_get_info(
|
|---|
| 618 | ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
|
|---|
| 619 | {
|
|---|
| 620 | audio_mixer_iface_t *mixer_iface = iface;
|
|---|
| 621 |
|
|---|
| 622 | if (!mixer_iface->get_info) {
|
|---|
| 623 | async_answer_0(callid, ENOTSUP);
|
|---|
| 624 | return;
|
|---|
| 625 | }
|
|---|
| 626 | const char *name = NULL;
|
|---|
| 627 | unsigned items = 0;
|
|---|
| 628 | const int ret = mixer_iface->get_info(fun, &name, &items);
|
|---|
| 629 | const size_t name_size = name ? str_size(name) + 1 : 0;
|
|---|
| 630 | async_answer_2(callid, ret, name_size, items);
|
|---|
| 631 | /* Send the name. */
|
|---|
| 632 | if (ret == EOK && name_size > 0) {
|
|---|
| 633 | size_t size;
|
|---|
| 634 | ipc_callid_t name_id;
|
|---|
| 635 | if (!async_data_read_receive(&name_id, &size)) {
|
|---|
| 636 | async_answer_0(name_id, EPARTY);
|
|---|
| 637 | return;
|
|---|
| 638 | }
|
|---|
| 639 | if (size != name_size) {
|
|---|
| 640 | async_answer_0(name_id, ELIMIT);
|
|---|
| 641 | return;
|
|---|
| 642 | }
|
|---|
| 643 | async_data_read_finalize(name_id, name, name_size);
|
|---|
| 644 | }
|
|---|
| 645 | }
|
|---|
| [4bbfb93] | 646 |
|
|---|
| [c09ad29e] | 647 | void remote_audio_mixer_get_item_info(
|
|---|
| 648 | ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
|
|---|
| 649 | {
|
|---|
| 650 | audio_mixer_iface_t *mixer_iface = iface;
|
|---|
| 651 |
|
|---|
| 652 | if (!mixer_iface->get_item_info) {
|
|---|
| 653 | async_answer_0(callid, ENOTSUP);
|
|---|
| 654 | return;
|
|---|
| 655 | }
|
|---|
| 656 |
|
|---|
| 657 | const unsigned item = DEV_IPC_GET_ARG1(*call);
|
|---|
| 658 | const char *name = NULL;
|
|---|
| 659 | unsigned channels = 0;
|
|---|
| 660 | const int ret = mixer_iface->get_item_info(fun, item, &name, &channels);
|
|---|
| 661 | const size_t name_size = name ? str_size(name) + 1 : 0;
|
|---|
| 662 | async_answer_2(callid, ret, name_size, channels);
|
|---|
| 663 | /* Send the name. */
|
|---|
| 664 | if (ret == EOK && name_size > 0) {
|
|---|
| 665 | size_t size;
|
|---|
| 666 | ipc_callid_t name_id;
|
|---|
| 667 | if (!async_data_read_receive(&name_id, &size)) {
|
|---|
| 668 | async_answer_0(name_id, EPARTY);
|
|---|
| 669 | return;
|
|---|
| 670 | }
|
|---|
| 671 | if (size != name_size) {
|
|---|
| 672 | async_answer_0(name_id, ELIMIT);
|
|---|
| 673 | return;
|
|---|
| 674 | }
|
|---|
| 675 | async_data_read_finalize(name_id, name, name_size);
|
|---|
| 676 | }
|
|---|
| 677 | }
|
|---|
| [4bbfb93] | 678 |
|
|---|
| [c09ad29e] | 679 | void remote_audio_mixer_get_channel_info(
|
|---|
| 680 | ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
|
|---|
| 681 | {
|
|---|
| 682 | audio_mixer_iface_t *mixer_iface = iface;
|
|---|
| 683 |
|
|---|
| 684 | if (!mixer_iface->get_channel_info) {
|
|---|
| 685 | async_answer_0(callid, ENOTSUP);
|
|---|
| 686 | return;
|
|---|
| 687 | }
|
|---|
| 688 |
|
|---|
| 689 | const unsigned item = DEV_IPC_GET_ARG1(*call);
|
|---|
| 690 | const unsigned channel = DEV_IPC_GET_ARG2(*call);
|
|---|
| 691 | const char *name = NULL;
|
|---|
| 692 | unsigned levels = 0;
|
|---|
| 693 | const int ret =
|
|---|
| 694 | mixer_iface->get_channel_info(fun, item, channel, &name, &levels);
|
|---|
| 695 | const size_t name_size = name ? str_size(name) + 1 : 0;
|
|---|
| 696 | async_answer_2(callid, ret, name_size, levels);
|
|---|
| 697 | /* Send the name. */
|
|---|
| 698 | if (ret == EOK && name_size > 0) {
|
|---|
| 699 | size_t size;
|
|---|
| 700 | ipc_callid_t name_id;
|
|---|
| 701 | if (!async_data_read_receive(&name_id, &size)) {
|
|---|
| 702 | async_answer_0(name_id, EPARTY);
|
|---|
| 703 | return;
|
|---|
| 704 | }
|
|---|
| 705 | if (size != name_size) {
|
|---|
| 706 | async_answer_0(name_id, ELIMIT);
|
|---|
| 707 | return;
|
|---|
| 708 | }
|
|---|
| 709 | async_data_read_finalize(name_id, name, name_size);
|
|---|
| 710 | }
|
|---|
| 711 | }
|
|---|
| [4bbfb93] | 712 |
|
|---|
| [c09ad29e] | 713 | void remote_audio_mixer_channel_mute_set(
|
|---|
| 714 | ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
|
|---|
| 715 | {
|
|---|
| 716 | audio_mixer_iface_t *mixer_iface = iface;
|
|---|
| 717 |
|
|---|
| 718 | if (!mixer_iface->channel_mute_set) {
|
|---|
| 719 | async_answer_0(callid, ENOTSUP);
|
|---|
| 720 | return;
|
|---|
| 721 | }
|
|---|
| 722 | const unsigned item = DEV_IPC_GET_ARG1(*call);
|
|---|
| 723 | const unsigned channel = DEV_IPC_GET_ARG2(*call);
|
|---|
| 724 | const bool mute = DEV_IPC_GET_ARG3(*call);
|
|---|
| 725 | const int ret = mixer_iface->channel_mute_set(fun, item, channel, mute);
|
|---|
| 726 | async_answer_0(callid, ret);
|
|---|
| 727 | }
|
|---|
| [4bbfb93] | 728 |
|
|---|
| [c09ad29e] | 729 | void remote_audio_mixer_channel_mute_get(
|
|---|
| 730 | ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
|
|---|
| 731 | {
|
|---|
| 732 | audio_mixer_iface_t *mixer_iface = iface;
|
|---|
| 733 |
|
|---|
| 734 | if (!mixer_iface->channel_mute_get) {
|
|---|
| 735 | async_answer_0(callid, ENOTSUP);
|
|---|
| 736 | return;
|
|---|
| 737 | }
|
|---|
| 738 | const unsigned item = DEV_IPC_GET_ARG1(*call);
|
|---|
| 739 | const unsigned channel = DEV_IPC_GET_ARG2(*call);
|
|---|
| 740 | bool mute = false;
|
|---|
| 741 | const int ret =
|
|---|
| 742 | mixer_iface->channel_mute_get(fun, item, channel, &mute);
|
|---|
| 743 | async_answer_1(callid, ret, mute);
|
|---|
| 744 | }
|
|---|
| [4bbfb93] | 745 |
|
|---|
| [c09ad29e] | 746 | void remote_audio_mixer_channel_volume_set(
|
|---|
| 747 | ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
|
|---|
| 748 | {
|
|---|
| 749 | audio_mixer_iface_t *mixer_iface = iface;
|
|---|
| 750 |
|
|---|
| 751 | if (!mixer_iface->channel_volume_set) {
|
|---|
| 752 | async_answer_0(callid, ENOTSUP);
|
|---|
| 753 | return;
|
|---|
| 754 | }
|
|---|
| 755 | const unsigned item = DEV_IPC_GET_ARG1(*call);
|
|---|
| 756 | const unsigned channel = DEV_IPC_GET_ARG2(*call);
|
|---|
| 757 | const unsigned level = DEV_IPC_GET_ARG3(*call);
|
|---|
| 758 | const int ret =
|
|---|
| 759 | mixer_iface->channel_volume_set(fun, item, channel, level);
|
|---|
| 760 | async_answer_0(callid, ret);
|
|---|
| 761 | }
|
|---|
| [4bbfb93] | 762 |
|
|---|
| [c09ad29e] | 763 | void remote_audio_mixer_channel_volume_get(
|
|---|
| 764 | ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
|
|---|
| 765 | {
|
|---|
| 766 | audio_mixer_iface_t *mixer_iface = iface;
|
|---|
| 767 |
|
|---|
| 768 | if (!mixer_iface->channel_volume_get) {
|
|---|
| 769 | async_answer_0(callid, ENOTSUP);
|
|---|
| 770 | return;
|
|---|
| 771 | }
|
|---|
| 772 | const unsigned item = DEV_IPC_GET_ARG1(*call);
|
|---|
| 773 | const unsigned channel = DEV_IPC_GET_ARG2(*call);
|
|---|
| 774 | unsigned current = 0, max = 0;
|
|---|
| 775 | const int ret =
|
|---|
| 776 | mixer_iface->channel_volume_get(fun, item, channel, ¤t, &max);
|
|---|
| 777 | async_answer_2(callid, ret, current, max);
|
|---|
| 778 | }
|
|---|
| 779 | #endif
|
|---|
| 780 |
|
|---|
| 781 | /**
|
|---|
| 782 | * @}
|
|---|
| 783 | */
|
|---|
| 784 |
|
|---|