forked from len0rd/rockbox
More recording stability, plus some feedback
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2860 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
11055c0471
commit
d703389780
3 changed files with 76 additions and 15 deletions
|
|
@ -25,6 +25,7 @@
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
#include "mpeg.h"
|
#include "mpeg.h"
|
||||||
|
#include "mas.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
@ -116,6 +117,18 @@ void adjust_cursor(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define BLINK_INTERVAL 2
|
||||||
|
|
||||||
|
unsigned int frame_times[] =
|
||||||
|
{
|
||||||
|
2400, /* 48kHz */
|
||||||
|
2612, /* 44.1kHz */
|
||||||
|
3600, /* 32kHz */
|
||||||
|
2400, /* 24kHz */
|
||||||
|
2612, /* 22.05kHz */
|
||||||
|
3200 /* 16kHz */
|
||||||
|
};
|
||||||
|
|
||||||
bool recording_screen(void)
|
bool recording_screen(void)
|
||||||
{
|
{
|
||||||
int button;
|
int button;
|
||||||
|
|
@ -127,6 +140,10 @@ bool recording_screen(void)
|
||||||
int w, h;
|
int w, h;
|
||||||
int update_countdown = 1;
|
int update_countdown = 1;
|
||||||
bool have_recorded = false;
|
bool have_recorded = false;
|
||||||
|
bool blink_toggle = false;
|
||||||
|
unsigned long seconds;
|
||||||
|
unsigned long last_seconds = 0;
|
||||||
|
int hours, minutes;
|
||||||
|
|
||||||
cursor = 0;
|
cursor = 0;
|
||||||
mpeg_stop();
|
mpeg_stop();
|
||||||
|
|
@ -176,6 +193,7 @@ bool recording_screen(void)
|
||||||
mpeg_record("");
|
mpeg_record("");
|
||||||
status_set_playmode(STATUS_RECORD);
|
status_set_playmode(STATUS_RECORD);
|
||||||
update_countdown = 1; /* Update immediately */
|
update_countdown = 1; /* Update immediately */
|
||||||
|
last_seconds = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -306,13 +324,31 @@ bool recording_screen(void)
|
||||||
{
|
{
|
||||||
timeout = current_tick + HZ/10;
|
timeout = current_tick + HZ/10;
|
||||||
|
|
||||||
|
seconds = mpeg_num_recorded_frames();
|
||||||
|
seconds *= frame_times[global_settings.rec_frequency];
|
||||||
|
seconds /= 100000;
|
||||||
|
|
||||||
update_countdown--;
|
update_countdown--;
|
||||||
if(update_countdown == 0)
|
if(update_countdown == 0 || seconds > last_seconds)
|
||||||
{
|
{
|
||||||
update_countdown = 10;
|
update_countdown = 5;
|
||||||
|
last_seconds = seconds;
|
||||||
|
|
||||||
lcd_clear_display();
|
lcd_clear_display();
|
||||||
peak_meter_draw(0, 8 + h, LCD_WIDTH, h);
|
|
||||||
|
if(mpeg_status() & MPEG_STATUS_RECORD)
|
||||||
|
{
|
||||||
|
blink_toggle = blink_toggle?false:true;
|
||||||
|
if(blink_toggle)
|
||||||
|
lcd_puts(0, 0, "Recording");
|
||||||
|
}
|
||||||
|
|
||||||
|
hours = seconds / 3600;
|
||||||
|
minutes = (seconds - (hours * 3600)) / 60;
|
||||||
|
snprintf(buf, 32, "%02d:%02d:%02d",
|
||||||
|
hours, minutes, seconds%60);
|
||||||
|
lcd_puts(0, 1, buf);
|
||||||
|
peak_meter_draw(0, 8 + h*2, LCD_WIDTH, h);
|
||||||
|
|
||||||
/* Show mic gain if input source is Mic */
|
/* Show mic gain if input source is Mic */
|
||||||
if(global_settings.rec_source == 0)
|
if(global_settings.rec_source == 0)
|
||||||
|
|
@ -363,9 +399,9 @@ bool recording_screen(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lcd_clearrect(0, 8 + h, LCD_WIDTH, h);
|
lcd_clearrect(0, 8 + h*2, LCD_WIDTH, h);
|
||||||
peak_meter_draw(0, 8 + h, LCD_WIDTH, h);
|
peak_meter_draw(0, 8 + h*2, LCD_WIDTH, h);
|
||||||
lcd_update_rect(0, 8 + h, LCD_WIDTH, h);
|
lcd_update_rect(0, 8 + h*2, LCD_WIDTH, h);
|
||||||
}
|
}
|
||||||
lcd_update();
|
lcd_update();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -473,6 +473,7 @@ static int lowest_watermark_level; /* Debug value to observe the buffer
|
||||||
bool recording; /* We are recording */
|
bool recording; /* We are recording */
|
||||||
static bool is_recording; /* We are (attempting to) record */
|
static bool is_recording; /* We are (attempting to) record */
|
||||||
bool stop_pending;
|
bool stop_pending;
|
||||||
|
unsigned long record_start_frame; /* Frame number where recording started */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int mpeg_file;
|
static int mpeg_file;
|
||||||
|
|
@ -646,7 +647,7 @@ static void dma_tick(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int num_bytes = 0;
|
int num_bytes = 0;
|
||||||
if(recording && (PBDR & 0x4000))
|
if(is_recording && (PBDR & 0x4000))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
timing_info[timing_info_index++] = current_tick;
|
timing_info[timing_info_index++] = current_tick;
|
||||||
|
|
@ -1589,8 +1590,6 @@ static void mpeg_thread(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
yield();
|
yield();
|
||||||
if(!queue_empty(&mpeg_queue))
|
if(!queue_empty(&mpeg_queue))
|
||||||
{
|
{
|
||||||
|
|
@ -1625,13 +1624,19 @@ static void mpeg_thread(void)
|
||||||
if(mpeg_file >= 0)
|
if(mpeg_file >= 0)
|
||||||
close(mpeg_file);
|
close(mpeg_file);
|
||||||
|
|
||||||
for(i = 0;i < 512;i++)
|
#if 0
|
||||||
{
|
{
|
||||||
DEBUGF("%d - %d us (%d bytes)\n", timing_info[i*2],
|
int i;
|
||||||
(timing_info[i*2+1] & 0xffff) *
|
for(i = 0;i < 512;i++)
|
||||||
10000 / 13824,
|
{
|
||||||
timing_info[i*2+1] >> 16);
|
DEBUGF("%d - %d us (%d bytes)\n",
|
||||||
|
timing_info[i*2],
|
||||||
|
(timing_info[i*2+1] & 0xffff) *
|
||||||
|
10000 / 13824,
|
||||||
|
timing_info[i*2+1] >> 16);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MPEG_SAVE_DATA:
|
case MPEG_SAVE_DATA:
|
||||||
|
|
@ -1862,6 +1867,9 @@ static void init_playback(void)
|
||||||
|
|
||||||
void mpeg_record(char *filename)
|
void mpeg_record(char *filename)
|
||||||
{
|
{
|
||||||
|
/* Read the current frame */
|
||||||
|
mas_readmem(MAS_BANK_D0, 0xfd0, &record_start_frame, 1);
|
||||||
|
|
||||||
is_recording = true;
|
is_recording = true;
|
||||||
queue_post(&mpeg_queue, MPEG_RECORD, (void*)filename);
|
queue_post(&mpeg_queue, MPEG_RECORD, (void*)filename);
|
||||||
}
|
}
|
||||||
|
|
@ -1872,6 +1880,22 @@ static void start_recording(void)
|
||||||
stop_pending = false;
|
stop_pending = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned long mpeg_num_recorded_frames(void)
|
||||||
|
{
|
||||||
|
unsigned long val;
|
||||||
|
|
||||||
|
if(is_recording)
|
||||||
|
{
|
||||||
|
/* Read the current frame */
|
||||||
|
mas_readmem(MAS_BANK_D0, 0xfd0, &val, 1);
|
||||||
|
|
||||||
|
return val - record_start_frame;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void mpeg_play(int offset)
|
void mpeg_play(int offset)
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ void mpeg_record(char *filename);
|
||||||
void mpeg_set_recording_options(int frequency, int quality,
|
void mpeg_set_recording_options(int frequency, int quality,
|
||||||
int source, int channel_mode);
|
int source, int channel_mode);
|
||||||
void mpeg_set_recording_gain(int left, int right, int mic);
|
void mpeg_set_recording_gain(int left, int right, int mic);
|
||||||
|
unsigned long mpeg_num_recorded_frames(void);
|
||||||
#endif
|
#endif
|
||||||
void mpeg_get_debugdata(struct mpeg_debug *dbgdata);
|
void mpeg_get_debugdata(struct mpeg_debug *dbgdata);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue