Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Hotkeys: Add placeholder for function return value

Seems a bit clearer to me than redefining the meaning
of ONPLAY_OK in this context, which was easy to miss.

Fixes the return value for the bookmark_create_menu
hotkey, too. It was previously mapped to ONPLAY_OK
in case the function failed, and to ONPLAY_RELOAD_DIR
if it succeeded. This had no ill effect - or any effect –
since either of the values were disregarded by the WPS
when executing a hotkey.

Return values of playlist_insert_shuffled also had no
effect (by design, apparently, see commit 482b45b).
Use ONPLAY_FUNC_RETURN in hotkey_assignment.

Behavior hasn't changed, it's only been made more
explicit.

Change-Id: Iefc60c9f42c1063af78d368dc382916848064d38

authored by

Christian Soffke and committed by
William Wilgus
6bc443f4 0d355a9c

+25 -25
+22 -25
apps/onplay.c
··· 1785 1785 1786 1786 #ifdef HAVE_HOTKEY 1787 1787 /* direct function calls, no need for menu callbacks */ 1788 - static bool delete_item(void) 1788 + static bool hotkey_delete_item(void) 1789 1789 { 1790 1790 #ifdef HAVE_MULTIVOLUME 1791 1791 /* no delete for volumes */ ··· 1795 1795 return delete_file_dir(); 1796 1796 } 1797 1797 1798 - static bool open_with(void) 1798 + static bool hotkey_open_with(void) 1799 1799 { 1800 1800 /* only open files */ 1801 1801 if (selected_file_attr & ATTR_DIRECTORY) ··· 1807 1807 return list_viewers(); 1808 1808 } 1809 1809 1810 - static int playlist_insert_shuffled(void) 1810 + static int hotkey_tree_pl_insert_shuffled(void) 1811 1811 { 1812 1812 if ((audio_status() & AUDIO_STATUS_PLAY) || 1813 1813 (selected_file_attr & ATTR_DIRECTORY) || 1814 1814 ((selected_file_attr & FILE_ATTR_MASK) == FILE_ATTR_M3U)) 1815 1815 { 1816 1816 add_to_playlist(&addtopl_insert_shuf); 1817 - return ONPLAY_START_PLAY; 1818 1817 } 1819 - 1820 1818 return ONPLAY_RELOAD_DIR; 1821 1819 } 1822 1820 1823 - static int tree_hotkey_run_plugin(void *param) 1821 + static int hotkey_tree_run_plugin(void *param) 1824 1822 { 1825 1823 if (filetype_load_plugin((const char*)param, selected_file) == PLUGIN_GOTO_WPS) 1826 1824 return ONPLAY_START_PLAY; ··· 1828 1826 return ONPLAY_RELOAD_DIR; 1829 1827 } 1830 1828 1831 - static int hotkey_run_plugin(void) 1829 + static int hotkey_wps_run_plugin(void) 1832 1830 { 1833 1831 open_plugin_run(ID2P(LANG_HOTKEY_WPS)); 1834 1832 return ONPLAY_OK; ··· 1838 1836 int action; /* hotkey_action */ 1839 1837 int lang_id; /* Language ID */ 1840 1838 struct menu_func func; /* Function to run if this entry is selected */ 1841 - int return_code; /* What to return after the function is run. ONPLAY_OK here */ 1842 - }; /* means to use function return code, see execute_hotkey */ 1839 + int return_code; /* What to return after the function is run. */ 1840 + }; /* (Pick ONPLAY_FUNC_RETURN to use function's return value) */ 1843 1841 1844 1842 #define HOTKEY_FUNC(func, param) {{(void *)func}, param} 1845 1843 ··· 1859 1857 ONPLAY_RELOAD_DIR }, 1860 1858 #endif 1861 1859 { HOTKEY_OPEN_WITH, LANG_ONPLAY_OPEN_WITH, 1862 - HOTKEY_FUNC(open_with, NULL), 1860 + HOTKEY_FUNC(hotkey_open_with, NULL), 1863 1861 ONPLAY_RELOAD_DIR }, 1864 1862 { HOTKEY_DELETE, LANG_DELETE, 1865 - HOTKEY_FUNC(delete_item, NULL), 1863 + HOTKEY_FUNC(hotkey_delete_item, NULL), 1866 1864 ONPLAY_RELOAD_DIR }, 1867 1865 { HOTKEY_INSERT, LANG_INSERT, 1868 1866 HOTKEY_FUNC(add_to_playlist, (intptr_t*)&addtopl_insert), 1869 1867 ONPLAY_RELOAD_DIR }, 1870 1868 { HOTKEY_INSERT_SHUFFLED, LANG_INSERT_SHUFFLED, 1871 - HOTKEY_FUNC(playlist_insert_shuffled, NULL), 1872 - ONPLAY_RELOAD_DIR }, 1869 + HOTKEY_FUNC(hotkey_tree_pl_insert_shuffled, NULL), 1870 + ONPLAY_FUNC_RETURN }, 1873 1871 { HOTKEY_PLUGIN, LANG_OPEN_PLUGIN, 1874 - HOTKEY_FUNC(hotkey_run_plugin, NULL), 1875 - ONPLAY_OK }, 1872 + HOTKEY_FUNC(hotkey_wps_run_plugin, NULL), 1873 + ONPLAY_FUNC_RETURN }, 1876 1874 { HOTKEY_BOOKMARK, LANG_BOOKMARK_MENU_CREATE, 1877 1875 HOTKEY_FUNC(bookmark_create_menu, NULL), 1878 1876 ONPLAY_OK }, 1879 1877 { HOTKEY_PROPERTIES, LANG_PROPERTIES, 1880 - HOTKEY_FUNC(tree_hotkey_run_plugin, (void *)"properties"), 1881 - ONPLAY_OK }, 1878 + HOTKEY_FUNC(hotkey_tree_run_plugin, (void *)"properties"), 1879 + ONPLAY_FUNC_RETURN }, 1882 1880 #ifdef HAVE_TAGCACHE 1883 1881 { HOTKEY_PICTUREFLOW, LANG_ONPLAY_PICTUREFLOW, 1884 - HOTKEY_FUNC(tree_hotkey_run_plugin, (void *)"pictureflow"), 1885 - ONPLAY_OK }, 1882 + HOTKEY_FUNC(hotkey_tree_run_plugin, (void *)"pictureflow"), 1883 + ONPLAY_FUNC_RETURN }, 1886 1884 #endif 1887 1885 }; 1888 1886 ··· 1905 1903 int i = ARRAYLEN(hotkey_items); 1906 1904 struct hotkey_assignment *this_item; 1907 1905 const int action = (is_wps ? global_settings.hotkey_wps : 1908 - global_settings.hotkey_tree); 1906 + global_settings.hotkey_tree); 1909 1907 1910 1908 /* search assignment struct for a match for the hotkey setting */ 1911 1909 while (i--) ··· 1923 1921 else 1924 1922 func_return = (*func.function)(); 1925 1923 } 1926 - /* return with the associated code */ 1927 1924 const int return_code = this_item->return_code; 1928 - /* ONPLAY_OK here means to use the function return code */ 1929 - if (return_code == ONPLAY_OK) 1930 - return func_return; 1931 - return return_code; 1925 + 1926 + if (return_code == ONPLAY_FUNC_RETURN) 1927 + return func_return; /* Use value returned by function */ 1928 + return return_code; /* or return the associated value */ 1932 1929 } 1933 1930 } 1934 1931
+3
apps/onplay.h
··· 31 31 ONPLAY_START_PLAY, 32 32 ONPLAY_PLAYLIST, 33 33 ONPLAY_PLUGIN, 34 + #ifdef HAVE_HOTKEY 35 + ONPLAY_FUNC_RETURN, /* for use in hotkey_assignment only */ 36 + #endif 34 37 }; 35 38 36 39 #ifdef HAVE_HOTKEY