source: mainline/uspace/lib/drv/include/audio_pcm_iface.h@ fb6c98f

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since fb6c98f was 018ab50, checked in by Jan Vesely <jano.vesely@…>, 13 years ago

audio: Move event callback into separate API calls.

  • Property mode set to 100644
File size: 3.9 KB
RevLine 
[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 * @addtogroup usb
30 * @{
31 */
32/** @file
33 * @brief Audio PCM buffer interface.
34 */
35
[90f05b0f]36#ifndef LIBDRV_AUDIO_PCM_IFACE_H_
37#define LIBDRV_AUDIO_PCM_IFACE_H_
[c09ad29e]38
39#include <async.h>
40#include <bool.h>
[2cc5c835]41#include <loc.h>
[ea6c838]42#include <pcm/sample_format.h>
[c09ad29e]43
44#include "ddf/driver.h"
45
[2e01b3f]46typedef enum {
[d86c9736]47 AUDIO_CAP_CAPTURE,
[2e01b3f]48 AUDIO_CAP_PLAYBACK,
49 AUDIO_CAP_MAX_BUFFER,
50 AUDIO_CAP_BUFFER_POS,
51 AUDIO_CAP_INTERRUPT,
52 AUDIO_CAP_INTERRUPT_MIN_FRAMES,
53 AUDIO_CAP_INTERRUPT_MAX_FRAMES,
54} audio_cap_t;
55
[1240bb9]56enum {
[57e8b3b]57 PCM_EVENT_FRAMES_PLAYED = IPC_FIRST_USER_METHOD,
[d86c9736]58 PCM_EVENT_FRAMES_CAPTURED,
[1240bb9]59 PCM_EVENT_PLAYBACK_TERMINATED,
[d86c9736]60 PCM_EVENT_CAPTURE_TERMINATED
[1240bb9]61};
62
[2cc5c835]63typedef async_sess_t audio_pcm_sess_t;
[1240bb9]64
[2cc5c835]65audio_pcm_sess_t *audio_pcm_open(const char *);
66audio_pcm_sess_t *audio_pcm_open_service(service_id_t service);
67void audio_pcm_close(audio_pcm_sess_t *);
68
69int audio_pcm_get_info_str(audio_pcm_sess_t *, const char **);
[63c34d7]70int audio_pcm_test_format(audio_pcm_sess_t *, unsigned *, unsigned *,
71 pcm_sample_format_t *);
[2e01b3f]72int audio_pcm_query_cap(audio_pcm_sess_t *, audio_cap_t, unsigned *);
[018ab50]73int audio_pcm_register_event_callback(audio_pcm_sess_t *,
[8de7ef2]74 async_client_conn_t, void *);
[018ab50]75int audio_pcm_unregister_event_callback(audio_pcm_sess_t *);
76
77int audio_pcm_get_buffer(audio_pcm_sess_t *, void **, size_t *);
78int audio_pcm_get_buffer_pos(audio_pcm_sess_t *, size_t *);
[2cc5c835]79int audio_pcm_release_buffer(audio_pcm_sess_t *);
[c09ad29e]80
[2cc5c835]81int audio_pcm_start_playback(audio_pcm_sess_t *, unsigned,
[346643c]82 unsigned, unsigned, pcm_sample_format_t);
[2cc5c835]83int audio_pcm_stop_playback(audio_pcm_sess_t *);
[c09ad29e]84
[d86c9736]85int audio_pcm_start_capture(audio_pcm_sess_t *, unsigned,
[346643c]86 unsigned, unsigned, pcm_sample_format_t);
[d86c9736]87int audio_pcm_stop_capture(audio_pcm_sess_t *);
[c09ad29e]88
89/** Audio pcm communication interface. */
90typedef struct {
91 int (*get_info_str)(ddf_fun_t *, const char **);
[63c34d7]92 int (*test_format)(ddf_fun_t *, unsigned *, unsigned *,
93 pcm_sample_format_t *);
[2e01b3f]94 unsigned (*query_cap)(ddf_fun_t *, audio_cap_t);
[fa91c0f]95 int (*get_buffer_pos)(ddf_fun_t *, size_t *);
[b497018]96 int (*get_buffer)(ddf_fun_t *, void **, size_t *);
97 int (*release_buffer)(ddf_fun_t *);
98 int (*set_event_session)(ddf_fun_t *, async_sess_t *);
[018ab50]99 async_sess_t * (*get_event_session)(ddf_fun_t *);
[b497018]100 int (*start_playback)(ddf_fun_t *, unsigned,
[346643c]101 unsigned, unsigned, pcm_sample_format_t);
[b497018]102 int (*stop_playback)(ddf_fun_t *);
[d86c9736]103 int (*start_capture)(ddf_fun_t *, unsigned,
[346643c]104 unsigned, unsigned, pcm_sample_format_t);
[d86c9736]105 int (*stop_capture)(ddf_fun_t *);
[90f05b0f]106} audio_pcm_iface_t;
[c09ad29e]107
108#endif
109/**
110 * @}
111 */
Note: See TracBrowser for help on using the repository browser.