Merge change 24337 into eclair
* changes: Fix issue 2107584: media server crash when AudioFlinger fails to allocate memory for track control block.
This commit is contained in:
@@ -2014,6 +2014,7 @@ AudioFlinger::ThreadBase::TrackBase::TrackBase(
|
|||||||
: RefBase(),
|
: RefBase(),
|
||||||
mThread(thread),
|
mThread(thread),
|
||||||
mClient(client),
|
mClient(client),
|
||||||
|
mCblk(0),
|
||||||
mFrameCount(0),
|
mFrameCount(0),
|
||||||
mState(IDLE),
|
mState(IDLE),
|
||||||
mClientTid(-1),
|
mClientTid(-1),
|
||||||
@@ -2162,21 +2163,23 @@ AudioFlinger::PlaybackThread::Track::Track(
|
|||||||
: TrackBase(thread, client, sampleRate, format, channelCount, frameCount, 0, sharedBuffer),
|
: TrackBase(thread, client, sampleRate, format, channelCount, frameCount, 0, sharedBuffer),
|
||||||
mMute(false), mSharedBuffer(sharedBuffer), mName(-1)
|
mMute(false), mSharedBuffer(sharedBuffer), mName(-1)
|
||||||
{
|
{
|
||||||
sp<ThreadBase> baseThread = thread.promote();
|
if (mCblk != NULL) {
|
||||||
if (baseThread != 0) {
|
sp<ThreadBase> baseThread = thread.promote();
|
||||||
PlaybackThread *playbackThread = (PlaybackThread *)baseThread.get();
|
if (baseThread != 0) {
|
||||||
mName = playbackThread->getTrackName_l();
|
PlaybackThread *playbackThread = (PlaybackThread *)baseThread.get();
|
||||||
|
mName = playbackThread->getTrackName_l();
|
||||||
|
}
|
||||||
|
LOGV("Track constructor name %d, calling thread %d", mName, IPCThreadState::self()->getCallingPid());
|
||||||
|
if (mName < 0) {
|
||||||
|
LOGE("no more track names available");
|
||||||
|
}
|
||||||
|
mVolume[0] = 1.0f;
|
||||||
|
mVolume[1] = 1.0f;
|
||||||
|
mStreamType = streamType;
|
||||||
|
// NOTE: audio_track_cblk_t::frameSize for 8 bit PCM data is based on a sample size of
|
||||||
|
// 16 bit because data is converted to 16 bit before being stored in buffer by AudioTrack
|
||||||
|
mCblk->frameSize = AudioSystem::isLinearPCM(format) ? channelCount * sizeof(int16_t) : sizeof(int8_t);
|
||||||
}
|
}
|
||||||
LOGV("Track constructor name %d, calling thread %d", mName, IPCThreadState::self()->getCallingPid());
|
|
||||||
if (mName < 0) {
|
|
||||||
LOGE("no more track names available");
|
|
||||||
}
|
|
||||||
mVolume[0] = 1.0f;
|
|
||||||
mVolume[1] = 1.0f;
|
|
||||||
mStreamType = streamType;
|
|
||||||
// NOTE: audio_track_cblk_t::frameSize for 8 bit PCM data is based on a sample size of
|
|
||||||
// 16 bit because data is converted to 16 bit before being stored in buffer by AudioTrack
|
|
||||||
mCblk->frameSize = AudioSystem::isLinearPCM(format) ? channelCount * sizeof(int16_t) : sizeof(int8_t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioFlinger::PlaybackThread::Track::~Track()
|
AudioFlinger::PlaybackThread::Track::~Track()
|
||||||
@@ -2390,14 +2393,16 @@ AudioFlinger::RecordThread::RecordTrack::RecordTrack(
|
|||||||
channelCount, frameCount, flags, 0),
|
channelCount, frameCount, flags, 0),
|
||||||
mOverflow(false)
|
mOverflow(false)
|
||||||
{
|
{
|
||||||
LOGV("RecordTrack constructor, size %d", (int)mBufferEnd - (int)mBuffer);
|
if (mCblk != NULL) {
|
||||||
if (format == AudioSystem::PCM_16_BIT) {
|
LOGV("RecordTrack constructor, size %d", (int)mBufferEnd - (int)mBuffer);
|
||||||
mCblk->frameSize = channelCount * sizeof(int16_t);
|
if (format == AudioSystem::PCM_16_BIT) {
|
||||||
} else if (format == AudioSystem::PCM_8_BIT) {
|
mCblk->frameSize = channelCount * sizeof(int16_t);
|
||||||
mCblk->frameSize = channelCount * sizeof(int8_t);
|
} else if (format == AudioSystem::PCM_8_BIT) {
|
||||||
} else {
|
mCblk->frameSize = channelCount * sizeof(int8_t);
|
||||||
mCblk->frameSize = sizeof(int8_t);
|
} else {
|
||||||
}
|
mCblk->frameSize = sizeof(int8_t);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioFlinger::RecordThread::RecordTrack::~RecordTrack()
|
AudioFlinger::RecordThread::RecordTrack::~RecordTrack()
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ public:
|
|||||||
status_t *status)
|
status_t *status)
|
||||||
{
|
{
|
||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
|
sp<IAudioTrack> track;
|
||||||
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
|
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
|
||||||
data.writeInt32(pid);
|
data.writeInt32(pid);
|
||||||
data.writeInt32(streamType);
|
data.writeInt32(streamType);
|
||||||
@@ -96,12 +97,14 @@ public:
|
|||||||
status_t lStatus = remote()->transact(CREATE_TRACK, data, &reply);
|
status_t lStatus = remote()->transact(CREATE_TRACK, data, &reply);
|
||||||
if (lStatus != NO_ERROR) {
|
if (lStatus != NO_ERROR) {
|
||||||
LOGE("createTrack error: %s", strerror(-lStatus));
|
LOGE("createTrack error: %s", strerror(-lStatus));
|
||||||
|
} else {
|
||||||
|
lStatus = reply.readInt32();
|
||||||
|
track = interface_cast<IAudioTrack>(reply.readStrongBinder());
|
||||||
}
|
}
|
||||||
lStatus = reply.readInt32();
|
|
||||||
if (status) {
|
if (status) {
|
||||||
*status = lStatus;
|
*status = lStatus;
|
||||||
}
|
}
|
||||||
return interface_cast<IAudioTrack>(reply.readStrongBinder());
|
return track;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual sp<IAudioRecord> openRecord(
|
virtual sp<IAudioRecord> openRecord(
|
||||||
@@ -115,6 +118,7 @@ public:
|
|||||||
status_t *status)
|
status_t *status)
|
||||||
{
|
{
|
||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
|
sp<IAudioRecord> record;
|
||||||
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
|
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
|
||||||
data.writeInt32(pid);
|
data.writeInt32(pid);
|
||||||
data.writeInt32(input);
|
data.writeInt32(input);
|
||||||
@@ -123,12 +127,17 @@ public:
|
|||||||
data.writeInt32(channelCount);
|
data.writeInt32(channelCount);
|
||||||
data.writeInt32(frameCount);
|
data.writeInt32(frameCount);
|
||||||
data.writeInt32(flags);
|
data.writeInt32(flags);
|
||||||
remote()->transact(OPEN_RECORD, data, &reply);
|
status_t lStatus = remote()->transact(OPEN_RECORD, data, &reply);
|
||||||
status_t lStatus = reply.readInt32();
|
if (lStatus != NO_ERROR) {
|
||||||
|
LOGE("openRecord error: %s", strerror(-lStatus));
|
||||||
|
} else {
|
||||||
|
lStatus = reply.readInt32();
|
||||||
|
record = interface_cast<IAudioRecord>(reply.readStrongBinder());
|
||||||
|
}
|
||||||
if (status) {
|
if (status) {
|
||||||
*status = lStatus;
|
*status = lStatus;
|
||||||
}
|
}
|
||||||
return interface_cast<IAudioRecord>(reply.readStrongBinder());
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual uint32_t sampleRate(int output) const
|
virtual uint32_t sampleRate(int output) const
|
||||||
|
|||||||
@@ -56,9 +56,13 @@ public:
|
|||||||
virtual sp<IMemory> getCblk() const
|
virtual sp<IMemory> getCblk() const
|
||||||
{
|
{
|
||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
|
sp<IMemory> cblk;
|
||||||
data.writeInterfaceToken(IAudioRecord::getInterfaceDescriptor());
|
data.writeInterfaceToken(IAudioRecord::getInterfaceDescriptor());
|
||||||
remote()->transact(GET_CBLK, data, &reply);
|
status_t status = remote()->transact(GET_CBLK, data, &reply);
|
||||||
return interface_cast<IMemory>(reply.readStrongBinder());
|
if (status == NO_ERROR) {
|
||||||
|
cblk = interface_cast<IMemory>(reply.readStrongBinder());
|
||||||
|
}
|
||||||
|
return cblk;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -81,9 +81,13 @@ public:
|
|||||||
virtual sp<IMemory> getCblk() const
|
virtual sp<IMemory> getCblk() const
|
||||||
{
|
{
|
||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
|
sp<IMemory> cblk;
|
||||||
data.writeInterfaceToken(IAudioTrack::getInterfaceDescriptor());
|
data.writeInterfaceToken(IAudioTrack::getInterfaceDescriptor());
|
||||||
remote()->transact(GET_CBLK, data, &reply);
|
status_t status = remote()->transact(GET_CBLK, data, &reply);
|
||||||
return interface_cast<IMemory>(reply.readStrongBinder());
|
if (status == NO_ERROR) {
|
||||||
|
cblk = interface_cast<IMemory>(reply.readStrongBinder());
|
||||||
|
}
|
||||||
|
return cblk;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user