Skip to content
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

Limit number of Oboe auto restart #4222

Merged
merged 6 commits into from
Dec 19, 2024
Merged

Limit number of Oboe auto restart #4222

merged 6 commits into from
Dec 19, 2024

Conversation

sauwming
Copy link
Member

To fix #4218.

It is reported that Oboe will keep restarting indefinitely upon error.

Also in this PR:
minor: remove unused label on_skip_dev.

Comment on lines 786 to 787
PJ_LOG(3, (THIS_FILE, "Oboe %s stream permanently stopped",
dir_st));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"permanent" because the nrestart will never be reset, so the instance is no longer usable?
Perhaps it can be avoided by adding param to Start(), something like inc_counter flag, which should be true only if it is called by error case? Not sure if it is necessary though.
This may also avoid putting nrestart = 0 in many places?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, remove the log. Now it will use the already existing log message Oboe stream restart failed. Will also notify the callback via PJMEDIA_EVENT_AUD_DEV_ERROR event, so this should be better.

Should I still modify the nrestart counter handling?
IMO, it still needs to be reset when the stream is working (i.e. if it successfully captures or plays an audio frame).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, remove the log. Now it will use the already existing log message Oboe stream restart failed. Will also notify the callback via PJMEDIA_EVENT_AUD_DEV_ERROR event, so this should be better.

Okay.

Just a note: putting ++nrestart inside PJ_LOG(3, ..) is not ideal, as it will not be executed (even not compiled) when PJ_MAX_LOG_LEVEL is set to <3?

Should I still modify the nrestart counter handling? IMO, it still needs to be reset when the stream is working (i.e. if it successfully captures or plays an audio frame).

Yes, it needs to be reset, just the reset places looks rather strange (multiple lines inside the callback), can it be put just once around here for example? Or there are cases that Start() may succeed but somehow the callback is not invoked?

pj_mutex_unlock(mutex);
return PJ_SUCCESS;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can't be put there (in ~L685) because then Start() will immediately reset the counter (after just incremented).

I move it to onAudioReady() instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still don't understand why it can't, as the reset is supposed to be done after the start succeeds (and not reset when fails). And putting it in callback make the reset will be done every callback instead of once only, should work just fine just rather seem strange/unnecessary :)
Also there seem to still another line that reset it in the thread loop too.

Anyway it is just a minor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start() usually just returns success, this is because requestStart() is asynchronous and returns immediately.
(https://google.github.io/oboe/classoboe_1_1_audio_stream.html#a3c484e314dee8dfed1d419f487b5d601)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, now it makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, perhaps we can use blocking start() instead?

virtual Result oboe::AudioStream::start(int64_t timeoutNanoseconds = kDefaultTimeoutNanos)

Start the stream. This will block until the stream has been started, an error occurs or 
timeoutNanoseconds has been reached.

I didn't change it because I don't know the reason why the non-blocking version was selected to be used in the first place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember it either, perhaps to avoid UI hiccup, e.g: make call always tries opening sound device first. I think better to just leave it for now?

@sauwming sauwming merged commit e85d827 into master Dec 19, 2024
35 of 36 checks passed
@sauwming sauwming deleted the oboe-restart branch December 19, 2024 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The ExtraAudioDevice is constantly refreshing the log and crash
2 participants