diff options
Diffstat (limited to 'firmware/target/arm/as3525/audio-as3525.c')
-rw-r--r-- | firmware/target/arm/as3525/audio-as3525.c | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/firmware/target/arm/as3525/audio-as3525.c b/firmware/target/arm/as3525/audio-as3525.c index 410fdfad79..b616153eae 100644 --- a/firmware/target/arm/as3525/audio-as3525.c +++ b/firmware/target/arm/as3525/audio-as3525.c | |||
@@ -25,44 +25,71 @@ | |||
25 | #include "audiohw.h" | 25 | #include "audiohw.h" |
26 | #include "sound.h" | 26 | #include "sound.h" |
27 | 27 | ||
28 | int audio_channels = 2; | ||
29 | int audio_output_source = AUDIO_SRC_PLAYBACK; | ||
30 | |||
31 | void audio_set_output_source(int source) | 28 | void audio_set_output_source(int source) |
32 | { | 29 | { |
33 | if ((unsigned)source >= AUDIO_NUM_SOURCES) | 30 | (void)source; |
34 | source = AUDIO_SRC_PLAYBACK; | 31 | } |
35 | |||
36 | audio_output_source = source; | ||
37 | } /* audio_set_output_source */ | ||
38 | 32 | ||
39 | void audio_input_mux(int source, unsigned flags) | 33 | void audio_input_mux(int source, unsigned flags) |
40 | { | 34 | { |
41 | static int last_source = AUDIO_SRC_PLAYBACK; | 35 | static int last_source = AUDIO_SRC_PLAYBACK; |
42 | 36 | #ifdef HAVE_RECORDING | |
43 | (void)flags; | 37 | static bool last_recording = false; |
38 | const bool recording = flags & SRCF_RECORDING; | ||
39 | #else | ||
40 | (void) flags; | ||
41 | #endif | ||
44 | 42 | ||
45 | switch (source) | 43 | switch (source) |
46 | { | 44 | { |
47 | default: /* playback - no recording */ | 45 | default: /* playback - no recording */ |
48 | source = AUDIO_SRC_PLAYBACK; | 46 | source = AUDIO_SRC_PLAYBACK; |
49 | case AUDIO_SRC_PLAYBACK: | 47 | case AUDIO_SRC_PLAYBACK: |
50 | audio_channels = 2; | ||
51 | if (source != last_source) | 48 | if (source != last_source) |
52 | { | 49 | { |
53 | audiohw_set_monitor(false); | 50 | audiohw_set_monitor(false); |
51 | #ifdef HAVE_RECORDING | ||
52 | audiohw_disable_recording(); | ||
53 | #endif | ||
54 | } | ||
55 | break; | ||
56 | |||
57 | #ifdef HAVE_RECORDING | ||
58 | case AUDIO_SRC_MIC: /* recording only */ | ||
59 | if (source != last_source) | ||
60 | { | ||
61 | audiohw_set_monitor(false); | ||
62 | audiohw_enable_recording(true); /* source mic */ | ||
54 | } | 63 | } |
55 | break; | 64 | break; |
65 | #endif | ||
56 | 66 | ||
57 | case AUDIO_SRC_FMRADIO: /* recording and playback */ | 67 | case AUDIO_SRC_FMRADIO: /* recording and playback */ |
58 | audio_channels = 2; | 68 | if (source == last_source |
59 | if (source == last_source) | 69 | #ifdef HAVE_RECORDING |
70 | && recording == last_recording | ||
71 | #endif | ||
72 | ) | ||
60 | break; | 73 | break; |
61 | 74 | ||
62 | audiohw_set_monitor(true); | 75 | #ifdef HAVE_RECORDING |
76 | last_recording = recording; | ||
77 | |||
78 | if (recording) | ||
79 | { | ||
80 | audiohw_set_monitor(false); | ||
81 | audiohw_enable_recording(false); | ||
82 | } | ||
83 | else | ||
84 | #endif | ||
85 | { | ||
86 | #ifdef HAVE_RECORDING | ||
87 | audiohw_disable_recording(); | ||
88 | #endif | ||
89 | audiohw_set_monitor(true); /* line 2 analog audio path */ | ||
90 | } | ||
63 | break; | 91 | break; |
64 | } /* end switch */ | 92 | } |
65 | 93 | ||
66 | last_source = source; | 94 | last_source = source; |
67 | } /* audio_input_mux */ | 95 | } |
68 | |||