| 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 libhound
|
|---|
| 29 | * @addtogroup audio
|
|---|
| 30 | * @{
|
|---|
| 31 | */
|
|---|
| 32 | /** @file
|
|---|
| 33 | * @brief Audio PCM buffer interface.
|
|---|
| 34 | */
|
|---|
| 35 |
|
|---|
| 36 | #ifndef LIBHOUND_CLIENT_H_
|
|---|
| 37 | #define LIBHOUND_CLIENT_H_
|
|---|
| 38 |
|
|---|
| 39 | #include <async.h>
|
|---|
| 40 | #include <stdbool.h>
|
|---|
| 41 | #include <pcm/format.h>
|
|---|
| 42 |
|
|---|
| 43 | #define HOUND_DEFAULT_TARGET "default"
|
|---|
| 44 | #define HOUND_ALL_TARGETS "all"
|
|---|
| 45 | #define DEFAULT_SINK "default" //DEPRECATED
|
|---|
| 46 |
|
|---|
| 47 | typedef struct hound_context hound_context_t;
|
|---|
| 48 | typedef struct hound_stream hound_stream_t;
|
|---|
| 49 |
|
|---|
| 50 | hound_context_t * hound_context_create_playback(const char *name,
|
|---|
| 51 | pcm_format_t format, size_t bsize);
|
|---|
| 52 | hound_context_t * hound_context_create_capture(const char *name,
|
|---|
| 53 | pcm_format_t format, size_t bsize);
|
|---|
| 54 | void hound_context_destroy(hound_context_t *hound);
|
|---|
| 55 |
|
|---|
| 56 | int hound_context_enable(hound_context_t *hound);
|
|---|
| 57 | int hound_context_disable(hound_context_t *hound);
|
|---|
| 58 |
|
|---|
| 59 | int hound_context_set_main_stream_format(hound_context_t *hound,
|
|---|
| 60 | unsigned channels, unsigned rate, pcm_sample_format_t format);
|
|---|
| 61 |
|
|---|
| 62 | int hound_context_get_available_targets(hound_context_t *hound,
|
|---|
| 63 | const char ***names, size_t *count);
|
|---|
| 64 | int hound_context_get_connected_targets(hound_context_t *hound,
|
|---|
| 65 | const char ***names, size_t *count);
|
|---|
| 66 |
|
|---|
| 67 | int hound_context_connect_target(hound_context_t *hound, const char* target);
|
|---|
| 68 | int hound_context_disconnect_target(hound_context_t *hound, const char* target);
|
|---|
| 69 |
|
|---|
| 70 | hound_stream_t *hound_stream_create(hound_context_t *hound, unsigned flags,
|
|---|
| 71 | pcm_format_t format, size_t bsize);
|
|---|
| 72 | void hound_stream_destroy(hound_stream_t *stream);
|
|---|
| 73 |
|
|---|
| 74 | int hound_stream_write(hound_stream_t *stream, const void *data, size_t size);
|
|---|
| 75 | int hound_stream_read(hound_stream_t *stream, void *data, size_t size);
|
|---|
| 76 |
|
|---|
| 77 | int hound_write_main_stream(hound_context_t *hound,
|
|---|
| 78 | const void *data, size_t size);
|
|---|
| 79 | int hound_read_main_stream(hound_context_t *hound, void *data, size_t size);
|
|---|
| 80 | int hound_write_replace_main_stream(hound_context_t *hound,
|
|---|
| 81 | const void *data, size_t size);
|
|---|
| 82 | int hound_write_immediate(hound_context_t *hound,
|
|---|
| 83 | pcm_format_t format, const void *data, size_t size);
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 | typedef async_sess_t hound_sess_t;
|
|---|
| 90 |
|
|---|
| 91 | typedef void (*data_callback_t)(void *, void *, ssize_t);
|
|---|
| 92 |
|
|---|
| 93 | hound_sess_t *hound_get_session(void);
|
|---|
| 94 | void hound_release_session(hound_sess_t *sess);
|
|---|
| 95 | int hound_register_playback(hound_sess_t *sess, const char *name,
|
|---|
| 96 | unsigned channels, unsigned rate, pcm_sample_format_t format,
|
|---|
| 97 | data_callback_t data_callback, void *arg);
|
|---|
| 98 | int hound_register_recording(hound_sess_t *sess, const char *name,
|
|---|
| 99 | unsigned channels, unsigned rate, pcm_sample_format_t format,
|
|---|
| 100 | data_callback_t data_callback, void *arg);
|
|---|
| 101 | int hound_unregister_playback(hound_sess_t *sess, const char *name);
|
|---|
| 102 | int hound_unregister_recording(hound_sess_t *sess, const char *name);
|
|---|
| 103 | int hound_create_connection(hound_sess_t *sess, const char *source, const char *sink);
|
|---|
| 104 | int hound_destroy_connection(hound_sess_t *sess, const char *source, const char *sink);
|
|---|
| 105 |
|
|---|
| 106 | #endif
|
|---|