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

Last change on this file since d7f7a4a was d7f7a4a, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 4 years ago

Replace some license headers with SPDX identifier

Headers are replaced using tools/transorm-copyright.sh only
when it can be matched verbatim with the license header used
throughout most of the codebase.

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 * SPDX-FileCopyrightText: 2012 Jan Vesely
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6/** @addtogroup libdrv
7 * @addtogroup usb
8 * @{
9 */
10/** @file
11 * @brief Audio PCM buffer interface.
12 */
13
14#ifndef LIBDRV_AUDIO_PCM_IFACE_H_
15#define LIBDRV_AUDIO_PCM_IFACE_H_
16
17#include <async.h>
18#include <stdbool.h>
19#include <loc.h>
20#include <pcm/sample_format.h>
21
22#include "ddf/driver.h"
23
24typedef enum {
25 /** Device is capable of audio capture */
26 AUDIO_CAP_CAPTURE,
27 /** Device is capable of audio playback */
28 AUDIO_CAP_PLAYBACK,
29 /** Maximum size of device buffer */
30 AUDIO_CAP_MAX_BUFFER,
31 /** Device is capable of providing accurate buffer position info */
32 AUDIO_CAP_BUFFER_POS,
33 /** Device is capable of event based playback or capture */
34 AUDIO_CAP_INTERRUPT,
35 /** Minimal size of playback/record fragment */
36 AUDIO_CAP_INTERRUPT_MIN_FRAMES,
37 /** Maximum size of playback/record fragment */
38 AUDIO_CAP_INTERRUPT_MAX_FRAMES,
39} audio_cap_t;
40
41typedef enum {
42 PCM_EVENT_PLAYBACK_STARTED = IPC_FIRST_USER_METHOD,
43 PCM_EVENT_CAPTURE_STARTED,
44 PCM_EVENT_FRAMES_PLAYED,
45 PCM_EVENT_FRAMES_CAPTURED,
46 PCM_EVENT_PLAYBACK_TERMINATED,
47 PCM_EVENT_CAPTURE_TERMINATED,
48} pcm_event_t;
49
50const char *audio_pcm_cap_str(audio_cap_t);
51const char *audio_pcm_event_str(pcm_event_t);
52
53typedef async_sess_t audio_pcm_sess_t;
54
55audio_pcm_sess_t *audio_pcm_open(const char *);
56audio_pcm_sess_t *audio_pcm_open_default(void);
57audio_pcm_sess_t *audio_pcm_open_service(service_id_t service);
58void audio_pcm_close(audio_pcm_sess_t *);
59
60errno_t audio_pcm_get_info_str(audio_pcm_sess_t *, char **);
61errno_t audio_pcm_test_format(audio_pcm_sess_t *, unsigned *, unsigned *,
62 pcm_sample_format_t *);
63errno_t audio_pcm_query_cap(audio_pcm_sess_t *, audio_cap_t, sysarg_t *);
64errno_t audio_pcm_register_event_callback(audio_pcm_sess_t *,
65 async_port_handler_t, void *);
66errno_t audio_pcm_unregister_event_callback(audio_pcm_sess_t *);
67
68errno_t audio_pcm_get_buffer(audio_pcm_sess_t *, void **, size_t *);
69errno_t audio_pcm_get_buffer_pos(audio_pcm_sess_t *, size_t *);
70errno_t audio_pcm_release_buffer(audio_pcm_sess_t *);
71
72errno_t audio_pcm_start_playback_fragment(audio_pcm_sess_t *, unsigned,
73 unsigned, unsigned, pcm_sample_format_t);
74errno_t audio_pcm_last_playback_fragment(audio_pcm_sess_t *);
75
76errno_t audio_pcm_start_playback(audio_pcm_sess_t *,
77 unsigned, unsigned, pcm_sample_format_t);
78errno_t audio_pcm_stop_playback_immediate(audio_pcm_sess_t *);
79errno_t audio_pcm_stop_playback(audio_pcm_sess_t *);
80
81errno_t audio_pcm_start_capture_fragment(audio_pcm_sess_t *, unsigned,
82 unsigned, unsigned, pcm_sample_format_t);
83errno_t audio_pcm_last_capture_fragment(audio_pcm_sess_t *);
84
85errno_t audio_pcm_start_capture(audio_pcm_sess_t *,
86 unsigned, unsigned, pcm_sample_format_t);
87errno_t audio_pcm_stop_capture_immediate(audio_pcm_sess_t *);
88errno_t audio_pcm_stop_capture(audio_pcm_sess_t *);
89
90/** Audio pcm communication interface. */
91typedef struct {
92 errno_t (*get_info_str)(ddf_fun_t *, const char **);
93 errno_t (*test_format)(ddf_fun_t *, unsigned *, unsigned *,
94 pcm_sample_format_t *);
95 unsigned (*query_cap)(ddf_fun_t *, audio_cap_t);
96 errno_t (*get_buffer_pos)(ddf_fun_t *, size_t *);
97 errno_t (*get_buffer)(ddf_fun_t *, void **, size_t *);
98 errno_t (*release_buffer)(ddf_fun_t *);
99 errno_t (*set_event_session)(ddf_fun_t *, async_sess_t *);
100 async_sess_t *(*get_event_session)(ddf_fun_t *);
101 errno_t (*start_playback)(ddf_fun_t *, unsigned,
102 unsigned, unsigned, pcm_sample_format_t);
103 errno_t (*stop_playback)(ddf_fun_t *, bool);
104 errno_t (*start_capture)(ddf_fun_t *, unsigned,
105 unsigned, unsigned, pcm_sample_format_t);
106 errno_t (*stop_capture)(ddf_fun_t *, bool);
107} audio_pcm_iface_t;
108
109#endif
110/**
111 * @}
112 */
Note: See TracBrowser for help on using the repository browser.