summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/recorder/recording.c50
-rw-r--r--firmware/mpeg.c40
-rw-r--r--firmware/mpeg.h1
3 files changed, 76 insertions, 15 deletions
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 50d5982a62..491907666f 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -25,6 +25,7 @@
25#include "system.h" 25#include "system.h"
26#include "lcd.h" 26#include "lcd.h"
27#include "mpeg.h" 27#include "mpeg.h"
28#include "mas.h"
28#include "button.h" 29#include "button.h"
29#include "kernel.h" 30#include "kernel.h"
30#include "settings.h" 31#include "settings.h"
@@ -116,6 +117,18 @@ void adjust_cursor(void)
116 } 117 }
117} 118}
118 119
120#define BLINK_INTERVAL 2
121
122unsigned int frame_times[] =
123{
124 2400, /* 48kHz */
125 2612, /* 44.1kHz */
126 3600, /* 32kHz */
127 2400, /* 24kHz */
128 2612, /* 22.05kHz */
129 3200 /* 16kHz */
130};
131
119bool recording_screen(void) 132bool recording_screen(void)
120{ 133{
121 int button; 134 int button;
@@ -127,6 +140,10 @@ bool recording_screen(void)
127 int w, h; 140 int w, h;
128 int update_countdown = 1; 141 int update_countdown = 1;
129 bool have_recorded = false; 142 bool have_recorded = false;
143 bool blink_toggle = false;
144 unsigned long seconds;
145 unsigned long last_seconds = 0;
146 int hours, minutes;
130 147
131 cursor = 0; 148 cursor = 0;
132 mpeg_stop(); 149 mpeg_stop();
@@ -176,6 +193,7 @@ bool recording_screen(void)
176 mpeg_record(""); 193 mpeg_record("");
177 status_set_playmode(STATUS_RECORD); 194 status_set_playmode(STATUS_RECORD);
178 update_countdown = 1; /* Update immediately */ 195 update_countdown = 1; /* Update immediately */
196 last_seconds = 0;
179 } 197 }
180 break; 198 break;
181 199
@@ -306,13 +324,31 @@ bool recording_screen(void)
306 { 324 {
307 timeout = current_tick + HZ/10; 325 timeout = current_tick + HZ/10;
308 326
327 seconds = mpeg_num_recorded_frames();
328 seconds *= frame_times[global_settings.rec_frequency];
329 seconds /= 100000;
330
309 update_countdown--; 331 update_countdown--;
310 if(update_countdown == 0) 332 if(update_countdown == 0 || seconds > last_seconds)
311 { 333 {
312 update_countdown = 10; 334 update_countdown = 5;
313 335 last_seconds = seconds;
336
314 lcd_clear_display(); 337 lcd_clear_display();
315 peak_meter_draw(0, 8 + h, LCD_WIDTH, h); 338
339 if(mpeg_status() & MPEG_STATUS_RECORD)
340 {
341 blink_toggle = blink_toggle?false:true;
342 if(blink_toggle)
343 lcd_puts(0, 0, "Recording");
344 }
345
346 hours = seconds / 3600;
347 minutes = (seconds - (hours * 3600)) / 60;
348 snprintf(buf, 32, "%02d:%02d:%02d",
349 hours, minutes, seconds%60);
350 lcd_puts(0, 1, buf);
351 peak_meter_draw(0, 8 + h*2, LCD_WIDTH, h);
316 352
317 /* Show mic gain if input source is Mic */ 353 /* Show mic gain if input source is Mic */
318 if(global_settings.rec_source == 0) 354 if(global_settings.rec_source == 0)
@@ -363,9 +399,9 @@ bool recording_screen(void)
363 } 399 }
364 else 400 else
365 { 401 {
366 lcd_clearrect(0, 8 + h, LCD_WIDTH, h); 402 lcd_clearrect(0, 8 + h*2, LCD_WIDTH, h);
367 peak_meter_draw(0, 8 + h, LCD_WIDTH, h); 403 peak_meter_draw(0, 8 + h*2, LCD_WIDTH, h);
368 lcd_update_rect(0, 8 + h, LCD_WIDTH, h); 404 lcd_update_rect(0, 8 + h*2, LCD_WIDTH, h);
369 } 405 }
370 lcd_update(); 406 lcd_update();
371 } 407 }
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 3226e250ac..dfd2785356 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -473,6 +473,7 @@ static int lowest_watermark_level; /* Debug value to observe the buffer
473bool recording; /* We are recording */ 473bool recording; /* We are recording */
474static bool is_recording; /* We are (attempting to) record */ 474static bool is_recording; /* We are (attempting to) record */
475bool stop_pending; 475bool stop_pending;
476unsigned long record_start_frame; /* Frame number where recording started */
476#endif 477#endif
477 478
478static int mpeg_file; 479static int mpeg_file;
@@ -646,7 +647,7 @@ static void dma_tick(void)
646 { 647 {
647 int i; 648 int i;
648 int num_bytes = 0; 649 int num_bytes = 0;
649 if(recording && (PBDR & 0x4000)) 650 if(is_recording && (PBDR & 0x4000))
650 { 651 {
651#ifdef DEBUG 652#ifdef DEBUG
652 timing_info[timing_info_index++] = current_tick; 653 timing_info[timing_info_index++] = current_tick;
@@ -1589,8 +1590,6 @@ static void mpeg_thread(void)
1589 } 1590 }
1590 else 1591 else
1591 { 1592 {
1592 int i;
1593
1594 yield(); 1593 yield();
1595 if(!queue_empty(&mpeg_queue)) 1594 if(!queue_empty(&mpeg_queue))
1596 { 1595 {
@@ -1625,13 +1624,19 @@ static void mpeg_thread(void)
1625 if(mpeg_file >= 0) 1624 if(mpeg_file >= 0)
1626 close(mpeg_file); 1625 close(mpeg_file);
1627 1626
1628 for(i = 0;i < 512;i++) 1627#if 0
1629 { 1628 {
1630 DEBUGF("%d - %d us (%d bytes)\n", timing_info[i*2], 1629 int i;
1631 (timing_info[i*2+1] & 0xffff) * 1630 for(i = 0;i < 512;i++)
1632 10000 / 13824, 1631 {
1633 timing_info[i*2+1] >> 16); 1632 DEBUGF("%d - %d us (%d bytes)\n",
1633 timing_info[i*2],
1634 (timing_info[i*2+1] & 0xffff) *
1635 10000 / 13824,
1636 timing_info[i*2+1] >> 16);
1637 }
1634 } 1638 }
1639#endif
1635 break; 1640 break;
1636 1641
1637 case MPEG_SAVE_DATA: 1642 case MPEG_SAVE_DATA:
@@ -1862,6 +1867,9 @@ static void init_playback(void)
1862 1867
1863void mpeg_record(char *filename) 1868void mpeg_record(char *filename)
1864{ 1869{
1870 /* Read the current frame */
1871 mas_readmem(MAS_BANK_D0, 0xfd0, &record_start_frame, 1);
1872
1865 is_recording = true; 1873 is_recording = true;
1866 queue_post(&mpeg_queue, MPEG_RECORD, (void*)filename); 1874 queue_post(&mpeg_queue, MPEG_RECORD, (void*)filename);
1867} 1875}
@@ -1872,6 +1880,22 @@ static void start_recording(void)
1872 stop_pending = false; 1880 stop_pending = false;
1873} 1881}
1874 1882
1883unsigned long mpeg_num_recorded_frames(void)
1884{
1885 unsigned long val;
1886
1887 if(is_recording)
1888 {
1889 /* Read the current frame */
1890 mas_readmem(MAS_BANK_D0, 0xfd0, &val, 1);
1891
1892 return val - record_start_frame;
1893 }
1894 else
1895 {
1896 return 0;
1897 }
1898}
1875#endif 1899#endif
1876 1900
1877void mpeg_play(int offset) 1901void mpeg_play(int offset)
diff --git a/firmware/mpeg.h b/firmware/mpeg.h
index d4e9c486fd..34c898dbe4 100644
--- a/firmware/mpeg.h
+++ b/firmware/mpeg.h
@@ -80,6 +80,7 @@ void mpeg_record(char *filename);
80void mpeg_set_recording_options(int frequency, int quality, 80void mpeg_set_recording_options(int frequency, int quality,
81 int source, int channel_mode); 81 int source, int channel_mode);
82void mpeg_set_recording_gain(int left, int right, int mic); 82void mpeg_set_recording_gain(int left, int right, int mic);
83unsigned long mpeg_num_recorded_frames(void);
83#endif 84#endif
84void mpeg_get_debugdata(struct mpeg_debug *dbgdata); 85void mpeg_get_debugdata(struct mpeg_debug *dbgdata);
85 86