Discussion:
Invalid Audio Buffer Size on Samsung Galaxy
joelt
2009-11-15 02:57:02 UTC
Permalink
The following works fine on a G1 but gives an error on the Samsung
Galaxy. I was hoping cross-platform support would be better than this.
See error below.

private final static int RATE = 44100;
private final static int CHANNEL_MODE =
AudioFormat.CHANNEL_CONFIGURATION_MONO;
private final static int ENCODING =
AudioFormat.ENCODING_PCM_16BIT;
private AudioRecord recorder_;


public boolean open() {

int bufferSize = 4 * AudioRecord.getMinBufferSize(RATE,
CHANNEL_MODE, ENCODING);
recorder_ = new AudioRecord(AudioSource.MIC, RATE, CHANNEL_MODE,
ENCODING, bufferSize);

last line gives the following on the Samsung Galaxy phone:
11-14 19:04:07.507: ERROR/AndroidRuntime(7617):
java.lang.IllegalArgumentException: Invalid audio buffer size.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
joelt
2009-11-15 03:49:07 UTC
Permalink
It is also spitting this out:
WARN/AudioHardwareMSM72XX(1018): getInputBufferSize bad sampling rate:
44100

Is there an API that will tell me which rates it _does_ support? It
doesn't look like it.
Post by joelt
The following works fine on a G1 but gives an error on the Samsung
Galaxy. I was hoping cross-platform support would be better than this.
See error below.
    private final static int RATE = 44100;
    private final static int CHANNEL_MODE =
AudioFormat.CHANNEL_CONFIGURATION_MONO;
    private final static int ENCODING =
AudioFormat.ENCODING_PCM_16BIT;
    private AudioRecord recorder_;
 public boolean open() {
  int bufferSize = 4 * AudioRecord.getMinBufferSize(RATE,
CHANNEL_MODE, ENCODING);
  recorder_ = new AudioRecord(AudioSource.MIC, RATE, CHANNEL_MODE,
ENCODING, bufferSize);
java.lang.IllegalArgumentException: Invalid audio buffer size.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
joelt
2009-11-15 16:55:20 UTC
Permalink
Further analysis reveals it only supports an 8k sampling rate. This is
obviously a bug. Where do I file a bug report against the Samsung
phone?
Post by joelt
44100
Is there an API that will tell me which rates it _does_ support? It
doesn't look like it.
Post by joelt
The following works fine on a G1 but gives an error on the Samsung
Galaxy. I was hoping cross-platform support would be better than this.
See error below.
    private final static int RATE = 44100;
    private final static int CHANNEL_MODE =
AudioFormat.CHANNEL_CONFIGURATION_MONO;
    private final static int ENCODING =
AudioFormat.ENCODING_PCM_16BIT;
    private AudioRecord recorder_;
 public boolean open() {
  int bufferSize = 4 * AudioRecord.getMinBufferSize(RATE,
CHANNEL_MODE, ENCODING);
  recorder_ = new AudioRecord(AudioSource.MIC, RATE, CHANNEL_MODE,
ENCODING, bufferSize);
java.lang.IllegalArgumentException: Invalid audio buffer size.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
TonyDoc
2009-11-16 21:31:46 UTC
Permalink
Add you bug to the list over at androidforums.com, samsung seem to
have a dreadful android/galaxy support team.
Post by joelt
Further analysis reveals it only supports an 8k sampling rate. This is
obviously a bug. Where do I file a bug report against the Samsung
phone?
Post by joelt
44100
Is there an API that will tell me which rates it _does_ support? It
doesn't look like it.
Post by joelt
The following works fine on a G1 but gives an error on the Samsung
Galaxy. I was hoping cross-platform support would be better than this.
See error below.
    private final static int RATE = 44100;
    private final static int CHANNEL_MODE =
AudioFormat.CHANNEL_CONFIGURATION_MONO;
    private final static int ENCODING =
AudioFormat.ENCODING_PCM_16BIT;
    private AudioRecord recorder_;
 public boolean open() {
  int bufferSize = 4 * AudioRecord.getMinBufferSize(RATE,
CHANNEL_MODE, ENCODING);
  recorder_ = new AudioRecord(AudioSource.MIC, RATE, CHANNEL_MODE,
ENCODING, bufferSize);
java.lang.IllegalArgumentException: Invalid audio buffer size.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
niko20
2009-11-16 21:51:14 UTC
Permalink
I hope you are bothering to check for ERROR_BAD_VALUE from the
getMinBufferSize, you can use this to determine if the hardware
supports the settings you want or not.

As far as cross-platform, this is still one of the valid reasons to
check the error codes, I don't think it's possible for us to say all
devices should support all formats, it just common sense.

-niko
Post by TonyDoc
Add you bug to the list over at androidforums.com, samsung seem to
have a dreadful android/galaxy support team.
Post by joelt
Further analysis reveals it only supports an 8k sampling rate. This is
obviously a bug. Where do I file a bug report against the Samsung
phone?
Post by joelt
44100
Is there an API that will tell me which rates it _does_ support? It
doesn't look like it.
Post by joelt
The following works fine on a G1 but gives an error on the Samsung
Galaxy. I was hoping cross-platform support would be better than this.
See error below.
    private final static int RATE = 44100;
    private final static int CHANNEL_MODE =
AudioFormat.CHANNEL_CONFIGURATION_MONO;
    private final static int ENCODING =
AudioFormat.ENCODING_PCM_16BIT;
    private AudioRecord recorder_;
 public boolean open() {
  int bufferSize = 4 * AudioRecord.getMinBufferSize(RATE,
CHANNEL_MODE, ENCODING);
  recorder_ = new AudioRecord(AudioSource.MIC, RATE, CHANNEL_MODE,
ENCODING, bufferSize);
java.lang.IllegalArgumentException: Invalid audio buffer size.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
Loading...