~aleteoryx/muditaos

78a448347e7a2ed7a50bebd136979bfe9820dff9 — Jakub Pyszczak 4 years ago 8bed01c
[EGD-7299] Fixed bt call crash

Fixed crash occurring during bluetooth call
if there was bluetooth device being turned off.
M module-bluetooth/Bluetooth/interface/BluetoothDriverImpl.cpp => module-bluetooth/Bluetooth/interface/BluetoothDriverImpl.cpp +1 -1
@@ 215,7 215,7 @@ namespace bluetooth
    }
    auto Driver::pair(Devicei device, std::uint8_t protectionLevel) -> bool
    {
        LOG_FATAL("Device: %s, addr: %s", device.name.c_str(), device.address_str());
        LOG_INFO("Device: %s, addr: %s", device.name.c_str(), device.address_str());
        return gap->pair(device, protectionLevel);
    }
    auto Driver::unpair(Devicei device) -> bool

M module-bluetooth/Bluetooth/interface/profiles/HFP/HFP.cpp => module-bluetooth/Bluetooth/interface/profiles/HFP/HFP.cpp +1 -0
@@ 276,6 276,7 @@ namespace bluetooth
            scoHandle = HCI_CON_HANDLE_INVALID;
            isAudioRouted                = false;
            isAudioConnectionEstablished = false;
            sendAudioEvent(audio::EventType::BlutoothHFPDeviceState, audio::Event::DeviceState::Disconnected);
            break;
        case HFP_SUBEVENT_START_RINGING:
            LOG_DEBUG("Start Ringing\n");

M module-bluetooth/Bluetooth/interface/profiles/HSP/HSP.cpp => module-bluetooth/Bluetooth/interface/profiles/HSP/HSP.cpp +1 -0
@@ 215,6 215,7 @@ namespace bluetooth
            LOG_DEBUG("Audio connection released.\n\n");
            scoHandle    = HCI_CON_HANDLE_INVALID;
            callAnswered = false;
            sendAudioEvent(audio::EventType::BlutoothHSPDeviceState, audio::Event::DeviceState::Disconnected);
            break;
        case HSP_SUBEVENT_MICROPHONE_GAIN_CHANGED:
            LOG_DEBUG("Received microphone gain change %d\n", hsp_subevent_microphone_gain_changed_get_gain(event));

M module-bluetooth/Bluetooth/interface/profiles/SCO/SCO.cpp => module-bluetooth/Bluetooth/interface/profiles/SCO/SCO.cpp +1 -4
@@ 127,10 127,7 @@ auto SCO::SCOImpl::audioInitialize(int sampleRate) -> Error
    metadata.channels        = 1;
    metadata.samplesPerFrame = audioSamplesPerPacket;

    if (sourceQueue != nullptr && sinkQueue != nullptr) {
        sendEvent(audio::EventType::BlutoothHSPDeviceState, audio::Event::DeviceState::Connected);
    }
    else {
    if (sourceQueue == nullptr || sinkQueue == nullptr) {
        LOG_ERROR("failed to create queue!");
        return Error(Error::SystemError);
    }

M module-services/service-evtmgr/EventManager.cpp => module-services/service-evtmgr/EventManager.cpp +5 -0
@@ 118,6 118,11 @@ sys::MessagePointer EventManagerCommon::DataReceivedHandler(sys::DataMessage *ms
                bluetooth::AudioProfile::HSP, (event->getDeviceState() == audio::Event::DeviceState::Connected));
            bus.sendUnicast(message, app::name_settings);
        } break;
        case audio::EventType::BlutoothHFPDeviceState: {
            auto message = std::make_shared<message::bluetooth::ProfileStatus>(
                bluetooth::AudioProfile::HFP, (event->getDeviceState() == audio::Event::DeviceState::Connected));
            bus.sendUnicast(message, app::name_settings);
        } break;
        default:
            break;
        }