summaryrefslogtreecommitdiff
path: root/apps/recorder/recording.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-06-08 23:42:04 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-06-08 23:42:04 +0000
commit2d48d0ffa6baddd19e6ff077f25068f90af7be3d (patch)
tree68c80646a748496fee423d77aa43afafb783b269 /apps/recorder/recording.c
parenta85793fc54a0079f5483d5a5c6c60b7d17ca688c (diff)
downloadrockbox-2d48d0ffa6baddd19e6ff077f25068f90af7be3d.tar.gz
rockbox-2d48d0ffa6baddd19e6ff077f25068f90af7be3d.zip
Straighten out some audio path APIs and misc. audio stuff. Having recording is not a prerequisite to having input/output source selection which is probably most useful when adding a audio input features like FM to a new port without forcing recording to be implemented first.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13599 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/recording.c')
-rw-r--r--apps/recorder/recording.c107
1 files changed, 15 insertions, 92 deletions
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 5738a34949..226ff9a17f 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -547,80 +547,6 @@ int rec_create_directory(void)
547 return 0; 547 return 0;
548} 548}
549 549
550#if CONFIG_CODEC == SWCODEC && !defined(SIMULATOR)
551
552# ifdef HAVE_SPDIF_REC
553# ifdef HAVE_ADJUSTABLE_CPU_FREQ
554static void rec_boost(bool state)
555{
556 static bool cpu_boosted = false;
557
558 if (state != cpu_boosted)
559 {
560 cpu_boost(state);
561 cpu_boosted = state;
562 }
563}
564# endif
565# endif
566
567/**
568 * Selects an audio source for recording or playback
569 * powers/unpowers related devices and sets up monitoring.
570 * Here because it calls app code and used only for HAVE_RECORDING atm.
571 * Would like it in pcm_record.c.
572 *
573 * Behaves like a firmware function in that it does not use global settings
574 * to determine the state.
575 *
576 * The order of setting monitoring may need tweaking dependent upon the
577 * selected source to get the smoothest transition.
578 */
579void rec_set_source(int source, unsigned flags)
580{
581 /** Do power up/down of associated device(s) **/
582
583 /** SPDIF **/
584#ifdef HAVE_SPDIF_REC
585 /* Always boost for SPDIF */
586 rec_boost(source == AUDIO_SRC_SPDIF);
587#endif /* HAVE_SPDIF_IN */
588
589#ifdef HAVE_SPDIF_POWER
590 /* Check if S/PDIF output power should be switched off or on. NOTE: assumes
591 both optical in and out is controlled by the same power source, which is
592 the case on H1x0. */
593 spdif_power_enable((source == AUDIO_SRC_SPDIF) ||
594 global_settings.spdif_enable);
595 /* Set the appropriate feed for spdif output */
596#ifdef HAVE_SPDIF_OUT
597 spdif_set_output_source(source, global_settings.spdif_enable);
598#endif
599#else /* !HAVE_SPDIF_POWER */
600#ifdef HAVE_SPDIF_OUT
601 spdif_set_output_source(source, true);
602#endif
603#endif /* !HAVE_SPDIF_POWER */
604
605 /** Tuner **/
606#if CONFIG_TUNER
607 /* Switch radio off or on per source and flags. */
608 if (source != AUDIO_SRC_FMRADIO)
609 radio_stop();
610 else if (flags & SRCF_FMRADIO_PAUSED)
611 radio_pause();
612 else
613 radio_start();
614#endif
615
616 /* set hardware inputs */
617 audio_set_source(source, flags);
618
619 peak_meter_playback((flags & SRCF_RECORDING) == 0);
620 peak_meter_enabled = true;
621} /* rec_set_source */
622#endif /* CONFIG_CODEC == SWCODEC && !defined(SIMULATOR) */
623
624void rec_init_recording_options(struct audio_recording_options *options) 550void rec_init_recording_options(struct audio_recording_options *options)
625{ 551{
626 options->rec_source = global_settings.rec_source; 552 options->rec_source = global_settings.rec_source;
@@ -637,6 +563,18 @@ void rec_init_recording_options(struct audio_recording_options *options)
637#endif 563#endif
638} 564}
639 565
566#if CONFIG_CODEC == SWCODEC && !defined (SIMULATOR)
567void rec_set_source(int source, unsigned flags)
568{
569 /* Set audio input source, power up/down devices */
570 audio_set_input_source(source, flags);
571
572 /* Set peakmeters for recording or reset to playback */
573 peak_meter_playback((flags & SRCF_RECORDING) == 0);
574 peak_meter_enabled = true;
575}
576#endif /* CONFIG_CODEC == SWCODEC && !defined (SIMULATOR) */
577
640void rec_set_recording_options(struct audio_recording_options *options) 578void rec_set_recording_options(struct audio_recording_options *options)
641{ 579{
642#if CONFIG_CODEC != SWCODEC 580#if CONFIG_CODEC != SWCODEC
@@ -2062,20 +2000,6 @@ void rec_set_source(int source, unsigned flags)
2062 flags = flags; 2000 flags = flags;
2063} 2001}
2064 2002
2065#ifdef HAVE_SPDIF_IN
2066#ifdef HAVE_SPDIF_POWER
2067void audio_set_spdif_power_setting(bool on)
2068{
2069 on = on;
2070}
2071
2072bool audio_get_spdif_power_setting(void)
2073{
2074 return true;
2075}
2076#endif /* HAVE_SPDIF_POWER */
2077#endif /* HAVE_SPDIF_IN */
2078
2079void audio_set_recording_options(struct audio_recording_options *options) 2003void audio_set_recording_options(struct audio_recording_options *options)
2080{ 2004{
2081 options = options; 2005 options = options;
@@ -2088,13 +2012,12 @@ void audio_set_recording_gain(int left, int right, int type)
2088 type = type; 2012 type = type;
2089} 2013}
2090 2014
2091void audio_set_output_source(int source) 2015void audio_record(const char *filename)
2092{ 2016{
2093 source = source; 2017 filename = filename;
2094} 2018}
2095 2019
2096 2020void audio_new_file(const char *filename)
2097void audio_record(const char *filename)
2098{ 2021{
2099 filename = filename; 2022 filename = filename;
2100} 2023}