diff --git a/.clang-format b/.clang-format index 4163ab7406..c6247d080e 100644 --- a/.clang-format +++ b/.clang-format @@ -29,7 +29,7 @@ BinPackParameters: false BraceWrapping: AfterCaseLabel: false AfterClass: false - AfterControlStatement: Never + AfterControlStatement: false AfterEnum: false AfterFunction: false AfterNamespace: false @@ -55,7 +55,7 @@ BreakConstructorInitializersBeforeComma: false BreakConstructorInitializers: BeforeComma BreakAfterJavaFieldAnnotations: false BreakStringLiterals: false -ColumnLimit: 0 +ColumnLimit: 120 CommentPragmas: '^ IWYU pragma:' QualifierAlignment: Leave CompactNamespaces: false diff --git a/plugins/gtkui/medialib/medialibwidget.c b/plugins/gtkui/medialib/medialibwidget.c index 95ca79952c..8c689e02ac 100644 --- a/plugins/gtkui/medialib/medialibwidget.c +++ b/plugins/gtkui/medialib/medialibwidget.c @@ -349,7 +349,10 @@ _scriptableSelectSelectionDidChange (gtkScriptableSelectViewController_t *vc, sc } static void -_scriptableSelectScriptableDidChange (gtkScriptableSelectViewController_t *view_controller, gtkScriptableChange_t change_type, void *context) { +_scriptableSelectScriptableDidChange ( + gtkScriptableSelectViewController_t *view_controller, + gtkScriptableChange_t change_type, + void *context) { w_medialib_viewer_t *mlv = context; scriptableItem_t *presets = plugin->get_queries_scriptable (mlv->source); scriptableItemSave (presets); @@ -433,13 +436,26 @@ _create_text_column (w_medialib_viewer_t *w, GtkTreeView *tree, int column_index } static GtkTreeViewColumn * -_create_lazy_pixbuf_column (w_medialib_viewer_t *w, GtkTreeView *tree, int path_column_index, int pixbuf_column_index, const char *title, int align_right) { +_create_lazy_pixbuf_column ( + w_medialib_viewer_t *w, + GtkTreeView *tree, + int path_column_index, + int pixbuf_column_index, + const char *title, + int align_right) { GtkCellRenderer *rend = NULL; rend = GTK_CELL_RENDERER (ml_cell_renderer_pixbuf_new (&w->pixbuf_cell_delegate)); if (align_right) { g_object_set (rend, "xalign", 1.0, NULL); } - return gtk_tree_view_column_new_with_attributes (title, rend, "path", path_column_index, "pixbuf", pixbuf_column_index, NULL); + return gtk_tree_view_column_new_with_attributes ( + title, + rend, + "path", + path_column_index, + "pixbuf", + pixbuf_column_index, + NULL); } static GtkTreeViewColumn * @@ -500,7 +516,11 @@ _collect_tracks_from_iter (GtkTreeModel *model, GtkTreeIter *iter, ddb_playItem_ } static int -_collect_selected_tracks (GtkTreeModel *model, GtkTreeSelection *selection, ddb_playItem_t **tracks, int append_position) { +_collect_selected_tracks ( + GtkTreeModel *model, + GtkTreeSelection *selection, + ddb_playItem_t **tracks, + int append_position) { GList *selected_rows = gtk_tree_selection_get_selected_rows (selection, NULL); int count = 0; @@ -710,12 +730,7 @@ _configure_did_activate (GtkButton *self, gpointer user_data) { } static void -_drag_data_get ( - GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *selection_data, - guint info, - guint time) { +_drag_data_get (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data, guint info, guint time) { GtkTreeModel *model = GTK_TREE_MODEL (gtk_tree_view_get_model (GTK_TREE_VIEW (widget))); GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)); @@ -727,7 +742,12 @@ _drag_data_get ( _collect_selected_tracks (model, selection, tracks, 0); GdkAtom type = gtk_selection_data_get_target (selection_data); - gtk_selection_data_set (selection_data, type, sizeof (void *) * 8, (const guchar *)tracks, count * sizeof (ddb_playItem_t *)); + gtk_selection_data_set ( + selection_data, + type, + sizeof (void *) * 8, + (const guchar *)tracks, + count * sizeof (ddb_playItem_t *)); free (tracks); tracks = NULL; @@ -801,11 +821,15 @@ _pixbuf_cell_did_become_visible (void *ctx, const char *pathstr) { } int64_t reload_index = mlv->reload_index; - GdkPixbuf *cached_cover = covermanager_cover_for_track_no_default (covermanager_shared (), track, mlv->artwork_source_id, ^(GdkPixbuf *img) { - if (reload_index == mlv->reload_index && img != NULL) { - _receive_cover (mlv, path, img); - } - }); + GdkPixbuf *cached_cover = covermanager_cover_for_track_no_default ( + covermanager_shared (), + track, + mlv->artwork_source_id, + ^(GdkPixbuf *img) { + if (reload_index == mlv->reload_index && img != NULL) { + _receive_cover (mlv, path, img); + } + }); if (cached_cover != NULL) { _receive_cover (mlv, path, cached_cover); @@ -908,7 +932,8 @@ w_medialib_viewer_create (void) { gtk_tree_view_set_model (GTK_TREE_VIEW (w->tree), GTK_TREE_MODEL (store)); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (w->tree), TRUE); - GtkTreeViewColumn *col_icon = _create_lazy_pixbuf_column (w, GTK_TREE_VIEW (w->tree), COL_PATH, COL_ICON, "Icon", 0); + GtkTreeViewColumn *col_icon = + _create_lazy_pixbuf_column (w, GTK_TREE_VIEW (w->tree), COL_PATH, COL_ICON, "Icon", 0); GtkTreeViewColumn *col_text = _create_text_column (w, GTK_TREE_VIEW (w->tree), COL_TITLE, "Title", 0); _setup_treeview_column (GTK_TREE_VIEW (w->tree), col_icon, "Icon", 0, 0); @@ -925,11 +950,7 @@ w_medialib_viewer_create (void) { g_signal_connect ((gpointer)w->tree, "button_press_event", G_CALLBACK (_treeview_row_mousedown), w); g_signal_connect ((gpointer)configure_button, "clicked", G_CALLBACK (_configure_did_activate), w); - GtkTargetEntry entry = { - .target = TARGET_PLAYITEM_POINTERS, - .flags = GTK_TARGET_SAME_APP, - .info = 0 - }; + GtkTargetEntry entry = { .target = TARGET_PLAYITEM_POINTERS, .flags = GTK_TARGET_SAME_APP, .info = 0 }; gtk_drag_source_set (GTK_WIDGET (w->tree), GDK_BUTTON1_MASK, &entry, 1, GDK_ACTION_COPY); g_signal_connect ((gpointer)w->tree, "drag_data_get", G_CALLBACK (_drag_data_get), w); diff --git a/plugins/gtkui/medialib/mlcellrendererpixbuf.c b/plugins/gtkui/medialib/mlcellrendererpixbuf.c index b9f56cb5f1..bac55e1ab4 100644 --- a/plugins/gtkui/medialib/mlcellrendererpixbuf.c +++ b/plugins/gtkui/medialib/mlcellrendererpixbuf.c @@ -64,11 +64,7 @@ _finalize (GObject *object) { } static void -_get_property ( - GObject *object, - guint param_id, - GValue *value, - GParamSpec *psec) { +_get_property (GObject *object, guint param_id, GValue *value, GParamSpec *psec) { MlCellRendererPixbuf *self = ML_CELL_RENDERER_PIXBUF (object); switch (param_id) { @@ -85,11 +81,7 @@ _get_property ( } static void -_set_property ( - GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) { +_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec) { MlCellRendererPixbuf *cellpixbuf = ML_CELL_RENDERER_PIXBUF (object); switch (param_id) { @@ -122,10 +114,24 @@ _set_property ( #if !GTK_CHECK_VERSION(3, 0, 0) static void -_get_size (GtkCellRenderer *cell, GtkWidget *widget, GdkRectangle *cell_area, gint *x_offset, gint *y_offset, gint *width, gint *height) { +_get_size ( + GtkCellRenderer *cell, + GtkWidget *widget, + GdkRectangle *cell_area, + gint *x_offset, + gint *y_offset, + gint *width, + gint *height) { #else static void -_get_size (GtkCellRenderer *cell, GtkWidget *widget, const GdkRectangle *cell_area, gint *x_offset, gint *y_offset, gint *width, gint *height) { +_get_size ( + GtkCellRenderer *cell, + GtkWidget *widget, + const GdkRectangle *cell_area, + gint *x_offset, + gint *y_offset, + gint *width, + gint *height) { #endif if (width != NULL) { *width = ML_CELL_RENDERER_PIXBUF_SIZE; @@ -137,7 +143,14 @@ _get_size (GtkCellRenderer *cell, GtkWidget *widget, const GdkRectangle *cell_ar #if !GTK_CHECK_VERSION(3, 0, 0) static void -_render (GtkCellRenderer *cell, GdkDrawable *window, GtkWidget *widget, GdkRectangle *background_area, GdkRectangle *cell_area, GdkRectangle *expose_area, GtkCellRendererState flags) { +_render ( + GtkCellRenderer *cell, + GdkDrawable *window, + GtkWidget *widget, + GdkRectangle *background_area, + GdkRectangle *cell_area, + GdkRectangle *expose_area, + GtkCellRendererState flags) { #else static void _render ( @@ -198,8 +211,14 @@ ml_cell_renderer_pixbuf_class_init (MlCellRendererPixbufClass *class) { class->parent_class.get_size = _get_size; class->parent_class.render = _render; - g_object_class_install_property (object_class, PROP_PATH, g_param_spec_string ("path", "Track Object", "The path", "", G_PARAM_READWRITE)); - g_object_class_install_property (object_class, PROP_PIXBUF, g_param_spec_object ("pixbuf", "Pixbuf Object", "The pixbuf", GDK_TYPE_PIXBUF, G_PARAM_READWRITE)); + g_object_class_install_property ( + object_class, + PROP_PATH, + g_param_spec_string ("path", "Track Object", "The path", "", G_PARAM_READWRITE)); + g_object_class_install_property ( + object_class, + PROP_PIXBUF, + g_param_spec_object ("pixbuf", "Pixbuf Object", "The pixbuf", GDK_TYPE_PIXBUF, G_PARAM_READWRITE)); } MlCellRendererPixbuf * diff --git a/src/playlist.c b/src/playlist.c index 88e4222ca1..eaecca919b 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -120,9 +120,7 @@ static uintptr_t _playlist_mutex; { pl_unlock (); } // used at startup to prevent crashes -static playlist_t _dummy_playlist = { - .refc = 1 -}; +static playlist_t _dummy_playlist = { .refc = 1 }; static int no_remove_notify; @@ -188,14 +186,25 @@ pl_free (void) { for (playItem_t *it = _playlists_head->head[PL_MAIN]; it; it = it->next[PL_MAIN]) { if (it->_refc > 1) { - fprintf (stderr, "\033[0;31mWARNING: playitem %p %s(%s) has refc=%d at delete time\033[37;0m\n", it, pl_find_meta_raw (it, ":URI"), pl_find_meta_raw (it, "track"), it->_refc); + fprintf ( + stderr, + "\033[0;31mWARNING: playitem %p %s(%s) has refc=%d at delete time\033[37;0m\n", + it, + pl_find_meta_raw (it, ":URI"), + pl_find_meta_raw (it, "track"), + it->_refc); } } //fprintf (stderr, "\033[0;31mplt refc %d\033[37;0m\n", playlists_head->refc); if (_playlists_head->refc > 1) { - fprintf (stderr, "\033[0;31mWARNING: PLAYLIST %p %s has refc=%d at delete time\033[37;0m\n", _playlists_head, _playlists_head->title, _playlists_head->refc); + fprintf ( + stderr, + "\033[0;31mWARNING: PLAYLIST %p %s has refc=%d at delete time\033[37;0m\n", + _playlists_head, + _playlists_head->title, + _playlists_head->refc); } plt_remove (0); @@ -733,7 +742,12 @@ plt_move (int from, int to) { return; } if (from >= _playlists_count || to >= _playlists_count) { - fprintf (stderr, "plt_move: attempt to move playlist to/from out of bounds index; from=%d, to=%d, count=%d\n", from, to, _playlists_count); + fprintf ( + stderr, + "plt_move: attempt to move playlist to/from out of bounds index; from=%d, to=%d, count=%d\n", + from, + to, + _playlists_count); return; } LOCK; @@ -903,7 +917,14 @@ pl_clear (void) { } playItem_t * /* insert internal cuesheet - called by plugins */ -plt_insert_cue_from_buffer (playlist_t *plt, playItem_t *after, playItem_t *origin, const uint8_t *buffer, int buffersize, int numsamples, int samplerate) { +plt_insert_cue_from_buffer ( + playlist_t *plt, + playItem_t *after, + playItem_t *origin, + const uint8_t *buffer, + int buffersize, + int numsamples, + int samplerate) { if (plt->loading_cue) { // means it was called from _load_cue plt->cue_numsamples = numsamples; @@ -936,7 +957,14 @@ plt_insert_dir_int ( void *user_data); static playItem_t * -plt_load_int (int visibility, playlist_t *plt, playItem_t *after, const char *fname, int *pabort, int (*cb) (playItem_t *it, void *data), void *user_data); +plt_load_int ( + int visibility, + playlist_t *plt, + playItem_t *after, + const char *fname, + int *pabort, + int (*cb) (playItem_t *it, void *data), + void *user_data); int fileadd_filter_test (ddb_file_found_data_t *data) { @@ -973,7 +1001,17 @@ plt_insert_file_int ( for (int i = 0; vfsplugs[i]; i++) { if (vfsplugs[i]->is_container) { if (vfsplugs[i]->is_container (fname)) { - playItem_t *it = plt_insert_dir_int (visibility, flags, plt, vfsplugs[i], after, fname, pabort, callback, NULL, user_data); + playItem_t *it = plt_insert_dir_int ( + visibility, + flags, + plt, + vfsplugs[i], + after, + fname, + pabort, + callback, + NULL, + user_data); if (it) { if (callback_with_result) { callback_with_result (DDB_INSERT_FILE_RESULT_SUCCESS, fname, user_data); @@ -1108,7 +1146,10 @@ plt_insert_file_int ( if (!strcasecmp (eol, "cue")) { playItem_t *inserted = plt_load_cue_file (plt, after, fname, NULL, NULL, 0); if (callback_with_result) { - callback_with_result (inserted ? DDB_INSERT_FILE_RESULT_SUCCESS : DDB_INSERT_FILE_RESULT_CUESHEET_ERROR, fname, user_data); + callback_with_result ( + inserted ? DDB_INSERT_FILE_RESULT_SUCCESS : DDB_INSERT_FILE_RESULT_CUESHEET_ERROR, + fname, + user_data); } return inserted; } @@ -1136,12 +1177,15 @@ plt_insert_file_int ( file_recognized = 1; - playItem_t *inserted = (playItem_t *)decoders[i]->insert ((ddb_playlist_t *)plt, DB_PLAYITEM (after), fname); + playItem_t *inserted = + (playItem_t *)decoders[i]->insert ((ddb_playlist_t *)plt, DB_PLAYITEM (after), fname); if (inserted != NULL) { if (callback && callback (inserted, user_data) < 0) { *pabort = 1; } - else if (callback_with_result && callback_with_result (DDB_INSERT_FILE_RESULT_SUCCESS, fname, user_data) < 0) { + else if ( + callback_with_result && + callback_with_result (DDB_INSERT_FILE_RESULT_SUCCESS, fname, user_data) < 0) { *pabort = 1; } if (file_add_listeners) { @@ -1178,12 +1222,15 @@ plt_insert_file_int ( } file_recognized = 1; - playItem_t *inserted = (playItem_t *)decoders[i]->insert ((ddb_playlist_t *)plt, DB_PLAYITEM (after), fname); + playItem_t *inserted = + (playItem_t *)decoders[i]->insert ((ddb_playlist_t *)plt, DB_PLAYITEM (after), fname); if (inserted != NULL) { if (callback && callback (inserted, user_data) < 0) { *pabort = 1; } - else if (callback_with_result && callback_with_result (DDB_INSERT_FILE_RESULT_SUCCESS, fname, user_data) < 0) { + else if ( + callback_with_result && + callback_with_result (DDB_INSERT_FILE_RESULT_SUCCESS, fname, user_data) < 0) { *pabort = 1; } if (file_add_listeners) { @@ -1232,8 +1279,23 @@ _get_insert_file_flags_from_config (void) { } playItem_t * -plt_insert_file (playlist_t *plt, playItem_t *after, const char *fname, int *pabort, int (*cb) (playItem_t *it, void *data), void *user_data) { - return plt_insert_file_int (0, _get_insert_file_flags_from_config (), plt, after, fname, pabort, cb, NULL, user_data); +plt_insert_file ( + playlist_t *plt, + playItem_t *after, + const char *fname, + int *pabort, + int (*cb) (playItem_t *it, void *data), + void *user_data) { + return plt_insert_file_int ( + 0, + _get_insert_file_flags_from_config (), + plt, + after, + fname, + pabort, + cb, + NULL, + user_data); } static int @@ -1242,7 +1304,14 @@ dirent_alphasort (const struct dirent **a, const struct dirent **b) { } static void -_get_fullname_and_dir (char *fullname, int sz, char *dir, int dirsz, DB_vfs_t *vfs, const char *dirname, const char *d_name) { +_get_fullname_and_dir ( + char *fullname, + int sz, + char *dir, + int dirsz, + DB_vfs_t *vfs, + const char *dirname, + const char *d_name) { char resolved_dirname[PATH_MAX]; char *res = realpath (dirname, resolved_dirname); @@ -1415,7 +1484,14 @@ plt_insert_dir_int ( // try loading cuesheets first for (int c = 0; c < ncuefiles; c++) { int i = cuefiles[c]; - _get_fullname_and_dir (fullname, sizeof (fullname), fulldir, sizeof (fulldir), vfs, dirname, namelist[i]->d_name); + _get_fullname_and_dir ( + fullname, + sizeof (fullname), + fulldir, + sizeof (fulldir), + vfs, + dirname, + namelist[i]->d_name); playItem_t *inserted = plt_load_cue_file (plt, after, fullname, fulldir, namelist, n); namelist[i]->d_name[0] = 0; @@ -1438,10 +1514,29 @@ plt_insert_dir_int ( _get_fullname_and_dir (fullname, sizeof (fullname), NULL, 0, vfs, dirname, namelist[i]->d_name); playItem_t *inserted = NULL; if (!vfs) { - inserted = plt_insert_dir_int (visibility, flags, plt, vfs, after, fullname, pabort, callback, callback_with_result, user_data); + inserted = plt_insert_dir_int ( + visibility, + flags, + plt, + vfs, + after, + fullname, + pabort, + callback, + callback_with_result, + user_data); } if (!inserted) { - inserted = plt_insert_file_int (visibility, flags, plt, after, fullname, pabort, callback, callback_with_result, user_data); + inserted = plt_insert_file_int ( + visibility, + flags, + plt, + after, + fullname, + pabort, + callback, + callback_with_result, + user_data); } if (inserted) { @@ -1464,17 +1559,40 @@ plt_insert_dir_int ( } playItem_t * -plt_insert_dir (playlist_t *playlist, playItem_t *after, const char *dirname, int *pabort, int (*cb) (playItem_t *it, void *data), void *user_data) { +plt_insert_dir ( + playlist_t *playlist, + playItem_t *after, + const char *dirname, + int *pabort, + int (*cb) (playItem_t *it, void *data), + void *user_data) { - playItem_t *ret = plt_insert_dir_int (0, _get_insert_file_flags_from_config (), playlist, NULL, after, dirname, pabort, cb, NULL, user_data); + playItem_t *ret = plt_insert_dir_int ( + 0, + _get_insert_file_flags_from_config (), + playlist, + NULL, + after, + dirname, + pabort, + cb, + NULL, + user_data); return ret; } static int -plt_add_file_int (int visibility, uint32_t flags, playlist_t *plt, const char *fname, int (*cb) (playItem_t *it, void *data), void *user_data) { +plt_add_file_int ( + int visibility, + uint32_t flags, + playlist_t *plt, + const char *fname, + int (*cb) (playItem_t *it, void *data), + void *user_data) { int abort = 0; - playItem_t *it = plt_insert_file_int (visibility, flags, plt, plt->tail[PL_MAIN], fname, &abort, cb, NULL, user_data); + playItem_t *it = + plt_insert_file_int (visibility, flags, plt, plt->tail[PL_MAIN], fname, &abort, cb, NULL, user_data); if (it) { // pl_insert_file doesn't hold reference, don't unref here return 0; @@ -1888,7 +2006,14 @@ length_to_uint8 (size_t len) { } int -plt_save (playlist_t *plt, playItem_t *first, playItem_t *last, const char *fname, int *pabort, int (*cb) (playItem_t *it, void *data), void *user_data) { +plt_save ( + playlist_t *plt, + playItem_t *first, + playItem_t *last, + const char *fname, + int *pabort, + int (*cb) (playItem_t *it, void *data), + void *user_data) { LOCK; plt->last_save_modification_idx = plt->modification_idx; const char *ext = strrchr (fname, '.'); @@ -1900,7 +2025,11 @@ plt_save (playlist_t *plt, playItem_t *first, playItem_t *last, const char *fnam if (exts && plug[i]->save) { for (int e = 0; exts[e]; e++) { if (!strcasecmp (exts[e], ext + 1)) { - int res = plug[i]->save ((ddb_playlist_t *)plt, fname, (DB_playItem_t *)_current_playlist->head[PL_MAIN], NULL); + int res = plug[i]->save ( + (ddb_playlist_t *)plt, + fname, + (DB_playItem_t *)_current_playlist->head[PL_MAIN], + NULL); UNLOCK; return res; } @@ -2187,7 +2316,14 @@ pl_save_all (void) { } static playItem_t * -plt_load_int (int visibility, playlist_t *plt, playItem_t *after, const char *fname, int *pabort, int (*cb) (playItem_t *it, void *data), void *user_data) { +plt_load_int ( + int visibility, + playlist_t *plt, + playItem_t *after, + const char *fname, + int *pabort, + int (*cb) (playItem_t *it, void *data), + void *user_data) { playItem_t *it = NULL; playItem_t *last_added = NULL; @@ -2230,10 +2366,17 @@ plt_load_int (int visibility, playlist_t *plt, playItem_t *after, const char *fn if (plug[p]->load && !strcasecmp (ext, plug[p]->extensions[e])) { DB_playItem_t *loaded_it = NULL; if (cb || (plug[p]->load && !plug[p]->load2)) { - loaded_it = plug[p]->load ((ddb_playlist_t *)plt, (DB_playItem_t *)after, fname, pabort, (int (*) (DB_playItem_t *, void *))cb, user_data); + loaded_it = plug[p]->load ( + (ddb_playlist_t *)plt, + (DB_playItem_t *)after, + fname, + pabort, + (int (*) (DB_playItem_t *, void *))cb, + user_data); } else if (plug[p]->plugin.api_vminor >= 5 && plug[p]->load2) { - loaded_it = plug[p]->load2 (visibility, (ddb_playlist_t *)plt, (DB_playItem_t *)after, fname, pabort); + loaded_it = + plug[p]->load2 (visibility, (ddb_playlist_t *)plt, (DB_playItem_t *)after, fname, pabort); } return (playItem_t *)loaded_it; } @@ -2516,7 +2659,13 @@ plt_load_int (int visibility, playlist_t *plt, playItem_t *after, const char *fn } playItem_t * -plt_load (playlist_t *plt, playItem_t *after, const char *fname, int *pabort, int (*cb) (playItem_t *it, void *data), void *user_data) { +plt_load ( + playlist_t *plt, + playItem_t *after, + const char *fname, + int *pabort, + int (*cb) (playItem_t *it, void *data), + void *user_data) { return plt_load_int (0, plt, after, fname, pabort, cb, user_data); } @@ -3252,7 +3401,9 @@ pl_format_title_int (const char *escape_chars, playItem_t *it, int idx, char *s, } } if (n < 1) { - fprintf (stderr, "pl_format_title_int: got unpredicted state while formatting escaped string. please report a bug.\n"); + fprintf ( + stderr, + "pl_format_title_int: got unpredicted state while formatting escaped string. please report a bug.\n"); *ss = 0; // should never happen return -1; } @@ -3769,7 +3920,9 @@ pl_ensure_lock (void) { return; } } - fprintf (stderr, "\033[0;31mnon-thread-safe playlist access function was called outside of pl_lock. please make a backtrace and post a bug. thank you.\033[37;0m\n"); + fprintf ( + stderr, + "\033[0;31mnon-thread-safe playlist access function was called outside of pl_lock. please make a backtrace and post a bug. thank you.\033[37;0m\n"); assert (0); #endif } @@ -3834,7 +3987,10 @@ unlisten_file_added (int id) { } int -listen_file_add_beginend (void (*callback_begin) (ddb_fileadd_data_t *data, void *user_data), void (*callback_end) (ddb_fileadd_data_t *data, void *user_data), void *user_data) { +listen_file_add_beginend ( + void (*callback_begin) (ddb_fileadd_data_t *data, void *user_data), + void (*callback_end) (ddb_fileadd_data_t *data, void *user_data), + void *user_data) { ddb_fileadd_beginend_listener_t *l; int id = 1; @@ -3911,12 +4067,24 @@ unregister_fileadd_filter (int id) { } playItem_t * -plt_load2 (int visibility, playlist_t *plt, playItem_t *after, const char *fname, int *pabort, int (*callback) (playItem_t *it, void *user_data), void *user_data) { +plt_load2 ( + int visibility, + playlist_t *plt, + playItem_t *after, + const char *fname, + int *pabort, + int (*callback) (playItem_t *it, void *user_data), + void *user_data) { return plt_load_int (visibility, plt, after, fname, pabort, callback, user_data); } int -plt_add_file2 (int visibility, playlist_t *plt, const char *fname, int (*callback) (playItem_t *it, void *user_data), void *user_data) { +plt_add_file2 ( + int visibility, + playlist_t *plt, + const char *fname, + int (*callback) (playItem_t *it, void *user_data), + void *user_data) { int res = plt_add_file_int (visibility, _get_insert_file_flags_from_config (), plt, fname, callback, user_data); return res; } @@ -3929,7 +4097,12 @@ pl_item_init (const char *fname) { } int -plt_add_dir2 (int visibility, playlist_t *plt, const char *dirname, int (*callback) (playItem_t *it, void *user_data), void *user_data) { +plt_add_dir2 ( + int visibility, + playlist_t *plt, + const char *dirname, + int (*callback) (playItem_t *it, void *user_data), + void *user_data) { int prev_sl = plt->follow_symlinks; plt->follow_symlinks = conf_get_int ("add_folders_follow_symlinks", 0); @@ -3937,7 +4110,17 @@ plt_add_dir2 (int visibility, playlist_t *plt, const char *dirname, int (*callba plt->ignore_archives = conf_get_int ("ignore_archives", 1); int abort = 0; - playItem_t *it = plt_insert_dir_int (visibility, _get_insert_file_flags_from_config (), plt, NULL, plt->tail[PL_MAIN], dirname, &abort, callback, NULL, user_data); + playItem_t *it = plt_insert_dir_int ( + visibility, + _get_insert_file_flags_from_config (), + plt, + NULL, + plt->tail[PL_MAIN], + dirname, + &abort, + callback, + NULL, + user_data); plt->ignore_archives = prev; plt->follow_symlinks = prev_sl; @@ -3949,17 +4132,50 @@ plt_add_dir2 (int visibility, playlist_t *plt, const char *dirname, int (*callba } playItem_t * -plt_insert_file2 (int visibility, playlist_t *playlist, playItem_t *after, const char *fname, int *pabort, int (*callback) (playItem_t *it, void *user_data), void *user_data) { - return plt_insert_file_int (visibility, _get_insert_file_flags_from_config (), playlist, after, fname, pabort, callback, NULL, user_data); +plt_insert_file2 ( + int visibility, + playlist_t *playlist, + playItem_t *after, + const char *fname, + int *pabort, + int (*callback) (playItem_t *it, void *user_data), + void *user_data) { + return plt_insert_file_int ( + visibility, + _get_insert_file_flags_from_config (), + playlist, + after, + fname, + pabort, + callback, + NULL, + user_data); } playItem_t * -plt_insert_dir2 (int visibility, playlist_t *plt, playItem_t *after, const char *dirname, int *pabort, int (*callback) (playItem_t *it, void *user_data), void *user_data) { +plt_insert_dir2 ( + int visibility, + playlist_t *plt, + playItem_t *after, + const char *dirname, + int *pabort, + int (*callback) (playItem_t *it, void *user_data), + void *user_data) { int prev_sl = plt->follow_symlinks; plt->follow_symlinks = conf_get_int ("add_folders_follow_symlinks", 0); plt->ignore_archives = conf_get_int ("ignore_archives", 1); - playItem_t *ret = plt_insert_dir_int (visibility, _get_insert_file_flags_from_config (), plt, NULL, after, dirname, pabort, callback, NULL, user_data); + playItem_t *ret = plt_insert_dir_int ( + visibility, + _get_insert_file_flags_from_config (), + plt, + NULL, + after, + dirname, + pabort, + callback, + NULL, + user_data); plt->follow_symlinks = prev_sl; plt->ignore_archives = 0; @@ -3967,7 +4183,15 @@ plt_insert_dir2 (int visibility, playlist_t *plt, playItem_t *after, const char } playItem_t * -plt_insert_dir3 (int visibility, uint32_t flags, playlist_t *plt, playItem_t *after, const char *dirname, int *pabort, int (*callback) (ddb_insert_file_result_t result, const char *fname, void *user_data), void *user_data) { +plt_insert_dir3 ( + int visibility, + uint32_t flags, + playlist_t *plt, + playItem_t *after, + const char *dirname, + int *pabort, + int (*callback) (ddb_insert_file_result_t result, const char *fname, void *user_data), + void *user_data) { return plt_insert_dir_int (visibility, flags, plt, NULL, after, dirname, pabort, NULL, callback, user_data); } @@ -4054,7 +4278,18 @@ plt_process_embedded_cue (playlist_t *plt, playItem_t *after, playItem_t *it, in const char *cuesheet = pl_find_meta (it, "cuesheet"); if (cuesheet) { const char *fname = pl_find_meta (it, ":URI"); - cue = plt_load_cuesheet_from_buffer (plt, after, fname, it, totalsamples, samplerate, (const uint8_t *)cuesheet, (int)strlen (cuesheet), NULL, 0, 0); + cue = plt_load_cuesheet_from_buffer ( + plt, + after, + fname, + it, + totalsamples, + samplerate, + (const uint8_t *)cuesheet, + (int)strlen (cuesheet), + NULL, + 0, + 0); } pl_unlock (); return cue; @@ -4161,13 +4396,7 @@ pl_set_shufflerating (playItem_t *it, int rating) { int pl_items_from_same_album (playItem_t *a, playItem_t *b) { - const char *keys[] = { - "band", - "album artist", - "albumartist", - "artist", - NULL - }; + const char *keys[] = { "band", "album artist", "albumartist", "artist", NULL }; const char *a_artist = NULL; const char *b_artist = NULL; diff --git a/src/streamer.c b/src/streamer.c index 2c93f0cee6..f82b8b7f7b 100644 --- a/src/streamer.c +++ b/src/streamer.c @@ -312,7 +312,12 @@ streamer_start_playback (playItem_t *from, playItem_t *it) { pl_item_unref (qnext); } - trace ("from=%p (%s), to=%p (%s) [2]\n", from, from ? pl_find_meta (from, ":URI") : "null", it, it ? pl_find_meta (it, ":URI") : "null"); + trace ( + "from=%p (%s), to=%p (%s) [2]\n", + from, + from ? pl_find_meta (from, ":URI") : "null", + it, + it ? pl_find_meta (it, ":URI") : "null"); send_trackchanged (from, it); started_timestamp = time (NULL); } @@ -577,9 +582,7 @@ _streamer_find_minimal_notplayed_imp (playlist_t *plt, unsigned int check_floor, // if check_floor is truthy, such that shufflerating > floor playItem_t *pmin = NULL; for (playItem_t *i = plt->head[PL_MAIN]; i; i = i->next[PL_MAIN]) { - if ( - !pl_get_played (i) && - (!pmin || pl_get_shufflerating (i) < pl_get_shufflerating (pmin)) && + if (!pl_get_played (i) && (!pmin || pl_get_shufflerating (i) < pl_get_shufflerating (pmin)) && (!check_floor || floor < pl_get_shufflerating (i))) { pmin = i; } @@ -602,9 +605,7 @@ _streamer_find_maximal_played_imp (playlist_t *plt, unsigned int check_ceil, int // if check_ceil is truthy, such that shufflerating < ceil playItem_t *pmax = NULL; for (playItem_t *i = plt->head[PL_MAIN]; i; i = i->next[PL_MAIN]) { - if ( - pl_get_played (i) && - (!pmax || pl_get_shufflerating (i) > pl_get_shufflerating (pmax)) && + if (pl_get_played (i) && (!pmax || pl_get_shufflerating (i) > pl_get_shufflerating (pmax)) && (!check_ceil || pl_get_shufflerating (i) < ceil)) { pmax = i; } @@ -800,7 +801,8 @@ get_prev_track (playItem_t *curr, ddb_shuffle_t shuffle, ddb_repeat_t repeat) { } if (pmax && shuffle == DDB_SHUFFLE_ALBUMS) { - while (pmax && pmax->next[PL_MAIN] && pl_get_played (pmax->next[PL_MAIN]) && pl_get_shufflerating (pmax) == pl_get_shufflerating (pmax->next[PL_MAIN])) { + while (pmax && pmax->next[PL_MAIN] && pl_get_played (pmax->next[PL_MAIN]) && + pl_get_shufflerating (pmax) == pl_get_shufflerating (pmax->next[PL_MAIN])) { pmax = pmax->next[PL_MAIN]; } } @@ -1179,7 +1181,8 @@ stream_track (playItem_t *it, int startpaused) { } ctmap_unlock (); - if (!plugs[0] && (!strcmp (cct, "audio/x-mpegurl") || !strncmp (cct, "text/html", 9) || !strncmp (cct, "audio/x-scpls", 13) || !strncmp (cct, "application/octet-stream", 9))) { + if (!plugs[0] && (!strcmp (cct, "audio/x-mpegurl") || !strncmp (cct, "text/html", 9) || + !strncmp (cct, "audio/x-scpls", 13) || !strncmp (cct, "application/octet-stream", 9))) { // download playlist into temp file trace ("downloading playlist into temp file...\n"); char *buf = NULL; @@ -1327,7 +1330,10 @@ stream_track (playItem_t *it, int startpaused) { for (;;) { if (!decoder_id[0] && plugs[0] && !plugs[plug_idx]) { pl_set_played (it, 1); - trace_err ("No suitable decoder found for stream %s of content-type %s\n", pl_find_meta (playing_track, ":URI"), cct); + trace_err ( + "No suitable decoder found for stream %s of content-type %s\n", + pl_find_meta (playing_track, ":URI"), + cct); if (!startpaused) { streamer_play_failed (it); @@ -1356,7 +1362,11 @@ stream_track (playItem_t *it, int startpaused) { if (exts) { for (int j = 0; exts[j]; j++) { if (!strcasecmp (exts[j], ext) || !strcmp (exts[j], "*")) { - fprintf (stderr, "streamer: %s : changed decoder plugin to %s\n", fname, decs[i]->plugin.id); + fprintf ( + stderr, + "streamer: %s : changed decoder plugin to %s\n", + fname, + decs[i]->plugin.id); pl_replace_meta (it, "!DECODER", decs[i]->plugin.id); pl_replace_meta (it, "!FILETYPE", ext); dec = decs[i]; @@ -1439,7 +1449,11 @@ stream_track (playItem_t *it, int startpaused) { streamer_set_streaming_track (it); streamer_unlock (); - trace ("bps=%d, channels=%d, samplerate=%d\n", new_fileinfo->fmt.bps, new_fileinfo->fmt.channels, new_fileinfo->fmt.samplerate); + trace ( + "bps=%d, channels=%d, samplerate=%d\n", + new_fileinfo->fmt.bps, + new_fileinfo->fmt.channels, + new_fileinfo->fmt.samplerate); break; } } @@ -1891,7 +1905,8 @@ streamer_thread (void *unused) { } if (_add_format_silence > 0) { res = streamreader_silence_block (block, streaming_track, fileinfo_curr, mutex); - int bytes_per_sec = fileinfo_curr->fmt.samplerate * fileinfo_curr->fmt.channels * (fileinfo_curr->fmt.bps / 8); + int bytes_per_sec = + fileinfo_curr->fmt.samplerate * fileinfo_curr->fmt.channels * (fileinfo_curr->fmt.bps / 8); _add_format_silence -= block->size / (double)bytes_per_sec; } else { @@ -2131,7 +2146,14 @@ process_output_block (streamblock_t *block, char *bytes, int bytes_available_siz extern void android_eq_apply (char *dspbytes, int dspsize); android_eq_apply (input, sz); - dsp_apply_simple_downsampler (datafmt.samplerate, datafmt.channels, input, sz, output->fmt.samplerate, &dspbytes, &dspsize); + dsp_apply_simple_downsampler ( + datafmt.samplerate, + datafmt.channels, + input, + sz, + output->fmt.samplerate, + &dspbytes, + &dspsize); datafmt.samplerate = output->fmt.samplerate; sz = dspsize; #else @@ -2175,7 +2197,8 @@ process_output_block (streamblock_t *block, char *bytes, int bytes_available_siz decoded_block->first = block->first; decoded_block->total_bytes = decoded_block->remaining_bytes = sz; decoded_block->is_silent_header = block->is_silent_header; - decoded_block->playback_time = (float)sz / output->fmt.samplerate / ((output->fmt.bps >> 3) * output->fmt.channels) * dspratio; + decoded_block->playback_time = + (float)sz / output->fmt.samplerate / ((output->fmt.bps >> 3) * output->fmt.channels) * dspratio; block->pos = block->size; streamreader_next_block (); @@ -2245,7 +2268,8 @@ streamer_apply_soft_volume (char *bytes, int sz) { if (ivolume != 1000) { int third = bytesread / 3; for (int i = 0; i < third; i++) { - int32_t sample = ((unsigned char)stream[0]) | ((unsigned char)stream[1] << 8) | ((signed char)stream[2] << 16); + int32_t sample = + ((unsigned char)stream[0]) | ((unsigned char)stream[1] << 8) | ((signed char)stream[2] << 16); int32_t newsample = (int32_t)((int64_t)sample * ivolume / 1000); stream[0] = (newsample & 0x0000ff); stream[1] = (newsample & 0x00ff00) >> 8; @@ -2405,7 +2429,10 @@ _streamer_fill_playback_buffer (void) { size_t latency = _output_ringbuf_setup (&plug_get_output ()->fmt); - while (block != NULL && decoded_blocks_have_free () && decoded_blocks_playback_time_total () < conf_playback_buffer_size && (_output_ringbuf.size - _output_ringbuf.remaining - latency) >= block->size * MAX_DSP_RATIO && !memcmp (&block->fmt, &last_block_fmt, sizeof (ddb_waveformat_t))) { + while (block != NULL && decoded_blocks_have_free () && + decoded_blocks_playback_time_total () < conf_playback_buffer_size && + (_output_ringbuf.size - _output_ringbuf.remaining - latency) >= block->size * MAX_DSP_RATIO && + !memcmp (&block->fmt, &last_block_fmt, sizeof (ddb_waveformat_t))) { int rb = process_output_block (block, _dsp_process_buffer.buffer, block->size * MAX_DSP_RATIO); if (rb <= 0) { break; @@ -2475,7 +2502,12 @@ streamer_read (char *bytes, int size) { } # endif ringbuf_read_keep_offset (&_output_ringbuf, _viz_read_buffer.buffer, viz_bytes, -offset); - viz_process (_viz_read_buffer.buffer, (int)viz_bytes, output, 4096, wave_size); // FIXME: fft size needs to be configurable + viz_process ( + _viz_read_buffer.buffer, + (int)viz_bytes, + output, + 4096, + wave_size); // FIXME: fft size needs to be configurable #endif // Play @@ -2552,7 +2584,11 @@ streamer_configchanged (void) { int new_conf_streamer_samplerate_mult_48 = clamp_samplerate (conf_get_int ("streamer.samplerate_mult_48", 48000)); int new_conf_streamer_samplerate_mult_44 = clamp_samplerate (conf_get_int ("streamer.samplerate_mult_44", 44100)); - if (conf_streamer_override_samplerate != new_conf_streamer_override_samplerate || conf_streamer_use_dependent_samplerate != new_conf_streamer_use_dependent_samplerate || conf_streamer_samplerate != new_conf_streamer_samplerate || conf_streamer_samplerate_mult_48 != new_conf_streamer_samplerate_mult_48 || conf_streamer_samplerate_mult_44 != new_conf_streamer_samplerate_mult_44 || formatchanged) { + if (conf_streamer_override_samplerate != new_conf_streamer_override_samplerate || + conf_streamer_use_dependent_samplerate != new_conf_streamer_use_dependent_samplerate || + conf_streamer_samplerate != new_conf_streamer_samplerate || + conf_streamer_samplerate_mult_48 != new_conf_streamer_samplerate_mult_48 || + conf_streamer_samplerate_mult_44 != new_conf_streamer_samplerate_mult_44 || formatchanged) { memset (&last_block_fmt, 0, sizeof (last_block_fmt)); }