Skip to content

Commit 0217cd1

Browse files
committed
Use std::function QueuedFunc overloads
1 parent 73830c8 commit 0217cd1

File tree

16 files changed

+34
-44
lines changed

16 files changed

+34
-44
lines changed

src/cdaudio/cdaudio-ng.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static void purge_playlist (Playlist playlist)
190190
}
191191

192192
/* main thread only */
193-
static void purge_all_playlists (void * = nullptr)
193+
static void purge_all_playlists ()
194194
{
195195
int playlists = Playlist::n_playlists ();
196196

@@ -759,7 +759,7 @@ static bool refresh_trackinfo (bool warning)
759759

760760
fail:
761761
reset_trackinfo ();
762-
purge_func.queue (purge_all_playlists, nullptr);
762+
purge_func.queue (purge_all_playlists);
763763
return false;
764764
}
765765

src/gtkui/ui_gtk.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ static void button_add_pressed ()
198198
audgui_run_filebrowser (false);
199199
}
200200

201-
static void title_change (void * = nullptr)
201+
static void title_change ()
202202
{
203203
delayed_title_change.stop ();
204204

@@ -435,7 +435,7 @@ static void ui_playback_begin ()
435435

436436
/* If "title change" is not called by 1/4 second after starting playback,
437437
* show "Buffering ..." as the window title. */
438-
delayed_title_change.queue (250, title_change, nullptr);
438+
delayed_title_change.queue (250, title_change);
439439
}
440440

441441
static void ui_playback_ready ()

src/gtkui/ui_playlist_widget.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ static void popup_trigger (PlaylistWidgetData * data, int pos)
272272

273273
data->popup_pos = pos;
274274
data->popup_timer.queue (aud_get_int ("filepopup_delay") * 100,
275-
aud::obj_member<PlaylistWidgetData, & PlaylistWidgetData::show_popup>, data);
275+
[data] () { data->show_popup (); });
276276
}
277277

278278
static void mouse_motion (void * user, GdkEventMotion * event, int row)

src/gtkui/ui_statusbar.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ static void no_advance_toggled (void *, void * label)
108108
else
109109
gtk_label_set_text ((GtkLabel *) label, _("Playlist mode."));
110110

111-
clear_timeout.start (1000, clear_message, label);
111+
clear_timeout.start (1000, std::bind (clear_message, label));
112112
}
113113

114114
static void stop_after_song_toggled (void *, void * label)
115115
{
116116
if (aud_get_bool ("stop_after_current_song"))
117117
gtk_label_set_text ((GtkLabel *) label, _("Stopping after song."));
118118

119-
clear_timeout.start (1000, clear_message, label);
119+
clear_timeout.start (1000, std::bind (clear_message, label));
120120
}
121121

122122
static void ui_statusbar_destroy_cb ()

src/qtui/main_window.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,9 @@ void MainWindow::playback_begin_cb()
373373

374374
m_last_playing = playing;
375375

376-
m_buffering_timer.queue(
377-
250, aud::obj_member<MainWindow, &MainWindow::buffering_cb>, this);
376+
m_buffering_timer.queue(250, [this]() { set_title(_("Buffering ...")); });
378377
}
379378

380-
void MainWindow::buffering_cb() { set_title(_("Buffering ...")); }
381-
382379
void MainWindow::pause_cb()
383380
{
384381
update_play_pause();

src/qtui/main_window.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ class MainWindow : public QMainWindow, audqt::DockHost
7272

7373
void title_change_cb();
7474
void playback_begin_cb();
75-
void buffering_cb();
7675
void playback_ready_cb();
7776
void pause_cb();
7877
void playback_stop_cb();

src/qtui/playlist-qt.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,8 @@ void PlaylistWidget::triggerPopup(int pos)
529529
audqt::infopopup_hide();
530530

531531
m_popup_pos = pos;
532-
m_popup_timer.queue(
533-
aud_get_int("filepopup_delay") * 100,
534-
aud::obj_member<PlaylistWidget, &PlaylistWidget::showPopup>, this);
532+
m_popup_timer.queue(aud_get_int("filepopup_delay") * 100,
533+
[this]() { showPopup(); });
535534
}
536535

537536
void PlaylistWidget::hidePopup()

src/qtui/status_bar.cc

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,6 @@ static aud::spinlock message_lock;
7474
static int current_message_level = -1;
7575
static unsigned current_message_serial = 0;
7676

77-
static void one_second_cb(void * serial)
78-
{
79-
auto lh = message_lock.take();
80-
81-
/* allow new messages after one second */
82-
if (aud::from_ptr<unsigned>(serial) == current_message_serial)
83-
current_message_level = -1;
84-
}
85-
8677
static bool set_message_level(audlog::Level level)
8778
{
8879
auto lh = message_lock.take();
@@ -94,8 +85,15 @@ static bool set_message_level(audlog::Level level)
9485
current_message_level = level;
9586
current_message_serial++;
9687

97-
message_func.queue(1000, one_second_cb,
98-
aud::to_ptr(current_message_serial));
88+
unsigned serial = current_message_serial;
89+
message_func.queue(1000, [serial]() {
90+
auto lh = message_lock.take();
91+
92+
/* allow new messages after one second */
93+
if (current_message_serial == serial)
94+
current_message_level = -1;
95+
});
96+
9997
return true;
10098
}
10199

src/search-tool-qt/search-tool-qt.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,7 @@ void SearchWidget::search_timeout ()
336336

337337
void SearchWidget::trigger_search ()
338338
{
339-
m_search_timer.queue (SEARCH_DELAY,
340-
aud::obj_member<SearchWidget, & SearchWidget::search_timeout>, this);
339+
m_search_timer.queue (SEARCH_DELAY, [this] () { search_timeout (); });
341340
m_search_pending = true;
342341
}
343342

src/search-tool/search-tool.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static void show_hide_widgets ()
132132
}
133133
}
134134

135-
static void search_timeout (void * = nullptr)
135+
static void search_timeout ()
136136
{
137137
const char * text = gtk_entry_get_text ((GtkEntry *) entry);
138138
auto terms = str_list_to_index (str_tolower_utf8 (text), " ");
@@ -164,7 +164,7 @@ static void search_timeout (void * = nullptr)
164164

165165
static void trigger_search ()
166166
{
167-
s_search_timer.queue (SEARCH_DELAY, search_timeout, nullptr);
167+
s_search_timer.queue (SEARCH_DELAY, search_timeout);
168168
s_search_pending = true;
169169
}
170170

@@ -403,7 +403,7 @@ static const AudguiListCallbacks list_callbacks = {
403403

404404
static void entry_cb (GtkEntry * entry, void * unused)
405405
{
406-
s_search_timer.queue (SEARCH_DELAY, search_timeout, nullptr);
406+
s_search_timer.queue (SEARCH_DELAY, search_timeout);
407407
s_search_pending = true;
408408
}
409409

0 commit comments

Comments
 (0)