Read about our upcoming Code of Conduct on this issue

Commit 1a0ed746 authored by alex@thinkpad's avatar alex@thinkpad
Browse files

Merged lua_fix into 1200D

--HG--
branch : 1200D
......@@ -6,7 +6,7 @@ _CONFIGS_compile_name = _compile
_CONFIGS_clean_name = _clean
_CONFIGS_install_name = _install
_CONFIGS_to_filter_out =
_CONFIGS_to_filter_out = CONFIG_QEMU
_CONFIGS_to_compile = $(filter-out $(_CONFIGS_to_filter_out), $(ML_SETUP_CONFIGS_WITH_DIR))
......
......@@ -23,7 +23,7 @@
%if MN_COUNT.get(mn,0) != 0:
<thead>
<tr><th align="left" colspan="${len(cams)+3}">&nbsp;</th></tr>
<tr><th align="left" colspan="${len(cams)+3}">${mn}</th></tr>
<tr><th id="${mn}" align="left" colspan="${len(cams)+3}">${mn}</th></tr>
<tr>
<th></th>
<th></th>
......
......@@ -279,40 +279,17 @@ static int parse_next_int(char* source, size_t max_len)
}
}
//for some reason I can't link to strstr
static char* my_strstr(char* source, const char* search)
{
if(source && search && strlen(source) > 0 && strlen(search) > 0)
{
for (size_t pos = 0; pos < strlen(source) - strlen(search); pos++)
{
int found = TRUE;
for(size_t i = 0; i < strlen(search); i++)
{
if(source[pos + i] != search[i])
{
found = FALSE;
break;
}
}
if(found)
return source + pos;
}
}
return NULL;
}
static int parse_property(const char * property, char * source, size_t max_len)
{
if(source)
{
char * loc = my_strstr(source, property);
char * loc = strstr(source, property);
return loc ? parse_next_int(loc + strlen(property), max_len) : 0;
}
return 0;
}
static MENU_SELECT_FUNC(adv_int_load)
static void adv_int_load(void)
{
char filename[MAX_PATH];
char line_temp[LINE_BUF_SIZE];
......@@ -332,35 +309,45 @@ static MENU_SELECT_FUNC(adv_int_load)
while(read_line(buffer, &buf_pos, FILE_BUF_SIZE, line_temp, LINE_BUF_SIZE) > 0)
{
int kfr_time = parse_next_int(line_temp, LINE_BUF_SIZE);
struct keyframe * new_kfr = new_keyframe(keyframes, kfr_time);
if(new_kfr)
if (kfr_time)
{
new_kfr->shutter = parse_property("tv=", line_temp, LINE_BUF_SIZE);
new_kfr->aperture = parse_property("av=", line_temp, LINE_BUF_SIZE);
new_kfr->iso = parse_property("iso=", line_temp, LINE_BUF_SIZE);
new_kfr->focus = parse_property("fcs=", line_temp, LINE_BUF_SIZE);
new_kfr->interval_time = parse_property("int=", line_temp, LINE_BUF_SIZE);
new_kfr->kelvin = parse_property("wb=", line_temp, LINE_BUF_SIZE);
new_kfr->bulb_duration = parse_property("bulb=", line_temp, LINE_BUF_SIZE);
struct keyframe * new_kfr = new_keyframe(keyframes, kfr_time);
if(new_kfr)
{
new_kfr->shutter = parse_property("tv=", line_temp, LINE_BUF_SIZE);
new_kfr->aperture = parse_property("av=", line_temp, LINE_BUF_SIZE);
new_kfr->iso = parse_property("iso=", line_temp, LINE_BUF_SIZE);
new_kfr->focus = parse_property("fcs=", line_temp, LINE_BUF_SIZE);
new_kfr->interval_time = parse_property("int=", line_temp, LINE_BUF_SIZE);
new_kfr->kelvin = parse_property("wb=", line_temp, LINE_BUF_SIZE);
new_kfr->bulb_duration = parse_property("bulb=", line_temp, LINE_BUF_SIZE);
}
}
}
success = TRUE;
}
else
{
NotifyBox(2000, "Error: Could not read file");
}
fio_free(buffer);
}
else
{
NotifyBox(2000, "Error: Could not create buffer");
}
FIO_CloseFile(f);
}
else
NotifyBox(2000, "Error: Could not open file");
{
printf("adv_int: sequence file not found.\n%s", filename);
}
if(success)
NotifyBox(2000, "Sequence File Loaded");
{
printf("adv_int: sequence file loaded.\n");
}
}
static MENU_SELECT_FUNC(adv_int_save)
......@@ -422,28 +409,7 @@ static MENU_UPDATE_FUNC(time_menu_update)
{
entry->unit = UNIT_DEC;
int seconds = get_config_var("interval.time") * keyframe_time;
static char msg[50];
msg[0] = '\0';
if (seconds >= 3600)
{
STR_APPEND(msg, "%dh", seconds / 3600);
seconds = seconds % 3600;
}
if (seconds >= 60)
{
STR_APPEND(msg, "%dm", seconds / 60);
seconds = seconds % 60;
}
if (seconds || !msg[0])
{
STR_APPEND(msg, "%ds", seconds);
}
MENU_SET_RINFO("%s", msg);
MENU_SET_RINFO("%s", format_time_hours_minutes_seconds(seconds));
}
if(keyframe_exists(keyframe_time))
MENU_SET_WARNING(MENU_WARN_NOT_WORKING,"This keyframe already exists, will be overwritten");
......@@ -783,12 +749,12 @@ PROP_HANDLER(PROP_GUI_STATE)
static struct menu_entry adv_int_menu[] =
{
{
.name = "Advanced Intervalometer",
.name = "Ramping options",
.priv = &adv_int,
.select = menu_open_submenu,
.max = 1,
.works_best_in = DEP_M_MODE,
.help = "Advanced intervalometer ramping",
.help = "Advanced intervalometer ramping options.",
.children = (struct menu_entry[])
{
{
......@@ -829,19 +795,16 @@ static struct menu_entry adv_int_menu[] =
}
},
{
.name = "Load...",
.select = adv_int_load,
.help = "Load keyframes from file"
},
{
.name = "Save...",
.name = "Save Keyframes",
.select = adv_int_save,
.help = "Save current keyframes to file"
.help = "Save current keyframes to file.",
.help2 = "This sequence will be auto-loaded at startup."
},
{
.name = "Clear",
.name = "Clear Keyframes",
.select = adv_int_clear,
.help = "Clears all keyframes"
.help = "Clears all keyframes.",
.help2 = "Note: this will not remove the saved sequence."
},
{
.name = "New Keyframe...",
......@@ -997,6 +960,7 @@ static struct menu_entry adv_int_menu[] =
static unsigned int adv_int_init()
{
adv_int_load();
menu_add("Intervalometer", adv_int_menu, COUNT(adv_int_menu));
return 0;
}
......
......@@ -30,11 +30,11 @@
#include "audio-common.c"
#include "boot-hack.h"
static CONFIG_INT( "audio.dgain.l", dgain_l, 0 );
static CONFIG_INT( "audio.dgain.r", dgain_r, 0 );
static CONFIG_INT( "audio.mgain", mgain, 4 );
static CONFIG_INT( "audio.mic-power", mic_power, 1 );
static CONFIG_INT( "audio.o2gain", o2gain, 0 );
static CONFIG_INT_EX( "audio.dgain.l", dgain_l, 0, dgain_on_change );
static CONFIG_INT_EX( "audio.dgain.r", dgain_r, 0, dgain_on_change );
static CONFIG_INT_EX( "audio.mgain", mgain, 4, mgain_on_change );
static CONFIG_INT_EX( "audio.mic-power", mic_power, 1, mic_power_on_change );
static CONFIG_INT ( "audio.o2gain", o2gain, 0 );
int audio_meters_are_drawn()
{
......@@ -353,70 +353,71 @@ audio_gain_to_cmd(
}
static void
audio_3bit_toggle( void * priv, int delta )
static CONFIG_VAR_CHANGE_FUNC(mgain_on_change)
{
unsigned * ptr = priv;
*ptr = (*ptr + delta) & 0x3;
#ifdef FEATURE_ANALOG_GAIN
#ifdef CONFIG_500D
*(var->value) = MOD(new_value, 10);
#else
*(var->value) = new_value & 0x7;
#endif
audio_configure( 1 );
return 1;
#else
return 0;
#endif
}
static void
audio_binary_toggle( void * priv, int delta )
static CONFIG_VAR_CHANGE_FUNC(alc_enable_on_change)
{
unsigned * ptr = priv;
*ptr = !*ptr;
#ifdef FEATURE_AGC_TOGGLE
*(var->value) = new_value;
audio_configure( 1 );
return 1;
#else
return 0;
#endif
}
#ifdef FEATURE_ANALOG_GAIN
static void
audio_mgain_toggle( void * priv, int delta )
static CONFIG_VAR_CHANGE_FUNC(input_choice_on_change)
{
unsigned * ptr = priv;
#ifdef CONFIG_500D
*ptr = MOD((*ptr + delta), 10);
#ifdef FEATURE_INPUT_SOURCE
*(var->value) = new_value;
audio_configure( 1 );
return 1;
#else
*ptr = (*ptr + delta) & 0x7;
return 0;
#endif
audio_configure( 1 );
}
#endif
#ifdef FEATURE_DIGITAL_GAIN
static inline void
audio_dgain_toggle_reverse( void * priv, int delta )
static CONFIG_VAR_CHANGE_FUNC(mic_power_on_change)
{
unsigned dgain = *(unsigned*) priv;
if( dgain <= 0 ) {
dgain = 36;
} else {
dgain -= 6;
}
*(unsigned*) priv = dgain;
#ifdef FEATURE_MIC_POWER
*(var->value) = new_value;
audio_configure( 1 );
return 1;
#else
return 0;
#endif
}
static void
audio_dgain_toggle( void * priv, int delta )
static CONFIG_VAR_CHANGE_FUNC(dgain_on_change)
{
if (delta < 0) // will the compiler optimize it? :)
{
audio_dgain_toggle_reverse( priv, delta );
return;
}
unsigned dgain = *(unsigned*) priv;
dgain += 6;
if( dgain > 40 )
dgain = 0;
*(unsigned*) priv = dgain;
#ifdef FEATURE_DIGITAL_GAIN
*(var->value) = COERCE(new_value, 0, 36);
audio_configure( 1 );
return 1;
#else
return 0;
#endif
}
#ifdef FEATURE_DIGITAL_GAIN
static MENU_UPDATE_FUNC(audio_dgain_display)
{
unsigned val = CURRENT_VALUE;
MENU_SET_VALUE("%d dB", val);
MENU_SET_RINFO("(dB)");
if (alc_enable)
MENU_SET_WARNING(MENU_WARN_NOT_WORKING, "AGC is enabled.");
MENU_SET_ENABLED(val);
......@@ -431,15 +432,6 @@ static MENU_UPDATE_FUNC(audio_lovl_display)
}
#endif
#ifdef FEATURE_INPUT_SOURCE
static void
audio_input_toggle( void * priv, int delta )
{
menu_numeric_toggle(priv, delta, 0, 4);
audio_configure( 1 );
}
#endif
#ifdef FEATURE_MIC_POWER
static MENU_UPDATE_FUNC(audio_micpower_display)
{
......@@ -460,7 +452,6 @@ static struct menu_entry audio_menus[] = {
{
.name = "Analog Gain",
.priv = &mgain,
.select = audio_mgain_toggle,
.icon_type = IT_PERCENT_OFF,
#ifdef CONFIG_500D
// should match gains[]
......@@ -486,7 +477,7 @@ static struct menu_entry audio_menus[] = {
.priv = &dgain_l,
.max = 36,
.icon_type = IT_PERCENT_OFF,
.select = audio_dgain_toggle,
.unit = UNIT_DEC,
.update = audio_dgain_display,
.help = "Digital gain (LEFT). Any nonzero value reduces quality.",
},
......@@ -495,7 +486,7 @@ static struct menu_entry audio_menus[] = {
.priv = &dgain_r,
.max = 36,
.icon_type = IT_PERCENT_OFF,
.select = audio_dgain_toggle,
.unit = UNIT_DEC,
.update = audio_dgain_display,
.help = "Digital gain (RIGHT). Any nonzero value reduces quality.",
},
......@@ -503,7 +494,6 @@ static struct menu_entry audio_menus[] = {
{
.name = "AGC",
.priv = &alc_enable,
.select = audio_binary_toggle,
.max = 1,
.help = "Automatic Gain Control - turn it off :)",
},
......@@ -516,7 +506,6 @@ static struct menu_entry audio_menus[] = {
{
.name = "Input source",
.priv = &input_choice,
.select = audio_input_toggle,
.icon_type = IT_DICE,
.max = 4,
.choices = (const char *[]) {"Internal mic", "L:int R:ext", "External stereo", "L:int R:balanced", "Auto int/ext"},
......@@ -530,7 +519,6 @@ static struct menu_entry audio_menus[] = {
.name = "Wind Filter",
.priv = &enable_filters,
.help = "High pass filter for wind noise reduction.",
.select = audio_binary_toggle,
.max = 1,
.depends_on = DEP_SOUND_RECORDING,
},
......@@ -547,7 +535,6 @@ static struct menu_entry audio_menus[] = {
{
.name = "Mic Power",
.priv = &mic_power,
.select = audio_binary_toggle,
.update = audio_micpower_display,
.max = 1,
.help = "Needed for int. and some other mics, but lowers impedance.",
......@@ -575,7 +562,6 @@ static struct menu_entry audio_menus[] = {
{
.name = "Headphone Mon.",
.priv = &audio_monitoring,
.select = audio_monitoring_toggle,
.max = 1,
.help = "Monitoring via A-V jack. Disable if you use a SD display.",
.depends_on = DEP_SOUND_RECORDING,
......@@ -584,7 +570,6 @@ static struct menu_entry audio_menus[] = {
{
.name = "Headphone Volume",
.priv = &lovl,
.select = audio_3bit_toggle,
.update = audio_lovl_display,
.max = 3,
.icon_type = IT_PERCENT_OFF,
......@@ -674,16 +659,16 @@ void volume_up()
{
int mgain_db = mgain_index2gain(mgain);
if (mgain_db < 32)
audio_mgain_toggle(&mgain, 1);
set_config_var_ptr(&mgain, mgain + 1);
#ifdef FEATURE_DIGITAL_GAIN
else
{
if( MAX(dgain_l, dgain_r) + 6 <= 40 )
{
if( MAX(dgain_l, dgain_r) + 6 <= 40 )
{
audio_dgain_toggle(&dgain_l, 1);
audio_dgain_toggle(&dgain_r, 1);
}
set_config_var_ptr(&dgain_l, dgain_l + 6);
set_config_var_ptr(&dgain_r, dgain_r + 6);
}
}
#endif
volume_display();
}
......@@ -694,14 +679,14 @@ void volume_down()
#ifdef FEATURE_DIGITAL_GAIN
if( MIN(dgain_l, dgain_r) > 0 )
{
audio_dgain_toggle(&dgain_l, -1);
audio_dgain_toggle(&dgain_r, -1);
}
else
{
set_config_var_ptr(&dgain_l, dgain_l - 6);
set_config_var_ptr(&dgain_r, dgain_r - 6);
}
else
#endif
if (mgain_db > 0)
audio_mgain_toggle(&mgain, -1);
set_config_var_ptr(&mgain, mgain + 1);
volume_display();
}
#endif
......
......@@ -46,7 +46,9 @@ int audio_thresholds[] = { 0x7fff, 0x7213, 0x65ab, 0x5a9d, 0x50c2, 0x47fa, 0x402
void audio_configure(int force);
static void volume_display();
#ifdef FEATURE_HEADPHONE_MONITORING
static void audio_monitoring_update();
#endif
static void audio_monitoring_display_headphones_connected_or_not();
static void audio_menus_init();
static void audio_input_toggle( void * priv, int delta );
......@@ -79,13 +81,47 @@ static struct gain_struct gain = {
.sem = (void*) 1,
};
static CONFIG_INT( "audio.lovl", lovl, 0 );
static CONFIG_INT( "audio.alc-enable", alc_enable, 0 );
static CONFIG_VAR_CHANGE_FUNC(lovl_on_change)
{
#ifdef FEATURE_HEADPHONE_OUTPUT_VOLUME
*(var->value) = COERCE(new_value, 0, 3);
audio_monitoring_update();
return 1;
#else
return 0;
#endif
}
static CONFIG_VAR_CHANGE_FUNC(audio_monitoring_var_on_change)
{
#ifdef FEATURE_HEADPHONE_MONITORING
*(var->value) = new_value;
audio_monitoring_update();
return 1;
#else
return 0;
#endif
}
static CONFIG_VAR_CHANGE_FUNC(enable_filters_on_change)
{
#ifdef FEATURE_WIND_FILTER
*(var->value) = new_value;
audio_configure( 1 );
return 1;
#else
return 0;
#endif
}
static CONFIG_INT_EX("audio.lovl", lovl, 0, lovl_on_change );
static CONFIG_INT_EX("audio.alc-enable", alc_enable, 0, alc_enable_on_change );
static int loopback = 1;
static CONFIG_INT( "audio.input-choice", input_choice, 4 ); //0=internal; 1=L int, R ext; 2 = stereo ext; 3 = L int, R ext balanced, 4 = auto (0 or 1)
static CONFIG_INT( "audio.filters", enable_filters, 0 ); //disable the HPF, LPF and pre-emphasis filters
static CONFIG_INT_EX("audio.input-choice", input_choice, 4, input_choice_on_change ); //0=internal; 1=L int, R ext; 2 = stereo ext; 3 = L int, R ext balanced, 4 = auto (0 or 1)
static CONFIG_INT_EX("audio.filters", enable_filters, 0, enable_filters_on_change ); //disable the HPF, LPF and pre-emphasis filters
#define cfg_draw_meters 1
static CONFIG_INT("audio.monitoring", audio_monitoring, 1);
static CONFIG_INT_EX("audio.monitoring", audio_monitoring, 1, audio_monitoring_var_on_change );
static int do_draw_meters = 0;
static struct audio_level audio_levels[2];
......@@ -1004,7 +1040,6 @@ void audio_monitoring_display_headphones_connected_or_not()
PROP_INT(PROP_USBRCA_MONITOR, rca_monitor);
#ifdef FEATURE_HEADPHONE_MONITORING
static void audio_monitoring_update();
static void
audio_monitoring_toggle( void * priv, int delta )
......@@ -1072,7 +1107,7 @@ PROP_HANDLER( PROP_MVR_REC_START )
void input_toggle()
{
#ifdef FEATURE_INPUT_SOURCE
audio_input_toggle(&input_choice, 1);
set_config_var_ptr(&input_choice, input_choice + 1);
NotifyBox(2000, "Input: %s", get_audio_input_string());
#endif
}
......
......@@ -31,17 +31,17 @@
#include "audio-common.c"
// Set defaults
CONFIG_INT( "audio.override_audio", cfg_override_audio, 0 );
CONFIG_INT( "audio.analog_gain", cfg_analog_gain, 0 );
CONFIG_INT( "audio.analog_boost", cfg_analog_boost, 0 ); //test
CONFIG_INT( "audio.enable_dc", cfg_filter_dc, 1 );
CONFIG_INT( "audio.enable_hpf2", cfg_filter_hpf2, 0 );
CONFIG_INT( "audio.hpf2config", cfg_filter_hpf2config,7 );
CONFIG_INT_EX( "audio.override_audio", cfg_override_audio, 0, override_audio_on_change );
CONFIG_INT_EX( "audio.analog_gain", cfg_analog_gain, 0, analog_gain_on_change );
CONFIG_INT_EX( "audio.analog_boost", cfg_analog_boost, 0, analog_boost_on_change ); //test
CONFIG_INT_EX( "audio.enable_dc", cfg_filter_dc, 1, audio_filter_on_change );
CONFIG_INT_EX( "audio.enable_hpf2", cfg_filter_hpf2, 0, audio_filter_on_change );
CONFIG_INT_EX( "audio.hpf2config", cfg_filter_hpf2config,7, filter_hpf2config_on_change );
CONFIG_INT( "audio.dgain", cfg_recdgain, 0 );
CONFIG_INT( "audio.dgain.l", dgain_l, 8 );
CONFIG_INT( "audio.dgain.r", dgain_r, 8 );
CONFIG_INT( "audio.effect.mode", cfg_effect_mode, 0 );
CONFIG_INT_EX( "audio.dgain", cfg_recdgain, 0, recdgain_on_change );
CONFIG_INT_EX( "audio.dgain.l", dgain_l, 8, dgain_on_change );
CONFIG_INT_EX( "audio.dgain.r", dgain_r, 8, dgain_on_change );
CONFIG_INT_EX( "audio.effect.mode", cfg_effect_mode, 0, effect_mode_on_change );
int audio_meters_are_drawn()
......@@ -389,13 +389,6 @@ audio_lovl_toggle( void * priv, int delta )
audio_ic_set_lineout_vol();
}
static void
audio_dgain_toggle( void * priv, int delta )
{
menu_numeric_toggle(priv, delta, 0, 15);
audio_ic_set_RecLRbalance();
}
static int
get_dgain_val(int isL){
......@@ -417,105 +410,109 @@ get_dgain_val(int isL){
return 0;
}
static MENU_UPDATE_FUNC(audio_dgain_display)
static CONFIG_VAR_CHANGE_FUNC(override_audio_on_change)
{
int dgainval = get_dgain_val(entry->priv == &dgain_l ? 1 : 0);
MENU_SET_VALUE("%d dB", dgainval);
if (alc_enable)
MENU_SET_WARNING(MENU_WARN_NOT_WORKING, "AGC is enabled.");
*(var->value) = COERCE(new_value, 0, 1);
audio_configure(2);
return 1;
}
static MENU_UPDATE_FUNC(audio_lovl_display)
static CONFIG_VAR_CHANGE_FUNC(analog_gain_on_change)
{
if (!audio_monitoring)
MENU_SET_WARNING(MENU_WARN_NOT_WORKING, "Headphone monitoring is disabled");
*(var->value) = COERCE(new_value, 0, 5);
audio_ic_set_analog_gain();
return 1;
}
static void
audio_alc_toggle( void * priv, int delta )
static CONFIG_VAR_CHANGE_FUNC(analog_boost_on_change)
{
menu_numeric_toggle(priv, 1, 0, 1);
audio_ic_set_agc();
*(var->value) = COERCE(new_value, 0, 6);
audio_ic_set_micboost();
return 1;
}
static void
audio_input_toggle( void * priv, int delta )
static CONFIG_VAR_CHANGE_FUNC(effect_mode_on_change)
{
menu_numeric_toggle(priv, delta, 0, 4);
if(*(unsigned*)priv == 3) *(unsigned*)priv += delta; //tamporaly disabled Ext:balanced. We can't find it.
audio_ic_set