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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 7f9df7b9 was 33b8d024, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 8 years ago

Remove const qualifier from the argument of free() and realloc(),
as well as in numerous other variables that hold ownership of memory.

By convention, a pointer that holds ownership is _never_ qualified by const.
This is reflected in the standard type signature of free() and realloc().
Allowing const pointers to hold ownership may seem superficially convenient,
but is actually quite confusing to experienced C programmers.

  • Property mode set to 100644
File size: 5.0 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
82errno_t audio_pcm_get_info_str(audio_pcm_sess_t *, char **);
83errno_t audio_pcm_test_format(audio_pcm_sess_t *, unsigned *, unsigned *,
84 pcm_sample_format_t *);
85errno_t audio_pcm_query_cap(audio_pcm_sess_t *, audio_cap_t, sysarg_t *);
86errno_t audio_pcm_register_event_callback(audio_pcm_sess_t *,
87 async_port_handler_t, void *);
88errno_t audio_pcm_unregister_event_callback(audio_pcm_sess_t *);
89
90errno_t audio_pcm_get_buffer(audio_pcm_sess_t *, void **, size_t *);
91errno_t audio_pcm_get_buffer_pos(audio_pcm_sess_t *, size_t *);
92errno_t audio_pcm_release_buffer(audio_pcm_sess_t *);
93
94errno_t audio_pcm_start_playback_fragment(audio_pcm_sess_t *, unsigned,
95 unsigned, unsigned, pcm_sample_format_t);
96errno_t audio_pcm_last_playback_fragment(audio_pcm_sess_t *);
97
98errno_t audio_pcm_start_playback(audio_pcm_sess_t *,
99 unsigned, unsigned, pcm_sample_format_t);
100errno_t audio_pcm_stop_playback_immediate(audio_pcm_sess_t *);
101errno_t audio_pcm_stop_playback(audio_pcm_sess_t *);
102
103errno_t audio_pcm_start_capture_fragment(audio_pcm_sess_t *, unsigned,
104 unsigned, unsigned, pcm_sample_format_t);
105errno_t audio_pcm_last_capture_fragment(audio_pcm_sess_t *);
106
107errno_t audio_pcm_start_capture(audio_pcm_sess_t *,
108 unsigned, unsigned, pcm_sample_format_t);
109errno_t audio_pcm_stop_capture_immediate(audio_pcm_sess_t *);
110errno_t audio_pcm_stop_capture(audio_pcm_sess_t *);
111
112/** Audio pcm communication interface. */
113typedef struct {
114 errno_t (*get_info_str)(ddf_fun_t *, const char **);
115 errno_t (*test_format)(ddf_fun_t *, unsigned *, unsigned *,
116 pcm_sample_format_t *);
117 unsigned (*query_cap)(ddf_fun_t *, audio_cap_t);
118 errno_t (*get_buffer_pos)(ddf_fun_t *, size_t *);
119 errno_t (*get_buffer)(ddf_fun_t *, void **, size_t *);
120 errno_t (*release_buffer)(ddf_fun_t *);
121 errno_t (*set_event_session)(ddf_fun_t *, async_sess_t *);
122 async_sess_t * (*get_event_session)(ddf_fun_t *);
123 errno_t (*start_playback)(ddf_fun_t *, unsigned,
124 unsigned, unsigned, pcm_sample_format_t);
125 errno_t (*stop_playback)(ddf_fun_t *, bool);
126 errno_t (*start_capture)(ddf_fun_t *, unsigned,
127 unsigned, unsigned, pcm_sample_format_t);
128 errno_t (*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.