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

Commit 4abacfc2 authored by Phil Burk's avatar Phil Burk Committed by android-build-merger
Browse files

aaudio: fix leak of AAudioBinderClient

am: 9b3f8ef2

Change-Id: I2e7f25a159efe384ca0ea51a581fac13cc58768b
parents d7d4b6ad 9b3f8ef2
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <binder/IServiceManager.h>
#include <utils/Mutex.h>
#include <utils/RefBase.h>
#include <utils/Singleton.h>

#include <aaudio/AAudio.h>

@@ -47,6 +48,8 @@ using namespace aaudio;
static android::Mutex gServiceLock;
static sp<IAAudioService>  gAAudioService;

ANDROID_SINGLETON_STATIC_INSTANCE(AAudioBinderClient);

// TODO Share code with other service clients.
// Helper function to get access to the "AAudioService" service.
// This code was modeled after frameworks/av/media/libaudioclient/AudioSystem.cpp
@@ -81,7 +84,8 @@ static void dropAAudioService() {
}

AAudioBinderClient::AAudioBinderClient()
        : AAudioServiceInterface() {}
        : AAudioServiceInterface()
        , Singleton<AAudioBinderClient>() {}

AAudioBinderClient::~AAudioBinderClient() {}

+4 −1
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
#ifndef ANDROID_AAUDIO_AAUDIO_BINDER_CLIENT_H
#define ANDROID_AAUDIO_AAUDIO_BINDER_CLIENT_H

#include <utils/Singleton.h>

#include <aaudio/AAudio.h>
#include "AAudioServiceDefinitions.h"
#include "AAudioServiceInterface.h"
@@ -30,7 +32,8 @@

namespace aaudio {

class AAudioBinderClient : public AAudioServiceInterface {
class AAudioBinderClient : public AAudioServiceInterface
        , public android::Singleton<AAudioBinderClient> {

public:

+1 −3
Original line number Diff line number Diff line
@@ -61,9 +61,7 @@ static aaudio_result_t builder_createStream(aaudio_direction_t direction,

        case AAUDIO_DIRECTION_OUTPUT:
            if (tryMMap) {
                // TODO use a singleton for the AAudioBinderClient
                AAudioBinderClient *aaudioClient = new AAudioBinderClient();
                *audioStreamPtr = new AudioStreamInternal(*aaudioClient, false);
                *audioStreamPtr = new AudioStreamInternal(AAudioBinderClient::getInstance(), false);
            } else {
                *audioStreamPtr = new AudioStreamTrack();
            }