forked from subogero/omxd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHACKING
70 lines (52 loc) · 2.58 KB
/
HACKING
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
CODING STYLE
============
Please use a variant of K&R, the Linux Coding Style:
https://www.kernel.org/doc/Documentation/CodingStyle
Also you can/should use C99 features, like variable declarations anywhere.
Please keep the declarations as close to the actual usage as possible.
COMMITS
=======
The first line of commit messages shall summarize the change in 50 characters,
include an issue id (like #19) at the end of line if relevant.
Additional details, if any, should follow after a blank line.
Use headlinese style: http://en.wikipedia.org/wiki/Headlinese
Add the important stuff, leave out the fluff. Using words like "project",
"omxd", "update" and "issue" is almost certainly wrong.
Each commit should be about one single change. For a big change, use a feature
branch and several small commits.
TECHNICAL DETAILS
=================
The /var/run/omxctl FIFO and the protocol
-----------------------------------------
As opposed to a socket, you can simply echo a command into a FIFO file.
And the protocol is dead simple: one-letter command plus optional filename.
The trick with FIFOs:
open() for read blocks until someone opens it for write.
open() for write blocks until soemone opens it for read.
writedec(), writestr(), printfd(), sscand(), WTF?
-------------------------------------------------
The similar C-library calls all come with unnecessary complication and, worse,
user-space buffering. And it was fun to write these, just using bare syscalls.
Why not store the playlist in memory?
-------------------------------------
Because that needs a lot of dynamic memory allocation. Which might lead to
memory leaks. Memory leaks in a daemon are bad.
The stupid man's way to avoid memory leaks is to avoid malloc() altogether.
The wise man knows that he is stupid.
Why store the playlist in memory, then ?!
-----------------------------------------
With the advent of the low-gap playback, the playlist returns 2 tracks.
It was much easier to implement with a dynamic in-memory playlist.
The in-file playlist.c was messy enough before, so it was abandoned.
Welcome to the m_list.c in-memory playlist: the list itself is not a
linked list but a dynamic array of pointers to dynamically allocated strings.
A dynamic array is directly addressable and needs an occasional realloc()
instead of many messy malloc() and free() calls.
Timekeeping
-----------
Track time evaluation shall be based on log file entry timestamps:
start: t_play = 0; t_start = t
pause: t_play += t - t_start; paused = 1
play: t_start = t; paused = 0
fFrR: t_play += t - t_start + dt; t_start = t
EOF: t_play += time - t_start unless paused