build system overhaul, lots of files changed

master
Alessandro Mauri 4 years ago
parent 5e89bf3f6a
commit 6cc3e03573
  1. 8
      makefile
  2. 10
      src/_footer.html
  3. 1
      src/_header.html
  4. 163
      src/alsadoc.md
  5. 3
      src/commonsizes.md
  6. 13
      src/index.md
  7. 3
      src/makesoftware.md
  8. 93
      src/styles.css

@ -1,17 +1,15 @@
SRCDIR = src SRCDIR = src
DESTDIR = dst DESTDIR = dst
SITENAME = "Mauri's website" DOMAIN = alemauri.eu
URL = alemauri.eu
all: all:
mkdir -p ${DESTDIR} rivet -o ${DESTDIR} ${SRCDIR} ${DOMAIN}
ssg ${SRCDIR} ${DESTDIR} ${SITENAME} 'https://${URL}'
test: all test: all
xdg-open ${DESTDIR}/index.html xdg-open ${DESTDIR}/index.html
install: all install: all
rsync -vmruLz --delete ${DESTDIR}/ www@${URL}:/www/ rsync -vmruLz --delete ${DESTDIR}/ www@${DOMAIN}:/www/
clean: clean:
rm -rf ${DESTDIR} rm -rf ${DESTDIR}

@ -1,11 +1,9 @@
<footer> <p>
<p>
Author: Alessandro Mauri Author: Alessandro Mauri
<a href="mailto:alemauri001@gmail.com">alemauri001@gmail.com</a> <a href="mailto:alemauri001@gmail.com">alemauri001@gmail.com</a>
</p> </p>
<p> <p>
The content of this site is licensed under the The content of this site is licensed under the
<a href="https://creativecommons.org/publicdomain/zero/1.0/"> <a href="https://creativecommons.org/publicdomain/zero/1.0/">
Creative Commons CC0 Public Domain Dedication</a> Creative Commons CC0 Public Domain Dedication</a>
</p> </p>
</footer>

@ -1,4 +1,3 @@
<title>Mauri's website</title>
<link rel="stylesheet" href="styles.css"> <link rel="stylesheet" href="styles.css">
<div class="header"> <div class="header">

@ -1,13 +1,54 @@
Title: Unofficial ALSA API documentation
Author: Alessandro Mauri
# Unofficial ALSA API documentation # Unofficial ALSA API documentation
ALSA has to be the **worst** documented API in the whole FOSS world, so since I ALSA has to be the **worst** documented API in the whole FOSS world, so since I
had to go trough the pain of reverse-engineering other programs I thought to save had to go trough the pain of reverse-engineering other programs I thought to save
you form the same pain. So I present to you the most half-hassed description of you form the same pain. So I present to you the most half-hassed description of
the ALSA API on the interweb. the ALSA API on the interweb.
Official links:
* ALSA documentation [main page](https://www.alsa-project.org/alsa-doc/alsa-lib/index.html)
- The [PCM interface](https://www.alsa-project.org/alsa-doc/alsa-lib/pcm.html)
Unofficial links:
* [Userspace documentaion](https://alsa.opensrc.org/)
## Functions ## Functions
All the functions I encountered and some documentation / explanation
---
### Interfaces ### Interfaces
TODO [//]: # (TODO explain what interfaces are)
---
### Streams
In ALSA a stream is the collection of audio data flowing from an application to
a card (playback), or from a card to an application (capture).
ALSA uses the ring buffer to store outgoing (playback) and incoming (capture,
record) samples. There are two pointers being maintained to allow a precise
communication between application and device; pointing to current processed
sample by hardware and last processed sample by application.
The modern audio chips allow to program the transfer time periods. It means that
the stream of samples is divided to small chunks. Device acknowledges to
application when the transfer of a chunk is complete.
The type of stream (or the direction in which sound is flowing) can be either
capture or playback and is determined by `snd_pcm_stream_t` which is defined as:
```c
typedef enum _snd_pcm_stream {
SND_PCM_STREAM_PLAYBACK = 0, // Playback stream
SND_PCM_STREAM_CAPTURE, // Capture stream
SND_PCM_STREAM_LAST = SND_PCM_STREAM_CAPTURE
} snd_pcm_stream_t;
```
---
### Hints ### Hints
Hints are names, descriptions and other information about sound cards, interfaces Hints are names, descriptions and other information about sound cards, interfaces
@ -112,3 +153,123 @@ int main (int argc, char *argv[])
return 0; return 0;
} }
``` ```
---
### PCMs
PCM is an abbreviation for "Pulse Code Modulation". PCM is how digital audio is
typically represented in a computer. The audio signal is represented by samples
of its instantaneous amplitude taken at regular intervals the representation of
each sample can take several forms.
In ALSA we usually use the term PCM to refer to a **PCM device**, a PCM device
is something like an abstract soundcard. It can either be a hardware device or a
PCM plugin layer device (like dmix, softvol, etc).
#### Open modes
**Blocking mode (0)**: when opening a PCM in blocked (which is the default mode)
the behaviour is that if the resources are already in use with another
application, then it blocks the caller, until resources are free.
**Non blocking mode (SND_PCM_NONBLOCK)**: the non-blocked mode doesn't block the
caller in any way and instead returns `-EBUSY` (that is `EBUSY * -1`) error when
the resources are not available.
**Asynchronous mode (SND_PCM_ASYNC)**:
The opening modes affect all the standard I/O operations (such as writing), in
the same way the options operate with `open(2)` and `write(2)`, so instead of
making the calling process wait when the resource is not available, operations
return `-EAGAIN /* EAGAIN * -1 */`, which literally means resource temporarly
unavailable. The operation mode for successive (to opening) I/O calls can be
changed with the `snd_pcm_nonblock()` function.
In ALSA PCM devices are controlled trough handles, which are basically pointers
to a data structure `snd_pcm_t` that defines it
```c
typedef struct _snd_pcm {
char *name;
snd_pcm_type_t type;
int stream;
int mode;
int poll_fd;
int setup;
unsigned int access; /* access mode */
unsigned int format; /* SND_PCM_FORMAT_* */
unsigned int subformat; /* subformat */
unsigned int rate; /* rate in Hz */
unsigned int channels; /* channels */
size_t fragment_size; /* fragment size */
unsigned int fragments; /* fragments */
unsigned int start_mode; /* start mode */
unsigned int ready_mode; /* ready detection mode */
unsigned int xrun_mode; /* xrun detection mode */
size_t avail_min; /* min avail frames for wakeup */
size_t xfer_min; /* xfer min size */
size_t xfer_align; /* xfer size need to be a multiple */
unsigned int time: 1; /* timestamp switch */
size_t boundary; /* pointers wrap point */
unsigned int info; /* Info for returned setup */
unsigned int msbits; /* used most significant bits */
unsigned int rate_master; /* Exact rate is rate_master / */
unsigned int rate_divisor; /* rate_divisor */
size_t fifo_size; /* chip FIFO size in frames */
size_t buffer_size;
size_t bits_per_sample;
size_t bits_per_frame;
size_t *appl_ptr;
volatile size_t *hw_ptr;
int mmap_rw;
snd_pcm_channel_info_t *mmap_channels;
snd_pcm_channel_area_t *running_areas;
snd_pcm_channel_area_t *stopped_areas;
void *stopped;
snd_pcm_ops_t *ops;
snd_pcm_fast_ops_t *fast_ops;
snd_pcm_t *op_arg;
snd_pcm_t *fast_op_arg;
void *private;
} snd_pcm_t;
```
That's a lot of stuff but luckly we have functions to operate on this struct.
#### `snd_pcm_open`
Open a pcm returning it's handle that is pointer to it's defining data structure,
`snd_pcm_t`
```c
int snd_pcm_open (snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t stream, int mode);
```
ARGS:
* `(const char)name`: PCM name identifier
* `(snd_pcm_stream_t)stream`: wanted stream
* `(int)mode`: mode of opening, valid modes are
- 0: blocking mode
- SND_PCM_NONBLOCK: non blocking mode
- SND_PCM_ASYNC: async notification mode
RESULT:
* `(snd_pcm_t)pcmp`: PCM handle, link to the PCM's defining struct. After use
the handle should be passed to `snd_pcm_close()` to close and free the resources.
RETURN: `(int)` 0 on success or negative code on error
#### `snd_pcm_close`
Close a PCM handle freeing the allocated resources
```c
int snd_pcm_close (snd_pcm_t *pcm);
```
ARGS:
* `(snd_pcm_t *)pcm`: the PCM handle to close
RESULT: RETURN: `(int)` 0 on success or negative code on error
#### `snd_pcm_nonblock`

@ -1,3 +1,6 @@
Title: Size in loc of common software
Author: Alessandro Mauri
# Size in loc of common software # Size in loc of common software
Bloat is everywhere, in 2018 I started my journey on debloating my digital Bloat is everywhere, in 2018 I started my journey on debloating my digital
life, so far I mostly use linux as my main OS (the mostly is due to uni life, so far I mostly use linux as my main OS (the mostly is due to uni

@ -1,11 +1,4 @@
# Mauri's blog lol Title: Mauri's blog homepage
Author: Alessandro Mauri
---
## Articles
[Size in loc of common software](commonsizes.html) # Mauri's blog lol
[Programs I would like to see made/remade](makesoftware.html)
[Unofficial ALSA documentation](alsadoc.html)

@ -1,3 +1,6 @@
Title: Programs someone should make
Author: Alessandro Mauri
# Programs that I'd like to see made/remade # Programs that I'd like to see made/remade
Most small utilities have already been made, and most big programs are perhaps Most small utilities have already been made, and most big programs are perhaps
too big even for a small team, moreover old software has a lot of historical too big even for a small team, moreover old software has a lot of historical

@ -1,10 +1,34 @@
/* Global options */ /* GLOBAL */
* { * {
text-align: left; text-align: left;
font-family: monospace; font-family: sans-serif;
} }
/* Table styles */ :root {
--bg: #282828;
--bg-code: #1d2021;
--bg-alt: #32302f;
--fg: #ebdbb2;
--fg-code: #fbf1c7;
--fg-alt: #d5c4a1;
--fg-link: #d79921;
}
body {
width: 50%;
margin: 0 auto;
background-color: var(--bg);
color: var(--fg);
padding: 10px;
}
html {
/* background-color: #696969;*/
scroll-behavior: smooth;
}
/* TABLES */
table, th, td { table, th, td {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
@ -21,64 +45,63 @@ th, td {
} }
th { th {
border-bottom: 1px solid black; border-bottom: 1px solid var(--fg);
} }
tr:nth-child(odd) { tr:nth-child(odd) {
background-color: #dcdcdc; background-color: var(--bg-alt);
} }
/* Code style */ /* CODE */
pre { pre {
background-color: #282828; background-color: var(--bg-code);
color: #ebdbb2; color: var(--fg-code);
padding: 2px; padding: 4px;
font-size: 14; font-size: 15;
font-family: monospace; font-family: monospace;
tab-size: 8; tab-size: 8;
} }
/*
:not(pre) > code { :not(pre) > code {
background-color: #f9f4d7; background-color: #f9f4d7;
color: #504945; color: #504945;
} }
*/
/* List styles */ /* LISTS */
li { li {
font-size: 14; font-size: 14;
} }
/* Paragraphs and text */ /* PARAGRAPHS */
p { p {
font-size: 16; font-size: 17;
padding-left: 20px; padding-left: 20px;
padding-right: 20px; padding-right: 20px;
} }
body { /* HEADINGS */
width: 50%; h1, h3, h5 {
margin: 0 auto; text-decoration: underline;
background-color: #f5fffa;
color: black;
padding: 10px;
} }
html { h2, h4, h6 {
/* background-color: #696969;*/ background-color: var(--bg-alt);
scroll-behavior: smooth;
} }
/* Headings and footer */ h1 { font-size: 35; }
h1 { h2 { font-size: 30; }
text-decoration: underline; h3 { font-size: 25; }
} h4, h5, h6 { font-size: 20; }
/*
h1, h2, h3, h4, h5, h6 { /* LINKS */
text-align: center; a {
color: var(--fg-link);
} }
*/
/* FOOTER */
footer { footer {
border: 1px solid black; border: 1px solid var(--fg);
} }
footer p { footer p {
@ -87,7 +110,7 @@ footer p {
font-size: 12; font-size: 12;
} }
/* Header style */ /* HEADER */
#thumb { #thumb {
position: absolute; position: absolute;
border-radius: 50%; border-radius: 50%;
@ -125,7 +148,7 @@ footer p {
height: 80px; height: 80px;
text-align: left; text-align: left;
line-height: 80px; line-height: 80px;
font-size: 16; font-size: 17;
border: 1px solid black; border: 1px solid var(--fg);
overflow: hidden; overflow: hidden;
} }

Loading…
Cancel
Save