lfb_event_trigger_feedback_async() internally uses a GTask to handle
invocation of the user provided callback when g_task_return_*() is
called.
Currently GTask is completed first and only afterwards is the state of
the event being updated which can lead to suprising behaviour in code
like this:
static void
on_event_triggered (LfbEvent *event,
GAsyncResult *res,
CallsRinger *self)
{
g_autoptr (GError) err = NULL;
gboolean ok;
g_return_if_fail (LFB_IS_EVENT (event));
ok = lfb_event_trigger_feedback_finish (event, res, &err);
if (ok) {
LfbEventState state = lfb_event_get_state (event);
/* do something with state */
}
}
In this case `state` would return a stale value that's about to get
changed. Instead it would be better to *first* change the state and only
afterwards complete the GTask.
This also makes the sync and async variants consistent in terms of when
they change the event state.
Closes: #59
The old wording could be interpreted as the feedback being discarded if
it's noisier than the currently selected profile which is not the case.
Also take the new per application settings into account.
Remove the feedback and the associated callback data before invoking the
callback (which then triggers FbdFeebackBased:ended) since we otherwise
remove the data from the currently playing sound from the hash table
instead of removing the data from the sound that just finished playing.
Call flow for a repeating sound before:
on_sound_play_finished_callback()
data->callback()
fbd_feedback_get_ended()
on_fb_ended()
fbd_feedback_run()
g_hash_table_insert(..., feedback, data)
fbd_dev_sound_play()
gsound_context_play_full() [async]
g_hash_table_remove (..., data->feedback) <- removes wrong feedback
So (since the feedback is still the same but only the callback data
changes) we end up removing the data from the currently playing sound
from the hash table and any calls to fbd_dev_sound_stop() would fail
to find data and hence not cancel the playing sound.
Call flow for a repeating sound now:
on_sound_play_finished_callback()
g_hash_table_remove (..., data->feedback)
data->callback()
fbd_feedback_get_ended()
on_fb_ended()
fbd_feedback_run()
g_hash_table_insert(..., feedback, data)
fbd_dev_sound_play()
gsound_context_play_full() [async]
So we remove the data of the currently playing sound before adding
the feedback to the hash table again. No ownership is transfered to
the hash table so no cleanusp need to be changed.
Closes: https://source.puri.sm/Librem5/feedbackd/-/issues/46
Phosh recently changed to XDG_CURRENT_DESKTOP=GNOME:Phosh and has since stopped
using the configured theme and instead used the fallback freedesktop theme.
Closes#41
This would allow users to create their own feedback profiles
without editing system files or using root privileges
Signed-off-by: Pablo Correa Gómez <ablocorrea@hotmail.com>
The README currently states that feedbackd uses the `default.json` theme, whose
location is hardcoded into the application. This doesn't reflect the current
state of the code.
Explain the ability to add custom themes and give some examples to the user.
Also mention the `feedbackd-device-themes` repository explicitly for users
looking to modify the current `default.json` theme. Adds explanations about the
correct naming of custom theme files and theme file precedence when multiple
themes exist.
Previously, assembly of the theme paths for custom paths (based on
`XDG_DATA_DIRS`) was performed using `g_strconcat`, which produced erroneous
file paths with missing path separators due to a typo in the code.
Instead, make use of `g_build_filename` to assemble the theme paths from
`XDG_DATA_DIRS` to look for custom themes, which automatically introduces
host-specific path separators between individual path components. This
introduces another temporary variable to ensure that the filename (which is
itself assembled from a name and the file ending) isn't mangled by introduction
of a path separator between these two "parts".