• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef AUDIO_VBUFFER_H
18 #define AUDIO_VBUFFER_H
19 
20 #include <pthread.h>
21 
22 typedef struct audio_vbuffer {
23   pthread_mutex_t lock;
24   uint8_t *data;
25   size_t frame_size;
26   size_t frame_count;
27   size_t head;
28   size_t tail;
29   size_t live;
30 } audio_vbuffer_t;
31 
32 int audio_vbuffer_init(audio_vbuffer_t *audio_vbuffer, size_t frame_count,
33                        size_t frame_size);
34 
35 int audio_vbuffer_destroy(audio_vbuffer_t *audio_vbuffer);
36 
37 int audio_vbuffer_live(audio_vbuffer_t *audio_vbuffer);
38 
39 int audio_vbuffer_dead(audio_vbuffer_t *audio_vbuffer);
40 
41 size_t audio_vbuffer_write(audio_vbuffer_t *audio_vbuffer, const void *buffer,
42                            size_t frame_count);
43 
44 size_t audio_vbuffer_read(audio_vbuffer_t *audio_vbuffer, void *buffer,
45                           size_t frame_count);
46 
47 #endif  // AUDIO_VBUFFER_H
48