-
-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Audio only master #1043
Audio only master #1043
Conversation
The audio-only was resetting the frame and settings parameter only when it was set. This created other issues that the "ndi receiver" reset was not done uniformly depending if there was video or audio only. This also created issue at launch to throw some error.
There is a known issue in this PR that might collide with a V6 feature. Let me test it on master before merging. |
Test Settings / steps:
Results possibles:
Test results :
Failure status #1 :
|
HOLD ON for merge! |
Adding a first Frame creation before any drawing start should help with the "frame not seen", "blank frame" and "audio only not on recording" issues.
This is now compatible with the latest added features. It should also fix some other issues where the "frame" of and NDI source is not visible (because size is 0x0 for some reasons). This also should follow the concept that :
Tested on MacOS (M2) with OBS 30.1.2 + test Pattern Generator and a 1K tone |
Related to the 0x0 frame, I have noticed in the latest OBS log output that it says:
So we will need to address the 0x0 problem soon anyway! :) |
@Trouffman Are we good/safe/ok to merge this? |
That error message is new it seems ! (The bmalloc 0 byte allocation) This has been tested on Mac, not yet windows/Linux. Can merge, will need testing anyway. |
This PR would be the place to test the changes on Linux and Windows. Once merged to master there won't be any installers generated until an actual release is tagged. |
Let do the test on this PR! |
I quickly tested on Windows (11) but I need more people to test it on windows.
|
8849a74
to
0fd3765
Compare
src/obs-ndi-source.cpp
Outdated
@@ -440,6 +440,16 @@ void *ndi_source_thread(void *data) | |||
|
|||
NDIlib_recv_create_v3_t *reset_recv_desc = &recv_desc; | |||
|
|||
if (!s->running) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get this.
This line is:
if (!s->running) { ... }
The next immediate line after this if statement is:
while (s->running) { ... }
If the if
statement is entered, then s->running
is false, then the while loop never will be entered.
If the if
statement isn't entered, then s->running
is true, then the while loop will be entered.
I know this ndi_source_thread
runs inside of the while loop.
So, this tells me that this if (!s->running) { ... }
statement is not doing anything.
😕
src/obs-ndi-source.cpp
Outdated
@@ -440,6 +440,16 @@ void *ndi_source_thread(void *data) | |||
|
|||
NDIlib_recv_create_v3_t *reset_recv_desc = &recv_desc; | |||
|
|||
if (!s->running) { | |||
// Force a clean frame at first start | |||
obs_source_output_video(obs_source, blank_video_frame()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allocates a blank video frame and never releases it.
We should probably just reuse s->config.blank_frame
Around DistroAV/src/obs-ndi-source.cpp Lines 202 to 208 in cb40079
I looked into the bmalloc: Allocating 0 bytes is broken behavior log warning and it has been around for over 2 years.We should probably fix this soon too! :) static obs_source_frame *blank_video_frame()
{
obs_source_frame *frame =
obs_source_frame_create(VIDEO_FORMAT_NONE, 0, 0);
frame->timestamp = os_gettime_ns();
return frame;
} This is causing the following OBS log message(s):
I wonder what OBS dev's recommendation is for the best way to have an audio/video capable source that intentionally wants to use only audio and no video. Making a 0x0 video made sense at the time and is obviously a borderline hack. Maybe what we should really be doing is defining two separate NDI Source types:
|
@Trouffman I think we should hold off on this code change and not push it to master. Maybe still keep it open to discuss? |
Agreed. This is not ready for prime time yet. |
So whenever I try to fix one behavior, this brings another side issue or another "combo" of settings that breaks Could be about time to rework that part more deeply. |
@paulpv This would be the new audio-Only fix approach. |
src/obs-ndi-source.cpp
Outdated
@@ -1075,7 +1098,7 @@ void *ndi_source_create(obs_data_t *settings, obs_source_t *obs_source) | |||
QString("OBS-NDI '%1'").arg(name).toUtf8(); | |||
|
|||
// Allocate blank video frame | |||
s->config.blank_frame = blank_video_frame(); | |||
// s->config.blank_frame = blank_video_frame(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentionally not creating any blank_frame?
Does this work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, the creation of the blank frame moved to ndi_source_update().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only line where config.blank_frame
is ever assigned.
There are no other calls to blank_video_frame()
.
So, nothing else is ever creating a blank frame.
If this is commented out then all uses of s->config.blank_frame
are just sending nullptr
.
Maybe this is intentional.
Maybe this is accidental.
Maybe you stumbled on a solution accidentally? 😃
If not calling blank_video_frame()
is intentional and fixes this, then maybe the whole static obs_source_frame *blank_video_frame()
method should be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a happy little accident :D that fixed the bug!
If we call "blank_video_frame()" = the bug exist. Setting config.blank_frame = nullptr (explicitly or not) fixes the problem.
I am looking though commit history to find the reason of that blank frame to see what it was used for. (fixing a bug maybe?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Digging deeper :
This blank_frame was added to fix the Audio only that was "keeping the last frame/not cleaning the frame".
7d1cf13
This was part of v4.3.0 : "Source bugfix: video not cleared when switching to Audio Only mode"
https://github.com/DistroAV/DistroAV/releases/tag/4.3.0
@Trouffman I will test this on Windows [and maybe Linux] once you reply to my comments. That commented out |
Tested and confirmed it works & fix the bug on MACOS & Windows 11. |
src/obs-ndi-source.cpp
Outdated
// Force a clean (blank) frame when settings change to Audio only | ||
if (recv_desc.bandwidth == | ||
NDIlib_recv_bandwidth_audio_only) { | ||
obs_source_output_video(obs_source, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per https://docs.obsproject.com/reference-sources#c.obs_source_output_video
Just use:
obs_source_output_video(obs_source, nullptr);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will update everywhere and get rid of the config.blank_frame then
src/obs-ndi-source.cpp
Outdated
if (config.bandwidth == | ||
NDIlib_recv_bandwidth_audio_only) { | ||
// Force a clean frame when source is updated | ||
obs_source_output_video(obs_source, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per https://docs.obsproject.com/reference-sources#c.obs_source_output_video
Just use:
obs_source_output_video(obs_source, nullptr);
@Trouffman Looks good! I will test this my tonight or tomorrow before approving the code. |
Tests out fine on both Mac and Windows.
All behaved as I would expect it to. More importantly:
I will merge to master. Thanks @Trouffman ! |
This is a master based cherry pick of @Trouffman 's main commit in #1027 to give him credit for the fix.
This will be released as 4.14.1 in a few days.