Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a58dabe2 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira
Browse files

Add support for ICS audio blobs

Enable with the ICS_AUDIO_BLOB CFLAG

Change-Id: Ie174d5997202b8931c1f11db62b6ec2e377f096a
parent 96076964
Loading
Loading
Loading
Loading
+41 −0
Original line number Original line Diff line number Diff line
@@ -206,11 +206,13 @@ static int load_audio_interface(const char *if_name, audio_hw_device_t **dev)
    if (rc) {
    if (rc) {
        goto out;
        goto out;
    }
    }
#ifndef ICS_AUDIO_BLOB
    if ((*dev)->common.version != AUDIO_DEVICE_API_VERSION_CURRENT) {
    if ((*dev)->common.version != AUDIO_DEVICE_API_VERSION_CURRENT) {
        ALOGE("%s wrong audio hw device version %04x", __func__, (*dev)->common.version);
        ALOGE("%s wrong audio hw device version %04x", __func__, (*dev)->common.version);
        rc = BAD_VALUE;
        rc = BAD_VALUE;
        goto out;
        goto out;
    }
    }
#endif
    return 0;
    return 0;


out:
out:
@@ -724,6 +726,7 @@ status_t AudioFlinger::setMasterMute(bool muted)
    mMasterMute = muted;
    mMasterMute = muted;


    // Set master mute in the HALs which support it.
    // Set master mute in the HALs which support it.
#ifndef ICS_AUDIO_BLOB
    for (size_t i = 0; i < mAudioHwDevs.size(); i++) {
    for (size_t i = 0; i < mAudioHwDevs.size(); i++) {
        AutoMutex lock(mHardwareLock);
        AutoMutex lock(mHardwareLock);
        AudioHwDevice *dev = mAudioHwDevs.valueAt(i);
        AudioHwDevice *dev = mAudioHwDevs.valueAt(i);
@@ -734,6 +737,7 @@ status_t AudioFlinger::setMasterMute(bool muted)
        }
        }
        mHardwareStatus = AUDIO_HW_IDLE;
        mHardwareStatus = AUDIO_HW_IDLE;
    }
    }
#endif


    // Now set the master mute in each playback thread.  Playback threads
    // Now set the master mute in each playback thread.  Playback threads
    // assigned to HALs which do not have master mute support will apply master
    // assigned to HALs which do not have master mute support will apply master
@@ -991,7 +995,11 @@ size_t AudioFlinger::getInputBufferSize(uint32_t sampleRate, audio_format_t form
        format: format,
        format: format,
    };
    };
    audio_hw_device_t *dev = mPrimaryHardwareDev->hwDevice();
    audio_hw_device_t *dev = mPrimaryHardwareDev->hwDevice();
#ifndef ICS_AUDIO_BLOB
    size_t size = dev->get_input_buffer_size(dev, &config);
    size_t size = dev->get_input_buffer_size(dev, &config);
#else
    size_t size = dev->get_input_buffer_size(dev, sampleRate, format, popcount(channelMask));
#endif
    mHardwareStatus = AUDIO_HW_IDLE;
    mHardwareStatus = AUDIO_HW_IDLE;
    return size;
    return size;
}
}
@@ -2844,11 +2852,13 @@ void AudioFlinger::MixerThread::threadLoop_mix()
    int64_t pts;
    int64_t pts;
    status_t status = INVALID_OPERATION;
    status_t status = INVALID_OPERATION;


#ifndef ICS_AUDIO_BLOB
    if (mNormalSink != 0) {
    if (mNormalSink != 0) {
        status = mNormalSink->getNextWriteTimestamp(&pts);
        status = mNormalSink->getNextWriteTimestamp(&pts);
    } else {
    } else {
        status = mOutputSink->getNextWriteTimestamp(&pts);
        status = mOutputSink->getNextWriteTimestamp(&pts);
    }
    }
#endif


    if (status != NO_ERROR) {
    if (status != NO_ERROR) {
        pts = AudioBufferProvider::kInvalidPTS;
        pts = AudioBufferProvider::kInvalidPTS;
@@ -6877,6 +6887,7 @@ audio_module_handle_t AudioFlinger::loadHwModule_l(const char *name)
    {  // scope for auto-lock pattern
    {  // scope for auto-lock pattern
        AutoMutex lock(mHardwareLock);
        AutoMutex lock(mHardwareLock);


#ifndef ICS_AUDIO_BLOB
        if (0 == mAudioHwDevs.size()) {
        if (0 == mAudioHwDevs.size()) {
            mHardwareStatus = AUDIO_HW_GET_MASTER_VOLUME;
            mHardwareStatus = AUDIO_HW_GET_MASTER_VOLUME;
            if (NULL != dev->get_master_volume) {
            if (NULL != dev->get_master_volume) {
@@ -6894,6 +6905,7 @@ audio_module_handle_t AudioFlinger::loadHwModule_l(const char *name)
                }
                }
            }
            }
        }
        }
#endif


        mHardwareStatus = AUDIO_HW_SET_MASTER_VOLUME;
        mHardwareStatus = AUDIO_HW_SET_MASTER_VOLUME;
        if ((NULL != dev->set_master_volume) &&
        if ((NULL != dev->set_master_volume) &&
@@ -6902,12 +6914,14 @@ audio_module_handle_t AudioFlinger::loadHwModule_l(const char *name)
                    AudioHwDevice::AHWD_CAN_SET_MASTER_VOLUME);
                    AudioHwDevice::AHWD_CAN_SET_MASTER_VOLUME);
        }
        }


#ifndef ICS_AUDIO_BLOB
        mHardwareStatus = AUDIO_HW_SET_MASTER_MUTE;
        mHardwareStatus = AUDIO_HW_SET_MASTER_MUTE;
        if ((NULL != dev->set_master_mute) &&
        if ((NULL != dev->set_master_mute) &&
            (OK == dev->set_master_mute(dev, mMasterMute))) {
            (OK == dev->set_master_mute(dev, mMasterMute))) {
            flags = static_cast<AudioHwDevice::Flags>(flags |
            flags = static_cast<AudioHwDevice::Flags>(flags |
                    AudioHwDevice::AHWD_CAN_SET_MASTER_MUTE);
                    AudioHwDevice::AHWD_CAN_SET_MASTER_MUTE);
        }
        }
#endif


        mHardwareStatus = AUDIO_HW_IDLE;
        mHardwareStatus = AUDIO_HW_IDLE;
    }
    }
@@ -6981,12 +6995,23 @@ audio_io_handle_t AudioFlinger::openOutput(audio_module_handle_t module,


    mHardwareStatus = AUDIO_HW_OUTPUT_OPEN;
    mHardwareStatus = AUDIO_HW_OUTPUT_OPEN;


#ifndef ICS_AUDIO_BLOB
    status = hwDevHal->open_output_stream(hwDevHal,
    status = hwDevHal->open_output_stream(hwDevHal,
                                          id,
                                          id,
                                          *pDevices,
                                          *pDevices,
                                          (audio_output_flags_t)flags,
                                          (audio_output_flags_t)flags,
                                          &config,
                                          &config,
                                          &outStream);
                                          &outStream);
#else
    status = hwDevHal->open_output_stream(hwDevHal,
                                          *pDevices,
                                          (int *)&config.format,
                                          &config.channel_mask,
                                          &config.sample_rate,
                                          &outStream);
    uint32_t newflags = flags | AUDIO_OUTPUT_FLAG_PRIMARY;
    flags = (audio_output_flags_t)newflags;
#endif


    mHardwareStatus = AUDIO_HW_IDLE;
    mHardwareStatus = AUDIO_HW_IDLE;
    ALOGV("openOutput() openOutputStream returned output %p, SamplingRate %d, Format %d, Channels %x, status %d",
    ALOGV("openOutput() openOutputStream returned output %p, SamplingRate %d, Format %d, Channels %x, status %d",
@@ -7162,8 +7187,16 @@ audio_io_handle_t AudioFlinger::openInput(audio_module_handle_t module,
    audio_hw_device_t *inHwHal = inHwDev->hwDevice();
    audio_hw_device_t *inHwHal = inHwDev->hwDevice();
    audio_io_handle_t id = nextUniqueId();
    audio_io_handle_t id = nextUniqueId();


#ifndef ICS_AUDIO_BLOB
    status = inHwHal->open_input_stream(inHwHal, id, *pDevices, &config,
    status = inHwHal->open_input_stream(inHwHal, id, *pDevices, &config,
                                        &inStream);
                                        &inStream);
#else
    status = inHwHal->open_input_stream(inHwHal, *pDevices, 
                                        (int *)&config.format, 
                                        &config.channel_mask,
                                        &config.sample_rate, (audio_in_acoustics_t)0,
                                        &inStream);
#endif
    ALOGV("openInput() openInputStream returned input %p, SamplingRate %d, Format %d, Channels %x, status %d",
    ALOGV("openInput() openInputStream returned input %p, SamplingRate %d, Format %d, Channels %x, status %d",
            inStream,
            inStream,
            config.sample_rate,
            config.sample_rate,
@@ -7180,7 +7213,15 @@ audio_io_handle_t AudioFlinger::openInput(audio_module_handle_t module,
        (popcount(config.channel_mask) <= FCC_2) && (popcount(reqChannels) <= FCC_2)) {
        (popcount(config.channel_mask) <= FCC_2) && (popcount(reqChannels) <= FCC_2)) {
        ALOGV("openInput() reopening with proposed sampling rate and channel mask");
        ALOGV("openInput() reopening with proposed sampling rate and channel mask");
        inStream = NULL;
        inStream = NULL;
#ifndef ICS_AUDIO_BLOB
        status = inHwHal->open_input_stream(inHwHal, id, *pDevices, &config, &inStream);
        status = inHwHal->open_input_stream(inHwHal, id, *pDevices, &config, &inStream);
#else
        status = inHwHal->open_input_stream(inHwHal, *pDevices, 
                                        (int *)&config.format, 
                                        &config.channel_mask,
                                        &config.sample_rate, (audio_in_acoustics_t)0,
                                        &inStream);
#endif
    }
    }


    if (status == NO_ERROR && inStream != NULL) {
    if (status == NO_ERROR && inStream != NULL) {
+9 −2
Original line number Original line Diff line number Diff line
@@ -388,12 +388,16 @@ status_t AudioPolicyService::setStreamVolumeIndex(audio_stream_type_t stream,
        return BAD_VALUE;
        return BAD_VALUE;
    }
    }
    Mutex::Autolock _l(mLock);
    Mutex::Autolock _l(mLock);

#ifndef ICS_AUDIO_BLOB
    if (mpAudioPolicy->set_stream_volume_index_for_device) {
    if (mpAudioPolicy->set_stream_volume_index_for_device) {
        return mpAudioPolicy->set_stream_volume_index_for_device(mpAudioPolicy,
        return mpAudioPolicy->set_stream_volume_index_for_device(mpAudioPolicy,
                                                                stream,
                                                                stream,
                                                                index,
                                                                index,
                                                                device);
                                                                device);
    } else {
    } else 
#endif
    {
        return mpAudioPolicy->set_stream_volume_index(mpAudioPolicy, stream, index);
        return mpAudioPolicy->set_stream_volume_index(mpAudioPolicy, stream, index);
    }
    }
}
}
@@ -409,12 +413,15 @@ status_t AudioPolicyService::getStreamVolumeIndex(audio_stream_type_t stream,
        return BAD_VALUE;
        return BAD_VALUE;
    }
    }
    Mutex::Autolock _l(mLock);
    Mutex::Autolock _l(mLock);
#ifndef ICS_AUDIO_BLOB
    if (mpAudioPolicy->get_stream_volume_index_for_device) {
    if (mpAudioPolicy->get_stream_volume_index_for_device) {
        return mpAudioPolicy->get_stream_volume_index_for_device(mpAudioPolicy,
        return mpAudioPolicy->get_stream_volume_index_for_device(mpAudioPolicy,
                                                                stream,
                                                                stream,
                                                                index,
                                                                index,
                                                                device);
                                                                device);
    } else {
    } else 
#endif
    {
        return mpAudioPolicy->get_stream_volume_index(mpAudioPolicy, stream, index);
        return mpAudioPolicy->get_stream_volume_index(mpAudioPolicy, stream, index);
    }
    }
}
}