[haiku-commits] haiku: hrev50078 - src/kits/media headers/private/media

  • From: b.vitruvio@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 9 Feb 2016 21:35:22 +0100 (CET)

hrev50078 adds 2 changesets to branch 'master'
old head: cc0d365ef7550b8613c8aa72c61ac24fd1260f68
new head: c1ad6121ca4471bbfd0e967f7b593009caf38e40
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=c1ad6121ca44+%5Ecc0d365ef755

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

d23913f2d90f: BMediaRecorder: Return the actual accepted format
  
  * Allow SoundRecorder to record without the need of a system mixer
  in front, for the nodes I can test.
  * Solve other format related problems.

c1ad6121ca44: BMediaRecorder: Solve possible problem with node references
  
  * Since the BMediaRecorder have an it's own estabilished policy
  relating releasing the producer node we will not interfere with
  it except when we are controlled from Cortex.

                                [ Dario Casalinuovo <b.vitruvio@xxxxxxxxx> ]

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

3 files changed, 35 insertions(+), 19 deletions(-)
headers/private/media/MediaRecorderNode.h |  4 ++-
src/kits/media/MediaRecorder.cpp          | 14 ++++++-----
src/kits/media/MediaRecorderNode.cpp      | 36 ++++++++++++++++++---------

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

Commit:      d23913f2d90f0a045a41d9e68a966f06a9e6fcf0
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d23913f2d90f
Author:      Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
Date:        Tue Feb  9 19:03:51 2016 UTC

BMediaRecorder: Return the actual accepted format

* Allow SoundRecorder to record without the need of a system mixer
in front, for the nodes I can test.
* Solve other format related problems.

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

diff --git a/src/kits/media/MediaRecorder.cpp b/src/kits/media/MediaRecorder.cpp
index 665bbf0..dd3347c 100644
--- a/src/kits/media/MediaRecorder.cpp
+++ b/src/kits/media/MediaRecorder.cpp
@@ -413,13 +413,11 @@ BMediaRecorder::_Connect(const media_node& node,
        if (ourOutput.source == media_source::null)
                return B_MEDIA_BAD_SOURCE;
 
-       fOutputSource = ourOutput.source;
-
        // find our Node's free input
        media_input ourInput;
        fNode->GetInput(&ourInput);
 
-       return BMediaRoster::CurrentRoster()->Connect(fOutputSource,
+       return BMediaRoster::CurrentRoster()->Connect(ourOutput.source,
                ourInput.destination, &ourFormat, &ourOutput, &ourInput,
                BMediaRoster::B_CONNECT_MUTED);
 }
diff --git a/src/kits/media/MediaRecorderNode.cpp 
b/src/kits/media/MediaRecorderNode.cpp
index 6a7a3a5..40371ac 100644
--- a/src/kits/media/MediaRecorderNode.cpp
+++ b/src/kits/media/MediaRecorderNode.cpp
@@ -104,6 +104,7 @@ BMediaRecorderNode::SetAcceptedFormat(const media_format& 
format)
 {
        CALLED();
 
+       fInput.format = format;
        fOKFormat = format;
 }
 
@@ -113,7 +114,7 @@ BMediaRecorderNode::AcceptedFormat() const
 {
        CALLED();
 
-       return fOKFormat;
+       return fInput.format;
 }
 
 

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

Revision:    hrev50078
Commit:      c1ad6121ca4471bbfd0e967f7b593009caf38e40
URL:         http://cgit.haiku-os.org/haiku/commit/?id=c1ad6121ca44
Author:      Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
Date:        Tue Feb  9 19:24:54 2016 UTC

BMediaRecorder: Solve possible problem with node references

* Since the BMediaRecorder have an it's own estabilished policy
relating releasing the producer node we will not interfere with
it except when we are controlled from Cortex.

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

diff --git a/headers/private/media/MediaRecorderNode.h 
b/headers/private/media/MediaRecorderNode.h
index 746e5ac..616ef2d 100644
--- a/headers/private/media/MediaRecorderNode.h
+++ b/headers/private/media/MediaRecorderNode.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014, Dario Casalinuovo
+ * Copyright 2014-2016, Dario Casalinuovo
  * Copyright 1999, Be Incorporated
  * All Rights Reserved.
  * This file may be used under the terms of the Be Sample Code License.
@@ -32,6 +32,7 @@ public:
                        void                            GetInput(media_input* 
input);
 
                        void                            SetDataEnabled(bool 
enabled);
+                       void                            
ActivateInternalConnect(bool connectMode);
 
 protected:
 
@@ -106,6 +107,7 @@ protected:
                        media_format            fOKFormat;
                        media_input                     fInput;
                        BString                         fName;
+                       bool                            fConnectMode;
 };
 
 }
diff --git a/src/kits/media/MediaRecorder.cpp b/src/kits/media/MediaRecorder.cpp
index dd3347c..2871dbe 100644
--- a/src/kits/media/MediaRecorder.cpp
+++ b/src/kits/media/MediaRecorder.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright 2015, Hamish Morrison <hamishm53@xxxxxxxxx>
- * Copyright 2014, Dario Casalinuovo
+ * Copyright 2014-2016, Dario Casalinuovo
  * Copyright 1999, Be Incorporated
  * All Rights Reserved.
  * This file may be used under the terms of the Be Sample Code License.
@@ -388,7 +388,7 @@ BMediaRecorder::_Connect(const media_node& node,
 
        fOutputNode = node;
 
-       // figure out the output provided
+       // Figure out the output provided
        if (output != NULL) {
                ourOutput = *output;
        } else if (err == B_OK) {
@@ -413,10 +413,14 @@ BMediaRecorder::_Connect(const media_node& node,
        if (ourOutput.source == media_source::null)
                return B_MEDIA_BAD_SOURCE;
 
-       // find our Node's free input
+       // Find our Node's free input
        media_input ourInput;
        fNode->GetInput(&ourInput);
 
+       // Acknowledge the node that we already know
+       // who is our producer node.
+       fNode->ActivateInternalConnect(false);
+
        return BMediaRoster::CurrentRoster()->Connect(ourOutput.source,
                ourInput.destination, &ourFormat, &ourOutput, &ourInput,
                BMediaRoster::B_CONNECT_MUTED);
diff --git a/src/kits/media/MediaRecorderNode.cpp 
b/src/kits/media/MediaRecorderNode.cpp
index 40371ac..40609cd 100644
--- a/src/kits/media/MediaRecorderNode.cpp
+++ b/src/kits/media/MediaRecorderNode.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014, Dario Casalinuovo
+ * Copyright 2014-2016, Dario Casalinuovo
  * Copyright 1999, Be Incorporated
  * All Rights Reserved.
  * This file may be used under the terms of the Be Sample Code License.
@@ -25,7 +25,8 @@ BMediaRecorderNode::BMediaRecorderNode(const char* name,
        BMediaNode(name),
        BMediaEventLooper(),
        BBufferConsumer(type),
-       fRecorder(recorder)
+       fRecorder(recorder),
+       fConnectMode(true)
 {
        CALLED();
 
@@ -141,6 +142,13 @@ BMediaRecorderNode::SetDataEnabled(bool enabled)
 
 
 void
+BMediaRecorderNode::ActivateInternalConnect(bool connectMode)
+{
+       fConnectMode = connectMode;
+}
+
+
+void
 BMediaRecorderNode::HandleEvent(const media_timed_event* event,
        bigtime_t lateness, bool realTimeEvent)
 {
@@ -298,16 +306,17 @@ BMediaRecorderNode::Connected(const media_source 
&producer,
        fInput.format = withFormat;
        *outInput = fInput;
 
-       // This is a workaround needed for us to get the node
-       // so that our owner class can do it's operations.
-       media_node node;
-       BMediaRosterEx* roster = MediaRosterEx(BMediaRoster::CurrentRoster());
-       if (roster->GetNodeFor(roster->NodeIDFor(producer.port), &node) != B_OK)
-               return B_MEDIA_BAD_NODE;
-
-       fRecorder->fOutputNode = node;
-       fRecorder->fReleaseOutputNode = true;
+       if (fConnectMode == true) {
+               // This is a workaround needed for us to get the node
+               // so that our owner class can do it's operations.
+               media_node node;
+               BMediaRosterEx* roster = 
MediaRosterEx(BMediaRoster::CurrentRoster());
+               if (roster->GetNodeFor(roster->NodeIDFor(producer.port), &node) 
!= B_OK)
+                       return B_MEDIA_BAD_NODE;
 
+               fRecorder->fOutputNode = node;
+               fRecorder->fReleaseOutputNode = true;
+       }
        fRecorder->SetUpConnection(producer);
        fRecorder->fConnected = true;
 
@@ -322,6 +331,8 @@ BMediaRecorderNode::Disconnected(const media_source& 
producer,
        CALLED();
 
        fInput.source = media_source::null;
+       // Reset the connection mode
+       fConnectMode = true;
        fRecorder->fConnected = false;
        fInput.format = fOKFormat;
 }


Other related posts:

  • » [haiku-commits] haiku: hrev50078 - src/kits/media headers/private/media - b . vitruvio