/
spiffs_stream.h
80 lines (71 loc) · 3.27 KB
/
spiffs_stream.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* ESPRESSIF MIT License
*
* Copyright (c) 2018 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
*
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
* it is free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef _SPIFFS_STREAM_H_
#define _SPIFFS_STREAM_H_
#include "audio_error.h"
#include "audio_element.h"
#include "audio_common.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief SPIFFS Stream configuration, if any entry is zero then the configuration will be set to default values
*/
typedef struct {
audio_stream_type_t type; /*!< Stream type */
int buf_sz; /*!< Audio Element Buffer size */
int out_rb_size; /*!< Size of output ringbuffer */
int task_stack; /*!< Task stack size */
int task_core; /*!< Task running in core (0 or 1) */
int task_prio; /*!< Task priority (based on freeRTOS priority) */
bool write_header; /*!< Choose to write amrnb/armwb header in spiffs whether or not (true or false, true means choose to write amrnb header) */
} spiffs_stream_cfg_t;
#define SPIFFS_STREAM_BUF_SIZE (4096)
#define SPIFFS_STREAM_TASK_STACK (3072)
#define SPIFFS_STREAM_TASK_CORE (0)
#define SPIFFS_STREAM_TASK_PRIO (4)
#define SPIFFS_STREAM_RINGBUFFER_SIZE (8 * 1024)
#define SPIFFS_STREAM_CFG_DEFAULT() { \
.type = AUDIO_STREAM_NONE, \
.buf_sz = SPIFFS_STREAM_BUF_SIZE, \
.out_rb_size = SPIFFS_STREAM_RINGBUFFER_SIZE, \
.task_stack = SPIFFS_STREAM_TASK_STACK, \
.task_core = SPIFFS_STREAM_TASK_CORE, \
.task_prio = SPIFFS_STREAM_TASK_PRIO, \
.write_header = true, \
}
/**
* @brief Create a handle to an Audio Element to stream data from SPIFFS to another Element
* or get data from other elements written to SPIFFS, depending on the configuration
* the stream type, either AUDIO_STREAM_READER or AUDIO_STREAM_WRITER.
*
* @param config The configuration
*
* @return The Audio Element handle
*/
audio_element_handle_t spiffs_stream_init(spiffs_stream_cfg_t *config);
#ifdef __cplusplus
}
#endif
#endif