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 Fragm...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Jan Berkel
October 26, 2012
Programming
250
1
Share
Picking up the pieces - Overcoming Device Fragmentation
Talk given at Droidcon London, Oct 2012. Jan Berkel and Jon Schmidt.
Jan Berkel
October 26, 2012
Other Decks in Programming
See All in Programming
開発体験を左右するライブラリの API 設計 - GraphQL スキーマ構築ライブラリから考える #tskaigi
izumin5210
2
1.5k
Migrations : C'est une question d'hygiène !
vinceamstoutz
0
2.8k
AIとRubyの静的型付け
ukin0k0
0
500
AIチームを指揮するOSS「TAKT」活用術 / How to Use “TAKT,” an OSS Tool for Orchestrating AI Teams
nrslib
6
770
プラグインで拡張される Context をtype-safe にする難しさと設計判断
kazupon
2
530
Inside Stream API
skrb
1
510
サーバーレスで作る、動画データ管理基盤
oyasumipants
0
330
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
210
Oxcを導入して開発体験が向上した話
yug1224
4
270
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
150
AI時代のUIはどこへ行く?その2!
yusukebe
18
6k
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.1k
Featured
See All Featured
Designing Powerful Visuals for Engaging Learning
tmiket
1
390
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
420
Scaling GitHub
holman
464
140k
Navigating Weather and Climate Data
rabernat
0
210
How to build a perfect <img>
jonoalderson
1
5.5k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
590
Bash Introduction
62gerente
615
210k
Leo the Paperboy
mayatellez
7
1.8k
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!