Skip to content

Commit 30d1244

Browse files
rom1vyume-chan
andcommitted
Add audio player
Play the decoded audio using SDL. The audio player frame sink receives the audio frames, resample them and write them to a byte buffer (introduced by this commit). On SDL audio callback (from an internal SDL thread), copy samples from this byte buffer to the SDL audio buffer. The byte buffer is protected by the SDL_AudioDeviceLock(), but it has been designed so that the producer and the consumer may write and read in parallel, provided that they don't access the same slices of the ring-buffer buffer. PR #3757 <Genymobile/scrcpy#3757> Co-authored-by: Simon Chan <[email protected]>
1 parent 4e6941e commit 30d1244

File tree

8 files changed

+519
-5
lines changed

8 files changed

+519
-5
lines changed

BUILD.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ First, you need to install the required packages:
1515
sudo apt install ffmpeg libsdl2-2.0-0 adb wget \
1616
gcc git pkg-config meson ninja-build libsdl2-dev \
1717
libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev \
18-
libusb-1.0-0 libusb-1.0-0-dev
18+
libswresample-dev libusb-1.0-0 libusb-1.0-0-dev
1919
```
2020

2121
Then clone the repo and execute the installation script
@@ -94,7 +94,7 @@ sudo apt install ffmpeg libsdl2-2.0-0 adb libusb-1.0-0
9494
# client build dependencies
9595
sudo apt install gcc git pkg-config meson ninja-build libsdl2-dev \
9696
libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev \
97-
libusb-1.0-0-dev
97+
libswresample-dev libusb-1.0-0-dev
9898

9999
# server build dependencies
100100
sudo apt install openjdk-11-jdk

app/meson.build

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ src = [
44
'src/adb/adb_device.c',
55
'src/adb/adb_parser.c',
66
'src/adb/adb_tunnel.c',
7+
'src/audio_player.c',
78
'src/cli.c',
89
'src/clock.c',
910
'src/compat.c',
@@ -30,6 +31,7 @@ src = [
3031
'src/version.c',
3132
'src/video_buffer.c',
3233
'src/util/acksync.c',
34+
'src/util/average.c',
3335
'src/util/bytebuf.c',
3436
'src/util/file.c',
3537
'src/util/intmap.c',
@@ -100,6 +102,7 @@ if not crossbuild_windows
100102
dependency('libavformat', version: '>= 57.33'),
101103
dependency('libavcodec', version: '>= 57.37'),
102104
dependency('libavutil'),
105+
dependency('libswresample'),
103106
dependency('sdl2', version: '>= 2.0.5'),
104107
]
105108

@@ -135,6 +138,7 @@ else
135138
cc.find_library('avcodec-60', dirs: ffmpeg_bin_dir),
136139
cc.find_library('avformat-60', dirs: ffmpeg_bin_dir),
137140
cc.find_library('avutil-58', dirs: ffmpeg_bin_dir),
141+
cc.find_library('swresample-4', dirs: ffmpeg_bin_dir),
138142
],
139143
include_directories: include_directories(ffmpeg_include_dir)
140144
)

0 commit comments

Comments
 (0)