diff options
-rw-r--r-- | apps/appevents.h | 6 | ||||
-rw-r--r-- | apps/audio_thread.c | 11 | ||||
-rw-r--r-- | apps/playback.c | 9 | ||||
-rw-r--r-- | apps/voice_thread.c | 4 | ||||
-rw-r--r-- | firmware/export/events.h | 1 |
5 files changed, 19 insertions, 12 deletions
diff --git a/apps/appevents.h b/apps/appevents.h index 8677dbd522..1efd8035e3 100644 --- a/apps/appevents.h +++ b/apps/appevents.h | |||
@@ -52,9 +52,13 @@ enum { | |||
52 | /* Next track medadata was just loaded | 52 | /* Next track medadata was just loaded |
53 | data = &(struct track_event){} */ | 53 | data = &(struct track_event){} */ |
54 | PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, | 54 | PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, |
55 | }; | ||
56 | |||
57 | /** VOICE events **/ | ||
58 | enum { | ||
55 | /* Voice is playing | 59 | /* Voice is playing |
56 | data = &(bool){true|false} */ | 60 | data = &(bool){true|false} */ |
57 | PLAYBACK_EVENT_VOICE_PLAYING, | 61 | VOICE_EVENT_IS_PLAYING = (EVENT_CLASS_VOICE|1), |
58 | }; | 62 | }; |
59 | 63 | ||
60 | /** Buffering events **/ | 64 | /** Buffering events **/ |
diff --git a/apps/audio_thread.c b/apps/audio_thread.c index 3af8b2bbf6..74f18454cc 100644 --- a/apps/audio_thread.c +++ b/apps/audio_thread.c | |||
@@ -27,6 +27,8 @@ | |||
27 | #include "usb.h" | 27 | #include "usb.h" |
28 | #include "pcm.h" | 28 | #include "pcm.h" |
29 | #include "sound.h" | 29 | #include "sound.h" |
30 | #include "pcmbuf.h" | ||
31 | #include "appevents.h" | ||
30 | #include "audio_thread.h" | 32 | #include "audio_thread.h" |
31 | #ifdef AUDIO_HAVE_RECORDING | 33 | #ifdef AUDIO_HAVE_RECORDING |
32 | #include "pcm_record.h" | 34 | #include "pcm_record.h" |
@@ -108,6 +110,13 @@ static void NORETURN_ATTR audio_thread(void) | |||
108 | } | 110 | } |
109 | } | 111 | } |
110 | 112 | ||
113 | void audio_voice_event(unsigned short id, void *data) | ||
114 | { | ||
115 | (void)id; | ||
116 | /* Make audio play softly while voice is speaking */ | ||
117 | pcmbuf_soft_mode(*(bool *)data); | ||
118 | } | ||
119 | |||
111 | void audio_queue_post(long id, intptr_t data) | 120 | void audio_queue_post(long id, intptr_t data) |
112 | { | 121 | { |
113 | queue_post(&audio_queue, id, data); | 122 | queue_post(&audio_queue, id, data); |
@@ -170,6 +179,8 @@ void INIT_ATTR audio_init(void) | |||
170 | recording_init(); | 179 | recording_init(); |
171 | #endif | 180 | #endif |
172 | 181 | ||
182 | add_event(VOICE_EVENT_IS_PLAYING, audio_voice_event); | ||
183 | |||
173 | /* Probably safe to say */ | 184 | /* Probably safe to say */ |
174 | audio_is_initialized = true; | 185 | audio_is_initialized = true; |
175 | 186 | ||
diff --git a/apps/playback.c b/apps/playback.c index dc88a37dc6..25aa1948d6 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -355,14 +355,6 @@ void audio_pcmbuf_sync_position(void); | |||
355 | 355 | ||
356 | /**************************************/ | 356 | /**************************************/ |
357 | 357 | ||
358 | /** --- voice event --- **/ | ||
359 | void playback_voice_event(unsigned short id, void *data) | ||
360 | { | ||
361 | (void)id; | ||
362 | /* Make audio play softly while voice is speaking */ | ||
363 | pcmbuf_soft_mode(*(bool *)data); | ||
364 | } | ||
365 | |||
366 | /** --- MP3Entry --- **/ | 358 | /** --- MP3Entry --- **/ |
367 | 359 | ||
368 | /* Does the mp3entry have enough info for us to use it? */ | 360 | /* Does the mp3entry have enough info for us to use it? */ |
@@ -3888,7 +3880,6 @@ void INIT_ATTR playback_init(void) | |||
3888 | track_list_init(); | 3880 | track_list_init(); |
3889 | buffering_init(); | 3881 | buffering_init(); |
3890 | pcmbuf_update_frequency(); | 3882 | pcmbuf_update_frequency(); |
3891 | add_event(PLAYBACK_EVENT_VOICE_PLAYING, playback_voice_event); | ||
3892 | #ifdef HAVE_CROSSFADE | 3883 | #ifdef HAVE_CROSSFADE |
3893 | /* Set crossfade setting for next buffer init which should be about... */ | 3884 | /* Set crossfade setting for next buffer init which should be about... */ |
3894 | pcmbuf_request_crossfade_enable(global_settings.crossfade); | 3885 | pcmbuf_request_crossfade_enable(global_settings.crossfade); |
diff --git a/apps/voice_thread.c b/apps/voice_thread.c index d8a7b27d14..59568d8ff9 100644 --- a/apps/voice_thread.c +++ b/apps/voice_thread.c | |||
@@ -372,7 +372,7 @@ static enum voice_state voice_message(struct voice_thread_data *td) | |||
372 | { | 372 | { |
373 | voice_playing = true; | 373 | voice_playing = true; |
374 | dsp_configure(td->dsp, DSP_SET_OUT_FREQUENCY, mixer_get_frequency()); | 374 | dsp_configure(td->dsp, DSP_SET_OUT_FREQUENCY, mixer_get_frequency()); |
375 | send_event(PLAYBACK_EVENT_VOICE_PLAYING, &voice_playing); | 375 | send_event(VOICE_EVENT_IS_PLAYING, &voice_playing); |
376 | } | 376 | } |
377 | 377 | ||
378 | quiet_counter = QUIET_COUNT; | 378 | quiet_counter = QUIET_COUNT; |
@@ -406,7 +406,7 @@ static enum voice_state voice_message(struct voice_thread_data *td) | |||
406 | if (quiet_counter <= 0) | 406 | if (quiet_counter <= 0) |
407 | { | 407 | { |
408 | voice_playing = false; | 408 | voice_playing = false; |
409 | send_event(PLAYBACK_EVENT_VOICE_PLAYING, &voice_playing); | 409 | send_event(VOICE_EVENT_IS_PLAYING, &voice_playing); |
410 | } | 410 | } |
411 | break; | 411 | break; |
412 | } | 412 | } |
diff --git a/firmware/export/events.h b/firmware/export/events.h index fd7f9df42e..4591058d4f 100644 --- a/firmware/export/events.h +++ b/firmware/export/events.h | |||
@@ -51,6 +51,7 @@ | |||
51 | #define EVENT_CLASS_GUI 0x0800 | 51 | #define EVENT_CLASS_GUI 0x0800 |
52 | #define EVENT_CLASS_RECORDING 0x1000 | 52 | #define EVENT_CLASS_RECORDING 0x1000 |
53 | #define EVENT_CLASS_LCD 0x2000 | 53 | #define EVENT_CLASS_LCD 0x2000 |
54 | #define EVENT_CLASS_VOICE 0x4000 | ||
54 | 55 | ||
55 | /** | 56 | /** |
56 | * Subscribe to an event with a simple callback. The callback will be called | 57 | * Subscribe to an event with a simple callback. The callback will be called |