[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>
|
---|
| 40 | #include <bool.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 {
|
---|
[d86c9736] | 47 | AUDIO_CAP_CAPTURE,
|
---|
[2e01b3f] | 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 |
|
---|
[c04ff9f] | 56 | typedef enum {
|
---|
| 57 | PCM_EVENT_PLAYBACK_STARTED = IPC_FIRST_USER_METHOD,
|
---|
| 58 | PCM_EVENT_CAPTURE_STARTED,
|
---|
| 59 | PCM_EVENT_FRAMES_PLAYED,
|
---|
[d86c9736] | 60 | PCM_EVENT_FRAMES_CAPTURED,
|
---|
[1240bb9] | 61 | PCM_EVENT_PLAYBACK_TERMINATED,
|
---|
[d86c9736] | 62 | PCM_EVENT_CAPTURE_TERMINATED
|
---|
[c04ff9f] | 63 | } pcm_event_t;
|
---|
[1240bb9] | 64 |
|
---|
[2cc5c835] | 65 | typedef async_sess_t audio_pcm_sess_t;
|
---|
[1240bb9] | 66 |
|
---|
[2cc5c835] | 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 **);
|
---|
[63c34d7] | 72 | int audio_pcm_test_format(audio_pcm_sess_t *, unsigned *, unsigned *,
|
---|
| 73 | pcm_sample_format_t *);
|
---|
[2e01b3f] | 74 | int audio_pcm_query_cap(audio_pcm_sess_t *, audio_cap_t, unsigned *);
|
---|
[018ab50] | 75 | int audio_pcm_register_event_callback(audio_pcm_sess_t *,
|
---|
[8de7ef2] | 76 | async_client_conn_t, void *);
|
---|
[018ab50] | 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 *);
|
---|
[2cc5c835] | 81 | int audio_pcm_release_buffer(audio_pcm_sess_t *);
|
---|
[c09ad29e] | 82 |
|
---|
[2cc5c835] | 83 | int audio_pcm_start_playback(audio_pcm_sess_t *, unsigned,
|
---|
[346643c] | 84 | unsigned, unsigned, pcm_sample_format_t);
|
---|
[2cc5c835] | 85 | int audio_pcm_stop_playback(audio_pcm_sess_t *);
|
---|
[c09ad29e] | 86 |
|
---|
[d86c9736] | 87 | int audio_pcm_start_capture(audio_pcm_sess_t *, unsigned,
|
---|
[346643c] | 88 | unsigned, unsigned, pcm_sample_format_t);
|
---|
[d86c9736] | 89 | int audio_pcm_stop_capture(audio_pcm_sess_t *);
|
---|
[c09ad29e] | 90 |
|
---|
| 91 | /** Audio pcm communication interface. */
|
---|
| 92 | typedef struct {
|
---|
| 93 | int (*get_info_str)(ddf_fun_t *, const char **);
|
---|
[63c34d7] | 94 | int (*test_format)(ddf_fun_t *, unsigned *, unsigned *,
|
---|
| 95 | pcm_sample_format_t *);
|
---|
[2e01b3f] | 96 | unsigned (*query_cap)(ddf_fun_t *, audio_cap_t);
|
---|
[fa91c0f] | 97 | int (*get_buffer_pos)(ddf_fun_t *, size_t *);
|
---|
[b497018] | 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 *);
|
---|
[018ab50] | 101 | async_sess_t * (*get_event_session)(ddf_fun_t *);
|
---|
[b497018] | 102 | int (*start_playback)(ddf_fun_t *, unsigned,
|
---|
[346643c] | 103 | unsigned, unsigned, pcm_sample_format_t);
|
---|
[b497018] | 104 | int (*stop_playback)(ddf_fun_t *);
|
---|
[d86c9736] | 105 | int (*start_capture)(ddf_fun_t *, unsigned,
|
---|
[346643c] | 106 | unsigned, unsigned, pcm_sample_format_t);
|
---|
[d86c9736] | 107 | int (*stop_capture)(ddf_fun_t *);
|
---|
[90f05b0f] | 108 | } audio_pcm_iface_t;
|
---|
[c09ad29e] | 109 |
|
---|
| 110 | #endif
|
---|
| 111 | /**
|
---|
| 112 | * @}
|
---|
| 113 | */
|
---|