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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
From e591698c1884e373de88a58eb8559fb1f21a0487 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= <[email protected]>
Date: Fri, 2 Jul 2010 03:07:01 +0200
Subject: [PATCH] Simulator: build recording code

---
 apps/SOURCES                         |    2 -
 apps/codecs.c                        |   10 ++--
 apps/codecs.h                        |    4 +-
 apps/codecs/SOURCES                  |   10 +++--
 apps/recorder/pcm_record.c           |    2 +-
 apps/recorder/recording.c            |   77 +---------------------------------
 firmware/target/hosted/sdl/pcm-sdl.c |   15 +++++--
 uisimulator/common/stubs.c           |    5 ++
 8 files changed, 32 insertions(+), 93 deletions(-)

diff --git a/apps/SOURCES b/apps/SOURCES
index 58186d2..181c780 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -161,9 +161,7 @@ dsp.c
 tdspeed.c
 #ifdef HAVE_RECORDING
 enc_config.c
-#ifndef SIMULATOR
 recorder/pcm_record.c
-#endif /* SIMULATOR */
 #endif
 eq.c	 	
 #if defined(CPU_COLDFIRE)
diff --git a/apps/codecs.c b/apps/codecs.c
index 22e692c..154faa3 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -167,7 +167,7 @@ struct codec_api ci = {
     __cyg_profile_func_exit,
 #endif

-#if defined(HAVE_RECORDING) && !defined(SIMULATOR)
+#ifdef HAVE_RECORDING
     false,  /* stop_encoder */
     0,      /* enc_codec_loaded */
     enc_get_inputs,
@@ -179,13 +179,13 @@ struct codec_api ci = {

     /* file */
     (open_func)PREFIX(open),
-    close,
-    (read_func)read,
+    PREFIX(close),
+    (read_func)PREFIX(read),
     PREFIX(lseek),
-    (write_func)write,
+    (write_func)PREFIX(write),
     round_value_to_list32,

-#endif
+#endif /* HAVE_RECORDING */

     /* new stuff at the end, sort into place next time
        the API gets incompatible */
diff --git a/apps/codecs.h b/apps/codecs.h
index c3dbc4a..c7bd1a8 100644
--- a/apps/codecs.h
+++ b/apps/codecs.h
@@ -44,7 +44,7 @@
 #include "thread.h"
 #endif
 #if (CONFIG_CODEC == SWCODEC)
-#if !defined(SIMULATOR) && defined(HAVE_RECORDING)
+#ifdef HAVE_RECORDING
 #include "pcm_record.h"
 #endif
 #include "dsp.h"
@@ -213,7 +213,7 @@ struct codec_api {
     void (*profile_func_exit)(void *this_fn, void *call_site);
 #endif

-#if defined(HAVE_RECORDING) && !defined(SIMULATOR)
+#ifdef HAVE_RECORDING
     volatile bool   stop_encoder;
     volatile int    enc_codec_loaded; /* <0=error, 0=pending, >0=ok */
     void            (*enc_get_inputs)(struct enc_inputs *inputs);
diff --git a/apps/codecs/SOURCES b/apps/codecs/SOURCES
index fe57354..ca50529 100644
--- a/apps/codecs/SOURCES
+++ b/apps/codecs/SOURCES
@@ -1,5 +1,5 @@
-#if CONFIG_CODEC == SWCODEC
 /* decoders */
+
 vorbis.c
 mpa.c
 flac.c
@@ -32,12 +32,14 @@ au.c
 vox.c
 wav64.c
 tta.c
-#if defined(HAVE_RECORDING) && !defined(SIMULATOR)
+
+#ifdef HAVE_RECORDING
+
 /* encoders */
+
 aiff_enc.c
 mp3_enc.c
 wav_enc.c
 wavpack_enc.c
-#endif
-#endif

+#endif /* HAVE_RECORDING */
diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c
index 3217509..704d859 100644
--- a/apps/recorder/pcm_record.c
+++ b/apps/recorder/pcm_record.c
@@ -23,7 +23,7 @@
 #include "kernel.h"
 #include "logf.h"
 #include "thread.h"
-#include <string.h>
+#include "string-extra.h"
 #include "storage.h"
 #include "usb.h"
 #include "buffer.h"
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index fd1ff75..ab7e7c9 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -691,7 +691,7 @@ void rec_init_recording_options(struct audio_recording_options *options)
 #endif
 }

-#if CONFIG_CODEC == SWCODEC && !defined (SIMULATOR)
+#if CONFIG_CODEC == SWCODEC
 void rec_set_source(int source, unsigned flags)
 {
     /* Set audio input source, power up/down devices */
@@ -701,7 +701,7 @@ void rec_set_source(int source, unsigned flags)
     peak_meter_playback((flags & SRCF_RECORDING) == 0);
     peak_meter_enable(true);
 }
-#endif /* CONFIG_CODEC == SWCODEC && !defined (SIMULATOR) */
+#endif /* CONFIG_CODEC == SWCODEC */

 void rec_set_recording_options(struct audio_recording_options *options)
 {
@@ -2321,79 +2321,6 @@ void audio_beep(int duration)
     /* dummy */
     (void)duration;
 }
-
-#ifdef SIMULATOR
-/* stubs for recording sim */
-void audio_init_recording(unsigned int buffer_offset)
-{
-    buffer_offset = buffer_offset;
-}
-
-void audio_close_recording(void)
-{
-}
-
-unsigned long pcm_rec_get_warnings(void)
-{
-    return 0;
-}
-
-unsigned long pcm_rec_sample_rate(void)
-{
-    return 0;
-}
-
-unsigned long audio_recorded_time(void)
-{
-    return 123;
-}
-
-unsigned long audio_num_recorded_bytes(void)
-{
-    return 5 * 1024 * 1024;
-}
-
-void rec_set_source(int source, unsigned flags)
-{
-    source = source;
-    flags = flags;
-}
-
-void audio_set_recording_options(struct audio_recording_options *options)
-{
-    options = options;
-}
-
-void audio_set_recording_gain(int left, int right, int type)
-{
-    left = left;
-    right = right;
-    type = type;
-}
-
-void audio_record(const char *filename)
-{
-    filename = filename;
-}
-
-void audio_new_file(const char *filename)
-{
-    filename = filename;
-}
-
-void audio_stop_recording(void)
-{
-}
-
-void audio_pause_recording(void)
-{
-}
-
-void audio_resume_recording(void)
-{
-}
-
-#endif /* #ifdef SIMULATOR */
 #endif /* #ifdef CONFIG_CODEC == SWCODEC */

 #endif /* HAVE_RECORDING */
diff --git a/firmware/target/hosted/sdl/pcm-sdl.c b/firmware/target/hosted/sdl/pcm-sdl.c
index 811d5c7..5591980 100644
--- a/firmware/target/hosted/sdl/pcm-sdl.c
+++ b/firmware/target/hosted/sdl/pcm-sdl.c
@@ -31,6 +31,10 @@
 #include "audiohw.h"
 #include "system.h"

+#ifdef HAVE_RECORDING
+#include "audiohw.h"
+#endif
+
 #include "pcm.h"
 #include "pcm_sampr.h"

@@ -284,16 +288,19 @@ void pcm_rec_dma_stop(void)
 {
 }

-unsigned long pcm_rec_status(void)
+const void * pcm_rec_dma_get_peak_buffer(void)
 {
-    return 0;
+    return NULL;
 }

-const void * pcm_rec_dma_get_peak_buffer(void)
+void audiohw_set_recvol(int left, int right, int type)
 {
-    return NULL;
+    (void)left;
+    (void)right;
+    (void)type;
 }

+
 #endif /* HAVE_RECORDING */

 void pcm_play_dma_init(void)
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c
index ee0c9f1..6d7d7de 100644
--- a/uisimulator/common/stubs.c
+++ b/uisimulator/common/stubs.c
@@ -56,6 +56,11 @@ bool fat_ismounted(int volume)
     return true;
 }

+int storage_spinup_time(void)
+{
+    return 0;
+}
+
 int storage_init(void)
 {
     return 1;
-- 
1.7.1