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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/*************************************************************************/
/* sample_manager_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, 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 SAMPLE_MANAGER_SW_H
#define SAMPLE_MANAGER_SW_H
#include "servers/audio_server.h"
class SampleManagerSW {
public:
/* SAMPLE API */
virtual RID sample_create(AS::SampleFormat p_format, bool p_stereo, int p_length)=0;
virtual void sample_set_description(RID p_sample, const String& p_description)=0;
virtual String sample_get_description(RID p_sample) const=0;
virtual AS::SampleFormat sample_get_format(RID p_sample) const=0;
virtual bool sample_is_stereo(RID p_sample) const=0;
virtual int sample_get_length(RID p_sample) const=0;
virtual void sample_set_data(RID p_sample, const DVector<uint8_t>& p_buffer)=0;
virtual const DVector<uint8_t> sample_get_data(RID p_sample) const=0;
virtual void *sample_get_data_ptr(RID p_sample) const=0;
virtual void sample_set_mix_rate(RID p_sample,int p_rate)=0;
virtual int sample_get_mix_rate(RID p_sample) const=0;
virtual void sample_set_loop_format(RID p_sample,AS::SampleLoopFormat p_format)=0;
virtual AS::SampleLoopFormat sample_get_loop_format(RID p_sample) const=0;
virtual void sample_set_loop_begin(RID p_sample,int p_pos)=0;
virtual int sample_get_loop_begin(RID p_sample) const=0;
virtual void sample_set_loop_end(RID p_sample,int p_pos)=0;
virtual int sample_get_loop_end(RID p_sample) const=0;
virtual bool is_sample(RID) const=0;
virtual void free(RID p_sample)=0;
virtual ~SampleManagerSW();
};
class SampleManagerMallocSW : public SampleManagerSW {
struct Sample {
void *data;
int length;
int length_bytes;
AS::SampleFormat format;
bool stereo;
AS::SampleLoopFormat loop_format;
int loop_begin;
int loop_end;
int mix_rate;
String description;
};
mutable RID_Owner<Sample> sample_owner;
public:
/* SAMPLE API */
virtual RID sample_create(AS::SampleFormat p_format, bool p_stereo, int p_length);
virtual void sample_set_description(RID p_sample, const String& p_description);
virtual String sample_get_description(RID p_sample) const;
virtual AS::SampleFormat sample_get_format(RID p_sample) const;
virtual bool sample_is_stereo(RID p_sample) const;
virtual int sample_get_length(RID p_sample) const;
virtual void sample_set_data(RID p_sample, const DVector<uint8_t>& p_buffer);
virtual const DVector<uint8_t> sample_get_data(RID p_sample) const;
virtual void *sample_get_data_ptr(RID p_sample) const;
virtual void sample_set_mix_rate(RID p_sample,int p_rate);
virtual int sample_get_mix_rate(RID p_sample) const;
virtual void sample_set_loop_format(RID p_sample,AS::SampleLoopFormat p_format);
virtual AS::SampleLoopFormat sample_get_loop_format(RID p_sample) const;
virtual void sample_set_loop_begin(RID p_sample,int p_pos);
virtual int sample_get_loop_begin(RID p_sample) const;
virtual void sample_set_loop_end(RID p_sample,int p_pos);
virtual int sample_get_loop_end(RID p_sample) const;
virtual bool is_sample(RID) const;
virtual void free(RID p_sample);
SampleManagerMallocSW();
virtual ~SampleManagerMallocSW();
};
#endif // SAMPLE_MANAGER_SW_H
|