Cannot create AudioTrack with larger audio output latency.

by AndroidJimmy » Fri, 27 Feb 2009 15:03:46 GMT


Sponsored Links
 I meet a problem about creating AudioTrack failed with larger audio
output latency.
It fails in AudioTrack::set(), blocked by codes below:

    if (frameCount < minFrameCount) {
      LOGE("Invalid buffer size: minFrameCount %d, frameCount %d",
minFrameCount, frameCount);
      return BAD_VALUE;
    }

I think this code is for guaranteeing there are enough buffer and
sample in AudioTrack to wait for audio output consuming the output
data.

In MediaPlayerService::AudioOutput::open(),  AudioTrack is created by
codes below:

    new AudioTrack(mStreamType, sampleRate, format, channelCount,
frameCount*bufferCount);

framecount is determined by frameCount = (sampleRate*afFrameCount)/
afSampleRate; In most situation, sampleRate is usually 44100,
bufferCount is hard-code in PV(4) and SONIVOX_PLAYER/VORBIS_PLAYER
(DEFAULT_AUDIOSINK_BUFFERCOUNT 4).

So if there is a larger output latency, PV/SONIVOX_PLAYER/
VORBIS_PLAYER may not create an AudioTrack with enough bufferCount.
These may happen when output is a larger latency network device, such
as BlueTooth, etc.

Is there a way to prevent from creating AudioTrack fail under this
situation?
Thanks.
--~--~---------~--~----~------------~-------~--~----~



Cannot create AudioTrack with larger audio output latency.

by Dave Sparks » Sat, 28 Feb 2009 03:15:30 GMT


 There are a bunch of patches coming related to this in Cupcake. The
app can either ask for the default latency or it can ask for the
latency and request something bigger.



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. listview activity not stopping

i have face this error,i cant found the solution please
help.Application is based on listview Activity.when u click on one
listview item then it ll go to another listview.second activity start
but ther is some error please help yr...this error ......
--------------------------------------------------------------------------------------------------------------------------------------------------------------------


07-27 15:38:48.117: WARN/dalvikvm(741): threadid=3: thread exiting
with uncaught exception (group=0x4000fe70)
07-27 15:38:48.127: ERROR/AndroidRuntime(741): Uncaught handler:
thread main exiting due to uncaught exception
07-27 15:38:48.147: ERROR/AndroidRuntime(741):
java.lang.RuntimeException: Unable to stop activity
{com.vigyaapan.Exercise/com.vigyaapan.Exercise.GymExercise}:
java.lang.NullPointerException
07-27 15:38:48.147: ERROR/AndroidRuntime(741):     at
android.app.ActivityThread.performStopActivityInner
(ActivityThread.java:2905)
07-27 15:38:48.147: ERROR/AndroidRuntime(741):     at
android.app.ActivityThread.handleStopActivity(ActivityThread.java:
2948)
07-27 15:38:48.147: ERROR/AndroidRuntime(741):     at
android.app.ActivityThread.access$2100(ActivityThread.java:112)
07-27 15:38:48.147: ERROR/AndroidRuntime(741):     at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1708)
07-27 15:38:48.147: ERROR/AndroidRuntime(741):     at
android.os.Handler.dispatchMessage(Handler.java:99)
07-27 15:38:48.147: ERROR/AndroidRuntime(741):     at
android.os.Looper.loop(Looper.java:123)
07-27 15:38:48.147: ERROR/AndroidRuntime(741):     at
android.app.ActivityThread.main(ActivityThread.java:3948)
07-27 15:38:48.147: ERROR/AndroidRuntime(741):     at
java.lang.reflect.Method.invokeNative(Native Method)
07-27 15:38:48.147: ERROR/AndroidRuntime(741):     at
java.lang.reflect.Method.invoke(Method.java:521)
07-27 15:38:48.147: ERROR/AndroidRuntime(741):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:782)
07-27 15:38:48.147: ERROR/AndroidRuntime(741):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
07-27 15:38:48.147: ERROR/AndroidRuntime(741):     at
dalvik.system.NativeStart.main(Native Method)
07-27 15:38:48.147: ERROR/AndroidRuntime(741): Caused by:
java.lang.NullPointerException
07-27 15:38:48.147: ERROR/AndroidRuntime(741):     at
android.app.Activity.performStop(Activity.java:3575)
07-27 15:38:48.147: ERROR/AndroidRuntime(741):     at
android.app.ActivityThread.performStopActivityInner
(ActivityThread.java:2902)
07-27 15:38:48.147: ERROR/AndroidRuntime(741):     ... 11 more

------------------------------------------------------------------------------------------------------------------------------------------------




here is my program
-------------------------------------------
package com.vigyaapan.Exercise;

import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.util.AndroidRuntimeException;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class GymExercise extends ListActivity
{
        DBExercise dbExercise = new DBExercise(this);
        Cursor cursor;
        String aryListMainMenu[];
        int intGetSelectedItem = 0;
        protected ListView lv;

    public void onCreate(Bundle savedInstanceState)
    {
        try
        {
                super.onCreate(savedInstanceState);

                dbExercise.openDataBase();
                dbExercise.getTricepDipImage();
                aryListMainMenu = dbExercise.displayMainMenu();
                startManagingCursor(cursor);
            if(dbExercise != null)
                        dbExercise.close();

            setContentView(R.layout.main);
            lv = (ListView)this.findViewById(android.R.id.list);
            setupListView();
        }
        catch(NullPointerException e)
        {
                e.printStackTrace();
        }
    }

    private void setupListView()
    {
        try
        {
                ArrayAdapter listItemAdapter = new ArrayAdapter
(this,android.R.layout.simple_list_item_1,aryListMainMenu);
                    lv.setAdapter(listItemAdapter);
                }
        catch(AndroidRuntimeException e)
        {
                e.printStackTrace();
        }
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position,
long id)
    {
        try
        {
                super.onListItemClick(l, v, position, id);
                if(position == 0)
                {
                        Intent intentShoulder = new Intent
(GymExercise.this,ShoulderViewController.class);
                        startActivity(intentShoulder);
                        lv.bringToFront();



                }
                if(position == 1)
                {
                        Intent intentTriceps = new Intent
(GymExercise.this,TricepsViewController.class);
                        startActivity(intentTriceps);


                }
                if(position == 2)
                {
                        Intent intentBiceps = new Intent
(GymExercise.this,BicepsViewController.class);
                        startActivity(intentBiceps);


                }
                if(position == 3)
                {
                        Intent intentChest = new Intent
(GymExercise.this,ChestViewController.class);
                        startActivity(intentChest);


                }
                if(position == 4)
                {
                        Intent intentBackView = new Intent
(GymExercise.this,BackViewController.class);
                        startActivity(intentBackView);

                        }
                if(position == 5)
                {
                        Intent intentLeg = new Intent
(GymExercise.this,LegViewController.class);
                        startActivity(intentLeg);


                }
            }
        catch(AndroidRuntimeException e)
        {
                e.printStackTrace();
        }
    }




}
---------------------------------------------------------------------------------------------------------------







package com.vigyaapan.Exercise;

import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class TricepsViewController extends ListActivity
{
        DBExercise dbExercise = new DBExercise(this);
        protected ListView lv;
        String[] aryTricepsList;
        public void onCreate(Bundle savedInstanceState)
        {
                try
        {
                super.onCreate(savedInstanceState);
                System.out.println("Inside Triceps class");
                dbExercise.openDataBase();
                aryTricepsList = dbExercise.getTriceps();
                if(dbExercise != null)
                        dbExercise.close();

                setContentView(R.layout.triceps);
            lv = (ListView)this.findViewById(android.R.id.list);
            setTricepsList();

        }
                catch(RuntimeException e)
                {
                        e.printStackTrace();
                }
        }

        /*
         * This method will get the populated values from database an load
into list view of triceps list
         */
        public void setTricepsList()
        {
                try
                {
                        ArrayAdapter listItemAdapter = new ArrayAdapter
(this,android.R.layout.simple_list_item_1,aryTricepsList);
                        System.out.println("Array 
count===>"+listItemAdapter.getCount());
                        lv.setAdapter(listItemAdapter);
                }
                catch(RuntimeException e)
                {
                        e.printStackTrace();
                }
        }
}




--~--~---------~--~----~------------~-------~--~----~

2. How did they made those "solve the math to dismiss the Alarm Clock" type apps?

I certainly hope they don't hold a wake lock. :)  They should just schedule
an alarm.








-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~

3. Threads for networking and DatagramSocket

4. pthread lib problem

5. where to download the linux-kernel for Android 1.5?

6. How to catch event from the virtual keyboard ?

7. how to disable the keygaurd and screen locking in android