1 /*
2  * Copyright (C) 2015-2017 Alibaba Group Holding Limited
3  */
4 
5 #ifndef PCM_DEV_H
6 #define PCM_DEV_H
7 
8 #include <stdio.h>
9 #include <aos/list.h>
10 #include "audio_drv.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 typedef struct {
17     int (*open)(void *dev);
18     int (*hw_params)(void *dev, audio_hw_params_t *params);
19     int (*sw_params)(void *dev, audio_sw_params_t *params);
20     int (*hw_prepare)(void *dev);
21     int (*start)(void *dev);
22     int (*readi)(void *dev, audio_xferi_t *xbuf);
23     int (*writei)(void *dev, audio_xferi_t *xbuf);
24     int (*readn)(void *dev, audio_xfern_t *xbuf);
25     int (*writen)(void *dev, audio_xfern_t *xbuf);
26     int (*drain)(void *dev);
27     int (*pause)(void *dev, int enable);
28     int (*stop)(void *dev);
29     int (*close)(void *dev);
30     int (*recover)(void *dev);
31     int (*suspend)(void *dev);
32     int (*resume)(void *dev);
33 } pcm_device_ops_t;
34 
35 typedef struct {
36     int dirType;
37     char *name;
38     audio_hw_params_t hwParams;
39     pcm_device_ops_t *ops;
40     audio_device_t *audioDevice;
41     void *private_data;
42     struct dlist_s list;
43 } pcm_device_t;
44 
45 pcm_device_t *audio_pcm_device_new(int dirType, const char *name, pcm_device_ops_t *ops, void *private_data);
46 int audio_pcm_device_free(pcm_device_t *dev);
47 
48 #ifdef __cplusplus
49 }
50 #endif
51 
52 #endif /* PCM_DEV_H */