5 Replies Latest reply on May 17, 2011 5:31 PM by tzeng

    appendBytes on mobile




      I'm working on a ShoutCast player in Adobe AIR. My code works very good on a Desktop machine with low CPU/ memory usage but uses a lot of CPU (18%) when run on a Android phone (HTC Desire). I discovered the bottleneck was the appendBytes api which uses almost 15% CPU. I currently can't post the code but this is how my player works:


      - I connect to a ShoutCast server using Sockets (ShoutCasts servers do not always return valid HTTP responses so i can't use URLStream).

      - I parse the headers and based on the content-type i use a different parser (mp3 or AAC)

      - I prepare a audio only FLV header and push it into the NetStream.

      - For AAC i will parse each frame and wrap it in a FLV tag. The first FLV tag will be a AudioSpecificConfig. The timestamp will be calculated based on the length of the frame.

      - For MP3 the same process applies. However no AudioSpecificConfig will be made.

      - When playing i will wait for the buffer to drop below 60% of the max buffer time (6 seconds) and start reading more flv tags untill the buffer is full.


      These are the problems i discovered when debugging the player on my phone:

      - It uses a lot of CPU when playing audio. CPU drops when i comment out the appendBytes line (to 2%, 3%).

      - The audio skips when you leave the program and try to do something (like scrolling).


      So my questions are:

      - Am i using the appendBytes api the wrong way and if so what is the best way to use it?

      - Is it possible to make the audio less choppy when leaving the program? Or does AIR not allow that?


      Best regards,