Skip to content

Commit 9cbca45

Browse files
authored
Merge branch 'Rockbox:master' into master
2 parents ef08e0a + 843ac23 commit 9cbca45

File tree

8 files changed

+167
-25
lines changed

8 files changed

+167
-25
lines changed

apps/lang/english-us.lang

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7164,7 +7164,7 @@
71647164
*: "Can't open %s"
71657165
</dest>
71667166
<voice>
7167-
*: ""
7167+
*: "Can't open plugin"
71687168
</voice>
71697169
</phrase>
71707170
<phrase>
@@ -16899,3 +16899,17 @@
1689916899
*: "sort playlists"
1690016900
</voice>
1690116901
</phrase>
16902+
<phrase>
16903+
id: LANG_TAGNAVI_ALL_TRACKS_SORTED_BY_ALBUM
16904+
desc: "[By album]" entry in tag browser
16905+
user: core
16906+
<source>
16907+
*: "[By album]"
16908+
</source>
16909+
<dest>
16910+
*: "[By album]"
16911+
</dest>
16912+
<voice>
16913+
*: "All tracks sorted by album"
16914+
</voice>
16915+
</phrase>

apps/lang/english.lang

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7333,7 +7333,7 @@
73337333
*: "Can't open %s"
73347334
</dest>
73357335
<voice>
7336-
*: ""
7336+
*: "Can't open plugin"
73377337
</voice>
73387338
</phrase>
73397339
<phrase>
@@ -16849,6 +16849,20 @@
1684916849
*: "View Album Art"
1685016850
</voice>
1685116851
</phrase>
16852+
<phrase>
16853+
id: LANG_TAGNAVI_ALL_TRACKS_SORTED_BY_ALBUM
16854+
desc: "[By album]" entry in tag browser
16855+
user: core
16856+
<source>
16857+
*: "[By album]"
16858+
</source>
16859+
<dest>
16860+
*: "[By album]"
16861+
</dest>
16862+
<voice>
16863+
*: "All tracks sorted by album"
16864+
</voice>
16865+
</phrase>
1685216866
<phrase>
1685316867
id: LANG_HP_LO_SELECT
1685416868
desc: Output Select

apps/lang/francais.lang

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,6 +2194,20 @@
21942194
*: "Toutes les pistes"
21952195
</voice>
21962196
</phrase>
2197+
<phrase>
2198+
id: LANG_TAGNAVI_ALL_TRACKS_SORTED_BY_ALBUM
2199+
desc: "[By album]" entry in tag browser
2200+
user: core
2201+
<source>
2202+
*: "[By album]"
2203+
</source>
2204+
<dest>
2205+
*: "[Par album]"
2206+
</dest>
2207+
<voice>
2208+
*: "Toutes les pistes triées par album"
2209+
</voice>
2210+
</phrase>
21972211
<phrase>
21982212
id: LANG_DISPLAY
21992213
desc: in settings_menu()

apps/plugin.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,13 @@ int plugin_load(const char* plugin, const void* parameter)
902902
strcpy(current_plugin, plugin);
903903
current_plugin_handle = lc_open(plugin, pluginbuf, PLUGIN_BUFFER_SIZE);
904904
if (current_plugin_handle == NULL) {
905+
if (global_settings.talk_menu)
906+
{
907+
talk_id(LANG_PLUGIN_CANT_OPEN, false);
908+
talk_spell(plugin, true);
909+
talk_force_enqueue_next();
910+
}
911+
/* (voiced above) */
905912
splashf(HZ*2, str(LANG_PLUGIN_CANT_OPEN), plugin);
906913
return -1;
907914
}

apps/tagtree.c

Lines changed: 97 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ struct tagentry {
8080
int newtable;
8181
int extraseek;
8282
int customaction;
83+
char* album_name;
8384
};
8485

8586
static struct tagentry* tagtree_get_entry(struct tree_context *c, int id);
@@ -90,6 +91,7 @@ enum table {
9091
TABLE_ROOT = 1,
9192
TABLE_NAVIBROWSE,
9293
TABLE_ALLSUBENTRIES,
94+
TABLE_ALLSUBENTRIES_SORTED_BY_ALBUMS,
9395
TABLE_PLAYTRACK,
9496
};
9597

@@ -913,6 +915,21 @@ static int compare(const void *p1, const void *p2)
913915
return qsort_fn(e1->name, e2->name, MAX_PATH);
914916
}
915917

918+
static int compare_with_albums(const void *p1, const void *p2)
919+
{
920+
struct tagentry *e1 = (struct tagentry *)p1;
921+
struct tagentry *e2 = (struct tagentry *)p2;
922+
int sort_album_res = qsort_fn(
923+
e1->album_name == NULL ? "" : e1->album_name,
924+
e2->album_name == NULL ? "" : e2->album_name, MAX_PATH);
925+
if (sort_album_res != 0)
926+
{
927+
/* If album name is different */
928+
return sort_album_res;
929+
}
930+
return qsort_fn(e1->name, e2->name, MAX_PATH);
931+
}
932+
916933
static void tagtree_buffer_event(unsigned short id, void *ev_data)
917934
{
918935
(void)id;
@@ -1597,7 +1614,7 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
15971614
#endif
15981615
, 0, 0, 0);
15991616

1600-
if (c->currtable == TABLE_ALLSUBENTRIES)
1617+
if (c->currtable == TABLE_ALLSUBENTRIES || c->currtable == TABLE_ALLSUBENTRIES_SORTED_BY_ALBUMS)
16011618
{
16021619
tag = tag_title;
16031620
level--;
@@ -1661,8 +1678,17 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
16611678
fmt = NULL;
16621679
for (i = 0; i < format_count; i++)
16631680
{
1664-
if (formats[i]->group_id == csi->format_id[level])
1665-
fmt = formats[i];
1681+
if (c->currtable == TABLE_ALLSUBENTRIES_SORTED_BY_ALBUMS)
1682+
{
1683+
/* If it is sorted by albums, we need to use the proper view
1684+
that includes the disc number etc so sorting will be correct for each albums.
1685+
Otherwise, tracks will be sorted by title names */
1686+
if (formats[i]->group_id != csi->format_id[level + 1])
1687+
continue;
1688+
}
1689+
else if (formats[i]->group_id != csi->format_id[level])
1690+
continue;
1691+
fmt = formats[i];
16661692
}
16671693

16681694
if (fmt)
@@ -1685,16 +1711,29 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
16851711

16861712
if (tag != tag_title && tag != tag_filename)
16871713
{
1688-
if (offset == 0)
1714+
bool show_album_sorted = (tag == tag_album);
1715+
int show_album_sorted_offset = (show_album_sorted ? 1 : 0);
1716+
if (offset == 0 && show_album_sorted)
1717+
{
1718+
dptr->newtable = TABLE_ALLSUBENTRIES_SORTED_BY_ALBUMS;
1719+
dptr->name = ID2P(LANG_TAGNAVI_ALL_TRACKS_SORTED_BY_ALBUM);
1720+
dptr->extraseek = 0;
1721+
dptr->customaction = ONPLAY_NO_CUSTOMACTION;
1722+
dptr++;
1723+
current_entry_count++;
1724+
c->special_entry_count++;
1725+
}
1726+
if (offset <= (show_album_sorted_offset))
16891727
{
16901728
dptr->newtable = TABLE_ALLSUBENTRIES;
16911729
dptr->name = ID2P(LANG_TAGNAVI_ALL_TRACKS);
1730+
dptr->extraseek = 0;
16921731
dptr->customaction = ONPLAY_NO_CUSTOMACTION;
16931732
dptr++;
16941733
current_entry_count++;
16951734
c->special_entry_count++;
16961735
}
1697-
if (offset <= 1)
1736+
if (offset <= (1 + show_album_sorted_offset))
16981737
{
16991738
dptr->newtable = TABLE_NAVIBROWSE;
17001739
dptr->name = ID2P(LANG_TAGNAVI_RANDOM);
@@ -1706,6 +1745,8 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
17061745
}
17071746

17081747
total_count += 2;
1748+
if (show_album_sorted)
1749+
total_count++;
17091750
}
17101751

17111752
while (tagcache_get_next(&tcs, tcs_buf, tcs_bufsz))
@@ -1727,7 +1768,15 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
17271768
/* Check the format */
17281769
for (i = 0; i < format_count; i++)
17291770
{
1730-
if (formats[i]->group_id != csi->format_id[level])
1771+
if (c->currtable == TABLE_ALLSUBENTRIES_SORTED_BY_ALBUMS)
1772+
{
1773+
/* If it is sorted by albums, we need to use the proper view
1774+
that includes the disc number etc so sorting will be correct for each albums.
1775+
Otherwise, tracks will be sorted by title names */
1776+
if (formats[i]->group_id != csi->format_id[level + 1])
1777+
continue;
1778+
}
1779+
else if (formats[i]->group_id != csi->format_id[level])
17311780
continue;
17321781

17331782
if (tagcache_check_clauses(&tcs, formats[i]->clause,
@@ -1744,13 +1793,22 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
17441793
{ /* Fallback to basename */
17451794
char *lastname = dptr->name;
17461795
dptr->name = core_get_data(c->cache.name_buffer_handle)+namebufused;
1747-
if (tagcache_retrieve(&tcs, tcs.idx_id, tag_virt_basename, dptr->name,
1796+
if ((c->cache.name_buffer_size - namebufused) > 0 &&
1797+
tagcache_retrieve(&tcs, tcs.idx_id, tag_virt_basename, dptr->name,
17481798
c->cache.name_buffer_size - namebufused))
17491799
{
17501800
namebufused += strlen(dptr->name)+1;
1801+
dptr->album_name = core_get_data(c->cache.name_buffer_handle)+namebufused;
1802+
if ((c->cache.name_buffer_size - namebufused) > 0 &&
1803+
tagcache_retrieve(&tcs, tcs.idx_id, tag_album, dptr->album_name,
1804+
c->cache.name_buffer_size - namebufused))
1805+
namebufused += strlen(dptr->album_name)+1;
1806+
else
1807+
dptr->album_name = NULL;
17511808
goto entry_skip_formatter;
17521809
}
17531810
dptr->name = lastname; /* restore last entry if filename failed */
1811+
dptr->album_name = NULL;
17541812
}
17551813

17561814
tcs.result = str(LANG_TAGNAVI_UNTAGGED);
@@ -1760,25 +1818,33 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
17601818

17611819
if (!tcs.ramresult || fmt)
17621820
{
1821+
17631822
dptr->name = core_get_data(c->cache.name_buffer_handle)+namebufused;
17641823

17651824
if (fmt)
17661825
{
17671826
int ret = format_str(&tcs, fmt, dptr->name,
17681827
c->cache.name_buffer_size - namebufused);
1769-
if (ret >= 0)
1828+
bool error_on_str_format = ret < 0;
1829+
if (!error_on_str_format)
17701830
{
17711831
namebufused += strlen(dptr->name)+1; /* include NULL */
1832+
dptr->album_name = core_get_data(c->cache.name_buffer_handle)+namebufused;
1833+
if ((c->cache.name_buffer_size - namebufused) > 0 &&
1834+
tagcache_retrieve(&tcs, tcs.idx_id, tag_album, dptr->album_name,
1835+
c->cache.name_buffer_size - namebufused))
1836+
namebufused += strlen(dptr->album_name)+1;
1837+
else
1838+
dptr->album_name = NULL;
17721839
}
17731840
else
17741841
{
1775-
dptr->name[0] = '\0';
17761842
if (ret == -4) /* buffer full */
17771843
{
17781844
logf("chunk mode #2: %d", current_entry_count);
17791845
c->dirfull = true;
17801846
sort = false;
1781-
break ;
1847+
break;
17821848
}
17831849

17841850
logf("format_str() failed");
@@ -1792,8 +1858,17 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
17921858
{
17931859
tcs_get_basename(&tcs, is_basename);
17941860
namebufused += tcs.result_len;
1795-
if (namebufused < c->cache.name_buffer_size)
1861+
bool buffer_full = (namebufused >= c->cache.name_buffer_size);
1862+
if (!buffer_full)
1863+
{
1864+
dptr->album_name = core_get_data(c->cache.name_buffer_handle)+namebufused;
1865+
if (tagcache_retrieve(&tcs, tcs.idx_id, tag_album, dptr->album_name,
1866+
c->cache.name_buffer_size - namebufused))
1867+
namebufused += strlen(dptr->album_name)+1;
1868+
else
1869+
dptr->album_name = NULL;
17961870
strcpy(dptr->name, tcs.result);
1871+
}
17971872
else
17981873
{
17991874
logf("chunk mode #2a: %d", current_entry_count);
@@ -1807,6 +1882,7 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
18071882
{
18081883
tcs_get_basename(&tcs, is_basename);
18091884
dptr->name = tcs.result;
1885+
dptr->album_name = NULL;
18101886
}
18111887
entry_skip_formatter:
18121888
dptr++;
@@ -1843,7 +1919,8 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
18431919
qsort(&entries[c->special_entry_count],
18441920
current_entry_count - c->special_entry_count,
18451921
sizeof(struct tagentry),
1846-
compare);
1922+
c->currtable == TABLE_ALLSUBENTRIES_SORTED_BY_ALBUMS ? compare_with_albums : compare
1923+
);
18471924
}
18481925

18491926
if (!init)
@@ -1985,6 +2062,7 @@ int tagtree_load(struct tree_context* c)
19852062
break;
19862063

19872064
case TABLE_ALLSUBENTRIES:
2065+
case TABLE_ALLSUBENTRIES_SORTED_BY_ALBUMS:
19882066
case TABLE_NAVIBROWSE:
19892067
logf("navibrowse...");
19902068

@@ -2060,10 +2138,10 @@ int tagtree_enter(struct tree_context* c, bool is_visible)
20602138
if (seek == -1) /* <Random> menu item was selected */
20612139
{
20622140
is_random_item = true;
2063-
if(c->filesindir<=2) /* Menu contains only <All> and <Random> menu items */
2141+
if(c->filesindir<=c->special_entry_count) /* Menu contains only special entries */
20642142
return 0;
20652143
srand(current_tick);
2066-
dptr = (tagtree_get_entry(c, 2+(rand() % (c->filesindir-2))));
2144+
dptr = (tagtree_get_entry(c, c->special_entry_count+(rand() % (c->filesindir-c->special_entry_count))));
20672145
seek = dptr->extraseek;
20682146
}
20692147
newextra = dptr->newtable;
@@ -2195,6 +2273,7 @@ int tagtree_enter(struct tree_context* c, bool is_visible)
21952273

21962274
case TABLE_NAVIBROWSE:
21972275
case TABLE_ALLSUBENTRIES:
2276+
case TABLE_ALLSUBENTRIES_SORTED_BY_ALBUMS:
21982277
if (newextra == TABLE_PLAYTRACK)
21992278
{
22002279
adjust_selection = false;
@@ -2504,7 +2583,8 @@ static bool insert_all_playlist(struct tree_context *c,
25042583
static bool goto_allsubentries(int newtable)
25052584
{
25062585
int i = 0;
2507-
while (i < 2 && (newtable == TABLE_NAVIBROWSE || newtable == TABLE_ALLSUBENTRIES))
2586+
while (i < 2 && (newtable == TABLE_NAVIBROWSE || newtable == TABLE_ALLSUBENTRIES
2587+
|| newtable == TABLE_ALLSUBENTRIES_SORTED_BY_ALBUMS))
25082588
{
25092589
tagtree_enter(tc, false);
25102590
tagtree_load(tc);
@@ -2746,6 +2826,7 @@ char *tagtree_get_title(struct tree_context* c)
27462826

27472827
case TABLE_NAVIBROWSE:
27482828
case TABLE_ALLSUBENTRIES:
2829+
case TABLE_ALLSUBENTRIES_SORTED_BY_ALBUMS:
27492830
logf("%s (NAVI/ALLSUB) idx: %d %s", __func__,
27502831
c->currextra, current_title[c->currextra]);
27512832
return current_title[c->currextra];
@@ -2768,6 +2849,7 @@ int tagtree_get_attr(struct tree_context* c)
27682849
break;
27692850

27702851
case TABLE_ALLSUBENTRIES:
2852+
case TABLE_ALLSUBENTRIES_SORTED_BY_ALBUMS:
27712853
attr = FILE_ATTR_AUDIO;
27722854
break;
27732855

apps/tree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct entry {
3535
unsigned time_write; /* Last write time */
3636
#ifdef HAVE_TAGCACHE
3737
int customaction; /* db use */
38+
char* album_name; /* db use */
3839
#endif
3940
};
4041

firmware/export/config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,5 +1453,10 @@ Lyre prototype 1 */
14531453
other than audio support */
14541454
#define AUDIOHW_SETTING(name, us, nd, st, minv, maxv, defv, expr...)
14551455

1456+
/* Trying to enable the setting without the underlying functions doesn't work */
1457+
#if defined(HAVE_LCD_SLEEP_SETTING) && !defined(HAVE_LCD_SLEEP)
1458+
#error "HAVE_LCD_SLEEP_SETTING requires HAVE_LCD_SLEEP"
1459+
#endif
1460+
14561461
#endif /* __CONFIG_H__ */
14571462

0 commit comments

Comments
 (0)