summaryrefslogtreecommitdiffstats
path: root/apps/recorder
diff options
context:
space:
mode:
Diffstat (limited to 'apps/recorder')
-rw-r--r--apps/recorder/pcm_record.c48
-rw-r--r--apps/recorder/peakmeter.c2
-rw-r--r--apps/recorder/recording.c245
3 files changed, 146 insertions, 149 deletions
diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c
index 9b0e779485..ef10f8a433 100644
--- a/apps/recorder/pcm_record.c
+++ b/apps/recorder/pcm_record.c
@@ -878,53 +878,37 @@ copy_buffer_mono_lr(void *dst, const void *src, size_t src_size)
ssize_t copy_size = src_size;
/* mono = (L + R) / 2 */
- do
- {
- *d++ = ((int32_t){s[0]} + s[1] + 1) >> 1;
- s+=2;
+ while(copy_size > 0) {
+ *d++ = ((int32_t)s[0] + (int32_t)s[1] + 1) >> 1;
+ s += 2;
+ copy_size -= PCM_SAMP_SIZE;
}
- while ((copy_size -= PCM_SAMP_SIZE) > 0);
return dst;
}
-/* Copy with mono conversion - output 1/2 size of input */
static void * ICODE_ATTR
-copy_buffer_mono_r(void *dst, const void *src, size_t src_size)
+copy_buffer_mono_l(void *dst, const void *src, size_t src_size)
{
- int16_t *d = (int16_t*)dst;
- int16_t const *s = (int16_t const*)src - 1;
+ int16_t *d = (int16_t*) dst;
+ int16_t const *s = (int16_t const*) src;
ssize_t copy_size = src_size;
- /* mono = R */
- do
- *d++ = *(s += 2);
- while ((copy_size -= PCM_SAMP_SIZE) > 0);
+
+ /* mono = L */
+ while(copy_size > 0) {
+ *d++ = *s;
+ s += 2;
+ copy_size -= PCM_SAMP_SIZE;
+ }
return dst;
}
-#if 1
-static void * ICODE_ATTR
-copy_buffer_mono_l(void *dst, const void *src, size_t src_size)
-{
- return copy_buffer_mono_r(dst, src -1, src_size);
-}
-#else
-/* Copy with mono conversion - output 1/2 size of input */
static void * ICODE_ATTR
-copy_buffer_mono_l(void *dst, const void *src, size_t src_size)
+copy_buffer_mono_r(void *dst, const void *src, size_t src_size)
{
- int16_t *d = (int16_t*)dst;
- int16_t const *s = (int16_t const*)src - 2;
- ssize_t copy_size = src_size;
- /* mono = L */
- do
- *d++ = *(s += 2);
- while ((copy_size -= PCM_SAMP_SIZE) > 0);
-
- return dst;
+ return copy_buffer_mono_l(dst, src + 2, src_size);
}
-#endif
/** pcm_rec_* group **/
diff --git a/apps/recorder/peakmeter.c b/apps/recorder/peakmeter.c
index 900bb6d7c3..c9e92b5762 100644
--- a/apps/recorder/peakmeter.c
+++ b/apps/recorder/peakmeter.c
@@ -58,6 +58,8 @@ static int pm_max_right;
#if defined(HAVE_AGC) || defined(HAVE_HISTOGRAM)
static int pm_peakhold_left; /* max. peak values between peakhold calls */
static int pm_peakhold_right; /* used for AGC and histogram display */
+#endif
+#ifdef HAVE_HISTOGRAM
static long next_histogram_update;
#endif
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index bf69e8f781..7215812f49 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -68,7 +68,9 @@
#include "splash.h"
#include "screen_access.h"
#include "action.h"
-#include "radio.h"
+#ifdef HAVE_FMRADIO_REC
+# include "radio.h"
+#endif
#include "viewport.h"
#include "list.h"
#include "general.h"
@@ -233,9 +235,9 @@ static long hist_time = 0;
static void set_gain(void)
{
+ switch(global_settings.rec_source) {
#ifdef HAVE_MIC_REC
- if(global_settings.rec_source == AUDIO_SRC_MIC)
- {
+ case AUDIO_SRC_MIC:
if (global_settings.rec_mic_gain > sound_max(SOUND_MIC_GAIN))
global_settings.rec_mic_gain = sound_max(SOUND_MIC_GAIN);
@@ -244,10 +246,11 @@ static void set_gain(void)
audio_set_recording_gain(global_settings.rec_mic_gain,
0, AUDIO_GAIN_MIC);
- }
- else
+ break;
#endif /* MIC */
- {
+#if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC)
+ HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
+ HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
if (global_settings.rec_left_gain > sound_max(SOUND_LEFT_GAIN))
global_settings.rec_left_gain = sound_max(SOUND_LEFT_GAIN);
@@ -260,11 +263,13 @@ static void set_gain(void)
if (global_settings.rec_right_gain < sound_min(SOUND_RIGHT_GAIN))
global_settings.rec_right_gain = sound_min(SOUND_RIGHT_GAIN);
- /* AUDIO_SRC_LINEIN, AUDIO_SRC_FMRADIO, AUDIO_SRC_SPDIF */
audio_set_recording_gain(global_settings.rec_left_gain,
global_settings.rec_right_gain,
AUDIO_GAIN_LINEIN);
+ break;
+#endif
}
+
/* reset the clipping indicators */
peak_meter_set_clip_hold(global_settings.peak_meter_clip_hold);
update_list = true;
@@ -332,6 +337,11 @@ static bool agc_gain_is_max(bool left, bool right)
static void change_recording_gain(bool increment, bool left, bool right)
{
+#if !defined(HAVE_LINE_REC) || !defined(HAVE_FMRADIO_REC)
+ (void)left;
+ (void)right;
+#endif
+
int factor = (increment ? 1 : -1);
switch (global_settings.rec_source)
@@ -729,43 +739,22 @@ static void trigger_listener(int trigger_status)
/* Stuff for drawing the screen */
enum rec_list_items_stereo {
- ITEM_VOLUME = 0,
- ITEM_GAIN = 1,
- ITEM_GAIN_L = 2,
- ITEM_GAIN_R = 3,
-#ifdef HAVE_AGC
- ITEM_AGC_MODE = 4,
- ITEM_AGC_MAXDB = 5,
- ITEM_FILENAME = 7,
- ITEM_COUNT = 7,
-#else
- ITEM_FILENAME = 7,
- ITEM_COUNT = 5,
+ ITEM_VOLUME,
+ ITEM_GAIN,
+#if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC)
+ ITEM_GAIN_L,
+ ITEM_GAIN_R,
#endif
-};
-
-enum rec_list_items_mono {
- ITEM_VOLUME_M = 0,
- ITEM_GAIN_M = 1,
#ifdef HAVE_AGC
- ITEM_AGC_MODE_M = 4,
- ITEM_AGC_MAXDB_M = 5,
- ITEM_FILENAME_M = 7,
- ITEM_COUNT_M = 5,
-#else
- ITEM_FILENAME_M = 7,
- ITEM_COUNT_M = 3,
+ ITEM_AGC_MODE,
+ ITEM_AGC_MAXDB,
#endif
-};
-
#ifdef HAVE_SPDIF_REC
-enum rec_list_items_spdif {
- ITEM_VOLUME_D = 0,
- ITEM_SAMPLERATE_D = 6,
- ITEM_FILENAME_D = 7,
- ITEM_COUNT_D = 3,
-};
+ ITEM_SAMPLERATE,
#endif
+ ITEM_FILENAME,
+ ITEM_COUNT,
+};
static int listid_to_enum[ITEM_COUNT];
@@ -789,26 +778,30 @@ static const char* reclist_get_name(int selected_item, void * data,
buf2, sizeof(buf2)));
break;
case ITEM_GAIN:
+ switch(global_settings.rec_source) {
#ifdef HAVE_MIC_REC
- if(global_settings.rec_source == AUDIO_SRC_MIC)
- {
+ case AUDIO_SRC_MIC:
/* Draw MIC recording gain */
snprintf(buffer, buffer_len, "%s: %s", str(LANG_GAIN),
fmt_gain(SOUND_MIC_GAIN,
global_settings.rec_mic_gain,
buf2, sizeof(buf2)));
- }
- else
+ break;
#endif /* MIC */
- {
+#if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC)
+ HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
+ HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:) {
int avg_gain = (global_settings.rec_left_gain +
global_settings.rec_right_gain) / 2;
snprintf(buffer, buffer_len, "%s: %s", str(LANG_GAIN),
fmt_gain(SOUND_LEFT_GAIN,
avg_gain,
buf2, sizeof(buf2)));
+ } break;
+#endif
}
break;
+#if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC)
case ITEM_GAIN_L:
snprintf(buffer, buffer_len, "%s: %s",
str(LANG_GAIN_LEFT),
@@ -823,42 +816,46 @@ static const char* reclist_get_name(int selected_item, void * data,
global_settings.rec_right_gain,
buf2, sizeof(buf2)));
break;
+#endif
#ifdef HAVE_AGC
case ITEM_AGC_MODE:
snprintf(buffer, buffer_len, "%s: %s",
str(LANG_RECORDING_AGC_PRESET),
agc_preset_str[agc_preset]);
break;
- case ITEM_AGC_MAXDB:
- if (agc_preset == 0)
+ case ITEM_AGC_MAXDB: {
+ int bias, which;
+ switch(global_settings.rec_source) {
+ default:
+#if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC)
+ HAVE_LINE_IN_(case AUDIO_SRC_LINEIN:)
+ HAVE_FMRADIO_IN_(case AUDIO_SRC_FMRADIO:)
+ which = SOUND_LEFT_GAIN;
+ bias = (global_settings.rec_left_gain + global_settings.rec_right_gain) / 2;
+ break;
+#endif
+#if defined(HAVE_MIC_REC)
+ case AUDIO_SRC_MIC:
+ which = SOUND_MIC_GAIN;
+ bias = global_settings.rec_mic_gain;
+ break;
+#endif /* MIC*/
+ }
+
+ if(agc_preset == 0) {
snprintf(buffer, buffer_len, "%s: %s",
str(LANG_RECORDING_AGC_MAXGAIN),
- fmt_gain(SOUND_LEFT_GAIN,
- agc_maxgain, buf2, sizeof(buf2)));
-#ifdef HAVE_MIC_REC
- else if (global_settings.rec_source == AUDIO_SRC_MIC)
- snprintf(buffer, buffer_len, "%s: %s (%s)",
- str(LANG_RECORDING_AGC_MAXGAIN),
- fmt_gain(SOUND_MIC_GAIN,
- agc_maxgain, buf2, sizeof(buf2)),
- fmt_gain(SOUND_MIC_GAIN,
- agc_maxgain - global_settings.rec_mic_gain,
- buf3, sizeof(buf3)));
- else
-#endif /* MIC */
+ fmt_gain(which, agc_maxgain, buf2, sizeof(buf2)));
+ } else {
snprintf(buffer, buffer_len, "%s: %s (%s)",
str(LANG_RECORDING_AGC_MAXGAIN),
- fmt_gain(SOUND_LEFT_GAIN,
- agc_maxgain, buf2, sizeof(buf2)),
- fmt_gain(SOUND_LEFT_GAIN,
- agc_maxgain -
- (global_settings.rec_left_gain +
- global_settings.rec_right_gain)/2,
- buf3, sizeof(buf3)));
- break;
+ fmt_gain(which, agc_maxgain, buf2, sizeof(buf2)),
+ fmt_gain(which, agc_maxgain - bias, buf3, sizeof(buf3)));
+ }
+ } break;
#endif
#ifdef HAVE_SPDIF_REC
- case ITEM_SAMPLERATE_D:
+ case ITEM_SAMPLERATE:
snprintf(buffer, buffer_len, "%s: %lu",
str(LANG_FREQUENCY), pcm_rec_sample_rate());
break;
@@ -902,12 +899,14 @@ static void recording_step_levels(int setting_id, int steps)
global_settings.volume += steps;
setvol();
break;
+#if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC)
case SOUND_LEFT_GAIN:
global_settings.rec_left_gain += steps;
break;
case SOUND_RIGHT_GAIN:
global_settings.rec_right_gain += steps;
break;
+#endif
#ifdef HAVE_MIC_REC
case SOUND_MIC_GAIN:
global_settings.rec_mic_gain += steps;
@@ -1150,46 +1149,37 @@ bool recording_screen(bool no_source)
set_gain();
update_countdown = 0; /* Update immediately */
+ int listi = 0;
+
/* populate translation table for list id -> enum */
#ifdef HAVE_SPDIF_REC
if(global_settings.rec_source == AUDIO_SRC_SPDIF)
{
- listid_to_enum[0] = ITEM_VOLUME_D;
- listid_to_enum[1] = ITEM_SAMPLERATE_D;
- listid_to_enum[2] = ITEM_FILENAME_D;
+ listid_to_enum[listi++] = ITEM_VOLUME;
+ listid_to_enum[listi++] = ITEM_SAMPLERATE;
+ listid_to_enum[listi++] = ITEM_FILENAME;
- gui_synclist_set_nb_items(&lists, ITEM_COUNT_D); /* spdif */
+ gui_synclist_set_nb_items(&lists, listi); /* spdif */
}
else
#endif
- if(HAVE_MIC_REC_((global_settings.rec_source == AUDIO_SRC_MIC) || )
- (global_settings.rec_channels == 1))
{
- listid_to_enum[0] = ITEM_VOLUME_M;
- listid_to_enum[1] = ITEM_GAIN_M;
-#ifdef HAVE_AGC
- listid_to_enum[2] = ITEM_AGC_MODE_M;
- listid_to_enum[3] = ITEM_AGC_MAXDB_M;
- listid_to_enum[4] = ITEM_FILENAME_M;
-#else
- listid_to_enum[2] = ITEM_FILENAME_M;
+ listid_to_enum[listi++] = ITEM_VOLUME;
+ listid_to_enum[listi++] = ITEM_GAIN;
+#if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC)
+ if(HAVE_MIC_REC_((global_settings.rec_source != AUDIO_SRC_MIC) || )
+ (global_settings.rec_channels != 1)) {
+ listid_to_enum[listi++] = ITEM_GAIN_L;
+ listid_to_enum[listi++] = ITEM_GAIN_R;
+ }
#endif
- gui_synclist_set_nb_items(&lists, ITEM_COUNT_M); /* mono */
- }
- else
- {
- listid_to_enum[0] = ITEM_VOLUME;
- listid_to_enum[1] = ITEM_GAIN;
- listid_to_enum[2] = ITEM_GAIN_L;
- listid_to_enum[3] = ITEM_GAIN_R;
#ifdef HAVE_AGC
- listid_to_enum[4] = ITEM_AGC_MODE;
- listid_to_enum[5] = ITEM_AGC_MAXDB;
- listid_to_enum[6] = ITEM_FILENAME;
-#else
- listid_to_enum[4] = ITEM_FILENAME;
+ listid_to_enum[listi++] = ITEM_AGC_MODE;
+ listid_to_enum[listi++] = ITEM_AGC_MAXDB;
#endif
- gui_synclist_set_nb_items(&lists, ITEM_COUNT); /* stereo */
+ listid_to_enum[listi++] = ITEM_FILENAME;
+
+ gui_synclist_set_nb_items(&lists, listi); /* stereo */
}
gui_synclist_draw(&lists);
@@ -1279,22 +1269,29 @@ bool recording_screen(bool no_source)
recording_step_levels(SOUND_VOLUME, 1);
break;
case ITEM_GAIN:
+ switch(global_settings.rec_source) {
#ifdef HAVE_MIC_REC
- if(global_settings.rec_source == AUDIO_SRC_MIC)
+ case AUDIO_SRC_MIC:
recording_step_levels(SOUND_MIC_GAIN, 1);
- else
+ break;
#endif /* MIC */
- {
+#if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC)
+ HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
+ HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
recording_step_levels(SOUND_LEFT_GAIN, 1);
recording_step_levels(SOUND_RIGHT_GAIN, 1);
+ break;
+#endif
}
break;
+#if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC)
case ITEM_GAIN_L:
recording_step_levels(SOUND_LEFT_GAIN, 1);
break;
case ITEM_GAIN_R:
recording_step_levels(SOUND_RIGHT_GAIN, 1);
break;
+#endif
#ifdef HAVE_AGC
case ITEM_AGC_MODE:
agc_preset = MIN(agc_preset + 1, AGC_MODE_SIZE);
@@ -1311,19 +1308,22 @@ bool recording_screen(bool no_source)
}
break;
case ITEM_AGC_MAXDB:
+ switch(global_settings.rec_source) {
+#if defined(HAVE_LINE_IN) || defined(HAVE_FMRADIO_IN)
+ HAVE_LINE_IN_(case AUDIO_SRC_LINEIN:)
+ HAVE_FMRADIO_IN_(case AUDIO_SRC_FMRADIO:)
+ agc_maxgain = MIN(agc_maxgain + 1,
+ sound_max(SOUND_LEFT_GAIN));
+ global_settings.rec_agc_maxgain_line = agc_maxgain;
+ break;
+#endif
#ifdef HAVE_MIC_REC
- if (global_settings.rec_source == AUDIO_SRC_MIC)
- {
+ case AUDIO_SRC_MIC:
agc_maxgain = MIN(agc_maxgain + 1,
sound_max(SOUND_MIC_GAIN));
global_settings.rec_agc_maxgain_mic = agc_maxgain;
- }
- else
+ break;
#endif /* MIC */
- {
- agc_maxgain = MIN(agc_maxgain + 1,
- sound_max(SOUND_LEFT_GAIN));
- global_settings.rec_agc_maxgain_line = agc_maxgain;
}
break;
#endif /* HAVE_AGC */
@@ -1339,22 +1339,29 @@ bool recording_screen(bool no_source)
recording_step_levels(SOUND_VOLUME, -1);
break;
case ITEM_GAIN:
+ switch(global_settings.rec_source) {
#ifdef HAVE_MIC_REC
- if(global_settings.rec_source == AUDIO_SRC_MIC)
+ case AUDIO_SRC_MIC:
recording_step_levels(SOUND_MIC_GAIN, -1);
- else
+ break;
#endif /* MIC */
- {
+#if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC)
+ HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
+ HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
recording_step_levels(SOUND_LEFT_GAIN, -1);
recording_step_levels(SOUND_RIGHT_GAIN, -1);
+ break;
+#endif
}
break;
+#if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC)
case ITEM_GAIN_L:
recording_step_levels(SOUND_LEFT_GAIN, -1);
break;
case ITEM_GAIN_R:
recording_step_levels(SOUND_RIGHT_GAIN, -1);
break;
+#endif
#ifdef HAVE_AGC
case ITEM_AGC_MODE:
agc_preset = MAX(agc_preset - 1, 0);
@@ -1371,18 +1378,22 @@ bool recording_screen(bool no_source)
}
break;
case ITEM_AGC_MAXDB:
+ switch(global_settings.rec_source) {
+#if defined(HAVE_LINE_IN) || defined(HAVE_FMRADIO_IN)
+ HAVE_LINE_IN_(case AUDIO_SRC_LINEIN:)
+ HAVE_FMRADIO_IN_(case AUDIO_SRC_FMRADIO:)
+ agc_maxgain = MAX(agc_maxgain - 1,
+ sound_min(SOUND_LEFT_GAIN));
+ global_settings.rec_agc_maxgain_line = agc_maxgain;
+ break;
+#endif
#ifdef HAVE_MIC_REC
- if (global_settings.rec_source == AUDIO_SRC_MIC)
- {
+ case AUDIO_SRC_MIC:
agc_maxgain = MAX(agc_maxgain - 1,
sound_min(SOUND_MIC_GAIN));
global_settings.rec_agc_maxgain_mic = agc_maxgain;
- } else
+ break;
#endif /* MIC */
- {
- agc_maxgain = MAX(agc_maxgain - 1,
- sound_min(SOUND_LEFT_GAIN));
- global_settings.rec_agc_maxgain_line = agc_maxgain;
}
break;
#endif /* HAVE_AGC */