Option to sleep in audio thread, to prevent audio chopping, by ZX81
This commit is contained in:
@@ -275,6 +275,16 @@ if [ -n "$var" ] ; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$CompatibilityHacksPreventAudioChopping" -o -z "$AUTO" ]; then
|
||||
echo
|
||||
echo -n "Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n) ($CompatibilityHacksPreventAudioChopping): "
|
||||
read var
|
||||
if [ -n "$var" ] ; then
|
||||
CompatibilityHacksPreventAudioChopping="$var"
|
||||
CHANGED=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$AppUsesJoystick" -o -z "$AUTO" ]; then
|
||||
echo
|
||||
echo "Application uses joystick (y) or (n), the on-screen DPAD will be used"
|
||||
@@ -626,6 +636,7 @@ echo SdlVideoResizeKeepAspect=$SdlVideoResizeKeepAspect >> AndroidAppSettings.cf
|
||||
echo CompatibilityHacks=$CompatibilityHacks >> AndroidAppSettings.cfg
|
||||
echo CompatibilityHacksStaticInit=$CompatibilityHacksStaticInit >> AndroidAppSettings.cfg
|
||||
echo CompatibilityHacksTextInputEmulatesHwKeyboard=$CompatibilityHacksTextInputEmulatesHwKeyboard >> AndroidAppSettings.cfg
|
||||
echo CompatibilityHacksPreventAudioChopping=$CompatibilityHacksPreventAudioChopping >> AndroidAppSettings.cfg
|
||||
echo AppUsesMouse=$AppUsesMouse >> AndroidAppSettings.cfg
|
||||
echo AppNeedsTwoButtonMouse=$AppNeedsTwoButtonMouse >> AndroidAppSettings.cfg
|
||||
echo ShowMouseCursor=$ShowMouseCursor >> AndroidAppSettings.cfg
|
||||
@@ -740,6 +751,12 @@ else
|
||||
CompatibilityHacksTextInputEmulatesHwKeyboard=false
|
||||
fi
|
||||
|
||||
if [ "$CompatibilityHacksPreventAudioChopping" = "y" ] ; then
|
||||
CompatibilityHacksPreventAudioChopping=-DSDL_AUDIO_PREVENT_CHOPPING_WITH_DELAY=1
|
||||
else
|
||||
CompatibilityHacksPreventAudioChopping=
|
||||
fi
|
||||
|
||||
if [ "$AppUsesMouse" = "y" ] ; then
|
||||
AppUsesMouse=true
|
||||
else
|
||||
@@ -950,7 +967,7 @@ cat project/jni/SettingsTemplate.mk | \
|
||||
sed "s^COMPILED_LIBRARIES := .*^COMPILED_LIBRARIES := $CompiledLibraries^" | \
|
||||
sed "s^APPLICATION_ADDITIONAL_CFLAGS :=.*^APPLICATION_ADDITIONAL_CFLAGS := $AppCflags^" | \
|
||||
sed "s^APPLICATION_ADDITIONAL_LDFLAGS :=.*^APPLICATION_ADDITIONAL_LDFLAGS := $AppLdflags^" | \
|
||||
sed "s^SDL_ADDITIONAL_CFLAGS :=.*^SDL_ADDITIONAL_CFLAGS := $RedefinedKeycodes $RedefinedKeycodesScreenKb^" | \
|
||||
sed "s^SDL_ADDITIONAL_CFLAGS :=.*^SDL_ADDITIONAL_CFLAGS := $RedefinedKeycodes $RedefinedKeycodesScreenKb $CompatibilityHacksPreventAudioChopping^" | \
|
||||
sed "s^APPLICATION_SUBDIRS_BUILD :=.*^APPLICATION_SUBDIRS_BUILD := $AppSubdirsBuild^" | \
|
||||
sed "s^APPLICATION_CUSTOM_BUILD_SCRIPT :=.*^APPLICATION_CUSTOM_BUILD_SCRIPT := $CustomBuildScript^" | \
|
||||
sed "s^SDL_VERSION :=.*^SDL_VERSION := $LibSdlVersion^" >> \
|
||||
|
||||
@@ -719,6 +719,7 @@ class Settings
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
String [] downloadFiles = Globals.DataDownloadUrl.split("\\^");
|
||||
boolean [] mandatory = new boolean[downloadFiles.length];
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.downloads));
|
||||
@@ -729,6 +730,11 @@ class Settings
|
||||
items[i] = new String(downloadFiles[i].split("[|]")[0]);
|
||||
if( items[i].toString().indexOf("!") == 0 )
|
||||
items[i] = items[i].toString().substring(1);
|
||||
if( items[i].toString().indexOf("!") == 0 )
|
||||
{
|
||||
items[i] = items[i].toString().substring(1);
|
||||
mandatory[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( Globals.OptionalDataDownload == null || Globals.OptionalDataDownload.length != items.length )
|
||||
@@ -744,7 +750,10 @@ class Settings
|
||||
}
|
||||
}
|
||||
if( oldFormat )
|
||||
{
|
||||
Globals.OptionalDataDownload[0] = true;
|
||||
mandatory[0] = true;
|
||||
}
|
||||
}
|
||||
|
||||
builder.setMultiChoiceItems(items, Globals.OptionalDataDownload, new DialogInterface.OnMultiChoiceClickListener()
|
||||
@@ -752,6 +761,10 @@ class Settings
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
||||
{
|
||||
Globals.OptionalDataDownload[item] = isChecked;
|
||||
if( mandatory[item] && !isChecked )
|
||||
{
|
||||
((AlertDialog)dialog).getListView().setItemChecked(item, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
|
||||
Submodule project/jni/application/openarena/engine updated: 687cdf8ab7...c98bcf9eea
Submodule project/jni/application/openarena/vm updated: dc740d594f...8ffdaa479d
@@ -130,6 +130,7 @@ AudioBootStrap ANDROIDAUD_bootstrap = {
|
||||
|
||||
static unsigned char * audioBuffer = NULL;
|
||||
static size_t audioBufferSize = 0;
|
||||
static Uint32 audioLastTick = 0;
|
||||
|
||||
// Extremely wicked JNI environment to call Java functions from C code
|
||||
static jbyteArray audioBufferJNI = NULL;
|
||||
@@ -243,6 +244,20 @@ static void ANDROIDAUD_CloseAudio(_THIS)
|
||||
static void ANDROIDAUD_WaitAudio(_THIS)
|
||||
{
|
||||
/* We will block in PlayAudio(), do nothing here */
|
||||
#ifdef SDL_AUDIO_PREVENT_CHOPPING_WITH_DELAY
|
||||
//ZX:
|
||||
if (audioLastTick == 0) {
|
||||
audioLastTick = SDL_GetTicks();
|
||||
} else {
|
||||
unsigned int audioNewTick = SDL_GetTicks();
|
||||
unsigned int delay_in_ms = (this->spec.samples*1000)/this->spec.freq;
|
||||
int deltaTick = audioNewTick - audioLastTick;
|
||||
if (delay_in_ms > deltaTick) {
|
||||
SDL_Delay( delay_in_ms - deltaTick );
|
||||
}
|
||||
audioLastTick = audioNewTick;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static JNIEnv * jniEnvPlaying = NULL;
|
||||
|
||||
Reference in New Issue
Block a user