Go Back   Android Forums > Android Development > ROM Development
ROM Development Dev lounge for our ROM developers.

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
 
LinkBack Thread Tools
Old August 23rd, 2012, 05:57 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Aug 2012
Posts: 1
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default C Thread priority for streamig USB Audio problems

Hi Folks,

I'm building a custom application on a custom device (2.3.5, kernel 2.6.38). The android device is acting as a USB Host, consuming audio from a connected USB media player device using standard USB Audio Class. I do have access to generate a new ROM for the custom device.

In a C thread (record thread), I'm opening a handle to the USB alsa recorder device (/dev/snd/), requesting pcm frames from the attached USB device using the snd_pcm_readi alsa API. Frames are now passed from recorder thread to a C playback thread to be queued to speaker output via ALSA and/or OpenSL.

When my application is in the foreground, the recorder thread runs in a timely manner, and audio playback is seamless. However, when my application gets backgrounded, I run another application in forground, or quickly scroll through any listviews or the home screen tiles, the C recorder thread gets starved. The C recorder thread cannot request USB audio frames fast enough, and music starts to skip. When the forground application idles again or I finish interacting with the UI, the music will once again be seamless.

As I understand, C threads in Android do not (and cannot) have real-time priority, verified by my failed attempts to bump up the pthread priority. My view of the solution is to bump up the recorder thread priority somehow, but not sure how to get beyond the android thread priority limitation. Or is there another solution (like not having a recorder/playback thread, and using builtin media features)?

Open to all suggestions or comments.

TIA,
ehdroid

ehdroid is offline  
Reply With Quote
sponsored links
Reply
Tags
alsa, c++, opensl, streaming audio, thread priority, usb audio


Go Back   Android Forums > Android Development > ROM Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 04:35 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.