[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>
|
---|
[03362fbd] | 40 | #include <stdbool.h>
|
---|
[2cc5c835] | 41 | #include <loc.h>
|
---|
[ea6c838] | 42 | #include <pcm/sample_format.h>
|
---|
[c09ad29e] | 43 |
|
---|
| 44 | #include "ddf/driver.h"
|
---|
| 45 |
|
---|
[2e01b3f] | 46 | typedef enum {
|
---|
[eb0ef51] | 47 | /** Device is capable of audio capture */
|
---|
[d86c9736] | 48 | AUDIO_CAP_CAPTURE,
|
---|
[eb0ef51] | 49 | /** Device is capable of audio playback */
|
---|
[2e01b3f] | 50 | AUDIO_CAP_PLAYBACK,
|
---|
[eb0ef51] | 51 | /** Maximum size of device buffer */
|
---|
[2e01b3f] | 52 | AUDIO_CAP_MAX_BUFFER,
|
---|
[eb0ef51] | 53 | /** Device is capable of providing accurate buffer position info */
|
---|
[2e01b3f] | 54 | AUDIO_CAP_BUFFER_POS,
|
---|
[eb0ef51] | 55 | /** Device is capable of event based playback or capture */
|
---|
[2e01b3f] | 56 | AUDIO_CAP_INTERRUPT,
|
---|
[eb0ef51] | 57 | /** Minimal size of playback/record fragment */
|
---|
[2e01b3f] | 58 | AUDIO_CAP_INTERRUPT_MIN_FRAMES,
|
---|
[eb0ef51] | 59 | /** Maximum size of playback/record fragment */
|
---|
[2e01b3f] | 60 | AUDIO_CAP_INTERRUPT_MAX_FRAMES,
|
---|
| 61 | } audio_cap_t;
|
---|
| 62 |
|
---|
[c04ff9f] | 63 | typedef enum {
|
---|
| 64 | PCM_EVENT_PLAYBACK_STARTED = IPC_FIRST_USER_METHOD,
|
---|
| 65 | PCM_EVENT_CAPTURE_STARTED,
|
---|
| 66 | PCM_EVENT_FRAMES_PLAYED,
|
---|
[d86c9736] | 67 | PCM_EVENT_FRAMES_CAPTURED,
|
---|
[1240bb9] | 68 | PCM_EVENT_PLAYBACK_TERMINATED,
|
---|
[e98a8c4] | 69 | PCM_EVENT_CAPTURE_TERMINATED,
|
---|
[c04ff9f] | 70 | } pcm_event_t;
|
---|
[1240bb9] | 71 |
|
---|
[e98a8c4] | 72 | const char *audio_pcm_cap_str(audio_cap_t);
|
---|
| 73 | const char *audio_pcm_event_str(pcm_event_t);
|
---|
| 74 |
|
---|
[2cc5c835] | 75 | typedef async_sess_t audio_pcm_sess_t;
|
---|
[1240bb9] | 76 |
|
---|
[2cc5c835] | 77 | audio_pcm_sess_t *audio_pcm_open(const char *);
|
---|
[6606378] | 78 | audio_pcm_sess_t *audio_pcm_open_default(void);
|
---|
[2cc5c835] | 79 | audio_pcm_sess_t *audio_pcm_open_service(service_id_t service);
|
---|
| 80 | void audio_pcm_close(audio_pcm_sess_t *);
|
---|
| 81 |
|
---|
[33b8d024] | 82 | errno_t audio_pcm_get_info_str(audio_pcm_sess_t *, char **);
|
---|
[b7fd2a0] | 83 | errno_t audio_pcm_test_format(audio_pcm_sess_t *, unsigned *, unsigned *,
|
---|
[63c34d7] | 84 | pcm_sample_format_t *);
|
---|
[b7fd2a0] | 85 | errno_t audio_pcm_query_cap(audio_pcm_sess_t *, audio_cap_t, sysarg_t *);
|
---|
| 86 | errno_t audio_pcm_register_event_callback(audio_pcm_sess_t *,
|
---|
[b688fd8] | 87 | async_port_handler_t, void *);
|
---|
[b7fd2a0] | 88 | errno_t audio_pcm_unregister_event_callback(audio_pcm_sess_t *);
|
---|
[018ab50] | 89 |
|
---|
[b7fd2a0] | 90 | errno_t audio_pcm_get_buffer(audio_pcm_sess_t *, void **, size_t *);
|
---|
| 91 | errno_t audio_pcm_get_buffer_pos(audio_pcm_sess_t *, size_t *);
|
---|
| 92 | errno_t audio_pcm_release_buffer(audio_pcm_sess_t *);
|
---|
[c09ad29e] | 93 |
|
---|
[b7fd2a0] | 94 | errno_t audio_pcm_start_playback_fragment(audio_pcm_sess_t *, unsigned,
|
---|
[92b638c] | 95 | unsigned, unsigned, pcm_sample_format_t);
|
---|
[b7fd2a0] | 96 | errno_t audio_pcm_last_playback_fragment(audio_pcm_sess_t *);
|
---|
[92b638c] | 97 |
|
---|
[b7fd2a0] | 98 | errno_t audio_pcm_start_playback(audio_pcm_sess_t *,
|
---|
[346643c] | 99 | unsigned, unsigned, pcm_sample_format_t);
|
---|
[b7fd2a0] | 100 | errno_t audio_pcm_stop_playback_immediate(audio_pcm_sess_t *);
|
---|
| 101 | errno_t audio_pcm_stop_playback(audio_pcm_sess_t *);
|
---|
[c09ad29e] | 102 |
|
---|
[b7fd2a0] | 103 | errno_t audio_pcm_start_capture_fragment(audio_pcm_sess_t *, unsigned,
|
---|
[92b638c] | 104 | unsigned, unsigned, pcm_sample_format_t);
|
---|
[b7fd2a0] | 105 | errno_t audio_pcm_last_capture_fragment(audio_pcm_sess_t *);
|
---|
[92b638c] | 106 |
|
---|
[b7fd2a0] | 107 | errno_t audio_pcm_start_capture(audio_pcm_sess_t *,
|
---|
[346643c] | 108 | unsigned, unsigned, pcm_sample_format_t);
|
---|
[b7fd2a0] | 109 | errno_t audio_pcm_stop_capture_immediate(audio_pcm_sess_t *);
|
---|
| 110 | errno_t audio_pcm_stop_capture(audio_pcm_sess_t *);
|
---|
[c09ad29e] | 111 |
|
---|
| 112 | /** Audio pcm communication interface. */
|
---|
| 113 | typedef struct {
|
---|
[b7fd2a0] | 114 | errno_t (*get_info_str)(ddf_fun_t *, const char **);
|
---|
| 115 | errno_t (*test_format)(ddf_fun_t *, unsigned *, unsigned *,
|
---|
[63c34d7] | 116 | pcm_sample_format_t *);
|
---|
[2e01b3f] | 117 | unsigned (*query_cap)(ddf_fun_t *, audio_cap_t);
|
---|
[b7fd2a0] | 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 *);
|
---|
[5b0cf63] | 122 | async_sess_t *(*get_event_session)(ddf_fun_t *);
|
---|
[b7fd2a0] | 123 | errno_t (*start_playback)(ddf_fun_t *, unsigned,
|
---|
[346643c] | 124 | unsigned, unsigned, pcm_sample_format_t);
|
---|
[b7fd2a0] | 125 | errno_t (*stop_playback)(ddf_fun_t *, bool);
|
---|
| 126 | errno_t (*start_capture)(ddf_fun_t *, unsigned,
|
---|
[346643c] | 127 | unsigned, unsigned, pcm_sample_format_t);
|
---|
[b7fd2a0] | 128 | errno_t (*stop_capture)(ddf_fun_t *, bool);
|
---|
[90f05b0f] | 129 | } audio_pcm_iface_t;
|
---|
[c09ad29e] | 130 |
|
---|
| 131 | #endif
|
---|
| 132 | /**
|
---|
| 133 | * @}
|
---|
| 134 | */
|
---|