[haiku-commits] haiku: hrev50886 - in src: add-ons/media/media-add-ons/multi_audio kits/media/experimental

  • From: b.vitruvio@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 20 Jan 2017 20:56:00 +0100 (CET)

hrev50886 adds 2 changesets to branch 'master'
old head: 534a5376408728ae93c6d6f976e961c5bf066dfe
new head: 19da5e15c33f9a85d1e4ca0779f5082fd9d1eaf0
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=19da5e15c33f+%5E534a53764087

----------------------------------------------------------------------------

0563e540b04f: MediaClient: Remove operator overloding from private class

19da5e15c33f: MultiAudioNode: Fix and polish output locking issues
  
  * For people involved please review, too much confusion seems
  to have been done in past.
  * The fBufferFreeSem is removed as it didn't make sense. It was
  used to detected when the output thread should be stopped, a
  boolean flag is used instead.
  * Avoid to allocate a BAutolocker at begin of the _OutputThread,
  plain Lock/Unlock is used instead.
  * The fBufferLock is now locked when a buffer is handled.

                                [ Dario Casalinuovo <b.vitruvio@xxxxxxxxx> ]

----------------------------------------------------------------------------

3 files changed, 11 insertions(+), 33 deletions(-)
.../media-add-ons/multi_audio/MultiAudioNode.cpp | 31 +++++++-------------
.../media-add-ons/multi_audio/MultiAudioNode.h   |  2 +-
src/kits/media/experimental/MediaClient.cpp      | 11 -------

############################################################################

Commit:      0563e540b04f5a3fb00033b7693be42cc66e0b4c
URL:         http://cgit.haiku-os.org/haiku/commit/?id=0563e540b04f
Author:      Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
Date:        Wed Jan 18 19:25:05 2017 UTC

MediaClient: Remove operator overloding from private class

----------------------------------------------------------------------------

diff --git a/src/kits/media/experimental/MediaClient.cpp 
b/src/kits/media/experimental/MediaClient.cpp
index c37d29a..fcd6c74 100755
--- a/src/kits/media/experimental/MediaClient.cpp
+++ b/src/kits/media/experimental/MediaClient.cpp
@@ -55,12 +55,6 @@ public:
        {
                return dynamic_cast<BMediaInput*>(ConnReleaser::Obj());
        }
-
-       operator BMediaInput* () const
-       {
-               return Obj();
-       }
-
 };
 
 
@@ -74,11 +68,6 @@ public:
        {
                return dynamic_cast<BMediaOutput*>(ConnReleaser::Obj());
        }
-
-       operator BMediaOutput* () const
-       {
-               return Obj();
-       }
 };
 
 

############################################################################

Revision:    hrev50886
Commit:      19da5e15c33f9a85d1e4ca0779f5082fd9d1eaf0
URL:         http://cgit.haiku-os.org/haiku/commit/?id=19da5e15c33f
Author:      Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
Date:        Fri Jan 20 19:48:27 2017 UTC

MultiAudioNode: Fix and polish output locking issues

* For people involved please review, too much confusion seems
to have been done in past.
* The fBufferFreeSem is removed as it didn't make sense. It was
used to detected when the output thread should be stopped, a
boolean flag is used instead.
* Avoid to allocate a BAutolocker at begin of the _OutputThread,
plain Lock/Unlock is used instead.
* The fBufferLock is now locked when a buffer is handled.

----------------------------------------------------------------------------

diff --git a/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp 
b/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp
index fc22874..2444794 100644
--- a/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp
+++ b/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp
@@ -173,6 +173,7 @@ MultiAudioNode::MultiAudioNode(BMediaAddOn* addon, const 
char* name,
        BBufferConsumer(B_MEDIA_RAW_AUDIO),
        BBufferProducer(B_MEDIA_RAW_AUDIO),
        BMediaEventLooper(),
+       fRunOutput(false),
        fBufferLock("multi audio buffers"),
        fThread(-1),
        fDevice(device),
@@ -1172,6 +1173,8 @@ MultiAudioNode::_HandleBuffer(const media_timed_event* 
event,
                fprintf(stderr,"        <- LATE BUFFER : %" B_PRIdBIGTIME "\n", 
lateness);
                buffer->Recycle();
        } else {
+               BAutolock _(fBufferLock);
+
                //WriteBuffer(buffer, *channel);
                // TODO: This seems like a very fragile mechanism to wait until
                // the previous buffer for this channel has been processed...
@@ -1777,18 +1780,13 @@ MultiAudioNode::_OutputThread()
 
        // init the performance time computation
        {
-               BAutolock locker(fBufferLock);
+               fBufferLock.Lock();
                
fTimeComputer.Init(fOutputPreferredFormat.u.raw_audio.frame_rate,
                        system_time());
+               fBufferLock.Unlock();
        }
 
-       while (true) {
-               // TODO: why this semaphore??
-               if (acquire_sem_etc(fBufferFreeSem, 1, B_RELATIVE_TIMEOUT, 0)
-                               == B_BAD_SEM_ID) {
-                       return B_OK;
-               }
-
+       while (fRunOutput) {
                BAutolock locker(fBufferLock);
                        // make sure the buffers don't change while we're 
playing with them
 
@@ -1836,9 +1834,6 @@ MultiAudioNode::_OutputThread()
                                                _WriteZeros(*input, 
input->fBufferCycle);
                                        //PRINT(("MultiAudioNode::Runthread 
WriteZeros\n"));
                                }
-
-                               // mark buffer free
-                               release_sem(fBufferFreeSem);
                        } else {
                                //PRINT(("playback_buffer_cycle non ok input : 
%i\n", i));
                        }
@@ -2048,21 +2043,14 @@ MultiAudioNode::_StartOutputThreadIfNeeded()
        if (fThread >= 0)
                return B_OK;
 
-       // allocate buffer free semaphore
-       fBufferFreeSem = create_sem(
-               fDevice->BufferList().return_playback_buffers - 1,
-               "multi_audio out buffer free");
-       if (fBufferFreeSem < B_OK)
-               return fBufferFreeSem;
+       fRunOutput = true;
 
        PublishTime(-50, 0, 0);
 
        fThread = spawn_thread(_OutputThreadEntry, "multi_audio audio output",
                B_REAL_TIME_PRIORITY, this);
-       if (fThread < B_OK) {
-               delete_sem(fBufferFreeSem);
+       if (fThread < B_OK)
                return fThread;
-       }
 
        resume_thread(fThread);
        return B_OK;
@@ -2073,7 +2061,8 @@ status_t
 MultiAudioNode::_StopOutputThread()
 {
        CALLED();
-       delete_sem(fBufferFreeSem);
+
+       fRunOutput = false;
 
        status_t exitValue;
        wait_for_thread(fThread, &exitValue);
diff --git a/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.h 
b/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.h
index 473c77b..0add2ff 100644
--- a/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.h
+++ b/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.h
@@ -208,6 +208,7 @@ private:
 
 private:
        status_t                        fInitStatus;
+       bool                            fRunOutput;
 
        BMediaAddOn*            fAddOn;
        int32                           fId;
@@ -227,7 +228,6 @@ private:
                // not the defaults that are in the parameters
        bigtime_t                       fBufferPeriod;
 
-       sem_id                          fBufferFreeSem;
        thread_id                       fThread;
        MultiAudioDevice*       fDevice;
        bool                            fTimeSourceStarted;


Other related posts: