tidbits

My only hesitation to remove my old blog was losing the couple of posts that may have had some lasting usefulness for others. Before taking the blog offline, I copied the contents of those posts here in hopes that they would get indexed by Google and still be accessible to people.

mod_rewrite and http auth with .htaccess

I spent a good portion of the last two days trying to get iCal to publish calendars to my PHPiCalendar installation using publish.ical.php. Whenever I tried to add auth in my /calendar/calendars/.htaccess with something like this I'd get a 404 error displayed by wordpress:

AuthType Basic
AuthName "iCal Upload"
AuthUserFile "/home/username/.htpasswds/calendar/calendars/passwd"
require valid-user
    

The relevant code in my /.htaccess file was:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
    

I couldn't figure out what was going on until I stumbled across this page after several hours of Googling. It seems that when the server sent back a 401 response (unauthorized), it was also trying to send out a page explaining the error. The RewriteRule in my root's .htaccess sucked up that error page's URL and displayed my blog instead. I'm not entirely sure why this happened. It seems like I still should have gotten a 401 response in my browser and tried to supply a username/password then, but that's not how it worked.

Here are the contents of the two .htaccess files once I got it working.

/.htaccess:

Options +FollowSymlinks
<ifmodule mod_rewrite.c>
RewriteEngine on
RewriteBase /
</ifmodule>

# otherwise the 401 page gets handled by WP
ErrorDocument 401 /unauthorized.html

# BEGIN WordPress
<ifmodule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</ifmodule>
# END WordPress
    

/calendar/calendars/.htaccess:

Options +FollowSymlinks

<ifmodule mod_rewrite.c>
RewriteEngine on

RewriteCond %{REQUEST_METHOD}  ^PUT$ [OR]
RewriteCond %{REQUEST_METHOD}  ^PROPFIND$ [OR]
RewriteCond %{REQUEST_METHOD}  ^DELETE$
RewriteRule ^.*$ publish.ical.php [L]
</ifmodule>

AuthType Basic
AuthName "iCal Upload"
AuthUserFile "/home/hoozh/.htpasswds/calendar/calendars/passwd"
require valid-user
    

Hopefully this will help someone solve the same problem I was having sooner!

revolution 7.1 struggles

Thanks to Newegg and FedEx I got my shiny new M-Audio Revolution 7.1 on Friday evening. As usual, I had to make a quick run to the local FedEx pick up location after work since they deliver ~14:00 to my house, and I'm always at work at that time. I knew that I'd made too many trips there when the guy behind the counter said "I recognize you, but I'll need to see your ID anyway." ... maybe that's a sign I've been getting a few too many toys recently.

I had long been unhappy with my old SoundBlaster Live! under linux. The center/sub/rear channels were fine, but the two front channels had horrible clipping problems at moderate mixer settings and were inaudible below ~50% volume. This left me with a 3.1 system which really wasn't acceptable. I'll probably end up taking this cruddy card to work because the on-board audio isn't supported in linux yet...

After a quick kernel recompilation (2.6.10), I had a driver for my new card, and I was ready to get cracking. Earlier this week I found a web page which I thought would guide me through the ALSA setup and get everything working perfectly for me. I quickly discovered that I had hoped for too much. Its instructions for getting dmix setup as the default were awesome (these are the swmix portion of the .asoundrc below), but there was a major problem -- dmix introduces a horrible crackling sound into the sound. I'm not sure if this is a problem with my setup or with the ice1724 support in ALSA, but I do know that it sucks... I've given up on dmix temporarily and opted to try my hand at configuring ALSA so that my 5.1 speakers would work.

After some tinkering around and booting into windows once to make sure that surround worked there (it's entirely possible that setting up the card in windows once was necessary, but not very likely) I eventually found this excellent FAQ answer which spawned the ch51dup portion of my current .asoundrc. For what it's worth, in alsamixer the following mixers control the following channels on my setup.

DAC = left front
DAC1 = right front
DAC2 = center
DAC3 = sub
DAC4 = left rear
DAC5 = right rear

Here's my current ~/.asoundrc . It does not have dmix enabled, and thus only supports one sound stream at a time. It works fine with xine for playing a dvd with surround support. It doesn't work so well with mplayer (unless you enjoy chipmunks). I'm starting to get a feel for how the ALSA config works, but there's still a small degree of black magic to it for me.

##  BEGIN .ASOUNDRC ##
pcm.!default {
  type plug
  slave.pcm "ch51dup"
  #slave.pcm "swmix"
}

# fake surround sound if we only get a stereo stream
pcm.ch51dup {
  type route
  slave {
    pcm "surround51"
    channels 6
  }
  ttable {
    0.0 1                  # put left front in left front
    1.1 1                  # put right front in right front
    0.2 1                  # put left front in left rear
    1.3 1                  # put right front in right rear
    0.4 0.5                # put 50% of left front in center
    1.4 0.5                # put 50% of right front in center
    0.5 0.5                # put 50% of left front in sub
    1.5 0.5                # put 50% of right front in sub
  }
}

# to try to get dmix working (and compatible with OSS)
pcm.swmix {
  type dmix
  ipc_key 333
  slave {
    pcm "hw:0,0"           # front two speakers
    period_time 0          # must be 0
    period_size 1024       # must be a power of 2
    buffer_size 8192       # must be a power of 2
    format "S32_LE"        # i've read that ice1724/revolution 7.1 require this
    #periods 128
    #rate 1000             # it's obvious if we're using swmix when this is on
  }
  bindings {
    0 0
    1 1
  }
}
###  END .ASOUNDRC ###
    

I'll post any updates that I have... I'd really love to get dmix working (properly), and I "need" to get sound working for Quake3. All in all, I still prefer my current situation to the one I was in a week ago. At least a single stream of audio sounds fantastic now. :)

Valid CSS! Valid XHTML 1.0 Transitional