Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flood records in console window: [server] WARN: Colud not get any audio timestamp #3812

Open
mihmig opened this issue Mar 14, 2023 · 4 comments

Comments

@mihmig
Copy link

mihmig commented Mar 14, 2023

Environment

  • OS: Windows 10 x64
  • scrcpy version: 2.0
  • installation method: Windows release.
  • device model: Motorola G9 Play
  • Android version: 11

Flood records in console window (several lines per second(!)):
[server] WARN: Colud not get any audio timestamp

@rom1v
Copy link
Collaborator

rom1v commented Mar 14, 2023

Thank you for your report.

Ln.w("Could not get any audio timestamp");

So this means that audioRecord.read() always returns 0, which is unexpected.

According to the documentation, this happens when the buffer is not a direct buffer, which is also unexpected (it's a buffer from MediaCodec).

Could you please paste the output of scrcpy -Vdebug (with just the beginning and the firsts warnings, not the thousand ones 😉)?

rom1v added a commit that referenced this issue Mar 14, 2023
If read() returns 0, then there is no data. According to the
documentation, it happens if the buffer is not a direct buffer:
<https://developer.android.com/reference/android/media/AudioRecord#read(java.nio.ByteBuffer,%20int)>

Refs #3812 <#3812>
@rom1v
Copy link
Collaborator

rom1v commented Mar 14, 2023

I can reproduce on my Android 11 device by disabling some workarounds:

diff --git a/server/src/main/java/com/genymobile/scrcpy/Server.java b/server/src/main/java/com/genymobile/scrcpy/Server.java
index 5800487da..3e5985ac8 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Server.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Server.java
@@ -83,11 +83,6 @@ public final class Server {
         //  - <https://github.com/Genymobile/scrcpy/issues/994>
         boolean mustFillAppInfo = Build.BRAND.equalsIgnoreCase("meizu");
 
-        // Before Android 11, audio is not supported.
-        // Since Android 12, we can properly set a context on the AudioRecord.
-        // Only on Android 11 we must fill app info for the AudioRecord to work.
-        mustFillAppInfo |= audio && Build.VERSION.SDK_INT == Build.VERSION_CODES.R;
-
         if (mustFillAppInfo) {
             Workarounds.fillAppInfo();
         }

On dev branch, commit 337d6c2 avoids to flood the console, but does not fix the audio problem.

@mihmig
Copy link
Author

mihmig commented Mar 16, 2023

Here are the required log entries:
scrcpy_debug_log.txt

@rom1v
Copy link
Collaborator

rom1v commented Mar 16, 2023

Oh, these logs show a different issue, it's not "Could not get any audio timestamp" but "Buffering threshold exceeded".

See #3793.

In particular, replace this binary: #3793 (comment)
And run scrcpy --audio-output-buffer=10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants