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.
This commit is contained in:
parent
d23913f2d9
commit
c1ad6121ca
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2015, Hamish Morrison <hamishm53@gmail.com>
|
||||
* 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);
|
||||
|
@ -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();
|
||||
|
||||
@ -140,6 +141,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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user