153a5a1b3Sopenharmony_ci/* Copyright (C) 2007 Jean-Marc Valin 253a5a1b3Sopenharmony_ci 353a5a1b3Sopenharmony_ci File: speex_buffer.h 453a5a1b3Sopenharmony_ci This is a very simple ring buffer implementation. It is not thread-safe 553a5a1b3Sopenharmony_ci so you need to do your own locking. 653a5a1b3Sopenharmony_ci 753a5a1b3Sopenharmony_ci Redistribution and use in source and binary forms, with or without 853a5a1b3Sopenharmony_ci modification, are permitted provided that the following conditions are 953a5a1b3Sopenharmony_ci met: 1053a5a1b3Sopenharmony_ci 1153a5a1b3Sopenharmony_ci 1. Redistributions of source code must retain the above copyright notice, 1253a5a1b3Sopenharmony_ci this list of conditions and the following disclaimer. 1353a5a1b3Sopenharmony_ci 1453a5a1b3Sopenharmony_ci 2. Redistributions in binary form must reproduce the above copyright 1553a5a1b3Sopenharmony_ci notice, this list of conditions and the following disclaimer in the 1653a5a1b3Sopenharmony_ci documentation and/or other materials provided with the distribution. 1753a5a1b3Sopenharmony_ci 1853a5a1b3Sopenharmony_ci 3. The name of the author may not be used to endorse or promote products 1953a5a1b3Sopenharmony_ci derived from this software without specific prior written permission. 2053a5a1b3Sopenharmony_ci 2153a5a1b3Sopenharmony_ci THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2253a5a1b3Sopenharmony_ci IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2353a5a1b3Sopenharmony_ci OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 2453a5a1b3Sopenharmony_ci DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 2553a5a1b3Sopenharmony_ci INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 2653a5a1b3Sopenharmony_ci (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 2753a5a1b3Sopenharmony_ci SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2853a5a1b3Sopenharmony_ci HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 2953a5a1b3Sopenharmony_ci STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 3053a5a1b3Sopenharmony_ci ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3153a5a1b3Sopenharmony_ci POSSIBILITY OF SUCH DAMAGE. 3253a5a1b3Sopenharmony_ci*/ 3353a5a1b3Sopenharmony_ci 3453a5a1b3Sopenharmony_ci#ifndef SPEEX_BUFFER_H 3553a5a1b3Sopenharmony_ci#define SPEEX_BUFFER_H 3653a5a1b3Sopenharmony_ci 3753a5a1b3Sopenharmony_ci#include "speexdsp_types.h" 3853a5a1b3Sopenharmony_ci 3953a5a1b3Sopenharmony_ci#ifdef __cplusplus 4053a5a1b3Sopenharmony_ciextern "C" { 4153a5a1b3Sopenharmony_ci#endif 4253a5a1b3Sopenharmony_ci 4353a5a1b3Sopenharmony_cistruct SpeexBuffer_; 4453a5a1b3Sopenharmony_citypedef struct SpeexBuffer_ SpeexBuffer; 4553a5a1b3Sopenharmony_ci 4653a5a1b3Sopenharmony_ciSpeexBuffer *speex_buffer_init(int size); 4753a5a1b3Sopenharmony_ci 4853a5a1b3Sopenharmony_civoid speex_buffer_destroy(SpeexBuffer *st); 4953a5a1b3Sopenharmony_ci 5053a5a1b3Sopenharmony_ciint speex_buffer_write(SpeexBuffer *st, void *data, int len); 5153a5a1b3Sopenharmony_ci 5253a5a1b3Sopenharmony_ciint speex_buffer_writezeros(SpeexBuffer *st, int len); 5353a5a1b3Sopenharmony_ci 5453a5a1b3Sopenharmony_ciint speex_buffer_read(SpeexBuffer *st, void *data, int len); 5553a5a1b3Sopenharmony_ci 5653a5a1b3Sopenharmony_ciint speex_buffer_get_available(SpeexBuffer *st); 5753a5a1b3Sopenharmony_ci 5853a5a1b3Sopenharmony_ciint speex_buffer_resize(SpeexBuffer *st, int len); 5953a5a1b3Sopenharmony_ci 6053a5a1b3Sopenharmony_ci#ifdef __cplusplus 6153a5a1b3Sopenharmony_ci} 6253a5a1b3Sopenharmony_ci#endif 6353a5a1b3Sopenharmony_ci 6453a5a1b3Sopenharmony_ci#endif 6553a5a1b3Sopenharmony_ci 6653a5a1b3Sopenharmony_ci 6753a5a1b3Sopenharmony_ci 6853a5a1b3Sopenharmony_ci 69