Skip to content

Commit

Permalink
fix(linux): Handle failures of OnMediaStateChange in OnMediaError (#1731
Browse files Browse the repository at this point in the history
)

# Description

Failures which occured in OnMediaStateChange method, were also thrown in
OnMediaError. So the error was propagated twice and therefore the tests
fail from time to time. This ensures to correctly throw the error only
once, but also log the state change failure.
  • Loading branch information
Gustl22 committed Dec 15, 2023
1 parent 87f3cb7 commit 3a5c6dc
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/audioplayers_linux/linux/audio_player.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ void AudioPlayer::OnMediaError(GError* error, gchar* debug) {
", Code: " + std::to_string(error->code) + ")";
FlValue* details = fl_value_new_string(detailsStr.c_str());
// https://gstreamer.freedesktop.org/documentation/gstreamer/gsterror.html#enumerations
if (error->domain == GST_STREAM_ERROR) {
if (error->domain == GST_STREAM_ERROR ||
error->domain == GST_RESOURCE_ERROR) {
message =
"Failed to set source. For troubleshooting, "
"see: " STR_LINK_TROUBLESHOOTING;
Expand Down Expand Up @@ -185,17 +186,12 @@ void AudioPlayer::OnMediaStateChange(GstObject* src,
GstStateChangeReturn ret =
gst_element_set_state(playbin, GST_STATE_PAUSED);
if (ret == GST_STATE_CHANGE_FAILURE) {
// Only use [OnLog] as error is handled via [OnMediaError].
gchar const* errorDescription =
"OnMediaStateChange -> GST_STATE_CHANGE_FAILURE:"
"Unable to set the pipeline from GST_STATE_READY to "
"GST_STATE_PAUSED.";
if (this->_isInitialized) {
this->OnError("LinuxAudioError", errorDescription, nullptr, nullptr);
} else {
this->OnError("LinuxAudioError",
"Failed to set source. For troubleshooting, "
"see: " STR_LINK_TROUBLESHOOTING,
fl_value_new_string(errorDescription), nullptr);
}
this->OnLog(errorDescription);
}
if (this->_isInitialized) {
this->_isInitialized = false;
Expand Down

0 comments on commit 3a5c6dc

Please sign in to comment.