[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/tor-browser][tor-browser-102.12.0esr-12.0-1] Bug 1832832 - protect encoder accesses in Java callbacks. r=media-playback-reviewers, alwu a=pascalc



Title: GitLab

richard pushed to branch tor-browser-102.12.0esr-12.0-1 at The Tor Project / Applications / Tor Browser

Commits:

  • d661761c
    by John Lin at 2023-06-06T16:34:36+00:00
    Bug 1832832 - protect encoder accesses in Java callbacks. r=media-playback-reviewers,alwu a=pascalc
    
    Differential Revision: https://phabricator.services.mozilla.com/D178564

2 changed files:

Changes:

  • dom/media/platforms/android/AndroidDataEncoder.cpp
    ... ... @@ -494,7 +494,10 @@ void AndroidDataEncoder<ConfigType>::CallbacksSupport::HandleInput(
    494 494
     template <typename ConfigType>
    
    495 495
     void AndroidDataEncoder<ConfigType>::CallbacksSupport::HandleOutput(
    
    496 496
         java::Sample::Param aSample, java::SampleBuffer::Param aBuffer) {
    
    497
    -  mEncoder->ProcessOutput(std::move(aSample), std::move(aBuffer));
    
    497
    +  MutexAutoLock lock(mMutex);
    
    498
    +  if (mEncoder) {
    
    499
    +    mEncoder->ProcessOutput(std::move(aSample), std::move(aBuffer));
    
    500
    +  }
    
    498 501
     }
    
    499 502
     
    
    500 503
     template <typename ConfigType>
    
    ... ... @@ -504,7 +507,10 @@ void AndroidDataEncoder<ConfigType>::CallbacksSupport::
    504 507
     template <typename ConfigType>
    
    505 508
     void AndroidDataEncoder<ConfigType>::CallbacksSupport::HandleError(
    
    506 509
         const MediaResult& aError) {
    
    507
    -  mEncoder->Error(aError);
    
    510
    +  MutexAutoLock lock(mMutex);
    
    511
    +  if (mEncoder) {
    
    512
    +    mEncoder->Error(aError);
    
    513
    +  }
    
    508 514
     }
    
    509 515
     
    
    510 516
     // Force compiler to generate code.
    

  • dom/media/platforms/android/AndroidDataEncoder.h
    ... ... @@ -13,6 +13,7 @@
    13 13
     
    
    14 14
     #include "mozilla/Maybe.h"
    
    15 15
     #include "mozilla/Monitor.h"
    
    16
    +#include "mozilla/Mutex.h"
    
    16 17
     
    
    17 18
     namespace mozilla {
    
    18 19
     
    
    ... ... @@ -36,7 +37,15 @@ class AndroidDataEncoder final : public MediaDataEncoder {
    36 37
       class CallbacksSupport final : public JavaCallbacksSupport {
    
    37 38
        public:
    
    38 39
         explicit CallbacksSupport(AndroidDataEncoder* aEncoder)
    
    39
    -        : mEncoder(aEncoder) {}
    
    40
    +        : mMutex("AndroidDataEncoder::CallbacksSupport") {
    
    41
    +      MutexAutoLock lock(mMutex);
    
    42
    +      mEncoder = aEncoder;
    
    43
    +    }
    
    44
    +
    
    45
    +    ~CallbacksSupport() {
    
    46
    +      MutexAutoLock lock(mMutex);
    
    47
    +      mEncoder = nullptr;
    
    48
    +    }
    
    40 49
     
    
    41 50
         void HandleInput(int64_t aTimestamp, bool aProcessed) override;
    
    42 51
         void HandleOutput(java::Sample::Param aSample,
    
    ... ... @@ -46,7 +55,8 @@ class AndroidDataEncoder final : public MediaDataEncoder {
    46 55
         void HandleError(const MediaResult& aError) override;
    
    47 56
     
    
    48 57
        private:
    
    49
    -    AndroidDataEncoder* mEncoder;
    
    58
    +    Mutex mMutex;
    
    59
    +    AndroidDataEncoder* mEncoder MOZ_GUARDED_BY(mMutex);
    
    50 60
       };
    
    51 61
       friend class CallbacksSupport;
    
    52 62
     
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits