Player mode is instantiated every boot up, regardless of situation. In this mode the computer is using the custom software I have written, it is responding to input from the frontpanel regarding behaviour, it is using the front panel for visual output and audio output is enabled.
Sequence
The PC itself is powered on and the operating system is booted. Linux has an optional pre-running stage that is initialized by the boot loader (LILO in this case). This stage utilizes a filesystem image file found on the permanent disk to build a RAM disk (referred to as initrd) and then accesses a file in that filesystem called linuxrc. This stage is useful for getting device drivers loaded or software raid initialized, especially if your root filesystem relies on them (it would be unbootable otherwise).
My software is written as linuxrc and is run from this pre-run stage. The initrd is full of tools that are necessary for my player software to run, it includes things like e2fsck and mke2fs. As my software starts, it checks the filesystems and mounts them as necessary
Partition | Mount Type |
/dev/hda5 | RO |
/dev/hda6 | RW |
/dev/hda7 | RW |
/dev/hda4 | RO |
/dev/hdb1 |
RO |
Only the writable filesystems are checked for errors, the read only filesystems cannot get into an inconsistent state. If any of the filesystems fail the check, they are reformatted clean (this is yet to happen). Should this happen all I will lose are some logs, and the state database. The player software has a default state and can recover from this.
Once all the filesystems are initialized, the state database is accessed, the front panel is initialized in the correct mode, the audio system is set up using the proper source (radio or mp3) and the player library is initialized at this time (left idle if unnecessary) finally the audio level is set to the previous level for your enjoyment.
When this is completed, the player software starts monitoring the serial port for control input from the front panel. It responds to that input as necessary (changing volume, skipping tracks, retuning radio etc) and it sends output to the panel, track name, volume level and elapsed time. This is the stage where most time is spent.
When the time comes to get out of the car, the power is turned off and the machine returns to the off state.
The software has a menu system to enable control over playlists, and radio presets, and one option in the menu is to switch to maintenance mode when maintenance mode is selected, the software unmounts the filesystems and exits. The Linux kernel then mounts the root filesystem and continues booting.