Merge change 2331 into donut
* changes: Fix issue 1846343 - part 1
This commit is contained in:
@@ -71065,6 +71065,17 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</constructor>
|
</constructor>
|
||||||
|
<method name="getAudioSourceMax"
|
||||||
|
return="int"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</method>
|
||||||
<method name="getMaxAmplitude"
|
<method name="getMaxAmplitude"
|
||||||
return="int"
|
return="int"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
@@ -71466,6 +71477,39 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
|
<field name="VOICE_CALL"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="4"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="VOICE_DOWNLINK"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="3"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
|
<field name="VOICE_UPLINK"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="2"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
</class>
|
</class>
|
||||||
<interface name="MediaRecorder.OnErrorListener"
|
<interface name="MediaRecorder.OnErrorListener"
|
||||||
abstract="true"
|
abstract="true"
|
||||||
|
|||||||
@@ -45,8 +45,6 @@ struct fields_t {
|
|||||||
jmethodID postNativeEventInJava; //... event post callback method
|
jmethodID postNativeEventInJava; //... event post callback method
|
||||||
int PCM16; //... format constants
|
int PCM16; //... format constants
|
||||||
int PCM8; //... format constants
|
int PCM8; //... format constants
|
||||||
int SOURCE_DEFAULT; //... record source constants
|
|
||||||
int SOURCE_MIC; //... record source constants
|
|
||||||
jfieldID nativeRecorderInJavaObj; // provides access to the C++ AudioRecord object
|
jfieldID nativeRecorderInJavaObj; // provides access to the C++ AudioRecord object
|
||||||
jfieldID nativeCallbackCookie; // provides access to the AudioRecord callback data
|
jfieldID nativeCallbackCookie; // provides access to the AudioRecord callback data
|
||||||
};
|
};
|
||||||
@@ -66,7 +64,7 @@ struct audiorecord_callback_cookie {
|
|||||||
#define AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT -16
|
#define AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT -16
|
||||||
#define AUDIORECORD_ERROR_SETUP_INVALIDCHANNELCOUNT -17
|
#define AUDIORECORD_ERROR_SETUP_INVALIDCHANNELCOUNT -17
|
||||||
#define AUDIORECORD_ERROR_SETUP_INVALIDFORMAT -18
|
#define AUDIORECORD_ERROR_SETUP_INVALIDFORMAT -18
|
||||||
#define AUDIORECORD_ERROR_SETUP_INVALIDSTREAMTYPE -19
|
#define AUDIORECORD_ERROR_SETUP_INVALIDSOURCE -19
|
||||||
#define AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED -20
|
#define AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED -20
|
||||||
|
|
||||||
jint android_media_translateRecorderErrorCode(int code) {
|
jint android_media_translateRecorderErrorCode(int code) {
|
||||||
@@ -154,17 +152,16 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
|
|||||||
int frameSize = nbChannels * bytesPerSample;
|
int frameSize = nbChannels * bytesPerSample;
|
||||||
size_t frameCount = buffSizeInBytes / frameSize;
|
size_t frameCount = buffSizeInBytes / frameSize;
|
||||||
|
|
||||||
// compare the source against the Java constants
|
// convert and check input source value
|
||||||
AudioRecord::stream_type arSource;
|
// input_source values defined in AudioRecord.h are equal to
|
||||||
if (source == javaAudioRecordFields.SOURCE_DEFAULT) {
|
// JAVA MediaRecord.AudioSource values minus 1.
|
||||||
arSource = AudioRecord::DEFAULT_INPUT;
|
AudioRecord::input_source arSource = (AudioRecord::input_source)(source - 1);
|
||||||
} else if (source == javaAudioRecordFields.SOURCE_MIC) {
|
if (arSource < AudioRecord::DEFAULT_INPUT ||
|
||||||
arSource = AudioRecord::MIC_INPUT;
|
arSource >= AudioRecord::NUM_INPUT_SOURCES) {
|
||||||
} else {
|
|
||||||
LOGE("Error creating AudioRecord: unknown source.");
|
LOGE("Error creating AudioRecord: unknown source.");
|
||||||
return AUDIORECORD_ERROR_SETUP_INVALIDSTREAMTYPE;
|
return AUDIORECORD_ERROR_SETUP_INVALIDSOURCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
audiorecord_callback_cookie *lpCallbackData = NULL;
|
audiorecord_callback_cookie *lpCallbackData = NULL;
|
||||||
AudioRecord* lpRecorder = NULL;
|
AudioRecord* lpRecorder = NULL;
|
||||||
|
|
||||||
@@ -511,8 +508,6 @@ static JNINativeMethod gMethods[] = {
|
|||||||
#define JAVA_POSTEVENT_CALLBACK_NAME "postEventFromNative"
|
#define JAVA_POSTEVENT_CALLBACK_NAME "postEventFromNative"
|
||||||
#define JAVA_CONST_PCM16_NAME "ENCODING_PCM_16BIT"
|
#define JAVA_CONST_PCM16_NAME "ENCODING_PCM_16BIT"
|
||||||
#define JAVA_CONST_PCM8_NAME "ENCODING_PCM_8BIT"
|
#define JAVA_CONST_PCM8_NAME "ENCODING_PCM_8BIT"
|
||||||
#define JAVA_CONST_SOURCEDEFAULT_NAME "SOURCE_DEFAULT"
|
|
||||||
#define JAVA_CONST_SOURCEMIC_NAME "SOURCE_MIC"
|
|
||||||
#define JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME "mNativeRecorderInJavaObj"
|
#define JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME "mNativeRecorderInJavaObj"
|
||||||
#define JAVA_NATIVECALLBACKINFO_FIELD_NAME "mNativeCallbackCookie"
|
#define JAVA_NATIVECALLBACKINFO_FIELD_NAME "mNativeCallbackCookie"
|
||||||
|
|
||||||
@@ -583,17 +578,6 @@ int register_android_media_AudioRecord(JNIEnv *env)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the recording source constants from the AudioRecord class
|
|
||||||
if ( !android_media_getIntConstantFromClass(env, javaAudioRecordFields.audioRecordClass,
|
|
||||||
kClassPathName,
|
|
||||||
JAVA_CONST_SOURCEDEFAULT_NAME, &(javaAudioRecordFields.SOURCE_DEFAULT))
|
|
||||||
|| !android_media_getIntConstantFromClass(env, javaAudioRecordFields.audioRecordClass,
|
|
||||||
kClassPathName,
|
|
||||||
JAVA_CONST_SOURCEMIC_NAME, &(javaAudioRecordFields.SOURCE_MIC)) ) {
|
|
||||||
// error log performed in getIntConstantFromClass()
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return AndroidRuntime::registerNativeMethods(env,
|
return AndroidRuntime::registerNativeMethods(env,
|
||||||
kClassPathName, gMethods, NELEM(gMethods));
|
kClassPathName, gMethods, NELEM(gMethods));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,10 +39,15 @@ class AudioRecord
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum stream_type {
|
// input sources values must always be defined in the range
|
||||||
|
// [AudioRecord::DEFAULT_INPUT, AudioRecord::NUM_INPUT_SOURCES[
|
||||||
|
enum input_source {
|
||||||
DEFAULT_INPUT =-1,
|
DEFAULT_INPUT =-1,
|
||||||
MIC_INPUT = 0,
|
MIC_INPUT = 0,
|
||||||
NUM_STREAM_TYPES
|
VOICE_UPLINK_INPUT = 1,
|
||||||
|
VOICE_DOWNLINK_INPUT = 2,
|
||||||
|
VOICE_CALL_INPUT = 3,
|
||||||
|
NUM_INPUT_SOURCES
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int DEFAULT_SAMPLE_RATE = 8000;
|
static const int DEFAULT_SAMPLE_RATE = 8000;
|
||||||
@@ -118,7 +123,7 @@ public:
|
|||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
*
|
*
|
||||||
* streamType: Select the audio input to record to (e.g. AudioRecord::MIC_INPUT).
|
* inputSource: Select the audio input to record to (e.g. AudioRecord::MIC_INPUT).
|
||||||
* sampleRate: Track sampling rate in Hz.
|
* sampleRate: Track sampling rate in Hz.
|
||||||
* format: PCM sample format (e.g AudioSystem::PCM_16_BIT for signed
|
* format: PCM sample format (e.g AudioSystem::PCM_16_BIT for signed
|
||||||
* 16 bits per sample).
|
* 16 bits per sample).
|
||||||
@@ -140,7 +145,7 @@ public:
|
|||||||
RECORD_IIR_ENABLE = AudioSystem::TX_IIR_ENABLE
|
RECORD_IIR_ENABLE = AudioSystem::TX_IIR_ENABLE
|
||||||
};
|
};
|
||||||
|
|
||||||
AudioRecord(int streamType,
|
AudioRecord(int inputSource,
|
||||||
uint32_t sampleRate = 0,
|
uint32_t sampleRate = 0,
|
||||||
int format = 0,
|
int format = 0,
|
||||||
int channelCount = 0,
|
int channelCount = 0,
|
||||||
@@ -165,7 +170,7 @@ public:
|
|||||||
* - NO_INIT: audio server or audio hardware not initialized
|
* - NO_INIT: audio server or audio hardware not initialized
|
||||||
* - PERMISSION_DENIED: recording is not allowed for the requesting process
|
* - PERMISSION_DENIED: recording is not allowed for the requesting process
|
||||||
* */
|
* */
|
||||||
status_t set(int streamType = 0,
|
status_t set(int inputSource = 0,
|
||||||
uint32_t sampleRate = 0,
|
uint32_t sampleRate = 0,
|
||||||
int format = 0,
|
int format = 0,
|
||||||
int channelCount = 0,
|
int channelCount = 0,
|
||||||
@@ -197,6 +202,7 @@ public:
|
|||||||
int channelCount() const;
|
int channelCount() const;
|
||||||
uint32_t frameCount() const;
|
uint32_t frameCount() const;
|
||||||
int frameSize() const;
|
int frameSize() const;
|
||||||
|
int inputSource() const;
|
||||||
|
|
||||||
|
|
||||||
/* After it's created the track is not active. Call start() to
|
/* After it's created the track is not active. Call start() to
|
||||||
@@ -323,7 +329,8 @@ private:
|
|||||||
audio_track_cblk_t* mCblk;
|
audio_track_cblk_t* mCblk;
|
||||||
uint8_t mFormat;
|
uint8_t mFormat;
|
||||||
uint8_t mChannelCount;
|
uint8_t mChannelCount;
|
||||||
uint8_t mReserved[2];
|
uint8_t mInputSource;
|
||||||
|
uint8_t mReserved;
|
||||||
status_t mStatus;
|
status_t mStatus;
|
||||||
uint32_t mLatency;
|
uint32_t mLatency;
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
|
|
||||||
virtual sp<IAudioRecord> openRecord(
|
virtual sp<IAudioRecord> openRecord(
|
||||||
pid_t pid,
|
pid_t pid,
|
||||||
int streamType,
|
int inputSource,
|
||||||
uint32_t sampleRate,
|
uint32_t sampleRate,
|
||||||
int format,
|
int format,
|
||||||
int channelCount,
|
int channelCount,
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ typedef void (*media_completion_f)(status_t status, void *cookie);
|
|||||||
enum audio_source {
|
enum audio_source {
|
||||||
AUDIO_SOURCE_DEFAULT = 0,
|
AUDIO_SOURCE_DEFAULT = 0,
|
||||||
AUDIO_SOURCE_MIC = 1,
|
AUDIO_SOURCE_MIC = 1,
|
||||||
|
AUDIO_SOURCE_VOICE_UPLINK = 2,
|
||||||
|
AUDIO_SOURCE_VOICE_DOWNLINK = 3,
|
||||||
|
AUDIO_SOURCE_VOICE_CALL = 4,
|
||||||
|
AUDIO_SOURCE_MAX = AUDIO_SOURCE_VOICE_CALL
|
||||||
};
|
};
|
||||||
|
|
||||||
enum video_source {
|
enum video_source {
|
||||||
|
|||||||
@@ -1553,7 +1553,6 @@ size_t AudioFlinger::MixerThread::getOutputFrameCount()
|
|||||||
AudioFlinger::MixerThread::TrackBase::TrackBase(
|
AudioFlinger::MixerThread::TrackBase::TrackBase(
|
||||||
const sp<MixerThread>& mixerThread,
|
const sp<MixerThread>& mixerThread,
|
||||||
const sp<Client>& client,
|
const sp<Client>& client,
|
||||||
int streamType,
|
|
||||||
uint32_t sampleRate,
|
uint32_t sampleRate,
|
||||||
int format,
|
int format,
|
||||||
int channelCount,
|
int channelCount,
|
||||||
@@ -1563,7 +1562,6 @@ AudioFlinger::MixerThread::TrackBase::TrackBase(
|
|||||||
: RefBase(),
|
: RefBase(),
|
||||||
mMixerThread(mixerThread),
|
mMixerThread(mixerThread),
|
||||||
mClient(client),
|
mClient(client),
|
||||||
mStreamType(streamType),
|
|
||||||
mFrameCount(0),
|
mFrameCount(0),
|
||||||
mState(IDLE),
|
mState(IDLE),
|
||||||
mClientTid(-1),
|
mClientTid(-1),
|
||||||
@@ -1713,12 +1711,13 @@ AudioFlinger::MixerThread::Track::Track(
|
|||||||
int channelCount,
|
int channelCount,
|
||||||
int frameCount,
|
int frameCount,
|
||||||
const sp<IMemory>& sharedBuffer)
|
const sp<IMemory>& sharedBuffer)
|
||||||
: TrackBase(mixerThread, client, streamType, sampleRate, format, channelCount, frameCount, 0, sharedBuffer)
|
: TrackBase(mixerThread, client, sampleRate, format, channelCount, frameCount, 0, sharedBuffer)
|
||||||
{
|
{
|
||||||
mVolume[0] = 1.0f;
|
mVolume[0] = 1.0f;
|
||||||
mVolume[1] = 1.0f;
|
mVolume[1] = 1.0f;
|
||||||
mMute = false;
|
mMute = false;
|
||||||
mSharedBuffer = sharedBuffer;
|
mSharedBuffer = sharedBuffer;
|
||||||
|
mStreamType = streamType;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioFlinger::MixerThread::Track::~Track()
|
AudioFlinger::MixerThread::Track::~Track()
|
||||||
@@ -1902,15 +1901,15 @@ void AudioFlinger::MixerThread::Track::setVolume(float left, float right)
|
|||||||
AudioFlinger::MixerThread::RecordTrack::RecordTrack(
|
AudioFlinger::MixerThread::RecordTrack::RecordTrack(
|
||||||
const sp<MixerThread>& mixerThread,
|
const sp<MixerThread>& mixerThread,
|
||||||
const sp<Client>& client,
|
const sp<Client>& client,
|
||||||
int streamType,
|
int inputSource,
|
||||||
uint32_t sampleRate,
|
uint32_t sampleRate,
|
||||||
int format,
|
int format,
|
||||||
int channelCount,
|
int channelCount,
|
||||||
int frameCount,
|
int frameCount,
|
||||||
uint32_t flags)
|
uint32_t flags)
|
||||||
: TrackBase(mixerThread, client, streamType, sampleRate, format,
|
: TrackBase(mixerThread, client, sampleRate, format,
|
||||||
channelCount, frameCount, flags, 0),
|
channelCount, frameCount, flags, 0),
|
||||||
mOverflow(false)
|
mOverflow(false), mInputSource(inputSource)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2235,7 +2234,7 @@ status_t AudioFlinger::TrackHandle::onTransact(
|
|||||||
|
|
||||||
sp<IAudioRecord> AudioFlinger::openRecord(
|
sp<IAudioRecord> AudioFlinger::openRecord(
|
||||||
pid_t pid,
|
pid_t pid,
|
||||||
int streamType,
|
int inputSource,
|
||||||
uint32_t sampleRate,
|
uint32_t sampleRate,
|
||||||
int format,
|
int format,
|
||||||
int channelCount,
|
int channelCount,
|
||||||
@@ -2258,7 +2257,7 @@ sp<IAudioRecord> AudioFlinger::openRecord(
|
|||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uint32_t(streamType) >= AudioRecord::NUM_STREAM_TYPES) {
|
if (uint32_t(inputSource) >= AudioRecord::NUM_INPUT_SOURCES) {
|
||||||
LOGE("invalid stream type");
|
LOGE("invalid stream type");
|
||||||
lStatus = BAD_VALUE;
|
lStatus = BAD_VALUE;
|
||||||
goto Exit;
|
goto Exit;
|
||||||
@@ -2301,7 +2300,7 @@ sp<IAudioRecord> AudioFlinger::openRecord(
|
|||||||
frameCount = ((frameCount - 1)/inFrameCount + 1) * inFrameCount;
|
frameCount = ((frameCount - 1)/inFrameCount + 1) * inFrameCount;
|
||||||
|
|
||||||
// create new record track. The record track uses one track in mHardwareMixerThread by convention.
|
// create new record track. The record track uses one track in mHardwareMixerThread by convention.
|
||||||
recordTrack = new MixerThread::RecordTrack(mHardwareMixerThread, client, streamType, sampleRate,
|
recordTrack = new MixerThread::RecordTrack(mHardwareMixerThread, client, inputSource, sampleRate,
|
||||||
format, channelCount, frameCount, flags);
|
format, channelCount, frameCount, flags);
|
||||||
}
|
}
|
||||||
if (recordTrack->getCblk() == NULL) {
|
if (recordTrack->getCblk() == NULL) {
|
||||||
@@ -2408,7 +2407,7 @@ bool AudioFlinger::AudioRecordThread::threadLoop()
|
|||||||
LOGV("AudioRecordThread: loop starting");
|
LOGV("AudioRecordThread: loop starting");
|
||||||
if (mRecordTrack != 0) {
|
if (mRecordTrack != 0) {
|
||||||
input = mAudioHardware->openInputStream(
|
input = mAudioHardware->openInputStream(
|
||||||
mRecordTrack->type(),
|
mRecordTrack->inputSource(),
|
||||||
mRecordTrack->format(),
|
mRecordTrack->format(),
|
||||||
mRecordTrack->channelCount(),
|
mRecordTrack->channelCount(),
|
||||||
mRecordTrack->sampleRate(),
|
mRecordTrack->sampleRate(),
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public:
|
|||||||
// record interface
|
// record interface
|
||||||
virtual sp<IAudioRecord> openRecord(
|
virtual sp<IAudioRecord> openRecord(
|
||||||
pid_t pid,
|
pid_t pid,
|
||||||
int streamType,
|
int inputSource,
|
||||||
uint32_t sampleRate,
|
uint32_t sampleRate,
|
||||||
int format,
|
int format,
|
||||||
int channelCount,
|
int channelCount,
|
||||||
@@ -232,7 +232,6 @@ private:
|
|||||||
|
|
||||||
TrackBase(const sp<MixerThread>& mixerThread,
|
TrackBase(const sp<MixerThread>& mixerThread,
|
||||||
const sp<Client>& client,
|
const sp<Client>& client,
|
||||||
int streamType,
|
|
||||||
uint32_t sampleRate,
|
uint32_t sampleRate,
|
||||||
int format,
|
int format,
|
||||||
int channelCount,
|
int channelCount,
|
||||||
@@ -260,10 +259,6 @@ private:
|
|||||||
return mCblk;
|
return mCblk;
|
||||||
}
|
}
|
||||||
|
|
||||||
int type() const {
|
|
||||||
return mStreamType;
|
|
||||||
}
|
|
||||||
|
|
||||||
int format() const {
|
int format() const {
|
||||||
return mFormat;
|
return mFormat;
|
||||||
}
|
}
|
||||||
@@ -293,7 +288,6 @@ private:
|
|||||||
sp<Client> mClient;
|
sp<Client> mClient;
|
||||||
sp<IMemory> mCblkMemory;
|
sp<IMemory> mCblkMemory;
|
||||||
audio_track_cblk_t* mCblk;
|
audio_track_cblk_t* mCblk;
|
||||||
int mStreamType;
|
|
||||||
void* mBuffer;
|
void* mBuffer;
|
||||||
void* mBufferEnd;
|
void* mBufferEnd;
|
||||||
uint32_t mFrameCount;
|
uint32_t mFrameCount;
|
||||||
@@ -328,6 +322,11 @@ private:
|
|||||||
void mute(bool);
|
void mute(bool);
|
||||||
void setVolume(float left, float right);
|
void setVolume(float left, float right);
|
||||||
|
|
||||||
|
int type() const {
|
||||||
|
return mStreamType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class MixerThread;
|
friend class MixerThread;
|
||||||
friend class AudioFlinger;
|
friend class AudioFlinger;
|
||||||
@@ -364,6 +363,7 @@ private:
|
|||||||
int8_t mRetryCount;
|
int8_t mRetryCount;
|
||||||
sp<IMemory> mSharedBuffer;
|
sp<IMemory> mSharedBuffer;
|
||||||
bool mResetDone;
|
bool mResetDone;
|
||||||
|
int mStreamType;
|
||||||
}; // end of Track
|
}; // end of Track
|
||||||
|
|
||||||
// record track
|
// record track
|
||||||
@@ -371,7 +371,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
RecordTrack(const sp<MixerThread>& mixerThread,
|
RecordTrack(const sp<MixerThread>& mixerThread,
|
||||||
const sp<Client>& client,
|
const sp<Client>& client,
|
||||||
int streamType,
|
int inputSource,
|
||||||
uint32_t sampleRate,
|
uint32_t sampleRate,
|
||||||
int format,
|
int format,
|
||||||
int channelCount,
|
int channelCount,
|
||||||
@@ -385,6 +385,8 @@ private:
|
|||||||
bool overflow() { bool tmp = mOverflow; mOverflow = false; return tmp; }
|
bool overflow() { bool tmp = mOverflow; mOverflow = false; return tmp; }
|
||||||
bool setOverflow() { bool tmp = mOverflow; mOverflow = true; return tmp; }
|
bool setOverflow() { bool tmp = mOverflow; mOverflow = true; return tmp; }
|
||||||
|
|
||||||
|
int inputSource() const { return mInputSource; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class AudioFlinger;
|
friend class AudioFlinger;
|
||||||
friend class AudioFlinger::RecordHandle;
|
friend class AudioFlinger::RecordHandle;
|
||||||
@@ -397,6 +399,7 @@ private:
|
|||||||
virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer);
|
virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer);
|
||||||
|
|
||||||
bool mOverflow;
|
bool mOverflow;
|
||||||
|
int mInputSource;
|
||||||
};
|
};
|
||||||
|
|
||||||
// playback track
|
// playback track
|
||||||
|
|||||||
@@ -98,8 +98,8 @@ AudioStreamIn* AudioHardwareGeneric::openInputStream(
|
|||||||
status_t *status, AudioSystem::audio_in_acoustics acoustics)
|
status_t *status, AudioSystem::audio_in_acoustics acoustics)
|
||||||
{
|
{
|
||||||
// check for valid input source
|
// check for valid input source
|
||||||
if ((inputSource != AudioRecord::DEFAULT_INPUT) &&
|
if ((inputSource < AudioRecord::DEFAULT_INPUT) ||
|
||||||
(inputSource != AudioRecord::MIC_INPUT)) {
|
(inputSource >= AudioRecord::NUM_INPUT_SOURCES)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ AudioStreamIn* AudioHardwareStub::openInputStream(
|
|||||||
status_t *status, AudioSystem::audio_in_acoustics acoustics)
|
status_t *status, AudioSystem::audio_in_acoustics acoustics)
|
||||||
{
|
{
|
||||||
// check for valid input source
|
// check for valid input source
|
||||||
if ((inputSource != AudioRecord::DEFAULT_INPUT) &&
|
if ((inputSource < AudioRecord::DEFAULT_INPUT) ||
|
||||||
(inputSource != AudioRecord::MIC_INPUT)) {
|
(inputSource >= AudioRecord::NUM_INPUT_SOURCES)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class AudioRecord
|
|||||||
private static final int AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT = -16;
|
private static final int AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT = -16;
|
||||||
private static final int AUDIORECORD_ERROR_SETUP_INVALIDCHANNELCOUNT = -17;
|
private static final int AUDIORECORD_ERROR_SETUP_INVALIDCHANNELCOUNT = -17;
|
||||||
private static final int AUDIORECORD_ERROR_SETUP_INVALIDFORMAT = -18;
|
private static final int AUDIORECORD_ERROR_SETUP_INVALIDFORMAT = -18;
|
||||||
private static final int AUDIORECORD_ERROR_SETUP_INVALIDSTREAMTYPE = -19;
|
private static final int AUDIORECORD_ERROR_SETUP_INVALIDSOURCE = -19;
|
||||||
private static final int AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED = -20;
|
private static final int AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED = -20;
|
||||||
|
|
||||||
// Events:
|
// Events:
|
||||||
@@ -113,13 +113,7 @@ public class AudioRecord
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private int mNativeRecorderInJavaObj;
|
private int mNativeRecorderInJavaObj;
|
||||||
/**
|
|
||||||
* Accessed by native methods: provides access to record source constants
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private final static int SOURCE_DEFAULT = MediaRecorder.AudioSource.DEFAULT;
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private final static int SOURCE_MIC = MediaRecorder.AudioSource.MIC;
|
|
||||||
/**
|
/**
|
||||||
* Accessed by native methods: provides access to the callback data.
|
* Accessed by native methods: provides access to the callback data.
|
||||||
*/
|
*/
|
||||||
@@ -252,8 +246,8 @@ public class AudioRecord
|
|||||||
|
|
||||||
//--------------
|
//--------------
|
||||||
// audio source
|
// audio source
|
||||||
if ( (audioSource != MediaRecorder.AudioSource.DEFAULT)
|
if ( (audioSource < MediaRecorder.AudioSource.DEFAULT) ||
|
||||||
&& (audioSource != MediaRecorder.AudioSource.MIC) ) {
|
(audioSource > MediaRecorder.getAudioSourceMax()) ) {
|
||||||
throw (new IllegalArgumentException("Invalid audio source."));
|
throw (new IllegalArgumentException("Invalid audio source."));
|
||||||
} else {
|
} else {
|
||||||
mRecordSource = audioSource;
|
mRecordSource = audioSource;
|
||||||
|
|||||||
@@ -125,6 +125,15 @@ public class MediaRecorder
|
|||||||
public static final int DEFAULT = 0;
|
public static final int DEFAULT = 0;
|
||||||
/** Microphone audio source */
|
/** Microphone audio source */
|
||||||
public static final int MIC = 1;
|
public static final int MIC = 1;
|
||||||
|
|
||||||
|
/** Voice call uplink (Tx) audio source */
|
||||||
|
public static final int VOICE_UPLINK = 2;
|
||||||
|
|
||||||
|
/** Voice call downlink (Rx) audio source */
|
||||||
|
public static final int VOICE_DOWNLINK = 3;
|
||||||
|
|
||||||
|
/** Voice call uplink + downlink audio source */
|
||||||
|
public static final int VOICE_CALL = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -202,6 +211,12 @@ public class MediaRecorder
|
|||||||
public native void setAudioSource(int audio_source)
|
public native void setAudioSource(int audio_source)
|
||||||
throws IllegalStateException;
|
throws IllegalStateException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the maximum value for audio sources.
|
||||||
|
* @see android.media.MediaRecorder.AudioSource
|
||||||
|
*/
|
||||||
|
public static final int getAudioSourceMax() { return AudioSource.VOICE_CALL; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the video source to be used for recording. If this method is not
|
* Sets the video source to be used for recording. If this method is not
|
||||||
* called, the output file will not contain an video track. The source needs
|
* called, the output file will not contain an video track. The source needs
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ static void
|
|||||||
android_media_MediaRecorder_setAudioSource(JNIEnv *env, jobject thiz, jint as)
|
android_media_MediaRecorder_setAudioSource(JNIEnv *env, jobject thiz, jint as)
|
||||||
{
|
{
|
||||||
LOGV("setAudioSource(%d)", as);
|
LOGV("setAudioSource(%d)", as);
|
||||||
if (as < AUDIO_SOURCE_DEFAULT || as > AUDIO_SOURCE_MIC) {
|
if (as < AUDIO_SOURCE_DEFAULT || as > AUDIO_SOURCE_MAX) {
|
||||||
jniThrowException(env, "java/lang/IllegalArgumentException", "Invalid audio source");
|
jniThrowException(env, "java/lang/IllegalArgumentException", "Invalid audio source");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ AudioRecord::AudioRecord()
|
|||||||
}
|
}
|
||||||
|
|
||||||
AudioRecord::AudioRecord(
|
AudioRecord::AudioRecord(
|
||||||
int streamType,
|
int inputSource,
|
||||||
uint32_t sampleRate,
|
uint32_t sampleRate,
|
||||||
int format,
|
int format,
|
||||||
int channelCount,
|
int channelCount,
|
||||||
@@ -61,7 +61,7 @@ AudioRecord::AudioRecord(
|
|||||||
int notificationFrames)
|
int notificationFrames)
|
||||||
: mStatus(NO_INIT)
|
: mStatus(NO_INIT)
|
||||||
{
|
{
|
||||||
mStatus = set(streamType, sampleRate, format, channelCount,
|
mStatus = set(inputSource, sampleRate, format, channelCount,
|
||||||
frameCount, flags, cbf, user, notificationFrames);
|
frameCount, flags, cbf, user, notificationFrames);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ AudioRecord::~AudioRecord()
|
|||||||
}
|
}
|
||||||
|
|
||||||
status_t AudioRecord::set(
|
status_t AudioRecord::set(
|
||||||
int streamType,
|
int inputSource,
|
||||||
uint32_t sampleRate,
|
uint32_t sampleRate,
|
||||||
int format,
|
int format,
|
||||||
int channelCount,
|
int channelCount,
|
||||||
@@ -104,8 +104,8 @@ status_t AudioRecord::set(
|
|||||||
return NO_INIT;
|
return NO_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (streamType == DEFAULT_INPUT) {
|
if (inputSource == DEFAULT_INPUT) {
|
||||||
streamType = MIC_INPUT;
|
inputSource = MIC_INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sampleRate == 0) {
|
if (sampleRate == 0) {
|
||||||
@@ -157,7 +157,7 @@ status_t AudioRecord::set(
|
|||||||
|
|
||||||
// open record channel
|
// open record channel
|
||||||
status_t status;
|
status_t status;
|
||||||
sp<IAudioRecord> record = audioFlinger->openRecord(getpid(), streamType,
|
sp<IAudioRecord> record = audioFlinger->openRecord(getpid(), inputSource,
|
||||||
sampleRate, format,
|
sampleRate, format,
|
||||||
channelCount,
|
channelCount,
|
||||||
frameCount,
|
frameCount,
|
||||||
@@ -201,6 +201,7 @@ status_t AudioRecord::set(
|
|||||||
mMarkerReached = false;
|
mMarkerReached = false;
|
||||||
mNewPosition = 0;
|
mNewPosition = 0;
|
||||||
mUpdatePeriod = 0;
|
mUpdatePeriod = 0;
|
||||||
|
mInputSource = (uint8_t)inputSource;
|
||||||
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
@@ -242,6 +243,11 @@ int AudioRecord::frameSize() const
|
|||||||
return channelCount()*((format() == AudioSystem::PCM_8_BIT) ? sizeof(uint8_t) : sizeof(int16_t));
|
return channelCount()*((format() == AudioSystem::PCM_8_BIT) ? sizeof(uint8_t) : sizeof(int16_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AudioRecord::inputSource() const
|
||||||
|
{
|
||||||
|
return (int)mInputSource;
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
status_t AudioRecord::start()
|
status_t AudioRecord::start()
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public:
|
|||||||
|
|
||||||
virtual sp<IAudioRecord> openRecord(
|
virtual sp<IAudioRecord> openRecord(
|
||||||
pid_t pid,
|
pid_t pid,
|
||||||
int streamType,
|
int inputSource,
|
||||||
uint32_t sampleRate,
|
uint32_t sampleRate,
|
||||||
int format,
|
int format,
|
||||||
int channelCount,
|
int channelCount,
|
||||||
@@ -110,7 +110,7 @@ public:
|
|||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
|
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
|
||||||
data.writeInt32(pid);
|
data.writeInt32(pid);
|
||||||
data.writeInt32(streamType);
|
data.writeInt32(inputSource);
|
||||||
data.writeInt32(sampleRate);
|
data.writeInt32(sampleRate);
|
||||||
data.writeInt32(format);
|
data.writeInt32(format);
|
||||||
data.writeInt32(channelCount);
|
data.writeInt32(channelCount);
|
||||||
@@ -384,14 +384,14 @@ status_t BnAudioFlinger::onTransact(
|
|||||||
case OPEN_RECORD: {
|
case OPEN_RECORD: {
|
||||||
CHECK_INTERFACE(IAudioFlinger, data, reply);
|
CHECK_INTERFACE(IAudioFlinger, data, reply);
|
||||||
pid_t pid = data.readInt32();
|
pid_t pid = data.readInt32();
|
||||||
int streamType = data.readInt32();
|
int inputSource = data.readInt32();
|
||||||
uint32_t sampleRate = data.readInt32();
|
uint32_t sampleRate = data.readInt32();
|
||||||
int format = data.readInt32();
|
int format = data.readInt32();
|
||||||
int channelCount = data.readInt32();
|
int channelCount = data.readInt32();
|
||||||
size_t bufferCount = data.readInt32();
|
size_t bufferCount = data.readInt32();
|
||||||
uint32_t flags = data.readInt32();
|
uint32_t flags = data.readInt32();
|
||||||
status_t status;
|
status_t status;
|
||||||
sp<IAudioRecord> record = openRecord(pid, streamType,
|
sp<IAudioRecord> record = openRecord(pid, inputSource,
|
||||||
sampleRate, format, channelCount, bufferCount, flags, &status);
|
sampleRate, format, channelCount, bufferCount, flags, &status);
|
||||||
reply->writeInt32(status);
|
reply->writeInt32(status);
|
||||||
reply->writeStrongBinder(record->asBinder());
|
reply->writeStrongBinder(record->asBinder());
|
||||||
|
|||||||
Reference in New Issue
Block a user