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

Commit 077a489c authored by Qasim Javed's avatar Qasim Javed
Browse files

rusty-gd: Remove CancelableTaskTracker

Pairing, connection and A2DP streaming works with rusty-gd.

Also, tested with the default flags to make sure I am not breaking
anything.

Bug: 171749953
Tag: #gd-refactor
Test: gd/cert/run --rhost DirectHciTest

Change-Id: I325e6aba146d9351aa7a06ab3c847cd410a502f3
parent 1bf02f52
Loading
Loading
Loading
Loading
+1 −24
Original line number Diff line number Diff line
@@ -36,20 +36,8 @@ namespace avrcp {
AvrcpService* AvrcpService::instance_ = nullptr;
AvrcpService::ServiceInterfaceImpl* AvrcpService::service_interface_ = nullptr;

std::mutex jni_mutex_;
btbase::AbstractMessageLoop* jni_message_loop_ = nullptr;
base::CancelableTaskTracker task_tracker_;

void do_in_avrcp_jni(const base::Closure& task) {
  std::lock_guard<std::mutex> lock(jni_mutex_);

  if (jni_message_loop_ == nullptr) {
    LOG(WARNING) << __func__ << ": jni_message_loop_ is null";
    return;
  }

  task_tracker_.PostTask(jni_message_loop_->task_runner().get(), FROM_HERE,
                         task);
  do_in_jni_thread(FROM_HERE, task);
}

class A2dpInterfaceImpl : public A2dpInterface {
@@ -466,11 +454,6 @@ void AvrcpService::ServiceInterfaceImpl::Init(
  CHECK(instance_ == nullptr);
  instance_ = new AvrcpService();

  {
    std::lock_guard<std::mutex> jni_lock(jni_mutex_);
    jni_message_loop_ = get_jni_message_loop();
  }

  do_in_main_thread(FROM_HERE,
                    base::Bind(&AvrcpService::Init, base::Unretained(instance_),
                               media_interface, volume_interface));
@@ -522,12 +505,6 @@ bool AvrcpService::ServiceInterfaceImpl::Cleanup() {

  if (instance_ == nullptr) return false;

  {
    std::lock_guard<std::mutex> jni_lock(jni_mutex_);
    task_tracker_.TryCancelAll();
    jni_message_loop_ = nullptr;
  }

  do_in_main_thread(FROM_HERE,
                    base::Bind(&AvrcpService::Cleanup, base::Owned(instance_)));

+1 −2
Original line number Diff line number Diff line
@@ -54,8 +54,7 @@ class OnceClosure {
  }

  void Run() const {
    base::SequencedTaskRunnerHandle::Get()->PostTask(
        FROM_HERE, std::move(*closure_));
    std::move(*closure_).Run();
    delete closure_;
    ((OnceClosure*)this)->closure_ = nullptr;
  }