Abstract away access to audio streams HAL in AudioFlinger
In this CL all direct access to audio_stream_t, audio_stream_out_t, and
audio_stream_in_t their functions is encapsulated within the new
hierarchy of Stream[In|Out]HalLocal classes. AudioFlinger uses
interface classes Stream[In|Out]HalInterface to access these functions.
Note that NBAIO still receives raw HAL stream handles and needs to be
converted separately.
Bug: 30222631
Test: manual with Loopback app
Change-Id: I6388cfa2006791c9c0aa7bb186719209726a2d48
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index b5ab782..81f59de 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -48,8 +48,6 @@
#include "DevicesFactoryHalInterface.h"
#include "EffectsFactoryHalInterface.h"
#include "ServiceUtilities.h"
-// FIXME: Remove after streams HAL is componentized
-#include "DeviceHalLocal.h"
#include <media/AudioResamplerPublic.h>
@@ -399,7 +397,7 @@
write(fd, result.string(), result.size());
}
- if (mEffectsFactoryHal.get() != NULL) {
+ if (mEffectsFactoryHal != 0) {
mEffectsFactoryHal->dumpEffects(fd);
} else {
String8 result(kNoEffectsFactory);
@@ -2013,7 +2011,6 @@
AudioStreamOut *out = thread->clearOutput();
ALOG_ASSERT(out != NULL, "out shouldn't be NULL");
// from now on thread->mOutput is NULL
- static_cast<DeviceHalLocal*>(out->hwDev().get())->closeOutputStream(out->stream);
delete out;
}
@@ -2109,12 +2106,12 @@
audio_config_t halconfig = *config;
sp<DeviceHalInterface> inHwHal = inHwDev->hwDevice();
- audio_stream_in_t *inStream = NULL;
- status_t status = static_cast<DeviceHalLocal*>(inHwHal.get())->openInputStream(
+ sp<StreamInHalInterface> inStream;
+ status_t status = inHwHal->openInputStream(
*input, devices, &halconfig, flags, address.string(), source, &inStream);
ALOGV("openInput_l() openInputStream returned input %p, SamplingRate %d"
", Format %#x, Channels %x, flags %#x, status %d addr %s",
- inStream,
+ inStream.get(),
halconfig.sample_rate,
halconfig.format,
halconfig.channel_mask,
@@ -2131,13 +2128,13 @@
(audio_channel_count_from_in_mask(config->channel_mask) <= FCC_8)) {
// FIXME describe the change proposed by HAL (save old values so we can log them here)
ALOGV("openInput_l() reopening with proposed sampling rate and channel mask");
- inStream = NULL;
- status = static_cast<DeviceHalLocal*>(inHwHal.get())->openInputStream(
+ inStream.clear();
+ status = inHwHal->openInputStream(
*input, devices, &halconfig, flags, address.string(), source, &inStream);
// FIXME log this new status; HAL should not propose any further changes
}
- if (status == NO_ERROR && inStream != NULL) {
+ if (status == NO_ERROR && inStream != 0) {
#ifdef TEE_SINK
// Try to re-use most recently used Pipe to archive a copy of input for dumpsys,
@@ -2284,7 +2281,6 @@
AudioStreamIn *in = thread->clearInput();
ALOG_ASSERT(in != NULL, "in shouldn't be NULL");
// from now on thread->mInput is NULL
- static_cast<DeviceHalLocal*>(in->hwDev().get())->closeInputStream(in->stream);
delete in;
}
@@ -2649,7 +2645,7 @@
goto Exit;
}
- if (mEffectsFactoryHal.get() == NULL) {
+ if (mEffectsFactoryHal == 0) {
lStatus = NO_INIT;
goto Exit;
}