forked from Genymobile/scrcpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move hardcoded audio configuration to AudioConfig
This will allow to use these constants from different classes not directly related to AudioCapture. PR Genymobile#5102 <Genymobile#5102>
- Loading branch information
1 parent
474e0f8
commit 0f7d3db
Showing
4 changed files
with
32 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
server/src/main/java/com/genymobile/scrcpy/audio/AudioConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.genymobile.scrcpy.audio; | ||
|
||
import android.media.AudioFormat; | ||
|
||
public final class AudioConfig { | ||
public static final int SAMPLE_RATE = 48000; | ||
public static final int CHANNEL_CONFIG = AudioFormat.CHANNEL_IN_STEREO; | ||
public static final int CHANNELS = 2; | ||
public static final int CHANNEL_MASK = AudioFormat.CHANNEL_IN_LEFT | AudioFormat.CHANNEL_IN_RIGHT; | ||
public static final int ENCODING = AudioFormat.ENCODING_PCM_16BIT; | ||
public static final int BYTES_PER_SAMPLE = 2; | ||
|
||
// Never read more than 1024 samples, even if the buffer is bigger (that would increase latency). | ||
// A lower value is useless, since the system captures audio samples by blocks of 1024 (so for example if we read by blocks of 256 samples, we | ||
// receive 4 successive blocks without waiting, then we wait for the 4 next ones). | ||
public static final int MAX_READ_SIZE = 1024 * CHANNELS * BYTES_PER_SAMPLE; | ||
|
||
private AudioConfig() { | ||
// Not instantiable | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters