forked from len0rd/rockbox
Only set volume on SYS_VOLUME_CHANGED the first time. Workaround for FS#12034.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29663 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
277b8fba71
commit
ce755dd9c5
2 changed files with 23 additions and 4 deletions
|
@ -85,9 +85,19 @@ public class RockboxPCM extends AudioTrack
|
||||||
pcmrange = getMaxVolume() - minpcmvolume;
|
pcmrange = getMaxVolume() - minpcmvolume;
|
||||||
|
|
||||||
setupVolumeHandler();
|
setupVolumeHandler();
|
||||||
|
postVolume(audiomanager.getStreamVolume(streamtype));
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void postVolumeChangedEvent(int volume);
|
private native void postVolumeChangedEvent(int volume);
|
||||||
|
|
||||||
|
private void postVolume(int volume)
|
||||||
|
{
|
||||||
|
int rbvolume = ((maxstreamvolume - volume) * -99) /
|
||||||
|
maxstreamvolume;
|
||||||
|
LOG("java:postVolumeChangedEvent, avol "+volume+" rbvol "+rbvolume);
|
||||||
|
postVolumeChangedEvent(rbvolume);
|
||||||
|
}
|
||||||
|
|
||||||
private void setupVolumeHandler()
|
private void setupVolumeHandler()
|
||||||
{
|
{
|
||||||
BroadcastReceiver broadcastReceiver = new BroadcastReceiver()
|
BroadcastReceiver broadcastReceiver = new BroadcastReceiver()
|
||||||
|
@ -105,9 +115,7 @@ public class RockboxPCM extends AudioTrack
|
||||||
volume != setstreamvolume &&
|
volume != setstreamvolume &&
|
||||||
rbservice.isRockboxRunning())
|
rbservice.isRockboxRunning())
|
||||||
{
|
{
|
||||||
int rbvolume = ((maxstreamvolume - volume) * -99) /
|
postVolume(volume);
|
||||||
maxstreamvolume;
|
|
||||||
postVolumeChangedEvent(rbvolume);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -190,6 +198,7 @@ public class RockboxPCM extends AudioTrack
|
||||||
|
|
||||||
private void set_volume(int volume)
|
private void set_volume(int volume)
|
||||||
{
|
{
|
||||||
|
LOG("java:set_volume("+volume+")");
|
||||||
/* Rockbox 'volume' is 0..-990 deci-dB attenuation.
|
/* Rockbox 'volume' is 0..-990 deci-dB attenuation.
|
||||||
Android streams have rather low resolution volume control,
|
Android streams have rather low resolution volume control,
|
||||||
typically 8 or 15 steps.
|
typically 8 or 15 steps.
|
||||||
|
@ -209,6 +218,7 @@ public class RockboxPCM extends AudioTrack
|
||||||
|
|
||||||
int oldstreamvolume = audiomanager.getStreamVolume(streamtype);
|
int oldstreamvolume = audiomanager.getStreamVolume(streamtype);
|
||||||
if (streamvolume != oldstreamvolume) {
|
if (streamvolume != oldstreamvolume) {
|
||||||
|
LOG("java:setStreamVolume("+streamvolume+")");
|
||||||
setstreamvolume = streamvolume;
|
setstreamvolume = streamvolume;
|
||||||
audiomanager.setStreamVolume(streamtype, streamvolume, 0);
|
audiomanager.setStreamVolume(streamtype, streamvolume, 0);
|
||||||
}
|
}
|
||||||
|
|
11
apps/misc.c
11
apps/misc.c
|
@ -58,6 +58,8 @@
|
||||||
#include "yesno.h"
|
#include "yesno.h"
|
||||||
#include "viewport.h"
|
#include "viewport.h"
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
#if CONFIG_TUNER
|
#if CONFIG_TUNER
|
||||||
#include "radio.h"
|
#include "radio.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -632,9 +634,16 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame
|
||||||
#if (CONFIG_PLATFORM & PLATFORM_HOSTED) && defined(PLATFORM_HAS_VOLUME_CHANGE)
|
#if (CONFIG_PLATFORM & PLATFORM_HOSTED) && defined(PLATFORM_HAS_VOLUME_CHANGE)
|
||||||
case SYS_VOLUME_CHANGED:
|
case SYS_VOLUME_CHANGED:
|
||||||
{
|
{
|
||||||
|
static bool firstvolume = true;
|
||||||
int volume = hosted_get_volume();
|
int volume = hosted_get_volume();
|
||||||
if (global_settings.volume != volume)
|
DEBUGF("SYS_VOLUME_CHANGED: %d\n", volume);
|
||||||
|
if (global_settings.volume != volume) {
|
||||||
global_settings.volume = volume;
|
global_settings.volume = volume;
|
||||||
|
if (firstvolume) {
|
||||||
|
setvol();
|
||||||
|
firstvolume = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue