Merge "226483: A2DP connected, but music out to speaker"
This commit is contained in:
@@ -185,6 +185,10 @@ public:
|
|||||||
static status_t unregisterEffect(int id);
|
static status_t unregisterEffect(int id);
|
||||||
static status_t setEffectEnabled(int id, bool enabled);
|
static status_t setEffectEnabled(int id, bool enabled);
|
||||||
|
|
||||||
|
// clear stream to output mapping cache (gStreamOutputMap)
|
||||||
|
// and output configuration cache (gOutputs)
|
||||||
|
static void clearAudioConfigCache();
|
||||||
|
|
||||||
static const sp<IAudioPolicyService>& get_audio_policy_service();
|
static const sp<IAudioPolicyService>& get_audio_policy_service();
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -236,7 +240,8 @@ private:
|
|||||||
|
|
||||||
// mapping between stream types and outputs
|
// mapping between stream types and outputs
|
||||||
static DefaultKeyedVector<int, audio_io_handle_t> gStreamOutputMap;
|
static DefaultKeyedVector<int, audio_io_handle_t> gStreamOutputMap;
|
||||||
// list of output descritor containing cached parameters (sampling rate, framecount, channel count...)
|
// list of output descriptors containing cached parameters
|
||||||
|
// (sampling rate, framecount, channel count...)
|
||||||
static DefaultKeyedVector<audio_io_handle_t, OutputDescriptor *> gOutputs;
|
static DefaultKeyedVector<audio_io_handle_t, OutputDescriptor *> gOutputs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -727,6 +727,14 @@ status_t AudioSystem::isStreamActive(int stream, bool* state, uint32_t inPastMs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AudioSystem::clearAudioConfigCache()
|
||||||
|
{
|
||||||
|
Mutex::Autolock _l(gLock);
|
||||||
|
LOGV("clearAudioConfigCache()");
|
||||||
|
gStreamOutputMap.clear();
|
||||||
|
gOutputs.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
void AudioSystem::AudioPolicyServiceClient::binderDied(const wp<IBinder>& who) {
|
void AudioSystem::AudioPolicyServiceClient::binderDied(const wp<IBinder>& who) {
|
||||||
|
|||||||
@@ -1164,6 +1164,10 @@ status_t AudioTrack::restoreTrack_l(audio_track_cblk_t*& cblk, bool fromStart)
|
|||||||
cblk->cv.broadcast();
|
cblk->cv.broadcast();
|
||||||
cblk->lock.unlock();
|
cblk->lock.unlock();
|
||||||
|
|
||||||
|
// refresh the audio configuration cache in this process to make sure we get new
|
||||||
|
// output parameters in getOutput_l() and createTrack_l()
|
||||||
|
AudioSystem::clearAudioConfigCache();
|
||||||
|
|
||||||
// if the new IAudioTrack is created, createTrack_l() will modify the
|
// if the new IAudioTrack is created, createTrack_l() will modify the
|
||||||
// following member variables: mAudioTrack, mCblkMemory and mCblk.
|
// following member variables: mAudioTrack, mCblkMemory and mCblk.
|
||||||
// It will also delete the strong references on previous IAudioTrack and IMemory
|
// It will also delete the strong references on previous IAudioTrack and IMemory
|
||||||
|
|||||||
@@ -1362,6 +1362,7 @@ AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinge
|
|||||||
for (int stream = 0; stream < AUDIO_STREAM_CNT; stream++) {
|
for (int stream = 0; stream < AUDIO_STREAM_CNT; stream++) {
|
||||||
mStreamTypes[stream].volume = mAudioFlinger->streamVolumeInternal(stream);
|
mStreamTypes[stream].volume = mAudioFlinger->streamVolumeInternal(stream);
|
||||||
mStreamTypes[stream].mute = mAudioFlinger->streamMute(stream);
|
mStreamTypes[stream].mute = mAudioFlinger->streamMute(stream);
|
||||||
|
mStreamTypes[stream].valid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1530,6 +1531,14 @@ sp<AudioFlinger::PlaybackThread::Track> AudioFlinger::PlaybackThread::createTra
|
|||||||
chain->setStrategy(AudioSystem::getStrategyForStream((audio_stream_type_t)track->type()));
|
chain->setStrategy(AudioSystem::getStrategyForStream((audio_stream_type_t)track->type()));
|
||||||
chain->incTrackCnt();
|
chain->incTrackCnt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// invalidate track immediately if the stream type was moved to another thread since
|
||||||
|
// createTrack() was called by the client process.
|
||||||
|
if (!mStreamTypes[streamType].valid) {
|
||||||
|
LOGW("createTrack_l() on thread %p: invalidating track on stream %d",
|
||||||
|
this, streamType);
|
||||||
|
android_atomic_or(CBLK_INVALID_ON, &track->mCblk->flags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lStatus = NO_ERROR;
|
lStatus = NO_ERROR;
|
||||||
|
|
||||||
@@ -2219,6 +2228,14 @@ void AudioFlinger::MixerThread::invalidateTracks(int streamType)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioFlinger::PlaybackThread::setStreamValid(int streamType, bool valid)
|
||||||
|
{
|
||||||
|
LOGV ("PlaybackThread::setStreamValid() thread %p, streamType %d, valid %d",
|
||||||
|
this, streamType, valid);
|
||||||
|
Mutex::Autolock _l(mLock);
|
||||||
|
|
||||||
|
mStreamTypes[streamType].valid = valid;
|
||||||
|
}
|
||||||
|
|
||||||
// getTrackName_l() must be called with ThreadBase::mLock held
|
// getTrackName_l() must be called with ThreadBase::mLock held
|
||||||
int AudioFlinger::MixerThread::getTrackName_l()
|
int AudioFlinger::MixerThread::getTrackName_l()
|
||||||
@@ -5074,11 +5091,14 @@ status_t AudioFlinger::setStreamOutput(uint32_t stream, int output)
|
|||||||
LOGV("setStreamOutput() stream %d to output %d", stream, output);
|
LOGV("setStreamOutput() stream %d to output %d", stream, output);
|
||||||
audioConfigChanged_l(AudioSystem::STREAM_CONFIG_CHANGED, output, &stream);
|
audioConfigChanged_l(AudioSystem::STREAM_CONFIG_CHANGED, output, &stream);
|
||||||
|
|
||||||
|
dstThread->setStreamValid(stream, true);
|
||||||
|
|
||||||
for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
|
for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
|
||||||
PlaybackThread *thread = mPlaybackThreads.valueAt(i).get();
|
PlaybackThread *thread = mPlaybackThreads.valueAt(i).get();
|
||||||
if (thread != dstThread &&
|
if (thread != dstThread &&
|
||||||
thread->type() != ThreadBase::DIRECT) {
|
thread->type() != ThreadBase::DIRECT) {
|
||||||
MixerThread *srcThread = (MixerThread *)thread;
|
MixerThread *srcThread = (MixerThread *)thread;
|
||||||
|
srcThread->setStreamValid(stream, false);
|
||||||
srcThread->invalidateTracks(stream);
|
srcThread->invalidateTracks(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -751,14 +751,18 @@ private:
|
|||||||
virtual uint32_t hasAudioSession(int sessionId);
|
virtual uint32_t hasAudioSession(int sessionId);
|
||||||
virtual uint32_t getStrategyForSession_l(int sessionId);
|
virtual uint32_t getStrategyForSession_l(int sessionId);
|
||||||
|
|
||||||
|
void setStreamValid(int streamType, bool valid);
|
||||||
|
|
||||||
struct stream_type_t {
|
struct stream_type_t {
|
||||||
stream_type_t()
|
stream_type_t()
|
||||||
: volume(1.0f),
|
: volume(1.0f),
|
||||||
mute(false)
|
mute(false),
|
||||||
|
valid(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
float volume;
|
float volume;
|
||||||
bool mute;
|
bool mute;
|
||||||
|
bool valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
Reference in New Issue
Block a user