summaryrefslogtreecommitdiffstats
path: root/media/libmedia
diff options
context:
space:
mode:
Diffstat (limited to 'media/libmedia')
-rw-r--r--media/libmedia/AudioRecord.cpp18
-rw-r--r--media/libmedia/AudioSystem.cpp103
-rw-r--r--media/libmedia/AudioTrack.cpp15
-rw-r--r--media/libmedia/IAudioFlinger.cpp47
-rw-r--r--media/libmedia/IAudioFlingerClient.cpp12
-rw-r--r--media/libmedia/IMediaRecorder.cpp29
-rw-r--r--media/libmedia/JetPlayer.cpp2
-rw-r--r--media/libmedia/ToneGenerator.cpp8
-rw-r--r--media/libmedia/mediaplayer.cpp2
-rw-r--r--media/libmedia/mediarecorder.cpp32
10 files changed, 179 insertions, 89 deletions
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index a987b92..3d39181 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -128,22 +128,8 @@ status_t AudioRecord::set(
return BAD_VALUE;
}
- size_t inputBuffSizeInBytes = -1;
- if (AudioSystem::getInputBufferSize(sampleRate, format, channelCount, &inputBuffSizeInBytes)
- != NO_ERROR) {
- LOGE("AudioSystem could not query the input buffer size.");
- return NO_INIT;
- }
- if (inputBuffSizeInBytes == 0) {
- LOGE("Recording parameters are not supported: sampleRate %d, channelCount %d, format %d",
- sampleRate, channelCount, format);
- return BAD_VALUE;
- }
- int frameSizeInBytes = channelCount * (format == AudioSystem::PCM_16_BIT ? 2 : 1);
-
- // We use 2* size of input buffer for ping pong use of record buffer.
- int minFrameCount = 2 * inputBuffSizeInBytes / frameSizeInBytes;
- LOGV("AudioRecord::set() minFrameCount = %d", minFrameCount);
+ // TODO: Get input frame count from hardware.
+ int minFrameCount = 1024*2;
if (frameCount == 0) {
frameCount = minFrameCount;
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index cf91105..63dfc3b 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -20,7 +20,6 @@
#include <utils/Log.h>
#include <utils/IServiceManager.h>
#include <media/AudioSystem.h>
-#include <media/AudioTrack.h>
#include <math.h>
namespace android {
@@ -31,9 +30,10 @@ sp<IAudioFlinger> AudioSystem::gAudioFlinger;
sp<AudioSystem::AudioFlingerClient> AudioSystem::gAudioFlingerClient;
audio_error_callback AudioSystem::gAudioErrorCallback = NULL;
// Cached values
-int AudioSystem::gOutSamplingRate = 0;
-int AudioSystem::gOutFrameCount = 0;
-uint32_t AudioSystem::gOutLatency = 0;
+int AudioSystem::gOutSamplingRate[NUM_AUDIO_OUTPUT_TYPES];
+int AudioSystem::gOutFrameCount[NUM_AUDIO_OUTPUT_TYPES];
+uint32_t AudioSystem::gOutLatency[NUM_AUDIO_OUTPUT_TYPES];
+bool AudioSystem::gA2dpEnabled;
// Cached values for recording queries
uint32_t AudioSystem::gPrevInSamplingRate = 16000;
int AudioSystem::gPrevInFormat = AudioSystem::PCM_16_BIT;
@@ -66,9 +66,12 @@ const sp<IAudioFlinger>& AudioSystem::get_audio_flinger()
gAudioFlinger = interface_cast<IAudioFlinger>(binder);
gAudioFlinger->registerClient(gAudioFlingerClient);
// Cache frequently accessed parameters
- gOutFrameCount = (int)gAudioFlinger->frameCount();
- gOutSamplingRate = (int)gAudioFlinger->sampleRate();
- gOutLatency = gAudioFlinger->latency();
+ for (int output = 0; output < NUM_AUDIO_OUTPUT_TYPES; output++) {
+ gOutFrameCount[output] = (int)gAudioFlinger->frameCount(output);
+ gOutSamplingRate[output] = (int)gAudioFlinger->sampleRate(output);
+ gOutLatency[output] = gAudioFlinger->latency(output);
+ }
+ gA2dpEnabled = gAudioFlinger->isA2dpEnabled();
}
LOGE_IF(gAudioFlinger==0, "no AudioFlinger!?");
return gAudioFlinger;
@@ -147,7 +150,7 @@ status_t AudioSystem::getMasterMute(bool* mute)
status_t AudioSystem::setStreamVolume(int stream, float value)
{
- if (uint32_t(stream) >= AudioTrack::NUM_STREAM_TYPES) return BAD_VALUE;
+ if (uint32_t(stream) >= NUM_STREAM_TYPES) return BAD_VALUE;
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) return PERMISSION_DENIED;
af->setStreamVolume(stream, value);
@@ -156,7 +159,7 @@ status_t AudioSystem::setStreamVolume(int stream, float value)
status_t AudioSystem::setStreamMute(int stream, bool mute)
{
- if (uint32_t(stream) >= AudioTrack::NUM_STREAM_TYPES) return BAD_VALUE;
+ if (uint32_t(stream) >= NUM_STREAM_TYPES) return BAD_VALUE;
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) return PERMISSION_DENIED;
af->setStreamMute(stream, mute);
@@ -165,7 +168,7 @@ status_t AudioSystem::setStreamMute(int stream, bool mute)
status_t AudioSystem::getStreamVolume(int stream, float* volume)
{
- if (uint32_t(stream) >= AudioTrack::NUM_STREAM_TYPES) return BAD_VALUE;
+ if (uint32_t(stream) >= NUM_STREAM_TYPES) return BAD_VALUE;
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) return PERMISSION_DENIED;
*volume = af->streamVolume(stream);
@@ -174,7 +177,7 @@ status_t AudioSystem::getStreamVolume(int stream, float* volume)
status_t AudioSystem::getStreamMute(int stream, bool* mute)
{
- if (uint32_t(stream) >= AudioTrack::NUM_STREAM_TYPES) return BAD_VALUE;
+ if (uint32_t(stream) >= NUM_STREAM_TYPES) return BAD_VALUE;
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) return PERMISSION_DENIED;
*mute = af->streamMute(stream);
@@ -252,37 +255,48 @@ int AudioSystem::logToLinear(float volume)
return volume ? 100 - int(dBConvertInverse * log(volume) + 0.5) : 0;
}
-status_t AudioSystem::getOutputSamplingRate(int* samplingRate)
+status_t AudioSystem::getOutputSamplingRate(int* samplingRate, int streamType)
{
- if (gOutSamplingRate == 0) {
+ int output = getOutput(streamType);
+
+ if (gOutSamplingRate[output] == 0) {
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) return PERMISSION_DENIED;
// gOutSamplingRate is updated by get_audio_flinger()
}
- *samplingRate = gOutSamplingRate;
+ LOGV("getOutputSamplingRate() streamType %d, output %d, sampling rate %d", streamType, output, gOutSamplingRate[output]);
+ *samplingRate = gOutSamplingRate[output];
return NO_ERROR;
}
-status_t AudioSystem::getOutputFrameCount(int* frameCount)
+status_t AudioSystem::getOutputFrameCount(int* frameCount, int streamType)
{
- if (gOutFrameCount == 0) {
+ int output = getOutput(streamType);
+
+ if (gOutFrameCount[output] == 0) {
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) return PERMISSION_DENIED;
// gOutFrameCount is updated by get_audio_flinger()
}
- *frameCount = gOutFrameCount;
+ LOGV("getOutputFrameCount() streamType %d, output %d, frame count %d", streamType, output, gOutFrameCount[output]);
+
+ *frameCount = gOutFrameCount[output];
return NO_ERROR;
}
-status_t AudioSystem::getOutputLatency(uint32_t* latency)
+status_t AudioSystem::getOutputLatency(uint32_t* latency, int streamType)
{
- if (gOutLatency == 0) {
+ int output = getOutput(streamType);
+
+ if (gOutLatency[output] == 0) {
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) return PERMISSION_DENIED;
// gOutLatency is updated by get_audio_flinger()
- }
- *latency = gOutLatency;
+ }
+ LOGV("getOutputLatency() streamType %d, output %d, latency %d", streamType, output, gOutLatency[output]);
+
+ *latency = gOutLatency[output];
return NO_ERROR;
}
@@ -315,24 +329,23 @@ status_t AudioSystem::getInputBufferSize(uint32_t sampleRate, int format, int ch
void AudioSystem::AudioFlingerClient::binderDied(const wp<IBinder>& who) {
Mutex::Autolock _l(AudioSystem::gLock);
AudioSystem::gAudioFlinger.clear();
- AudioSystem::gOutSamplingRate = 0;
- AudioSystem::gOutFrameCount = 0;
- AudioSystem::gOutLatency = 0;
+
+ for (int output = 0; output < NUM_AUDIO_OUTPUT_TYPES; output++) {
+ gOutFrameCount[output] = 0;
+ gOutSamplingRate[output] = 0;
+ gOutLatency[output] = 0;
+ }
AudioSystem::gInBuffSize = 0;
-
+
if (gAudioErrorCallback) {
gAudioErrorCallback(DEAD_OBJECT);
}
LOGW("AudioFlinger server died!");
}
-void AudioSystem::AudioFlingerClient::audioOutputChanged(uint32_t frameCount, uint32_t samplingRate, uint32_t latency) {
-
- AudioSystem::gOutFrameCount = frameCount;
- AudioSystem::gOutSamplingRate = samplingRate;
- AudioSystem::gOutLatency = latency;
-
- LOGV("AudioFlinger output changed!");
+void AudioSystem::AudioFlingerClient::a2dpEnabledChanged(bool enabled) {
+ gA2dpEnabled = enabled;
+ LOGV("AudioFlinger A2DP enabled status changed! %d", enabled);
}
void AudioSystem::setErrorCallback(audio_error_callback cb) {
@@ -340,5 +353,31 @@ void AudioSystem::setErrorCallback(audio_error_callback cb) {
gAudioErrorCallback = cb;
}
+int AudioSystem::getOutput(int streamType)
+{
+ if (streamType == DEFAULT) {
+ streamType = MUSIC;
+ }
+ if (gA2dpEnabled && routedToA2dpOutput(streamType)) {
+ return AUDIO_OUTPUT_A2DP;
+ } else {
+ return AUDIO_OUTPUT_HARDWARE;
+ }
+}
+
+bool AudioSystem::routedToA2dpOutput(int streamType) {
+ switch(streamType) {
+ case MUSIC:
+ case VOICE_CALL:
+ case BLUETOOTH_SCO:
+ case SYSTEM:
+ return true;
+ default:
+ return false;
+ }
+}
+
+
+
}; // namespace android
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 63b2012..1ffad46 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -128,22 +128,21 @@ status_t AudioTrack::set(
return NO_INIT;
}
int afSampleRate;
- if (AudioSystem::getOutputSamplingRate(&afSampleRate) != NO_ERROR) {
+ if (AudioSystem::getOutputSamplingRate(&afSampleRate, streamType) != NO_ERROR) {
return NO_INIT;
}
int afFrameCount;
- if (AudioSystem::getOutputFrameCount(&afFrameCount) != NO_ERROR) {
+ if (AudioSystem::getOutputFrameCount(&afFrameCount, streamType) != NO_ERROR) {
return NO_INIT;
}
uint32_t afLatency;
- if (AudioSystem::getOutputLatency(&afLatency) != NO_ERROR) {
+ if (AudioSystem::getOutputLatency(&afLatency, streamType) != NO_ERROR) {
return NO_INIT;
}
-
// handle default values first.
- if (streamType == DEFAULT) {
- streamType = MUSIC;
+ if (streamType == AudioSystem::DEFAULT) {
+ streamType = AudioSystem::MUSIC;
}
if (sampleRate == 0) {
sampleRate = afSampleRate;
@@ -260,7 +259,7 @@ status_t AudioTrack::set(
mMarkerPosition = 0;
mNewPosition = 0;
mUpdatePeriod = 0;
-
+
return NO_ERROR;
}
@@ -434,7 +433,7 @@ void AudioTrack::setSampleRate(int rate)
{
int afSamplingRate;
- if (AudioSystem::getOutputSamplingRate(&afSamplingRate) != NO_ERROR) {
+ if (AudioSystem::getOutputSamplingRate(&afSamplingRate, mStreamType) != NO_ERROR) {
return;
}
// Resampler implementation limits input sampling rate to 2 x output sampling rate.
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp
index 4215820..5cbb25c 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libmedia/IAudioFlinger.cpp
@@ -53,7 +53,8 @@ enum {
SET_PARAMETER,
REGISTER_CLIENT,
GET_INPUTBUFFERSIZE,
- WAKE_UP
+ WAKE_UP,
+ IS_A2DP_ENABLED
};
class BpAudioFlinger : public BpInterface<IAudioFlinger>
@@ -123,42 +124,47 @@ public:
return interface_cast<IAudioRecord>(reply.readStrongBinder());
}
- virtual uint32_t sampleRate() const
+ virtual uint32_t sampleRate(int output) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
+ data.writeInt32(output);
remote()->transact(SAMPLE_RATE, data, &reply);
return reply.readInt32();
}
- virtual int channelCount() const
+ virtual int channelCount(int output) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
+ data.writeInt32(output);
remote()->transact(CHANNEL_COUNT, data, &reply);
return reply.readInt32();
}
- virtual int format() const
+ virtual int format(int output) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
+ data.writeInt32(output);
remote()->transact(FORMAT, data, &reply);
return reply.readInt32();
}
- virtual size_t frameCount() const
+ virtual size_t frameCount(int output) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
+ data.writeInt32(output);
remote()->transact(FRAME_COUNT, data, &reply);
return reply.readInt32();
}
- virtual uint32_t latency() const
+ virtual uint32_t latency(int output) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
+ data.writeInt32(output);
remote()->transact(LATENCY, data, &reply);
return reply.readInt32();
}
@@ -333,6 +339,14 @@ public:
remote()->transact(WAKE_UP, data, &reply);
return;
}
+
+ virtual bool isA2dpEnabled() const
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
+ remote()->transact(IS_A2DP_ENABLED, data, &reply);
+ return (bool)reply.readInt32();
+ }
};
IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger");
@@ -385,27 +399,32 @@ status_t BnAudioFlinger::onTransact(
} break;
case SAMPLE_RATE: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- reply->writeInt32( sampleRate() );
+ int output = data.readInt32();
+ reply->writeInt32( sampleRate(output) );
return NO_ERROR;
} break;
case CHANNEL_COUNT: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- reply->writeInt32( channelCount() );
+ int output = data.readInt32();
+ reply->writeInt32( channelCount(output) );
return NO_ERROR;
} break;
case FORMAT: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- reply->writeInt32( format() );
+ int output = data.readInt32();
+ reply->writeInt32( format(output) );
return NO_ERROR;
} break;
case FRAME_COUNT: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- reply->writeInt32( frameCount() );
+ int output = data.readInt32();
+ reply->writeInt32( frameCount(output) );
return NO_ERROR;
} break;
case LATENCY: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- reply->writeInt32( latency() );
+ int output = data.readInt32();
+ reply->writeInt32( latency(output) );
return NO_ERROR;
} break;
case SET_MASTER_VOLUME: {
@@ -519,7 +538,11 @@ status_t BnAudioFlinger::onTransact(
wakeUp();
return NO_ERROR;
} break;
-
+ case IS_A2DP_ENABLED: {
+ CHECK_INTERFACE(IAudioFlinger, data, reply);
+ reply->writeInt32( (int)isA2dpEnabled() );
+ return NO_ERROR;
+ } break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
diff --git a/media/libmedia/IAudioFlingerClient.cpp b/media/libmedia/IAudioFlingerClient.cpp
index d956266..5feb11f 100644
--- a/media/libmedia/IAudioFlingerClient.cpp
+++ b/media/libmedia/IAudioFlingerClient.cpp
@@ -38,13 +38,11 @@ public:
{
}
- void audioOutputChanged(uint32_t frameCount, uint32_t samplingRate, uint32_t latency)
+ void a2dpEnabledChanged(bool enabled)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlingerClient::getInterfaceDescriptor());
- data.writeInt32(frameCount);
- data.writeInt32(samplingRate);
- data.writeInt32(latency);
+ data.writeInt32((int)enabled);
remote()->transact(AUDIO_OUTPUT_CHANGED, data, &reply);
}
};
@@ -65,10 +63,8 @@ status_t BnAudioFlingerClient::onTransact(
switch(code) {
case AUDIO_OUTPUT_CHANGED: {
CHECK_INTERFACE(IAudioFlingerClient, data, reply);
- uint32_t frameCount = data.readInt32();
- uint32_t samplingRate = data.readInt32();
- uint32_t latency = data.readInt32();
- audioOutputChanged(frameCount, samplingRate, latency);
+ bool enabled = (bool)data.readInt32();
+ a2dpEnabledChanged(enabled);
return NO_ERROR;
} break;
default:
diff --git a/media/libmedia/IMediaRecorder.cpp b/media/libmedia/IMediaRecorder.cpp
index 1f6d599..507d03e 100644
--- a/media/libmedia/IMediaRecorder.cpp
+++ b/media/libmedia/IMediaRecorder.cpp
@@ -39,7 +39,8 @@ enum {
SET_OUTPUT_FORMAT,
SET_VIDEO_ENCODER,
SET_AUDIO_ENCODER,
- SET_OUTPUT_FILE,
+ SET_OUTPUT_FILE_PATH,
+ SET_OUTPUT_FILE_FD,
SET_VIDEO_SIZE,
SET_VIDEO_FRAMERATE,
SET_PREVIEW_SURFACE,
@@ -139,7 +140,18 @@ public:
Parcel data, reply;
data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
data.writeCString(path);
- remote()->transact(SET_OUTPUT_FILE, data, &reply);
+ remote()->transact(SET_OUTPUT_FILE_PATH, data, &reply);
+ return reply.readInt32();
+ }
+
+ status_t setOutputFile(int fd, int64_t offset, int64_t length) {
+ LOGV("setOutputFile(%d, %lld, %lld)", fd, offset, length);
+ Parcel data, reply;
+ data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
+ data.writeFileDescriptor(fd);
+ data.writeInt64(offset);
+ data.writeInt64(length);
+ remote()->transact(SET_OUTPUT_FILE_FD, data, &reply);
return reply.readInt32();
}
@@ -330,13 +342,22 @@ status_t BnMediaRecorder::onTransact(
return NO_ERROR;
} break;
- case SET_OUTPUT_FILE: {
- LOGV("SET_OUTPUT_FILE");
+ case SET_OUTPUT_FILE_PATH: {
+ LOGV("SET_OUTPUT_FILE_PATH");
CHECK_INTERFACE(IMediaRecorder, data, reply);
const char* path = data.readCString();
reply->writeInt32(setOutputFile(path));
return NO_ERROR;
} break;
+ case SET_OUTPUT_FILE_FD: {
+ LOGV("SET_OUTPUT_FILE_FD");
+ CHECK_INTERFACE(IMediaRecorder, data, reply);
+ int fd = dup(data.readFileDescriptor());
+ int64_t offset = data.readInt64();
+ int64_t length = data.readInt64();
+ reply->writeInt32(setOutputFile(fd, offset, length));
+ return NO_ERROR;
+ } break;
case SET_VIDEO_SIZE: {
LOGV("SET_VIDEO_SIZE");
CHECK_INTERFACE(IMediaRecorder, data, reply);
diff --git a/media/libmedia/JetPlayer.cpp b/media/libmedia/JetPlayer.cpp
index ead24d4..9bd75c2 100644
--- a/media/libmedia/JetPlayer.cpp
+++ b/media/libmedia/JetPlayer.cpp
@@ -96,7 +96,7 @@ int JetPlayer::init()
// create the output AudioTrack
mAudioTrack = new AudioTrack();
- mAudioTrack->set(AudioTrack::MUSIC, //TODO parametrize this
+ mAudioTrack->set(AudioSystem::MUSIC, //TODO parametrize this
pLibConfig->sampleRate,
1, // format = PCM 16bits per sample,
pLibConfig->numChannels,
diff --git a/media/libmedia/ToneGenerator.cpp b/media/libmedia/ToneGenerator.cpp
index fa36460..7fafc56 100644
--- a/media/libmedia/ToneGenerator.cpp
+++ b/media/libmedia/ToneGenerator.cpp
@@ -93,7 +93,7 @@ ToneGenerator::ToneGenerator(int streamType, float volume) {
mState = TONE_IDLE;
- if (AudioSystem::getOutputSamplingRate(&mSamplingRate) != NO_ERROR) {
+ if (AudioSystem::getOutputSamplingRate(&mSamplingRate, streamType) != NO_ERROR) {
LOGE("Unable to marshal AudioFlinger");
return;
}
@@ -182,7 +182,7 @@ bool ToneGenerator::startTone(int toneType) {
mLock.lock();
if (mState == TONE_STARTING) {
if (mWaitCbkCond.waitRelative(mLock, seconds(1)) != NO_ERROR) {
- LOGE("--- timed out");
+ LOGE("--- Immediate start timed out");
mState = TONE_IDLE;
}
}
@@ -200,7 +200,7 @@ bool ToneGenerator::startTone(int toneType) {
}
LOGV("cond received");
} else {
- LOGE("--- timed out");
+ LOGE("--- Delayed start timed out");
mState = TONE_IDLE;
}
}
@@ -235,7 +235,7 @@ void ToneGenerator::stopTone() {
if (lStatus == NO_ERROR) {
LOGV("track stop complete, time %d", (unsigned int)(systemTime()/1000000));
} else {
- LOGE("--- timed out");
+ LOGE("--- Stop timed out");
mState = TONE_IDLE;
mpAudioTrack->stop();
}
diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp
index 31ff507..bd8579c 100644
--- a/media/libmedia/mediaplayer.cpp
+++ b/media/libmedia/mediaplayer.cpp
@@ -82,7 +82,7 @@ MediaPlayer::MediaPlayer()
mListener = NULL;
mCookie = NULL;
mDuration = -1;
- mStreamType = AudioTrack::MUSIC;
+ mStreamType = AudioSystem::MUSIC;
mCurrentPosition = -1;
mSeekPosition = -1;
mCurrentState = MEDIA_PLAYER_IDLE;
diff --git a/media/libmedia/mediarecorder.cpp b/media/libmedia/mediarecorder.cpp
index 6ee4c0d..4ab26ac 100644
--- a/media/libmedia/mediarecorder.cpp
+++ b/media/libmedia/mediarecorder.cpp
@@ -248,7 +248,33 @@ status_t MediaRecorder::setOutputFile(const char* path)
status_t ret = mMediaRecorder->setOutputFile(path);
if (OK != ret) {
- LOGV("setAudioEncoder failed: %d", ret);
+ LOGV("setOutputFile failed: %d", ret);
+ mCurrentState = MEDIA_RECORDER_ERROR;
+ return UNKNOWN_ERROR;
+ }
+ mIsOutputFileSet = true;
+ return ret;
+}
+
+status_t MediaRecorder::setOutputFile(int fd, int64_t offset, int64_t length)
+{
+ LOGV("setOutputFile(%d, %lld, %lld)", fd, offset, length);
+ if(mMediaRecorder == NULL) {
+ LOGE("media recorder is not initialized yet");
+ return INVALID_OPERATION;
+ }
+ if (mIsOutputFileSet) {
+ LOGE("output file has already been set");
+ return INVALID_OPERATION;
+ }
+ if (!(mCurrentState & MEDIA_RECORDER_DATASOURCE_CONFIGURED)) {
+ LOGE("setOutputFile called in an invalid state(%d)", mCurrentState);
+ return INVALID_OPERATION;
+ }
+
+ status_t ret = mMediaRecorder->setOutputFile(fd, offset, length);
+ if (OK != ret) {
+ LOGV("setOutputFile failed: %d", ret);
mCurrentState = MEDIA_RECORDER_ERROR;
return UNKNOWN_ERROR;
}
@@ -306,7 +332,7 @@ status_t MediaRecorder::prepare()
return INVALID_OPERATION;
}
if (!(mCurrentState & MEDIA_RECORDER_DATASOURCE_CONFIGURED)) {
- LOGE("setVideoFrameRate called in an invalid state: %d", mCurrentState);
+ LOGE("prepare called in an invalid state: %d", mCurrentState);
return INVALID_OPERATION;
}
@@ -328,7 +354,7 @@ status_t MediaRecorder::getMaxAmplitude(int* max)
return INVALID_OPERATION;
}
if (mCurrentState & MEDIA_RECORDER_ERROR) {
- LOGE("setVideoFrameRate called in an invalid state: %d", mCurrentState);
+ LOGE("getMaxAmplitude called in an invalid state: %d", mCurrentState);
return INVALID_OPERATION;
}