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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 79ea5af was b688fd8, checked in by Martin Decky <martin@…>, 10 years ago

gradually introduce async ports, initial phase

The initial phase is to reimplement the traditional async client connections as an untyped fallback port. This creates the possibility to introduce ports typed by interface type gradually in later changesets.

  • Property mode set to 100644
File size: 4.9 KB
Line 
1/*
2 * Copyright (c) 2012 Jan Vesely
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
36#ifndef LIBDRV_AUDIO_PCM_IFACE_H_
37#define LIBDRV_AUDIO_PCM_IFACE_H_
38
39#include <async.h>
40#include <stdbool.h>
41#include <loc.h>
42#include <pcm/sample_format.h>
43
44#include "ddf/driver.h"
45
46typedef enum {
47 /** Device is capable of audio capture */
48 AUDIO_CAP_CAPTURE,
49 /** Device is capable of audio playback */
50 AUDIO_CAP_PLAYBACK,
51 /** Maximum size of device buffer */
52 AUDIO_CAP_MAX_BUFFER,
53 /** Device is capable of providing accurate buffer position info */
54 AUDIO_CAP_BUFFER_POS,
55 /** Device is capable of event based playback or capture */
56 AUDIO_CAP_INTERRUPT,
57 /** Minimal size of playback/record fragment */
58 AUDIO_CAP_INTERRUPT_MIN_FRAMES,
59 /** Maximum size of playback/record fragment */
60 AUDIO_CAP_INTERRUPT_MAX_FRAMES,
61} audio_cap_t;
62
63typedef enum {
64 PCM_EVENT_PLAYBACK_STARTED = IPC_FIRST_USER_METHOD,
65 PCM_EVENT_CAPTURE_STARTED,
66 PCM_EVENT_FRAMES_PLAYED,
67 PCM_EVENT_FRAMES_CAPTURED,
68 PCM_EVENT_PLAYBACK_TERMINATED,
69 PCM_EVENT_CAPTURE_TERMINATED,
70} pcm_event_t;
71
72const char *audio_pcm_cap_str(audio_cap_t);
73const char *audio_pcm_event_str(pcm_event_t);
74
75typedef async_sess_t audio_pcm_sess_t;
76
77audio_pcm_sess_t *audio_pcm_open(const char *);
78audio_pcm_sess_t *audio_pcm_open_default(void);
79audio_pcm_sess_t *audio_pcm_open_service(service_id_t service);
80void audio_pcm_close(audio_pcm_sess_t *);
81
82int audio_pcm_get_info_str(audio_pcm_sess_t *, const char **);
83int audio_pcm_test_format(audio_pcm_sess_t *, unsigned *, unsigned *,
84 pcm_sample_format_t *);
85int audio_pcm_query_cap(audio_pcm_sess_t *, audio_cap_t);
86int audio_pcm_register_event_callback(audio_pcm_sess_t *,
87 async_port_handler_t, void *);
88int audio_pcm_unregister_event_callback(audio_pcm_sess_t *);
89
90int audio_pcm_get_buffer(audio_pcm_sess_t *, void **, size_t *);
91int audio_pcm_get_buffer_pos(audio_pcm_sess_t *, size_t *);
92int audio_pcm_release_buffer(audio_pcm_sess_t *);
93
94int audio_pcm_start_playback_fragment(audio_pcm_sess_t *, unsigned,
95 unsigned, unsigned, pcm_sample_format_t);
96int audio_pcm_last_playback_fragment(audio_pcm_sess_t *);
97
98int audio_pcm_start_playback(audio_pcm_sess_t *,
99 unsigned, unsigned, pcm_sample_format_t);
100int audio_pcm_stop_playback_immediate(audio_pcm_sess_t *);
101int audio_pcm_stop_playback(audio_pcm_sess_t *);
102
103int audio_pcm_start_capture_fragment(audio_pcm_sess_t *, unsigned,
104 unsigned, unsigned, pcm_sample_format_t);
105int audio_pcm_last_capture_fragment(audio_pcm_sess_t *);
106
107int audio_pcm_start_capture(audio_pcm_sess_t *,
108 unsigned, unsigned, pcm_sample_format_t);
109int audio_pcm_stop_capture_immediate(audio_pcm_sess_t *);
110int audio_pcm_stop_capture(audio_pcm_sess_t *);
111
112/** Audio pcm communication interface. */
113typedef struct {
114 int (*get_info_str)(ddf_fun_t *, const char **);
115 int (*test_format)(ddf_fun_t *, unsigned *, unsigned *,
116 pcm_sample_format_t *);
117 unsigned (*query_cap)(ddf_fun_t *, audio_cap_t);
118 int (*get_buffer_pos)(ddf_fun_t *, size_t *);
119 int (*get_buffer)(ddf_fun_t *, void **, size_t *);
120 int (*release_buffer)(ddf_fun_t *);
121 int (*set_event_session)(ddf_fun_t *, async_sess_t *);
122 async_sess_t * (*get_event_session)(ddf_fun_t *);
123 int (*start_playback)(ddf_fun_t *, unsigned,
124 unsigned, unsigned, pcm_sample_format_t);
125 int (*stop_playback)(ddf_fun_t *, bool);
126 int (*start_capture)(ddf_fun_t *, unsigned,
127 unsigned, unsigned, pcm_sample_format_t);
128 int (*stop_capture)(ddf_fun_t *, bool);
129} audio_pcm_iface_t;
130
131#endif
132/**
133 * @}
134 */
Note: See TracBrowser for help on using the repository browser.