Posts Tagged ‘linux’

h1

Radio station across town

2010-10-01

Recently, I’ve been heavily involved with the transition involved with moving the radio station out of its downtown office and into the new office known as Burnt Mill. Here are a few things I’ve done lately:

– Wrote a console peak meter.
It’s desirable to avoid running an X11 server, and imperative to never put any critical server processes on top of it. The GUI is a nice tool that has its place, but for a system to boot quickly, it must only perform the necessary tasks to revive critical services (in this case, audio streaming). On a similar note, my systems should probably migrate from ext2 to ext3, since journaling will mitigate time lost to running filesystem check (fsck) every twenty-third boot.

I first did a prototype using #!/bin/bash but was unsatisfied by the load placed on the processor. As it turns out, if you use C you don’t have to open and close the device four times every second. You can open it once at runtime and then just use ioclts to get info from the device. My approach was then to take the existing code base of OSS 4.x (Open Sound System — the acronym is ambiguous since it also refers to Open Source Software), modify ossmix.c in place and recompile. By trimming all methods related to write operations, and all unnecessary constants related to objects other than VUMETER, I was able to easily port the shell scrpit’s echo commands which were written using ANSI for colors and some box-drawing Unicode glyphs. I have yet to develop a method to detect whether the shell supports Unicode, but I have gotten some funky results using Putty’s default translation settings (ISO-8859-1). ASCII art using apostrophes, full stops, and hyphens should be sufficient for most.

– Increased latency on the Delta 1010 connected to the on-air system
We’re using a combination of FMPEG and VideoLAN Client to transmit audio from point to point and have had a lot of “audio output is starving” messages. At first, it was packets being dropped. After notifying our provider, they did some investigating, and I haven’t seen any UDP checksum errors since. However, the drivers must communicate effectively with the applications, and must be scheduled accordingly. By changing the /usr/lib/oss/conf/oss_envy24.conf to have envy24_nfrags to a lower number, I reduced the number of messages logged about starving by an order of magnitude.

– Found out that Shoutcast is now being heavily claimed by AOL
Apparently they want royalties for licensing the official Fraunhofer MP3 encoder in order to use their software, and they don’t want VideoLAN to have Shoutcast capability due to licensing conflicts. I could go ahead and use the old version of the software that has been running for over five years on an older machine, or I could move to Icecast which is open sourced.

OSS has its advantages, such as troubleshooting USB drivers. We have a Behringer UCA-202 that we’re trying to use as an audio input to the streaming server. Of course I’d be much happier if it just worked, but OSS has just recently gone open source [again], so I’m prepared to contribute when necessary. By taking the suggestion to modify the src/kernel/drv/oss_usb/ossudb_audio.c file’s write_control_value function to return 1; things started to work (somewhat). Unfortunately the sound card is locked to 48000 sample rate, and my version of Shoutcast expects 44100/16/2. There remains work to be done.

h1

Arguments for using the yyyy-mm-dd format

2010-04-25

The common way to write a date in the United States is to put the month first followed by a slash and the date e.g. 4/25. In some scenarios it is advisable to prefix the month with a leading zero e.g. 04/25 or in filenames as 04-25 since slashes are typically used as pathname delimiters. This is useful because the most common filename sorting algorithm is alphabetic string comparison, which does not pay attention to the semantically assigned numerical values of the expression, but merely compares the ASCII [or Unicode] value of each character. What can happen is that directories containing files of an entire year will sort improperly when transitioning from 9-31 to 10-01 (or even worse, 10-1). Observe:
1-01
1-02
1-03
10-01
11-24
12-31
9-30
9-31

If however, we use leading zeroes such that the number of characters used to describe the date remains constant, the files with sort themselves chronologically.
01-01
01-02
01-03
09-30
09-31
10-01
11-24
12-31

If we apply year to the expression, the American standard is to put it on the end, e.g. 4/25/10 or 04-25-10. For greater clarity, four digits are used: 04-25-2010. One can see that using this convention results in months being clustered with varying year rather than a chronological order:
02-24-2008
02-28-2007
04-19-2006
10-31-2009

I’d like to diverge for a moment and mention that the Russian standard is quite different. dd-mm-yyyy e.g. 25.04.2010, or 25.4 for short. This isn’t very useful for sorting filenames, but it does demonstrate the reasons behind the orderings that we use are typically because they reflect the syntax of spoken language, e.g. April the Twenty-fifth as opposed to Двадсать Пятого Апрелья or 4月25日.

Ah, the Japanese system. Much like our own, they put the month first – however it’s more common to see the numerals written in Japanese e.g. 四月二十五日 instead. Their system is different than ours, in that they put the year first, following the spoken tradition of starting with general and then following with more concrete terms. The date format yyyy-mm-dd is useful to us as programmers because filenames will sort in strict chronological order using this nomenclature.
2007-11-23
2008-11-23
2009-04-25
2009-12-31
2010-01-01
2010-04-25

In fact, it is common practice in Linux to specify dates in this format, going from broad to general, and time of day can be included e.g. 2010-04-25 01:55 EDT (GMT-4). Good night.

h1

Networking on Linux

2010-04-10

Here’s something worth mentioning. In Arch Linux, there are a couple of places to enable/disable IP forwarding. In order to make sure forwarding is enabled,

/etc/sysctl.conf

net.ipv4.ip_forward = 1.

Also make sure:

/etc/conf.d/iptables

IP_FORWARD=1.

Naturally this all relates to making sure the file

/proc/sys/net/ipv4/ip_forward

has a one instead of a zero in it.