Spresense SDK Library
v3.4.6-5ba3997155669912adc4b68df0dc983c4388532a
Loading...
Searching...
No Matches
al_stream.h
1
/****************************************************************************
2
* modules/include/audiolite/al_stream.h
3
*
4
* Copyright 2023 Sony Semiconductor Solutions Corporation
5
*
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions
8
* are met:
9
*
10
* 1. Redistributions of source code must retain the above copyright
11
* notice, this list of conditions and the following disclaimer.
12
* 2. Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in
14
* the documentation and/or other materials provided with the
15
* distribution.
16
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
17
* the names of its contributors may be used to endorse or promote
18
* products derived from this software without specific prior written
19
* permission.
20
*
21
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
* POSSIBILITY OF SUCH DAMAGE.
33
*
34
****************************************************************************/
35
36
#ifndef __INCLUDE_AUDIOLITE_STREAM_H
37
#define __INCLUDE_AUDIOLITE_STREAM_H
38
39
/****************************************************************************
40
* Included Files
41
****************************************************************************/
42
43
#include <nuttx/config.h>
44
45
#include <stdio.h>
46
47
#include <mossfw/mossfw_lock.h>
48
#include <audiolite/al_memalloc.h>
49
50
/****************************************************************************
51
* Class Definitions
52
****************************************************************************/
53
54
/****************************************************************************
55
* class: audiolite_stream
56
****************************************************************************/
57
58
class
audiolite_stream
59
{
60
public
:
61
virtual
~audiolite_stream
(){};
62
63
virtual
int
rfile(
const
char
*fname) = 0;
64
virtual
int
wfile(
const
char
*fname) = 0;
65
66
virtual
void
close() = 0;
67
virtual
int
filesize() = 0;
68
virtual
int
seek(
int
size) = 0;
69
virtual
int
seekcur(
int
size) = 0;
70
virtual
int
seekend(
int
size) = 0;
71
virtual
bool
has_file() = 0;
72
73
virtual
int
read_data(
void
*data,
int
sz,
int
toms) = 0;
74
virtual
int
write_data(
void
*data,
int
sz,
int
toms) = 0;
75
virtual
int
receive_data(
audiolite_mem
*mem,
int
ofst,
int
toms) = 0;
76
virtual
int
send_data(
audiolite_mem
*mem,
int
ofst,
int
toms) = 0;
77
};
78
79
/****************************************************************************
80
* class: audiolite_filestream
81
****************************************************************************/
82
83
class
audiolite_filestream
:
public
audiolite_stream
84
{
85
private
:
86
FILE *_fp;
87
bool
_self_open;
88
mossfw_lock_t _lock;
89
90
int
open_file(
const
char
*fname,
const
char
*flg);
91
92
public
:
93
audiolite_filestream
() : _fp(NULL), _self_open(
false
)
94
{
95
mossfw_lock_init(&_lock);
96
};
97
~audiolite_filestream
();
98
99
int
rfile(
const
char
*fname);
100
int
wfile(
const
char
*fname);
101
int
set_file(FILE *fp);
102
103
void
close();
104
int
filesize();
105
int
seek(
int
size);
106
int
seekcur(
int
size);
107
int
seekend(
int
size);
108
bool
has_file();
109
110
int
read_data(
void
*data,
int
sz,
int
toms);
111
int
write_data(
void
*data,
int
sz,
int
toms);
112
int
receive_data(
audiolite_mem
*mem,
int
ofst,
int
toms);
113
int
send_data(
audiolite_mem
*mem,
int
ofst,
int
toms);
114
};
115
116
#endif
/* __INCLUDE_AUDIOLITE_STREAM_H */
audiolite_filestream
Definition
al_stream.h:84
audiolite_mem
Definition
al_memalloc.h:112
audiolite_stream
Definition
al_stream.h:59
spresense
sdk
modules
include
audiolite
al_stream.h
Generated by
1.12.0