Skip to content

Commit

Permalink
Fix dependencies and progress bar of audio playback
Browse files Browse the repository at this point in the history
Signed-off-by: Jacki <[email protected]>
  • Loading branch information
TheJackiMonster committed May 15, 2024
1 parent abeaae1 commit 4f8a95b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Install dependencies (framework)
run: |
sudo apt-get -qq update
sudo apt-get -qq install libgcrypt20-dev recutils libjansson-dev libsodium-dev libcurl4-gnutls-dev libidn2-dev libunistring-dev libsqlite3-dev libmicrohttpd-dev
sudo apt-get -qq install libgcrypt20-dev recutils libjansson-dev libsodium-dev libcurl4-gnutls-dev libidn2-dev libunistring-dev libsqlite3-dev libmicrohttpd-dev libltdl-dev
- name: Build framework
run: |
Expand Down
3 changes: 2 additions & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ parts:
- libunistring-dev
- libsqlite3-dev
- libmicrohttpd-dev
- libltdl-dev
stage-packages:
- libgcrypt20
- recutils
Expand All @@ -80,6 +81,7 @@ parts:
- libmicrohttpd12
- libgnutls-dane0
- libunbound8
- libltdl7
source: http://ftpmirror.gnu.org/gnunet/gnunet-0.21.1.tar.gz
plugin: autotools
autotools-configure-parameters:
Expand Down Expand Up @@ -116,7 +118,6 @@ parts:
- libpipewire-0.3-0t64
- libportal1
- libportal-gtk3-1
- libltdl7
source: http://ftpmirror.gnu.org/gnunet/messenger-gtk-0.9.0.tar.gz
plugin: meson
meson-parameters:
Expand Down
42 changes: 26 additions & 16 deletions src/ui/chat.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,14 +999,23 @@ _play_timer_func(gpointer user_data)
g_assert(user_data);

UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data;
gint64 pos, len;

const gdouble played_seconds = 0.010 * handle->play_time + 0.005;
const gdouble listen_seconds = MAX(handle->record_time - 0.010, 0.0);
handle->play_timer = 0;

if (played_seconds < listen_seconds)
if (!(handle->play_pipeline))
return FALSE;

if (!gst_element_query_position(handle->play_pipeline, GST_FORMAT_TIME, &pos))
return FALSE;

if (!gst_element_query_duration(handle->play_pipeline, GST_FORMAT_TIME, &len))
return FALSE;

if (pos < len)
gtk_progress_bar_set_fraction(
handle->recording_progress_bar,
played_seconds / listen_seconds
1.0 * pos / len
);
else
gtk_progress_bar_set_fraction(
Expand All @@ -1015,16 +1024,11 @@ _play_timer_func(gpointer user_data)
);

if (handle->playing)
{
handle->play_time++;
handle->play_timer = util_timeout_add(
10,
_play_timer_func,
handle
);
}
else
handle->play_timer = 0;

return FALSE;
}
Expand Down Expand Up @@ -1066,14 +1070,20 @@ handle_play_bus_watch(UNUSED GstBus *bus,

switch (type)
{
case GST_MESSAGE_STREAM_START:
handle->play_time = 0;
handle->play_timer = util_idle_add(
_play_timer_func,
handle
);

case GST_MESSAGE_STATE_CHANGED:
{
GstState old_state, new_state, pending_state;
gst_message_parse_state_changed(msg, &old_state, &new_state, &pending_state);

if (GST_STATE_PLAYING == new_state)
handle->play_timer = util_idle_add(
_play_timer_func,
handle
);
else if (GST_STATE_PLAYING == old_state)
_stop_playing_recording(handle, FALSE);
break;
}
case GST_MESSAGE_EOS:
if (handle->playing)
_stop_playing_recording(handle, FALSE);
Expand Down
1 change: 0 additions & 1 deletion src/ui/chat.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ typedef struct UI_CHAT_Handle
guint record_time;

guint play_timer;
guint play_time;

GstElement *record_pipeline;
GstElement *record_sink;
Expand Down

0 comments on commit 4f8a95b

Please sign in to comment.