Loading services/audioflinger/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ LOCAL_SRC_FILES:= \ AudioHwDevice.cpp \ AudioStreamOut.cpp \ SpdifStreamOut.cpp \ StreamHalLocal.cpp \ DeviceHalLocal.cpp \ DevicesFactoryHalLocal.cpp \ EffectHalLocal.cpp \ Loading services/audioflinger/AudioFlinger.cpp +8 −12 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -399,7 +397,7 @@ status_t AudioFlinger::dump(int fd, const Vector<String16>& args) write(fd, result.string(), result.size()); } if (mEffectsFactoryHal.get() != NULL) { if (mEffectsFactoryHal != 0) { mEffectsFactoryHal->dumpEffects(fd); } else { String8 result(kNoEffectsFactory); Loading Loading @@ -2013,7 +2011,6 @@ void AudioFlinger::closeOutputFinish(const sp<PlaybackThread>& thread) 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; } Loading Loading @@ -2109,12 +2106,12 @@ sp<AudioFlinger::RecordThread> AudioFlinger::openInput_l(audio_module_handle_t m 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, Loading @@ -2131,13 +2128,13 @@ sp<AudioFlinger::RecordThread> AudioFlinger::openInput_l(audio_module_handle_t m (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, Loading Loading @@ -2284,7 +2281,6 @@ void AudioFlinger::closeInputFinish(const sp<RecordThread>& thread) 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; } Loading Loading @@ -2649,7 +2645,7 @@ sp<IEffect> AudioFlinger::createEffect( goto Exit; } if (mEffectsFactoryHal.get() == NULL) { if (mEffectsFactoryHal == 0) { lStatus = NO_INIT; goto Exit; } Loading services/audioflinger/AudioFlinger.h +3 −2 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ #include "SpdifStreamOut.h" #include "AudioHwDevice.h" #include "LinearMap.h" #include "StreamHalInterface.h" #include <powermanager/IPowerManager.h> Loading Loading @@ -615,12 +616,12 @@ private: struct AudioStreamIn { AudioHwDevice* const audioHwDev; audio_stream_in_t* const stream; sp<StreamInHalInterface> stream; audio_input_flags_t flags; sp<DeviceHalInterface> hwDev() const { return audioHwDev->hwDevice(); } AudioStreamIn(AudioHwDevice *dev, audio_stream_in_t *in, audio_input_flags_t flags) : AudioStreamIn(AudioHwDevice *dev, sp<StreamInHalInterface> in, audio_input_flags_t flags) : audioHwDev(dev), stream(in), flags(flags) {} }; Loading services/audioflinger/AudioStreamOut.cpp +27 −25 Original line number Diff line number Diff line Loading @@ -24,9 +24,8 @@ #include "AudioHwDevice.h" #include "AudioStreamOut.h" #include "DeviceHalInterface.h" #include "StreamHalInterface.h" // FIXME: Remove after streams HAL is componentized #include "DeviceHalLocal.h" namespace android { Loading @@ -44,6 +43,10 @@ AudioStreamOut::AudioStreamOut(AudioHwDevice *dev, audio_output_flags_t flags) { } AudioStreamOut::~AudioStreamOut() { } sp<DeviceHalInterface> AudioStreamOut::hwDev() const { return audioHwDev->hwDevice(); Loading @@ -51,12 +54,12 @@ sp<DeviceHalInterface> AudioStreamOut::hwDev() const status_t AudioStreamOut::getRenderPosition(uint64_t *frames) { if (stream == NULL) { if (stream == 0) { return NO_INIT; } uint32_t halPosition = 0; status_t status = stream->get_render_position(stream, &halPosition); status_t status = stream->getRenderPosition(&halPosition); if (status != NO_ERROR) { return status; } Loading Loading @@ -88,12 +91,12 @@ status_t AudioStreamOut::getRenderPosition(uint32_t *frames) status_t AudioStreamOut::getPresentationPosition(uint64_t *frames, struct timespec *timestamp) { if (stream == NULL) { if (stream == 0) { return NO_INIT; } uint64_t halPosition = 0; status_t status = stream->get_presentation_position(stream, &halPosition, timestamp); status_t status = stream->getPresentationPosition(&halPosition, timestamp); if (status != NO_ERROR) { return status; } Loading @@ -119,13 +122,13 @@ status_t AudioStreamOut::open( struct audio_config *config, const char *address) { audio_stream_out_t *outStream; sp<StreamOutHalInterface> outStream; audio_output_flags_t customFlags = (config->format == AUDIO_FORMAT_IEC61937) ? (audio_output_flags_t)(flags | AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO) : flags; int status = static_cast<DeviceHalLocal*>(hwDev().get())->openOutputStream( int status = hwDev()->openOutputStream( handle, devices, customFlags, Loading @@ -135,7 +138,7 @@ status_t AudioStreamOut::open( ALOGV("AudioStreamOut::open(), HAL returned " " stream %p, sampleRate %d, Format %#x, " "channelMask %#x, status %d", outStream, outStream.get(), config->sample_rate, config->format, config->channel_mask, Loading @@ -147,7 +150,7 @@ status_t AudioStreamOut::open( struct audio_config customConfig = *config; customConfig.format = AUDIO_FORMAT_PCM_16_BIT; status = static_cast<DeviceHalLocal*>(hwDev().get())->openOutputStream( status = hwDev()->openOutputStream( handle, devices, customFlags, Loading @@ -160,7 +163,7 @@ status_t AudioStreamOut::open( if (status == NO_ERROR) { stream = outStream; mHalFormatHasProportionalFrames = audio_has_proportional_frames(config->format); mHalFrameSize = audio_stream_out_frame_size(stream); status = stream->getFrameSize(&mHalFrameSize); } return status; Loading @@ -168,47 +171,46 @@ status_t AudioStreamOut::open( audio_format_t AudioStreamOut::getFormat() const { return stream->common.get_format(&stream->common); audio_format_t result; return stream->getFormat(&result) == OK ? result : AUDIO_FORMAT_INVALID; } uint32_t AudioStreamOut::getSampleRate() const { return stream->common.get_sample_rate(&stream->common); uint32_t result; return stream->getSampleRate(&result) == OK ? result : 0; } audio_channel_mask_t AudioStreamOut::getChannelMask() const { return stream->common.get_channels(&stream->common); audio_channel_mask_t result; return stream->getChannelMask(&result) == OK ? result : AUDIO_CHANNEL_INVALID; } int AudioStreamOut::flush() { ALOG_ASSERT(stream != NULL); mRenderPosition = 0; mFramesWritten = 0; mFramesWrittenAtStandby = 0; if (stream->flush != NULL) { return stream->flush(stream); } return NO_ERROR; status_t result = stream->flush(); return result != INVALID_OPERATION ? result : NO_ERROR; } int AudioStreamOut::standby() { ALOG_ASSERT(stream != NULL); mRenderPosition = 0; mFramesWrittenAtStandby = mFramesWritten; return stream->common.standby(&stream->common); return stream->standby(); } ssize_t AudioStreamOut::write(const void *buffer, size_t numBytes) { ALOG_ASSERT(stream != NULL); ssize_t bytesWritten = stream->write(stream, buffer, numBytes); if (bytesWritten > 0 && mHalFrameSize > 0) { size_t bytesWritten; status_t result = stream->write(buffer, numBytes, &bytesWritten); if (result == OK && bytesWritten > 0 && mHalFrameSize > 0) { mFramesWritten += bytesWritten / mHalFrameSize; } return bytesWritten; return result == OK ? bytesWritten : result; } } // namespace android services/audioflinger/AudioStreamOut.h +3 −2 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ namespace android { class AudioHwDevice; class DeviceHalInterface; class StreamOutHalInterface; /** * Managed access to a HAL output stream. Loading @@ -37,7 +38,7 @@ public: // For emphasis, we could also make all pointers to them be "const *", // but that would clutter the code unnecessarily. AudioHwDevice * const audioHwDev; audio_stream_out_t *stream; sp<StreamOutHalInterface> stream; const audio_output_flags_t flags; sp<DeviceHalInterface> hwDev() const; Loading @@ -50,7 +51,7 @@ public: struct audio_config *config, const char *address); virtual ~AudioStreamOut() { } virtual ~AudioStreamOut(); // Get the bottom 32-bits of the 64-bit render position. status_t getRenderPosition(uint32_t *frames); Loading Loading
services/audioflinger/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ LOCAL_SRC_FILES:= \ AudioHwDevice.cpp \ AudioStreamOut.cpp \ SpdifStreamOut.cpp \ StreamHalLocal.cpp \ DeviceHalLocal.cpp \ DevicesFactoryHalLocal.cpp \ EffectHalLocal.cpp \ Loading
services/audioflinger/AudioFlinger.cpp +8 −12 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -399,7 +397,7 @@ status_t AudioFlinger::dump(int fd, const Vector<String16>& args) write(fd, result.string(), result.size()); } if (mEffectsFactoryHal.get() != NULL) { if (mEffectsFactoryHal != 0) { mEffectsFactoryHal->dumpEffects(fd); } else { String8 result(kNoEffectsFactory); Loading Loading @@ -2013,7 +2011,6 @@ void AudioFlinger::closeOutputFinish(const sp<PlaybackThread>& thread) 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; } Loading Loading @@ -2109,12 +2106,12 @@ sp<AudioFlinger::RecordThread> AudioFlinger::openInput_l(audio_module_handle_t m 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, Loading @@ -2131,13 +2128,13 @@ sp<AudioFlinger::RecordThread> AudioFlinger::openInput_l(audio_module_handle_t m (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, Loading Loading @@ -2284,7 +2281,6 @@ void AudioFlinger::closeInputFinish(const sp<RecordThread>& thread) 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; } Loading Loading @@ -2649,7 +2645,7 @@ sp<IEffect> AudioFlinger::createEffect( goto Exit; } if (mEffectsFactoryHal.get() == NULL) { if (mEffectsFactoryHal == 0) { lStatus = NO_INIT; goto Exit; } Loading
services/audioflinger/AudioFlinger.h +3 −2 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ #include "SpdifStreamOut.h" #include "AudioHwDevice.h" #include "LinearMap.h" #include "StreamHalInterface.h" #include <powermanager/IPowerManager.h> Loading Loading @@ -615,12 +616,12 @@ private: struct AudioStreamIn { AudioHwDevice* const audioHwDev; audio_stream_in_t* const stream; sp<StreamInHalInterface> stream; audio_input_flags_t flags; sp<DeviceHalInterface> hwDev() const { return audioHwDev->hwDevice(); } AudioStreamIn(AudioHwDevice *dev, audio_stream_in_t *in, audio_input_flags_t flags) : AudioStreamIn(AudioHwDevice *dev, sp<StreamInHalInterface> in, audio_input_flags_t flags) : audioHwDev(dev), stream(in), flags(flags) {} }; Loading
services/audioflinger/AudioStreamOut.cpp +27 −25 Original line number Diff line number Diff line Loading @@ -24,9 +24,8 @@ #include "AudioHwDevice.h" #include "AudioStreamOut.h" #include "DeviceHalInterface.h" #include "StreamHalInterface.h" // FIXME: Remove after streams HAL is componentized #include "DeviceHalLocal.h" namespace android { Loading @@ -44,6 +43,10 @@ AudioStreamOut::AudioStreamOut(AudioHwDevice *dev, audio_output_flags_t flags) { } AudioStreamOut::~AudioStreamOut() { } sp<DeviceHalInterface> AudioStreamOut::hwDev() const { return audioHwDev->hwDevice(); Loading @@ -51,12 +54,12 @@ sp<DeviceHalInterface> AudioStreamOut::hwDev() const status_t AudioStreamOut::getRenderPosition(uint64_t *frames) { if (stream == NULL) { if (stream == 0) { return NO_INIT; } uint32_t halPosition = 0; status_t status = stream->get_render_position(stream, &halPosition); status_t status = stream->getRenderPosition(&halPosition); if (status != NO_ERROR) { return status; } Loading Loading @@ -88,12 +91,12 @@ status_t AudioStreamOut::getRenderPosition(uint32_t *frames) status_t AudioStreamOut::getPresentationPosition(uint64_t *frames, struct timespec *timestamp) { if (stream == NULL) { if (stream == 0) { return NO_INIT; } uint64_t halPosition = 0; status_t status = stream->get_presentation_position(stream, &halPosition, timestamp); status_t status = stream->getPresentationPosition(&halPosition, timestamp); if (status != NO_ERROR) { return status; } Loading @@ -119,13 +122,13 @@ status_t AudioStreamOut::open( struct audio_config *config, const char *address) { audio_stream_out_t *outStream; sp<StreamOutHalInterface> outStream; audio_output_flags_t customFlags = (config->format == AUDIO_FORMAT_IEC61937) ? (audio_output_flags_t)(flags | AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO) : flags; int status = static_cast<DeviceHalLocal*>(hwDev().get())->openOutputStream( int status = hwDev()->openOutputStream( handle, devices, customFlags, Loading @@ -135,7 +138,7 @@ status_t AudioStreamOut::open( ALOGV("AudioStreamOut::open(), HAL returned " " stream %p, sampleRate %d, Format %#x, " "channelMask %#x, status %d", outStream, outStream.get(), config->sample_rate, config->format, config->channel_mask, Loading @@ -147,7 +150,7 @@ status_t AudioStreamOut::open( struct audio_config customConfig = *config; customConfig.format = AUDIO_FORMAT_PCM_16_BIT; status = static_cast<DeviceHalLocal*>(hwDev().get())->openOutputStream( status = hwDev()->openOutputStream( handle, devices, customFlags, Loading @@ -160,7 +163,7 @@ status_t AudioStreamOut::open( if (status == NO_ERROR) { stream = outStream; mHalFormatHasProportionalFrames = audio_has_proportional_frames(config->format); mHalFrameSize = audio_stream_out_frame_size(stream); status = stream->getFrameSize(&mHalFrameSize); } return status; Loading @@ -168,47 +171,46 @@ status_t AudioStreamOut::open( audio_format_t AudioStreamOut::getFormat() const { return stream->common.get_format(&stream->common); audio_format_t result; return stream->getFormat(&result) == OK ? result : AUDIO_FORMAT_INVALID; } uint32_t AudioStreamOut::getSampleRate() const { return stream->common.get_sample_rate(&stream->common); uint32_t result; return stream->getSampleRate(&result) == OK ? result : 0; } audio_channel_mask_t AudioStreamOut::getChannelMask() const { return stream->common.get_channels(&stream->common); audio_channel_mask_t result; return stream->getChannelMask(&result) == OK ? result : AUDIO_CHANNEL_INVALID; } int AudioStreamOut::flush() { ALOG_ASSERT(stream != NULL); mRenderPosition = 0; mFramesWritten = 0; mFramesWrittenAtStandby = 0; if (stream->flush != NULL) { return stream->flush(stream); } return NO_ERROR; status_t result = stream->flush(); return result != INVALID_OPERATION ? result : NO_ERROR; } int AudioStreamOut::standby() { ALOG_ASSERT(stream != NULL); mRenderPosition = 0; mFramesWrittenAtStandby = mFramesWritten; return stream->common.standby(&stream->common); return stream->standby(); } ssize_t AudioStreamOut::write(const void *buffer, size_t numBytes) { ALOG_ASSERT(stream != NULL); ssize_t bytesWritten = stream->write(stream, buffer, numBytes); if (bytesWritten > 0 && mHalFrameSize > 0) { size_t bytesWritten; status_t result = stream->write(buffer, numBytes, &bytesWritten); if (result == OK && bytesWritten > 0 && mHalFrameSize > 0) { mFramesWritten += bytesWritten / mHalFrameSize; } return bytesWritten; return result == OK ? bytesWritten : result; } } // namespace android
services/audioflinger/AudioStreamOut.h +3 −2 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ namespace android { class AudioHwDevice; class DeviceHalInterface; class StreamOutHalInterface; /** * Managed access to a HAL output stream. Loading @@ -37,7 +38,7 @@ public: // For emphasis, we could also make all pointers to them be "const *", // but that would clutter the code unnecessarily. AudioHwDevice * const audioHwDev; audio_stream_out_t *stream; sp<StreamOutHalInterface> stream; const audio_output_flags_t flags; sp<DeviceHalInterface> hwDev() const; Loading @@ -50,7 +51,7 @@ public: struct audio_config *config, const char *address); virtual ~AudioStreamOut() { } virtual ~AudioStreamOut(); // Get the bottom 32-bits of the 64-bit render position. status_t getRenderPosition(uint32_t *frames); Loading