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 <bool.h>
|
---|
41 | #include <loc.h>
|
---|
42 | #include <pcm/sample_format.h>
|
---|
43 |
|
---|
44 | #include "ddf/driver.h"
|
---|
45 |
|
---|
46 | typedef enum {
|
---|
47 | AUDIO_CAP_CAPTURE,
|
---|
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 |
|
---|
56 | typedef enum {
|
---|
57 | PCM_EVENT_PLAYBACK_STARTED = IPC_FIRST_USER_METHOD,
|
---|
58 | PCM_EVENT_CAPTURE_STARTED,
|
---|
59 | PCM_EVENT_FRAMES_PLAYED,
|
---|
60 | PCM_EVENT_FRAMES_CAPTURED,
|
---|
61 | PCM_EVENT_PLAYBACK_TERMINATED,
|
---|
62 | PCM_EVENT_CAPTURE_TERMINATED
|
---|
63 | } pcm_event_t;
|
---|
64 |
|
---|
65 | typedef async_sess_t audio_pcm_sess_t;
|
---|
66 |
|
---|
67 | audio_pcm_sess_t *audio_pcm_open(const char *);
|
---|
68 | audio_pcm_sess_t *audio_pcm_open_service(service_id_t service);
|
---|
69 | void audio_pcm_close(audio_pcm_sess_t *);
|
---|
70 |
|
---|
71 | int audio_pcm_get_info_str(audio_pcm_sess_t *, const char **);
|
---|
72 | int audio_pcm_test_format(audio_pcm_sess_t *, unsigned *, unsigned *,
|
---|
73 | pcm_sample_format_t *);
|
---|
74 | int audio_pcm_query_cap(audio_pcm_sess_t *, audio_cap_t, unsigned *);
|
---|
75 | int audio_pcm_register_event_callback(audio_pcm_sess_t *,
|
---|
76 | async_client_conn_t, void *);
|
---|
77 | int audio_pcm_unregister_event_callback(audio_pcm_sess_t *);
|
---|
78 |
|
---|
79 | int audio_pcm_get_buffer(audio_pcm_sess_t *, void **, size_t *);
|
---|
80 | int audio_pcm_get_buffer_pos(audio_pcm_sess_t *, size_t *);
|
---|
81 | int audio_pcm_release_buffer(audio_pcm_sess_t *);
|
---|
82 |
|
---|
83 | int audio_pcm_start_playback(audio_pcm_sess_t *, unsigned,
|
---|
84 | unsigned, unsigned, pcm_sample_format_t);
|
---|
85 | int audio_pcm_stop_playback(audio_pcm_sess_t *);
|
---|
86 |
|
---|
87 | int audio_pcm_start_capture(audio_pcm_sess_t *, unsigned,
|
---|
88 | unsigned, unsigned, pcm_sample_format_t);
|
---|
89 | int audio_pcm_stop_capture(audio_pcm_sess_t *);
|
---|
90 |
|
---|
91 | /** Audio pcm communication interface. */
|
---|
92 | typedef struct {
|
---|
93 | int (*get_info_str)(ddf_fun_t *, const char **);
|
---|
94 | int (*test_format)(ddf_fun_t *, unsigned *, unsigned *,
|
---|
95 | pcm_sample_format_t *);
|
---|
96 | unsigned (*query_cap)(ddf_fun_t *, audio_cap_t);
|
---|
97 | int (*get_buffer_pos)(ddf_fun_t *, size_t *);
|
---|
98 | int (*get_buffer)(ddf_fun_t *, void **, size_t *);
|
---|
99 | int (*release_buffer)(ddf_fun_t *);
|
---|
100 | int (*set_event_session)(ddf_fun_t *, async_sess_t *);
|
---|
101 | async_sess_t * (*get_event_session)(ddf_fun_t *);
|
---|
102 | int (*start_playback)(ddf_fun_t *, unsigned,
|
---|
103 | unsigned, unsigned, pcm_sample_format_t);
|
---|
104 | int (*stop_playback)(ddf_fun_t *);
|
---|
105 | int (*start_capture)(ddf_fun_t *, unsigned,
|
---|
106 | unsigned, unsigned, pcm_sample_format_t);
|
---|
107 | int (*stop_capture)(ddf_fun_t *);
|
---|
108 | } audio_pcm_iface_t;
|
---|
109 |
|
---|
110 | #endif
|
---|
111 | /**
|
---|
112 | * @}
|
---|
113 | */
|
---|