Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Picking up the pieces - Overcoming Device Fragmentation
Search
Jan Berkel
October 26, 2012
Programming
1
240
Picking up the pieces - Overcoming Device Fragmentation
Talk given at Droidcon London, Oct 2012. Jan Berkel and Jon Schmidt.
Jan Berkel
October 26, 2012
Tweet
Share
Other Decks in Programming
See All in Programming
エンターテイメント業界で利用されるAWS
demuyan
0
210
VS Code をプロダクトにどう取り込むか
onomax
1
370
GraphQLサーバの構成要素を整理する #ハッカー鮨 #tsukijigraphql / graphql server technology selection
izumin5210
4
840
TCAとKMPを用いた新規動画配信アプリ 「ABEMA Live」の設計
tomu28
1
110
大規模Reactアプリのリアーキテクチャ~8万行のTanStack Query移行の軌跡~
kj455
4
960
Micro Frontends for Java Microservices - Devnexus 2024
mraible
PRO
0
490
はてなにおける CSS Modules、及び CSS Modules に足りないもの / CSS Modules in Hatena, and CSS Modules missing parts
mizdra
7
940
MetricKitで予期せぬ終了を検知する話 / Detect unexpected termination with MetricKit
nekowen
1
190
DMMプラットフォームがTiDB Cloudを採用した背景
pospome
8
4.1k
SwiftUIで使いやすいToastの作り方 / How to build a Toast system which is easy to use in SwiftUI
lovee
3
150
Fast JSX: Don't clone props object #28768
yossydev
1
120
Apache Hive 4 on Treasure Data
ryukobayashi
0
340
Featured
See All Featured
Navigating Team Friction
lara
178
13k
Code Review Best Practice
trishagee
55
15k
How to name files
jennybc
65
93k
The Mythical Team-Month
searls
216
42k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
241
1.2M
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
187
16k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
25
2.3k
KATA
mclloyd
15
12k
Fashionably flexible responsive web design (full day workshop)
malarkey
398
65k
What’s in a name? Adding method to the madness
productmarketing
PRO
16
2.6k
Ruby is Unlike a Banana
tanoku
96
10k
Learning to Love Humans: Emotional Interface Design
aarron
267
39k
Transcript
Overcoming Device Fragmentation Jan Berkel Jon Schmidt
• Launched in 2008 • Upload, record, share original audio
content • Receive feedback from the community directly on the waveform • 10+ million official app installs over all platforms “Unmute the web”
SoundCloud on Android Connect to and receive updates from your
account. Discover, listen, and interact with SoundCloud’s library of audio.
SoundCloud on Android Record sounds to your Android device, then
upload and share to SoundCloud.
Playback + Recording Core functionality of the app
LESSONS LEARNED: PLAYBACK
v1.0
“Love it” “Why does this app suck so bad?”
“There was a problem playing that Sound” SoundCloud on Android
(2010 -?)
MediaPlayer player = new MediaPlayer(); player.setDataSource( "http://api.soundcloud.com/tracks/123/stream" ); player.prepare(); player.start();
player.start() MediaPlayer App Framework mediaplayer.cpp libmedia MediaPlayerService AudioTrack audiotrack.cpp Audio
Flinger / HAL ALSA? Kernel SoundCloud Java C / C++
OpenCore MediaPlayerService Stagefright
“All non-trivial abstractions, to some degree, are leaky” J Spolsky
Why do we have to care?
OpenCore Since the beginning Mature, stable, but limited
OpenCORE seeking is broken
Stagefright Default on Android 2.2 and beyond (but OpenCore support
continued)
We support Android 2.1 +
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD) { isStagefright = true; } That
should be easy Not exactly...
[media.stagefright.enable-player]: [false] [media.stagefright.enable-meta]: [false] [media.stagefright.enable-scan]: [false] [media.stagefright.enable-http]: [true] [media.stagefright.enable-rtsp]: [false]
/system/build.prop
Frankenstein Builds
MediaPlayer mp = new MediaPlayer(); mp.setDataSource(String.format("http://127.0.0.1:%d/", socketPort)); mp.prepare(); mp.start(); Connect
to a Local Socket if (res.indexOf("User-Agent: stagefright") >= 0) { isStagefright = true; } Read the user agent
v2.0
Stream Proxy MediaPlayer Stream Proxy Connection Manager Data Storage Socket
Manager Chunk Manager
if (mProxy == null) { mProxy = new StreamProxy(getApp()).init().start(); }
mMediaPlayer.setDataSource( String.format("http://127.0.0.1:%d/%s", mProxy.getPort(), path) ); http://code.google.com/p/npr-android-app Stream Proxy
• Control the connection logic • caching layer The Good
The Bad • Still no control over buffer • Introduced new streaming problems Stream Proxy
HTTP CLIENT Y U NO WORK!? HttpClient is broken
try { return getHttpClient().execute(target, request); } catch (NullPointerException e) {
request.abort(); throw new BrokenHttpClientException(e); } HttpClient is broken
• Write our own MediaPlayer • Request prioritization • Mobile
friendly codecs Plans for the future
“this is an experimental feature and might not work on
all devices”
LESSONS LEARNED: RECORDING
AUDIO CODEC CODER-DECODER mp3, aac, flac, ogg ...
December 2010 available codecs on Android... AMR NB
record raw audio, encode later.
open source, no patents, good quality Java port = slow
Second Iteration AAC
if (Build.SDK_INT >= 10) // use built-in AAC else //
slow vorbis encoding Only available on 2.3.3
and everything was good. until we had to rewrite.
NEW RECORDING
REQUIREMENTS user is able to trim fade in/out
REQUIREMENTS pause recording and resume later more accurate waveform
We needed a new recording infrastructure.
AudioRecord Sound Recorder Vorbis Encoder Amplitude Analyzer Vorbis Decoder Native
Layer ̇⽃ AudioTrack
arm-v5 CPU flavours arm-v7a x86 mips
AudioRecord Sound Recorder Vorbis Encoder Amplitude Analyzer Vorbis Decoder Native
Layer ̇⽃ AudioTrack Wav Writer
JellyBean new low-level media APIs
Device API Level CPU Fragmentation
Putting it back together
CRASH REPORTS
BETA TESTING
READ THE SOURCE CODE
HACKS
DO IT YOURSELF
Jan Berkel Jon Schmidt http://snd.sc/droidcon-2012 www.soundcloud.com Thanks!