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
diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c
index 217d276..3410202 100644
--- a/apps/recorder/pcm_record.c
+++ b/apps/recorder/pcm_record.c
@@ -127,7 +127,11 @@ static unsigned long  pre_record_ticks;  /* pre-record time in ticks       */
 ****************************************************************************/

 /** buffer parameters where incoming PCM data is placed **/
+#if MEM <= 2
+#define PCM_NUM_CHUNKS             16 /* Power of 2 */
+#else
 #define PCM_NUM_CHUNKS            256 /* Power of 2 */
+#endif
 #define PCM_CHUNK_SIZE           8192 /* Power of 2 */
 #define PCM_CHUNK_MASK          (PCM_NUM_CHUNKS*PCM_CHUNK_SIZE - 1)

@@ -168,15 +172,20 @@ static int            flood_watermark; /* boost thread priority when here  */
 #endif

 /* Constants that control watermarks */
-#define LOW_SECONDS     1       /* low watermark time till empty           */
 #define MINI_CHUNKS    10       /* chunk count for mini flush              */
 #ifdef HAVE_PRIORITY_SCHEDULING
 #define PRIO_SECONDS   10       /* max flush time before priority boost    */
 #endif
-#if MEM <= 16
+#if MEM <= 2
+#define LOW_SECONDS     1/4     /* low watermark time till empty           */
+#define PANIC_SECONDS   1/2     /* flood watermark time until full         */
+#define FLUSH_SECONDS   1       /* flush watermark time until full         */
+#elif MEM <= 16
+#define LOW_SECONDS     1       /* low watermark time till empty           */
 #define PANIC_SECONDS   5       /* flood watermark time until full         */
 #define FLUSH_SECONDS   7       /* flush watermark time until full         */
 #else
+#define LOW_SECONDS     1       /* low watermark time till empty           */
 #define PANIC_SECONDS   8
 #define FLUSH_SECONDS  10
 #endif /* MEM */
@@ -734,7 +743,7 @@ static void pcmrec_refresh_watermarks(void)
     logf("ata spinup: %d", storage_spinup_time());

     /* set the low mark for when flushing stops if automatic */
-    low_watermark = (LOW_SECONDS*4*sample_rate + (enc_chunk_size-1))
+    low_watermark = (sample_rate*4*LOW_SECONDS + (enc_chunk_size-1))
                         / enc_chunk_size;
     logf("low wmk: %d", low_watermark);

@@ -744,7 +753,7 @@ static void pcmrec_refresh_watermarks(void)
        pcm data (if not yet full enough to boost itself)
        and not falsely trip the alarm. */
     flood_watermark = enc_num_chunks -
-        (PANIC_SECONDS*4*sample_rate + (enc_chunk_size-1))
+        (sample_rate*4*PANIC_SECONDS + (enc_chunk_size-1))
              / enc_chunk_size;

     if (flood_watermark < low_watermark)
@@ -756,7 +765,7 @@ static void pcmrec_refresh_watermarks(void)
     logf("flood at: %d", flood_watermark);
 #endif
     spinup_time = last_storage_spinup_time = storage_spinup_time();
-
+#if (CONFIG_STORAGE & STORAGE_ATA)
     /* write at 8s + st remaining in enc_buffer - range 12s to
        20s total - default to 3.5s spinup. */
     if (spinup_time == 0)
@@ -765,6 +774,7 @@ static void pcmrec_refresh_watermarks(void)
         spinup_time = 2*HZ;      /* ludicrous - ramdisk?          */
     else if (spinup_time > 10*HZ)
         spinup_time = 10*HZ;     /* do you have a functioning HD? */
+#endif

     /* try to start writing with 10s remaining after disk spinup */
     high_watermark = enc_num_chunks -
@@ -773,9 +783,9 @@ static void pcmrec_refresh_watermarks(void)

     if (high_watermark < low_watermark)
     {
+        logf("warning: low 'write at' (%d)", high_watermark);
         high_watermark = low_watermark;
         low_watermark /= 2;
-        logf("warning: low 'write at'");
     }

     logf("write at: %d", high_watermark);
diff --git a/firmware/export/config/sansaclip.h b/firmware/export/config/sansaclip.h
index 6cf7ec7..c139d91 100644
--- a/firmware/export/config/sansaclip.h
+++ b/firmware/export/config/sansaclip.h
@@ -12,7 +12,7 @@
 #define HW_SAMPR_CAPS       SAMPR_CAP_ALL

 /* define this if you have recording possibility */
-//#define HAVE_RECORDING
+#define HAVE_RECORDING

 #define REC_SAMPR_CAPS      SAMPR_CAP_ALL