1*23a1bbc3SMatthias Ringwald /* 2*23a1bbc3SMatthias Ringwald * Copyright (C) 2017 BlueKitchen GmbH 3*23a1bbc3SMatthias Ringwald * 4*23a1bbc3SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5*23a1bbc3SMatthias Ringwald * modification, are permitted provided that the following conditions 6*23a1bbc3SMatthias Ringwald * are met: 7*23a1bbc3SMatthias Ringwald * 8*23a1bbc3SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9*23a1bbc3SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10*23a1bbc3SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11*23a1bbc3SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12*23a1bbc3SMatthias Ringwald * documentation and/or other materials provided with the distribution. 13*23a1bbc3SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14*23a1bbc3SMatthias Ringwald * contributors may be used to endorse or promote products derived 15*23a1bbc3SMatthias Ringwald * from this software without specific prior written permission. 16*23a1bbc3SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 17*23a1bbc3SMatthias Ringwald * personal benefit and not for any commercial purpose or for 18*23a1bbc3SMatthias Ringwald * monetary gain. 19*23a1bbc3SMatthias Ringwald * 20*23a1bbc3SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21*23a1bbc3SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22*23a1bbc3SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23*23a1bbc3SMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24*23a1bbc3SMatthias Ringwald * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25*23a1bbc3SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26*23a1bbc3SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27*23a1bbc3SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28*23a1bbc3SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29*23a1bbc3SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30*23a1bbc3SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31*23a1bbc3SMatthias Ringwald * SUCH DAMAGE. 32*23a1bbc3SMatthias Ringwald * 33*23a1bbc3SMatthias Ringwald * Please inquire about commercial licensing options at 34*23a1bbc3SMatthias Ringwald * [email protected] 35*23a1bbc3SMatthias Ringwald * 36*23a1bbc3SMatthias Ringwald */ 37*23a1bbc3SMatthias Ringwald 38*23a1bbc3SMatthias Ringwald #ifndef __BTSTACK_AUDIO_DMA_H 39*23a1bbc3SMatthias Ringwald #define __BTSTACK_AUDIO_DMA_H 40*23a1bbc3SMatthias Ringwald 41*23a1bbc3SMatthias Ringwald #include <stdint.h> 42*23a1bbc3SMatthias Ringwald 43*23a1bbc3SMatthias Ringwald #if defined __cplusplus 44*23a1bbc3SMatthias Ringwald extern "C" { 45*23a1bbc3SMatthias Ringwald #endif 46*23a1bbc3SMatthias Ringwald 47*23a1bbc3SMatthias Ringwald /* 48*23a1bbc3SMatthias Ringwald * btstack_audio.h 49*23a1bbc3SMatthias Ringwald * 50*23a1bbc3SMatthias Ringwald * Abstraction layer for 16-bit audio playback and recording within BTstack 51*23a1bbc3SMatthias Ringwald */ 52*23a1bbc3SMatthias Ringwald 53*23a1bbc3SMatthias Ringwald typedef struct { 54*23a1bbc3SMatthias Ringwald 55*23a1bbc3SMatthias Ringwald /** 56*23a1bbc3SMatthias Ringwald * @brief Setup audio codec for specified samplerate and number of channels 57*23a1bbc3SMatthias Ringwald * @param Channels (1=mono, 2=stereo) 58*23a1bbc3SMatthias Ringwald * @param Sample rate 59*23a1bbc3SMatthias Ringwald * @param Playback callback 60*23a1bbc3SMatthias Ringwald * @param Recording callback 61*23a1bbc3SMatthias Ringwald * @return 1 on success 62*23a1bbc3SMatthias Ringwald */ 63*23a1bbc3SMatthias Ringwald int (*init)(uint8_t channels, 64*23a1bbc3SMatthias Ringwald uint32_t samplerate, 65*23a1bbc3SMatthias Ringwald void (*playback) ( int16_t * buffer, uint16_t num_samples), 66*23a1bbc3SMatthias Ringwald void (*recording)(const int16_t * buffer, uint16_t num_samples)); 67*23a1bbc3SMatthias Ringwald 68*23a1bbc3SMatthias Ringwald /** 69*23a1bbc3SMatthias Ringwald * @brief Start stream 70*23a1bbc3SMatthias Ringwald */ 71*23a1bbc3SMatthias Ringwald void (*start_stream)(void); 72*23a1bbc3SMatthias Ringwald 73*23a1bbc3SMatthias Ringwald /** 74*23a1bbc3SMatthias Ringwald * @brief Close audio codec 75*23a1bbc3SMatthias Ringwald */ 76*23a1bbc3SMatthias Ringwald void (*close)(void); 77*23a1bbc3SMatthias Ringwald 78*23a1bbc3SMatthias Ringwald } btstack_audio_t; 79*23a1bbc3SMatthias Ringwald 80*23a1bbc3SMatthias Ringwald /** 81*23a1bbc3SMatthias Ringwald * @brief Get BTstack Audio Instance 82*23a1bbc3SMatthias Ringwald * @returns btstack_audio implementation 83*23a1bbc3SMatthias Ringwald */ 84*23a1bbc3SMatthias Ringwald const btstack_audio_t * btstack_audio_get_instance(void); 85*23a1bbc3SMatthias Ringwald 86*23a1bbc3SMatthias Ringwald /** 87*23a1bbc3SMatthias Ringwald * @brief Get BTstack Audio Instance 88*23a1bbc3SMatthias Ringwald * @param btstack_audio implementation 89*23a1bbc3SMatthias Ringwald */ 90*23a1bbc3SMatthias Ringwald void btstack_audio_set_instance(const btstack_audio_t * audio_impl); 91*23a1bbc3SMatthias Ringwald 92*23a1bbc3SMatthias Ringwald 93*23a1bbc3SMatthias Ringwald // common implementations 94*23a1bbc3SMatthias Ringwald const btstack_audio_t * btstack_audio_portaudio_get_instance(void); 95*23a1bbc3SMatthias Ringwald const btstack_audio_t * btstack_audio_embedded_get_instance(void); 96*23a1bbc3SMatthias Ringwald 97*23a1bbc3SMatthias Ringwald #if defined __cplusplus 98*23a1bbc3SMatthias Ringwald } 99*23a1bbc3SMatthias Ringwald #endif 100*23a1bbc3SMatthias Ringwald 101*23a1bbc3SMatthias Ringwald #endif 102