summaryrefslogtreecommitdiff
path: root/apps/recorder/recording.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/recorder/recording.c')
-rw-r--r--apps/recorder/recording.c114
1 files changed, 5 insertions, 109 deletions
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 73d0425f24..6750acc691 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -38,12 +38,6 @@
38#include "spdif.h" 38#include "spdif.h"
39#endif 39#endif
40#endif /* CONFIG_CODEC == SWCODEC */ 40#endif /* CONFIG_CODEC == SWCODEC */
41#ifdef HAVE_UDA1380
42#include "uda1380.h"
43#endif
44#ifdef HAVE_TLV320
45#include "tlv320.h"
46#endif
47#include "recording.h" 41#include "recording.h"
48#include "mp3_playback.h" 42#include "mp3_playback.h"
49#include "mas.h" 43#include "mas.h"
@@ -580,36 +574,14 @@ static void rec_boost(bool state)
580 * The order of setting monitoring may need tweaking dependent upon the 574 * The order of setting monitoring may need tweaking dependent upon the
581 * selected source to get the smoothest transition. 575 * selected source to get the smoothest transition.
582 */ 576 */
583#if defined(HAVE_UDA1380)
584#define ac_disable_recording uda1380_disable_recording
585#define ac_enable_recording uda1380_enable_recording
586#define ac_set_monitor uda1380_set_monitor
587#elif defined(HAVE_TLV320)
588#define ac_disable_recording tlv320_disable_recording
589#define ac_enable_recording tlv320_enable_recording
590#define ac_set_monitor tlv320_set_monitor
591#endif
592
593void rec_set_source(int source, unsigned flags) 577void rec_set_source(int source, unsigned flags)
594{ 578{
595 /* Prevent pops from unneeded switching */
596 static int last_source = AUDIO_SRC_PLAYBACK;
597#ifdef HAVE_TLV320
598 static bool last_recording = false;
599#endif
600
601 bool recording = flags & SRCF_RECORDING;
602 /* Default to peakmeter record. */
603 bool pm_playback = false;
604 bool pm_enabled = true;
605
606 /** Do power up/down of associated device(s) **/ 579 /** Do power up/down of associated device(s) **/
607 580
608 /** SPDIF **/ 581 /** SPDIF **/
609#ifdef HAVE_SPDIF_IN 582#ifdef HAVE_SPDIF_IN
610 /* Always boost for SPDIF */ 583 /* Always boost for SPDIF */
611 if ((source == AUDIO_SRC_SPDIF) != (source == last_source)) 584 rec_boost(source == AUDIO_SRC_SPDIF);
612 rec_boost(source == AUDIO_SRC_SPDIF);
613#endif /* HAVE_SPDIF_IN */ 585#endif /* HAVE_SPDIF_IN */
614 586
615#ifdef HAVE_SPDIF_POWER 587#ifdef HAVE_SPDIF_POWER
@@ -639,87 +611,11 @@ void rec_set_source(int source, unsigned flags)
639 radio_start(); 611 radio_start();
640#endif 612#endif
641 613
642 switch (source) 614 /* set hardware inputs */
643 { 615 audio_set_source(source, flags);
644 default: /* playback - no recording */
645 source = AUDIO_SRC_PLAYBACK;
646 case AUDIO_SRC_PLAYBACK:
647 pm_playback = true;
648 if (source == last_source)
649 break;
650 ac_disable_recording();
651 ac_set_monitor(false);
652 pcm_rec_mux(0); /* line in */
653 break;
654
655 case AUDIO_SRC_MIC: /* recording only */
656 if (source == last_source)
657 break;
658 ac_enable_recording(true); /* source mic */
659 pcm_rec_mux(0); /* line in */
660 break;
661
662 case AUDIO_SRC_LINEIN: /* recording only */
663 if (source == last_source)
664 break;
665 pcm_rec_mux(0); /* line in */
666 ac_enable_recording(false); /* source line */
667 break;
668 616
669#ifdef HAVE_SPDIF_IN 617 peak_meter_playback((flags & SRCF_RECORDING) == 0);
670 case AUDIO_SRC_SPDIF: /* recording only */ 618 peak_meter_enabled = true;
671 if (source == last_source)
672 break;
673 ac_disable_recording();
674 break;
675#endif /* HAVE_SPDIF_IN */
676
677#ifdef HAVE_FMRADIO_IN
678 case AUDIO_SRC_FMRADIO: /* recording and playback */
679 if (!recording)
680 {
681 audio_set_recording_gain(sound_default(SOUND_LEFT_GAIN),
682 sound_default(SOUND_RIGHT_GAIN), AUDIO_GAIN_LINEIN);
683 pm_playback = true;
684 pm_enabled = false;
685 }
686
687 pcm_rec_mux(1); /* fm radio */
688
689#ifdef HAVE_UDA1380
690 if (source == last_source)
691 break;
692 /* I2S recording and playback */
693 uda1380_enable_recording(false); /* source line */
694 uda1380_set_monitor(true);
695#endif
696#ifdef HAVE_TLV320
697 /* I2S recording and analog playback */
698 if (source == last_source && recording == last_recording)
699 break;
700
701 last_recording = recording;
702
703 if (recording)
704 tlv320_enable_recording(false); /* source line */
705 else
706 {
707 tlv320_disable_recording();
708 tlv320_set_monitor(true); /* analog bypass */
709 }
710#endif
711 break;
712/* #elif defined(CONFIG_TUNER) */
713/* Have radio but cannot record it */
714/* case AUDIO_SRC_FMRADIO: */
715/* break; */
716#endif /* HAVE_FMRADIO_IN */
717 } /* end switch */
718
719 peak_meter_playback(pm_playback);
720 peak_meter_enabled = pm_enabled;
721
722 last_source = source;
723} /* rec_set_source */ 619} /* rec_set_source */
724#endif /* CONFIG_CODEC == SWCODEC && !defined(SIMULATOR) */ 620#endif /* CONFIG_CODEC == SWCODEC && !defined(SIMULATOR) */
725 621