challenges and lessons learned
play

challenges and lessons learned Pierre-Louis Bossart UMG Platform - PowerPoint PPT Presentation

Audio playback on mobile devices: challenges and lessons learned Pierre-Louis Bossart UMG Platform Architecture LPC2009 Ultra Mobility Group Intel Confidential Outline PulseAudio is a fundamental component of the Moblin distribution Goal:


  1. Audio playback on mobile devices: challenges and lessons learned Pierre-Louis Bossart UMG Platform Architecture LPC2009 Ultra Mobility Group Intel Confidential

  2. Outline PulseAudio is a fundamental component of the Moblin distribution Goal: share lessons learned on upcoming consumer/mobile devices – Optimized/secure music playback – Volume control – Delay management with HDMI LPC2009 Ultra Mobility Group Intel Confidential

  3. Music playback recap App Application PulseAudio SRC Decoder Sink Sink_input Sink_input Pa_stream HDMI Sink USB BlueZ ALSA PMIC Intel relies on PulseAudio for – Mixing – Detection and transition to ‘plugable’ output. LPC2009 Ultra Mobility Group Intel Confidential

  4. Low-power use cases PA Timer-based scheduling enables long sleep-time (up to 2s if the ALSA buffer is big enough) – Music playback app can specify that latency is not an issue – Application processor can decode a large buffer then go to sleep with PCM is rendered • Optimal battery life is still reached with separate audio engine Alert Application PulseAudio Sink SRC Dec element Sink_input Sink ALSA Decoder Mix PMIC Audio Engine LPC2009 Ultra Mobility Group Intel Confidential

  5. DRM use cases Content-protection is still a requirement – Premium content (BluRay), Wireless providers (OMA, etc) • Different levels of protection – Compressed content protected – High-resolution PCM protected only – PCM playback to certain outputs only • Solution to meet all requirements: secure hardware pipeline Alert Application PulseAudio Sink_input Sink SRC Dec element Sink ALSA Hw decrypt Decoder Mix PMIC Security Engine Audio Engine LPC2009 Ultra Mobility Group Intel Confidential

  6. Stack evolution Alert PulseAudio Application Sink_input SRC Dec element Sink Sink_input Sink Only if allowed by content provider Downmix BlueZ ALSA Hw decrypt Decoder Mix PMIC Security Engine Audio Engine Main hurdles: Gstreamer pipeline creation Transitions between modes LPC2009 Ultra Mobility Group Intel Confidential

  7. Gstreamer audio pipeline Main ways of creating pipeline – Explicit pipeline – Autoplug (playbin/decodebin) – All of the above • High rank for hw-accelerated elements may not be enough. • Too many details may prevent any kind of hardware pipeline • gst-launch -v filesrc location=music.ogg ! decodebin ! Volume volume=0.8 ! audioconvert ! audioresample ! alsasink – PCM data need to be provided back to the host… • Playbin assumes PCM data will be provided for visualization • Solution: – Clone of playbin to remove visualization part… – Modify apps to enable hardware pipeline • Code clean-up required anyway in media player (remove wake-ups, UI refresh when screen is off, etc) LPC2009 Ultra Mobility Group Intel Confidential

  8. Routing transitions and audio policy PolicyRules • Audio policy exists in all mobile devices PulseAudio • Examples: Application Policy engine – BT device paired • Audio policy moves sink_inputs to BT A2DP output – Ringtone: Module-detect • Music playback paused while ringtone plays • Music playback mixed with ringtone • Audio policy needs interaction with application for state changes – Example: PulseAudio cannot pause a stream on its own • Coherency issues with UI, stream displayed as playing but not moving • Pause/resume requests are handled by application • Routing requests need to be provided by Audio policy – New requirement to enable audio pipeline: • Routing transitions need to be notified to the application in addition to state transitions LPC2009 Ultra Mobility Group Intel Confidential

  9. PA event callback PolicyRules Propagate event to top-level Application PulseAudio SRC Decoder Sink Policy engine Stream_event_callback Module-detect Only make sense when a true pa_stream was opened – Transition between BT and local playback possible – To handle a transition between local playback and BT, would need to keep an open pa_stream connection but never send any actual data until the policy changes the routing. • Can be done but dangerous LPC2009 Ultra Mobility Group Intel Confidential

  10. Moblin Audio Manager Audio Manager is a PulseAudio module Defines new stream type to extend pa_stream – am_stream can be • Regular pa_stream when data flows through PA • Hw accelerated stream • Audio Manager relies on – Native hooks to trap all pa_stream events – DBUS messages from application when hw accelerated stream changes states. • Requires application using hardware pipeline to register with AudioManager – Notifies application of policy decision (stop/pause) or routing change. LPC2009 Ultra Mobility Group Intel Confidential

  11. Discussion PA event callback is only available after pa_stream was created. – Need to open a pa_stream connection to know that you don’t need the connection • Event- propagation isn’t straightforward in apps – Callback handled by audio back-end – Needs to be propagated to main event loop/UI • Audio Manager – Requires Intel to modify apps&PulseAudio • Ideally, there would be only one generic enough means of interaction between PulseAudio and applications – Available for mobile and desktop/laptop LPC2009 Ultra Mobility Group Intel Confidential

  12. Proposal PolicyRules PulseAudio StateRequested Application Policy engine StateNotified Module-detect Common DBUS interface – Application requests a state – PulseAudio notifies the state granted by audio policy • Can be used to convey audio policy or routing decisions • Doesn’t seem too incompatible with Maemo • Would be fine with Moblin • Would only require minor change in ‘module -cork-music-on- phone’ LPC2009 Ultra Mobility Group Intel Confidential

  13. Volume control Significant evolutions in PA code in H1’09 ringtone alert music – Flat-volumes Issue: SW SW SW Decoder Decoder Decoder – Not all volumes are controlled through ALSA mixer V1.N V1.3 V1.2 – Different experience when using sw and hw Host decoder • Solutions: PA Mixer – ‘fake’ pa_stream • Visible in pavucontrol HW Decoder • No vu-meter since no data is sent V2.2 V1.3 • Application doesn’t know how the device volume was changed FM RX analog HW/FW Mixer – Add ALSA mixer input • Odd since ALSA not really used for low-power/DRM playback Audio V3.1 V1.4 Engine – Provide volume change information over DBUS PMIC Mixer LPC2009 Ultra Mobility Group Intel Confidential

  14. HDMI lip-sync Audio Processing HDMI Split in Video processing HDMI receiver splits audio and video payload Audio and video processing have different latencies – Video enhancements typically require 100s of ms of buffering – Need to delay audio data to maintain alignment • When audio and video processing are performed on different devices, delay needs to be applied at the source • HDMI v1.3 provides audio/video latencies in EDID fields – Read by HDAudio driver, reported in /proc file – Note: Delay is dynamic • If video resolution changes, required audio delay needs to change • Issue: Linux audio stack doesn’t do anything with it – Lip-sync issue! LPC2009 Ultra Mobility Group Intel Confidential

  15. HDMI stack App PulseAudio Audio Audio Sink Sink_input Sink_input 3 decoder SRC Demux A/V sync Sink Video Video sink decoder 2 Application ALSA configuration Display driver 1 HDMI out Delay can be handled In the driver In PulseAudio By the application LPC2009 Ultra Mobility Group Intel Confidential

  16. Lip-sync discussion Delay at driver level – Needs to be done for every link that handles audio/video (not just wired HDMI) – Needs to be done for each and every HDMI driver. Not good. – Internal delay, should not affect sample counts reported by snd_pcm_delay(). • Delay at PA level – Would need to obtain delay information from ALSA – No such interface at this time – May interfere with latency computations • Need to remove delay from sample counts/latency reports to avoid influencing A/V sync in app Application – A/V sync handled by application, would be possible to apply delay and take delay into account – Would need an interface from PulseAudio to know by how much the audio is delayed LPC2009 Ultra Mobility Group Intel Confidential

  17. Conclusion Minor enhancements of interfaces needed to allow for – Seamless handling of hardware-accelerated audio – Better HDMI experience • This is not rocket-science – Mainly dependencies on others • Let’s work together on this – Would benefit the desktop as well. LPC2009 Ultra Mobility Group Intel Confidential

  18. Questions? LPC2009 Ultra Mobility Group Intel Confidential

Recommend


More recommend