Lagrange [work/v1.10]

Android: Audio output details

=> b5186f399923fad2739fe46eb7058267fc219b98

diff --git a/res/about/android-version.gmi b/res/about/android-version.gmi
index 8ddfc10d..6d7c0321 100644
--- a/res/about/android-version.gmi
+++ b/res/about/android-version.gmi
@@ -7,7 +7,7 @@
 # Release notes
 
 ## 1.13 (Beta 6)
-* Enabled audio output. WAV and Ogg Vorbis decoding is supported in this build.
+* Enabled audio output. WAV and Ogg Vorbis decoding is supported in this build. NOTE: At the moment, playback is not supported when app is in the background, or when the screen is locked. Also, playback may not start if there is already an active player on the page.
 * Fixed showing error page for an empty server response.
 * Fixes for Spartan: query strings, input prompt default content, empty paths.
 * Added Spartan URL handler.
diff --git a/src/audio/player.c b/src/audio/player.c
index de430b17..67ca9521 100644
--- a/src/audio/player.c
+++ b/src/audio/player.c
@@ -21,6 +21,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
 
 #include "player.h"
+#include "defs.h"
 #include "buf.h"
 #include "lang.h"
 
@@ -620,7 +621,7 @@ static iContentSpec contentSpec_Player_(const iPlayer *d) {
     iAssert(content.inputFormat == content.output.format ||
             (content.inputFormat == AUDIO_S24LSB && content.output.format == AUDIO_S16) ||
             (content.inputFormat == AUDIO_F64LSB && content.output.format == AUDIO_F32));
-    content.output.samples = 8192;
+    content.output.samples = isAndroid_Platform() ? content.output.freq / 2 : 8192;
     return content;
 }
 
@@ -742,14 +743,14 @@ size_t sourceDataSize_Player(const iPlayer *d) {
 
 static iBool setupSDLAudio_(iBool init) {
     static iBool isAudioInited_ = iFalse;
-    if (init) {
+    if (init && !isAudioInited_) {
         if (SDL_InitSubSystem(SDL_INIT_AUDIO)) {
             fprintf(stderr, "[SDL] audio init failed: %s\n", SDL_GetError());
             return iFalse;
         }
         isAudioInited_ = iTrue;
     }
-    else if (isAudioInited_) {
+    else if (!init && isAudioInited_ && !isAndroid_Platform()) {
         SDL_QuitSubSystem(SDL_INIT_AUDIO);
         isAudioInited_ = iFalse;
     }
diff --git a/src/defs.h b/src/defs.h
index 2d1ef68c..6174f6d3 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -48,6 +48,14 @@ iLocalDef iBool isAppleDesktop_Platform(void) {
 #endif
 }
 
+iLocalDef iBool isAndroid_Platform(void) {
+#if defined (iPlatformAndroid)
+    return iTrue;
+#else
+    return iFalse;
+#endif
+}
+
 iLocalDef iBool isMobile_Platform(void) {
 #if defined (iPlatformMobile) /* defined on iOS and Android */
     return iTrue;
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.10/cdiff/b5186f399923fad2739fe46eb7058267fc219b98
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
55.91834 milliseconds
Gemini-to-HTML Time
0.213367 milliseconds

This content has been proxied by September (ba2dc).