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

Commit b421f021 authored by Atneya Nair's avatar Atneya Nair
Browse files

Inherit RefBase virtually across libaudioclient

Since RefBase holds a reference count, it should be inherited
virtually in diamond inheritance scenarios. Since the inheritance
structure of callbacks and interfaces is opaque, these classes
should take the slight performance hit of virtual inheritance to
prevent future difficult to detect bugs and leaks. If performance is
critical, we should inherit non-virtually but make the class final.

Bug: 207034551
Test: Compiles
Change-Id: I1ee39c98735757173c81ccdf3dcc09252a073f8a
parent 40e55d33
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ struct effect_param_cblk_t;

// ----------------------------------------------------------------------------

class AudioEffect : public RefBase
class AudioEffect : public virtual RefBase
{
public:

+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ enum audio_io_config_event_t {

// audio input/output descriptor used to cache output configurations in client process to avoid
// frequent calls through IAudioFlinger
class AudioIoDescriptor : public RefBase {
class AudioIoDescriptor : public virtual RefBase {
public:
    AudioIoDescriptor() = default;
    // For AUDIO_{INPUT|OUTPUT}_CLOSED events.
+3 −3
Original line number Diff line number Diff line
@@ -538,7 +538,7 @@ public:


    // A listener for capture state changes.
    class CaptureStateListener : public RefBase {
    class CaptureStateListener : public virtual RefBase {
    public:
        // Called whenever capture state changes.
        virtual void onStateChanged(bool active) = 0;
@@ -563,7 +563,7 @@ public:

    // ----------------------------------------------------------------------------

    class AudioVolumeGroupCallback : public RefBase
    class AudioVolumeGroupCallback : public virtual RefBase
    {
    public:

@@ -578,7 +578,7 @@ public:
    static status_t addAudioVolumeGroupCallback(const sp<AudioVolumeGroupCallback>& callback);
    static status_t removeAudioVolumeGroupCallback(const sp<AudioVolumeGroupCallback>& callback);

    class AudioPortCallback : public RefBase
    class AudioPortCallback : public virtual RefBase
    {
    public:

+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ namespace android {

// ----------------------------------------------------------------------------

class IAudioFlinger : public RefBase {
class IAudioFlinger : public virtual RefBase {
public:
    static constexpr char DEFAULT_SERVICE_NAME[] = "media.audio_flinger";