summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2017-12-12 20:14:34 -0500
committerMichael Sevakis <jethead71@rockbox.org>2017-12-12 20:28:56 -0500
commitc8564f1ca8287eba9220df191d13c949bb49c8ce (patch)
tree7428918a9a6660dd53eefc7bf2be047e9eddccf0
parent838ff9c67d4ade0e0e0ee7132eb933a7c861d384 (diff)
downloadrockbox-c8564f1.tar.gz
rockbox-c8564f1.zip
Get voice event out of playback.c
Purpose: A step in removing all voice references from playback code and prelude to other changes. Change-Id: Ic3ad7f7a33b979693e18a3456ced37eb1d2281a4
-rw-r--r--apps/appevents.h6
-rw-r--r--apps/audio_thread.c11
-rw-r--r--apps/playback.c9
-rw-r--r--apps/voice_thread.c4
-rw-r--r--firmware/export/events.h1
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 {
/* Next track medadata was just loaded
data = &(struct track_event){} */
PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE,
+};
+
+/** VOICE events **/
+enum {
/* Voice is playing
data = &(bool){true|false} */
- PLAYBACK_EVENT_VOICE_PLAYING,
+ VOICE_EVENT_IS_PLAYING = (EVENT_CLASS_VOICE|1),
};
/** 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 @@
#include "usb.h"
#include "pcm.h"
#include "sound.h"
+#include "pcmbuf.h"
+#include "appevents.h"
#include "audio_thread.h"
#ifdef AUDIO_HAVE_RECORDING
#include "pcm_record.h"
@@ -108,6 +110,13 @@ static void NORETURN_ATTR audio_thread(void)
}
}
+void audio_voice_event(unsigned short id, void *data)
+{
+ (void)id;
+ /* Make audio play softly while voice is speaking */
+ pcmbuf_soft_mode(*(bool *)data);
+}
+
void audio_queue_post(long id, intptr_t data)
{
queue_post(&audio_queue, id, data);
@@ -170,6 +179,8 @@ void INIT_ATTR audio_init(void)
recording_init();
#endif
+ add_event(VOICE_EVENT_IS_PLAYING, audio_voice_event);
+
/* Probably safe to say */
audio_is_initialized = true;
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);
/**************************************/
-/** --- voice event --- **/
-void playback_voice_event(unsigned short id, void *data)
-{
- (void)id;
- /* Make audio play softly while voice is speaking */
- pcmbuf_soft_mode(*(bool *)data);
-}
-
/** --- MP3Entry --- **/
/* Does the mp3entry have enough info for us to use it? */
@@ -3888,7 +3880,6 @@ void INIT_ATTR playback_init(void)
track_list_init();
buffering_init();
pcmbuf_update_frequency();
- add_event(PLAYBACK_EVENT_VOICE_PLAYING, playback_voice_event);
#ifdef HAVE_CROSSFADE
/* Set crossfade setting for next buffer init which should be about... */
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)
{
voice_playing = true;
dsp_configure(td->dsp, DSP_SET_OUT_FREQUENCY, mixer_get_frequency());
- send_event(PLAYBACK_EVENT_VOICE_PLAYING, &voice_playing);
+ send_event(VOICE_EVENT_IS_PLAYING, &voice_playing);
}
quiet_counter = QUIET_COUNT;
@@ -406,7 +406,7 @@ static enum voice_state voice_message(struct voice_thread_data *td)
if (quiet_counter <= 0)
{
voice_playing = false;
- send_event(PLAYBACK_EVENT_VOICE_PLAYING, &voice_playing);
+ send_event(VOICE_EVENT_IS_PLAYING, &voice_playing);
}
break;
}
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 @@
#define EVENT_CLASS_GUI 0x0800
#define EVENT_CLASS_RECORDING 0x1000
#define EVENT_CLASS_LCD 0x2000
+#define EVENT_CLASS_VOICE 0x4000
/**
* Subscribe to an event with a simple callback. The callback will be called