diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/export/config/android.h | 3 | ||||
-rw-r--r-- | firmware/export/kernel.h | 1 | ||||
-rw-r--r-- | firmware/export/system.h | 4 | ||||
-rw-r--r-- | firmware/target/hosted/android/pcm-android.c | 25 |
4 files changed, 33 insertions, 0 deletions
diff --git a/firmware/export/config/android.h b/firmware/export/config/android.h index ed1a283c7d..69a758d69b 100644 --- a/firmware/export/config/android.h +++ b/firmware/export/config/android.h @@ -79,6 +79,9 @@ /* define this if the target has volume keys which can be used in the lists */ #define HAVE_VOLUME_IN_LIST +/* define this if the host platform can change volume outside of rockbox */ +#define PLATFORM_HAS_VOLUME_CHANGE + #define HAVE_SW_TONE_CONTROLS /* Define current usage levels. */ diff --git a/firmware/export/kernel.h b/firmware/export/kernel.h index 6aaf11ddb9..66efce33f6 100644 --- a/firmware/export/kernel.h +++ b/firmware/export/kernel.h @@ -83,6 +83,7 @@ #define SYS_IAP_HANDLEPKT MAKE_SYS_EVENT(SYS_EVENT_CLS_MISC, 2) #define SYS_CALL_INCOMING MAKE_SYS_EVENT(SYS_EVENT_CLS_MISC, 3) #define SYS_CALL_HUNG_UP MAKE_SYS_EVENT(SYS_EVENT_CLS_MISC, 4) +#define SYS_VOLUME_CHANGED MAKE_SYS_EVENT(SYS_EVENT_CLS_MISC, 5) #define IS_SYSEVENT(ev) ((ev & SYS_EVENT) == SYS_EVENT) diff --git a/firmware/export/system.h b/firmware/export/system.h index 78bddae387..3f626c3688 100644 --- a/firmware/export/system.h +++ b/firmware/export/system.h @@ -137,6 +137,10 @@ int get_cpu_boost_counter(void); #undef htobe32 #endif +#if (CONFIG_PLATFORM & PLATFORM_HOSTED) && defined(PLATFORM_HAS_VOLUME_CHANGE) +int hosted_get_volume(void); +#endif + /* Get the byte offset of a type's member */ #define OFFSETOF(type, membername) ((off_t)&((type *)0)->membername) diff --git a/firmware/target/hosted/android/pcm-android.c b/firmware/target/hosted/android/pcm-android.c index 4c34e3cd91..24881bd3df 100644 --- a/firmware/target/hosted/android/pcm-android.c +++ b/firmware/target/hosted/android/pcm-android.c @@ -179,3 +179,28 @@ void pcm_set_mixer_volume(int volume) (*env_ptr)->CallVoidMethod(env_ptr, RockboxPCM_instance, set_volume_method, volume); } + +/* Due to limitations of default_event_handler(), parameters gets swallowed when + * being posted with queue_broadcast(), so workaround this by caching the last + * value. + */ +static int lastPostedVolume = -1; +int hosted_get_volume(void) +{ + return lastPostedVolume; +} + +JNIEXPORT void JNICALL +Java_org_rockbox_RockboxPCM_postVolumeChangedEvent(JNIEnv *env, + jobject this, + jint volume) +{ + (void) env; + (void) this; + + if (volume != lastPostedVolume) + { + lastPostedVolume = volume; + queue_broadcast(SYS_VOLUME_CHANGED, 0); + } +} |