Commit graph

15746 commits

Author SHA1 Message Date
William Wilgus
6f020ef155 filetree.c add checks for invalid file entries
Admittedly I can not really think of a reason this would occur
in normal use but if it does it'll result in a crash so
better safe than sorry

Change-Id: I593652bb658475bbd9a18026243c02524f5e7ccb
2018-12-14 06:09:38 -06:00
William Wilgus
3f110daf30 Fix tree.c->tree_get_entry_at() buffer overflow
I observed a crash on buflib>move_block
after dumping ram I noticed that the buffer for filetypes was being corrupted

tree_get_entry_at returns a entry from the buflib 'tree entry' buffer
filetree.c->ft_load writes data to this buffer before checking if it has
reached the last entry resulting in buffer overflow that overwrites the
next entry in the buffer ['filetypes']

Patch checks that the index passed to tree_get_entry_at() is in range
otherwise it returns NULL

Added checks + panic in other functions using tree_get_entry_at()
Fixed tree_lock_cache() calls in playlist and filetree

Change-Id: Ibf9e65652b4e00445e8e509629aebbcddffcfd4d
2018-12-14 01:28:17 -06:00
William Wilgus
ce0b31d87d Shortcuts, Fix FS#13151 Deleting shortcut removes name, icon, talkclip
FS#13151 - Deleting item from shortcut menu corrupts the menu's display

The function that writes shortcut.txt didn't write existing
name, icon or talkclip items

Change-Id: I4418700c82f91522b2dd8a975548d7bd91f150d3
Now: writes all three supplying default values if the items don't exist
2018-12-10 12:04:55 -06:00
William Wilgus
62a5ed49cc Fix possible truncation misc.c->output_dyn_value + use Kibytes
output_dyn_value now requires the count for number of units

Binary scale now shows Kibibytes instead of kilobytes (g#1742)

Fixes output for negative values as well

Change-Id: I8aa896860e97d2453fa35069e2dfe1caac60109f
2018-12-09 22:54:55 -06:00
William Wilgus
74701a16a5 Decrease static code size recording.c
Forgot static for recording_step_levels()

There is no need to re-calculate split_time or split_bytes each loop
you can't change them within recording screen --  these become constants

We don't need longs to store the conversion of minutes to seconds
or MB to bytes these are now shorts and the conversion takes place within
rec_timesplit_seconds() and rec_sizesplit_bytes() respectively

Change-Id: Ie1514085e92e00e67eb1942c0f4f8820714587e9
2018-12-08 18:05:13 -06:00
William Wilgus
7907eb8946 Fix truncation warning recording.c->recording_screen
Limit buf2 to enough characters(16) to display signed int & label

consolidate gain/volume settings

Change-Id: I9ef6aa1e16ea2a17acc311a9b7e1c0556f58eff7
2018-12-08 16:03:47 -06:00
William Wilgus
78b2d13567 Pdbox hide cast-function-type fix overlapping memcpy
dsoundfile.c used memcpy for overlapping memory regions switched to memmove
Suppress the 160+ warnings for cast-function-type
This plugin would require major work to fix these warnings

Change-Id: I309d914839c1e70126a05b387863fd21613497a9
2018-12-08 06:23:19 -06:00
William Wilgus
6bfd7da97c Fix Truncation warning in cuesheet.c->browse_cuesheet
give user concrete indication that track title has been truncated
by adding '~' at end of string

Change-Id: I53034f4a09c103eb98ae1e0ef0a8a843fd2a2c6e
2018-12-08 04:47:27 -06:00
Marcin Bukat
4e8ef17a8b More keymap refinements
Change-Id: If3ae6ece7848b143088d5f9ec8c00ed593d59ed2
2018-12-06 15:15:26 +01:00
Marcin Bukat
b552a37205 Tweak keymaps
Taken partly from:
http://forums.rockbox.org/index.php/topic,51653.msg243214/topicseen.html#msg243214

Change-Id: I7a565df0d6bd5a14cab541498e02ab64f25fa45f
2018-12-03 15:20:44 +01:00
William Wilgus
3d72119dd4 mpegplayer fix warnings
this should fix 'warning: cast between incompatible function types'

Change-Id: I7d192b8953fd14511431cb50254900f566eb0574
2018-11-26 01:51:09 -05:00
William Wilgus
9ed486bdc7 lua add LCD_DEFAULT_FG, fix 2-bit screen fg/bg inversion
Change-Id: Ibe2bc6602ff27524a3b96d9523780acbfbf03c76
2018-11-24 16:40:23 -05:00
William Wilgus
e36edaee55 Lua fix crash on arm devices
This is a seemingly random bug that only affects (as far as I can tell)
arm devices it isn't actually random as code changes cause it to
appear/disappear based on alignment

Change-Id: I4cbc4370677959319f8589fe454e854c45623468
2018-11-17 09:04:05 -05:00
William Wilgus
03718bdb76 Lua fix reader bug in lzio
When loading a file, Lua may call the reader function again after it
returned end of input

https://www.lua.org/bugs.html#5.1.5-2

Change-Id: Ic2f4d727705a0b8f48ce792f6a9f7af25a503037
2018-11-15 11:20:54 +01:00
William Wilgus
b69faf0bcc lua update to 5.1.5
Modify Rocklua towards upstream 5.1.5

Clean up some of the Rocklua implementation

Change-Id: Iac722e827899cf84f5ca004ef7ae7ddce5f7fbbe
2018-11-11 19:42:30 -05:00
William Wilgus
b5fb9781a6 Lua fix pixel-painter score save
pixel-painter was depending on the old readline code that
returned nil for empty lines however empty lines should
have returned an empty string

Change-Id: Ic06ce920a7ab38e1fb8f7197d637e74ed9e35653
2018-11-05 07:18:08 +01:00
William Wilgus
85079483c5 Lua Boomshine Update with circles + levels
added a few more levels and increased difficulty based on level

Rliimage allows us to use circles in boomshine
Optimized some of the code to exceed the speed of the original

Change-Id: I68eb74f8b68fcdc8a9d022cd172374744425f15d
2018-11-05 00:30:46 -05:00
William Wilgus
d9f9def505 Lua fix failure to read lines longer than LUAL_BUFFERSIZE
Readline didn't handle lines longer than LUAL_BUFFERSIZE it now
reads these in chunks.

Change-Id: Iffe12447e5441ff6b479ce3de1d36df64c276183
2018-11-02 23:18:30 -04:00
William Wilgus
f6e10b8488 Lua optimize combine and rework similar functions
rb.strncasecmp
    strcasecmp just exclude count -> rb.strncasecmp(s1, s2)

rb.backlight_brightness_set
    backlight_set_brightness -- redundant
    rb.backlight_brightness_use_setting -> rb.backlight_brightness_set()

rb.buttonlight_brightness_set
    buttonlight_set_brightness -- redundant
    rb.buttonlight_brightness_use_setting -> rb.buttonlight_brightness_set()

rb.mixer_frequency
    rb.mixer_set_frequency -> mixer_frequency(freq)
    rb.mixer_get_frequency -> mixer_frequency

rb.backlight_onoff
    rb.backlight_on  -> rb.backlight_onoff(true)
    rb.backlight_off -> rb.backlight_onoff(false)

rb.touchscreen_mode
    rb.touchscreen_set_mode -> rb.touchscreen_mode(mode)
    rb.touchscreen_get_mode -> rb.touchscreen_mode()

rb.schedule_cpu_boost
    rb.trigger_cpu_boost -> rb.schedule_cpu_boost(true)
    rb.cancel_cpu_boost -> rb.schedule_cpu_boost(false)

Includes rbcompat.lua for backwards compatibility
if your script is broken by this change you simply add
`require("rbcompat")` to the top for the old functionality

Change-Id: Ibffd79a0d9be6d7d6a65cc4af5c0a1c6a0f3f94d
2018-11-02 18:00:06 +01:00
William Wilgus
bb025e3962 lua fix rlimage FB_SCALARPACK()
FB_SCALARPACK(lua_tointeger()) was calling lua_tointeger 3x on color targets

Change-Id: I7b3d73bba5dbc0aa4388b123de11410572fe67c5
2018-11-02 00:42:57 -04:00
William Wilgus
9b385f37ef Lua fix dir string constants and pcm_play_pause & pcm_set_frequency
String constants were already expanded in the first macro
pcm functions were looking for stack position #1 when they needed stack pos #2

Change-Id: I7b4fb90953ab2395b77cbd550fdd257fafca6aae
2018-11-01 18:18:46 -04:00
William Wilgus
be7a58c331 Lua Fix utf8encode, remove utf16 functions
The auto generated utf8/16 encode/decode functions did not work.
Upon implementing them correctly I found that lua handles the utf-8
form properly but I could not get utf-16 to work without crashing
maybe someone can come along later and implement utf-16 safe string
functions but for now utf-16 is removed.

Change-Id: I97a044e200dc27f683a45487cd93fce667c670c4
2018-11-01 16:34:02 +01:00
William Wilgus
bbfe477811 Lua Add underscores in audio, pcm, playlist functions
Lessen confusion for end users looking for the underlying function names in
plugin.h

Change-Id: I6662dc7bd9f22d83af372b3d3c5af53d9a1eac9a
2018-10-31 09:23:00 -04:00
William Wilgus
74fe5203d0 lua consolidate pcm_ functions
The way to call the pcm functions has changed
rb.pcm("option", var)
rb.pcm_set_frequency(freq) = becomes rb.pcm("pcmsetfrequency", freq)

added pcm.lua to the includes for conversion to old functions
if your script is broken by this change you simply add
`require("pcm")` to the top for the old functionality

added rb.pcm("calculatepeaks")

Change-Id: I092057b0c0b5575e567862661f122da1ca2680e8
2018-10-30 14:16:01 -04:00
William Wilgus
2e1ca20097 Lua restore audio_set_recording_gain, audio_set_output,input
Did not mean to wipe out these function when I consolidated audio

Made the regex for audio_ and playlist_ exact matches instead of fuzzy

Change-Id: I7537d1b494afb114c8b6333ea177b1e482f6b672
2018-10-30 12:05:15 -04:00
William Wilgus
6d8d2422ea Lua update strftime.c from dietlibc source
Adds %F -- %Y-%m-%d
Fixes possible buffer overflow when writing final \0
Frees a bit of code on NON-RTC targets

Change-Id: I1c2600a68ee88c6c99f411ae6646861578683f90
2018-10-30 02:39:11 -04:00
William Wilgus
eab73b3dee Lua replace fscanf
Rocklua was using the full fscanf implementation
to simply read %ld for the file:read("*n") function
wasting 1k on unneeded/unused functionality

Instead, I've implemented a filetol function to duplicate it
without the extra overhead using strtol which as an added bonus
ERANGE errors now resolve to LONG_MIN and LONGMAX instead of
integer overflow

filetol()
   reads long int from an open file, skips preceding
   whitespaces returns -1 if error, 1 on success.
   *num set to LONG_MAX or LONG_MIN on overflow.
   If number of digits is > than LUAI_MAXNUMBER2STR
   filepointer will continue till the next non digit
   but buffer will stop being filled with characters.
   Preceding zero is ignored.

Change-Id: Ia42d0f73c63a894625bca4581e9b7e1cc7387fd2
2018-10-29 23:22:35 -04:00
William Wilgus
cc0a4c632a Lua remove strncat.c & strcspn.c
Change-Id: I08256f31e733d2674054e8e589d539d1396a0ee6
2018-10-30 04:17:06 +01:00
William Wilgus
df8233e4ab Lua expand multiple screen support
Some of the lcd functions had support for multiple screens but this wasn't
very safe since the screen number wasn't bounded within the screens[] array
This adds support for all the lcd functions along with checking that screen#
is bounded properly, adds around 600 bytes to devices with a remote screen
devices without a remote screen lock to SCREEN_MAIN

Change-Id: I618bbc7b3919c7b0ff375fb2d71949d7cab43c87
2018-10-30 04:16:23 +01:00
William Wilgus
80352c2c2d Lua rliimage optimize rli_marshal, rli_copy, lcd_xxx_bitmap
rli_marshal and rli_copy allow the use of a custom lua function
instead of the built-ins, this custom function can signal to stop
before the whole image is iterated.

Originally it was checking for a return of 0
which was additional overhead for the built-in functions
(which never stop early) as well.
Now custom_transform sets the x & y deltas to 0 to indicate early
exit removing an extra 'if' per cycle and return from all of the
rli_transform functions

The lcd_xxx_bitmap functions all require x, y, w, h, screen these calls
have been consolidated into a single function get_bmp_bounds()

Change-Id: I88de3149c58d1bfb40e9d1a91341fb86cbd63b51
2018-10-30 04:16:23 +01:00
William Wilgus
73f2bd9c46 Lua remove gmtime.c use rb_plugin version instead
Change-Id: Ia6d47a13ec8ae407661a78c56513ac0c164216da
2018-10-28 07:15:29 -04:00
William Wilgus
5449500a67 Lua Rlimage metatable
Put rliimage functions into the rb.image metatable instead of the rb. table

Change-Id: Iecdc564c2ea9739656e2025b51bb5d5c62e3dbc1
2018-10-25 07:10:46 -04:00
William Wilgus
55533c4d36 Lua Fix kbd_input
While luaL_addstring() works perfectly fine for the
final buffer once Lual_pushresult() is called
kbd_input doesn't display a previous input properly
since the buffer hasn't been finalized yet

Change-Id: Ic50acaa8b7b17077dec8750dd2b6382624e8a549
2018-10-25 06:30:58 -04:00
William Wilgus
b5786ded64 Lua cleanup kbd_input, gui_syncyesno_run, do_menu
Removes unneeded functions from kbd_input
Consolidates message filling function for gui_syncyesno_run & do_menu

Change-Id: If3c3cea3cbf37a8dc52983c0db174de6d54b35f8
2018-10-25 12:06:10 +02:00
William Wilgus
e4c5f5d412 lua consolidate playlist_ functions
The way to call the playlist functions has changed
rb.playlist("option", var)
rb.playlist_add(filename) = becomes rb.playlist("add", filename)

added playlist.lua to the includes for conversion to old functions
if your script is broken by this change you simply add `require("playlist")`
to the top for the old functionality

added rb.playlist_tracks(dir, filename) to playlist.lua
this will allow you to add all tracks in a playlist.m3u8
to a lua table

Change-Id: I87fcc56be365d8495d214f069331b6ddbfbef1db
2018-10-25 05:59:42 -04:00
William Wilgus
b670fcd50d lua add audio_play consolidate audio_ functions
audio_play was removed from the rocklib I assume due to inconsistent
behavior I've readded it with a check for audio paused which instead
uses rewind/ff and then resumes audio

the way to call the audio functions has changed as well
rb.audio("option", var)
so rb.audio_play(0, 0) becomes rb.audio("play", 0, 0)
audio_audio_flush_and_reload_tracks becomes
rb.audio("flushandreloadtracks")

all functions except audio("getfilepos") return the previous (or still current)
status

added audio.lua to the includes for conversion to old functions
if your script is broken by this change you simply add `require("audio")`
to the top for the old functionality

Change-Id: I364adf0c85d9c12b98cde29c26fbe5ee05b9d331
2018-10-24 12:37:29 -04:00
William Wilgus
20b98f6fd0 Lua fix create_numbered_filename
I didn't realize that some devices used the *num variable
this fixes that oversight

Change-Id: I2ecd6f475bebdd6ce745b360be3762a069bfc2b1
2018-10-24 11:16:25 -04:00
William Wilgus
df4cb9bafc Lua fix strip_extension and create_numbered_filename
Both of these functions modified the string in the lua stack

per lua manual:
'When a C function receives a string argument from Lua,
there are only two rules that it must observe: Not to pop the string
from the stack while accessing it and never to modify the string'

strip_extension will still work with old parameters
and is thus backwards compatible
strip_extension("filename")

create_numbered_filename has changed slightly and IS NOT backwards compatible

create_numbered_filename(path, prefix, suffix, [number])
(number defaults to -1)

Change-Id: I34cf7e2f6f691f33d5ac2b2e995855a171fb99b3
2018-10-24 06:05:53 +02:00
William Wilgus
948984309a lua move rocklib_img to its own separate loadable module
allows rocklib_img to be excluded if needed

stops rocklib_aux from generating redundant prototypes for
lcd_mono_bitmap[_part]

Change-Id: Ie208ad71ab5f9a7deb026dc01a5b0a0631a0d29c
2018-10-22 14:00:58 -04:00
William Wilgus
7a132a257a Fix playback.c audio_track_count() warning
changes return to unsigned int to match underlying aliased function

Change-Id: I7015c7ad929344441249aa7c4f2af361142fcaf4
2018-10-18 09:57:20 -04:00
William Wilgus
dd40c46d50 Fix menu warnings
change offending bool return to int

warning: cast between incompatible function types from
'_Bool (*)(void)' to 'int (*)(void)' [-Wcast-function-type]

forgot to remove -- typedef int (*menu_function)(void);

Change-Id: Ie4c8d3ddb0fb7843c4ec584203350d658d6bee3e
2018-10-18 00:06:31 +02:00
William Wilgus
07fed9053a lua optimize current_path function
frees up around 500 bytes by using the builtin string functionality

Change-Id: Icd4ec921d3fec339b8a4b7f80c9c63d51d4c101c
2018-10-15 18:24:10 +02:00
William Wilgus
0b7a8d5afd Lua remove unusable/unneeded functions from rocklib_aux
rocklib_aux is auto generated from plugin.h
there are a few functions that get added automatically that
are unusable without their companion functions or duplicate
functionality already supplied by lua

Duplicated functionality:
rb->rand, rb->srand
-- see math.rand math.srand

rb->remove, rb->rename
-- see os.remove, os.rename

Unusable:
rb->open_utf8
-- this should be added to the lua file open routines (if at all)

rb->codec_run_proc, rb->codec_close
-- without rb->codec_load_file these are pointless

rb->timer_set_period, timer_unregister
-- even with timer_register implemented lua is not
-- reentrant and crashes the state when timer fires

Shouldn't be used!:
rb->strlcpy, rb->strlcat, rb->strcpy, rb->strcat
-- lua reuses strings by hashed values you break this contract if
-- you change strings behind its back plus lua provides a way to
-- do these functions safely within the strings api

Change-Id: I2f65704a90930378cbbceb254e52f61e8074471e
2018-10-12 17:31:25 -04:00
Solomon Peachy
d2cef81bba mips: fix some compile warnings.
Change-Id: Ia5e83702313c1c184480290d3b0e6a66f01b7277
2018-10-09 22:35:37 -04:00
Solomon Peachy
53d72a8be1 fix builds broken by the selective stack bump for opus seeking.
Change-Id: I9eb3b4d2bc88293b09679c27fbceaaa7788ba553
2018-10-09 15:00:48 -04:00
William Wilgus
046cc497ad Fix red rocklib_img 32-24 bit targets
int is an incompatible type for targets that have 32bit fb_data
need to use FB_SCALARPACK for them

Change-Id: Ib3b5ff19c54d8d1bb76af33d0538a17a71301514
2018-10-08 19:59:50 -04:00
William Wilgus
c0682e0944 Clean up rocklib_img
optimize both size and speed
fix invert for color screens

Change-Id: I7edecae32dcb3daf5b3ed984a0e5b3d463269e60
2018-10-09 01:02:25 +02:00
William Wilgus
e4b843335b lua rocklib cleanup
removes tslf allocations from do_menu and gui_syncyesno_run in favor of
lua_newuserdata

removes some luaL_opt functions in favor of equivalent lua_to functions

moves some definitions to the rocklib.h file

Change-Id: Iaacc3249b8f1af2c220ce59dead0050c66cb3b04
2018-10-08 23:15:16 +02:00
Solomon Peachy
3e209f34e4 misc: Fix some assorted compiler warnings
Change-Id: Ibc4aac79e6fce92ad4414ed50122c2d4d6295f89
2018-09-28 11:53:15 -04:00
Martin Nowak
e18425197e fix FS#13060 - Seeking in long opus files leads to crash on Sansa Clip+
- increase decoder thread stack size just enough (2KiB) to
  avoid stack overflows when seeking in opus files
- only do so on devices with at least 8MiB of RAM

Change-Id: I7e7182ae866338b4aad6ed7e32391ddd667121bd
2018-09-28 17:47:28 +02:00