debug sound in linux - first steps!!
Wednesday, July 09, 2008
My sound stopped after having worked for 6 months. I hadn't run any updates, and even tried booting into previous kernels to check, but that didn't help. Finally I discovered the answer, but not thanks to internet searching. Here are the requirements:
- If you are running linux
- If you have Windows on another partition you can dual boot into
- If sound works ok in Windows
- Check for a hardware mute switch and/or volume control on the machine (especially laptops) - this will affect Windows as well, so if it's currently working there then this won't be the problem
- Boot into Windows. Unmute the sound. Try linux again
The silver-lining in this exercise in frustration was fixing my VLC performance. I had noticed for a few weeks that music and movies played in VLC would be silent for the first 10s or so. Running VLC in terminal gave complaints about pulseaudio not found.
Solution here for me was to go into the VLC preferences> Output Modules and check the box for advanced options. Change 'Audio Output Module' from default to 'ALSA audio output'.
The alternative option would be to install pulseaudio (sudo aptitude install pulseaudio). It seems pulseaudio is the new default sound server in Ubuntu and provides more advanced sound functionality, particularly when it comes to combining sounds, so this may be the best chouce.
greasemonkey for ff3rc1
Wednesday, June 11, 2008
Use greasemonkey and the latest firefox 3 releases as they come out? Well greasemonkey was only compatible up to ff3b5, but you can get a version (supposedly production-ready) from this link. Phew!
EDIT: Not required now as firefox3 is officially released.
opensource hardware in nz
Tuesday, May 27, 2008
Came across this site that stocks some really fun looking hardware. Of particular note is stocking only opensource-capable routers, laptops without an OS (no M$ tax!) and single-board computers that use only 5-7 watts that you could really have some fun with. Oh and who could pass up a GSM modem with built-in GPS? Oh, the gadgetry and geekyness.
nicegear.co.nz
jni - call C/C++/Assembly from Java
Friday, May 23, 2008
- Create Java class containing native method(s) (static or instance) defining interface with C code.public class Processor {
public static native double process(double x, double y);
} - Compile to Java class file.
- Run javah -jni [-o path/to/CProcessor.h] Processorto generate C header file from the Java. Eg. CProcessor.h:/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Processor */
#ifndef _Included_Processor
#define _Included_Processor
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: Processor
* Method: process
* Signature: (DD)D
*/
JNIEXPORT jdouble JNICALL Java_Processor_process
(JNIEnv *, jclass, jdouble, jdouble);
#ifdef __cplusplus
}
#endif
#endif - Create a .c C source file - this is the stub to call the target code. Include header
and "Processor.h". The angle brackets mean it is registered as a library file for the compiler, whereas the speech marks denote a stand-alone header file. May need to include the path the Processor.h within the speech marks. Here is a simple example that just sums the two input numbers, rather than calling any other C: #include <jni.h>
#include <math.h>
#include "../headers/CProcessor.h"
#include <stdio.h>
JNIEXPORT jdouble JNICALL Java_Processor_process
(JNIEnv *env , jclass obj, jdouble val1, jdouble val2) {
return (val1+val2);
} - Run (eg for linux)gcc -shared -I /usr/lib/jvm/java-1.5.0-sun-1.5.0.15/include/ -Ito create the library file (indicated by 'shared' flag). Any compiler errors about missing .h headers should be solved by the inclusion (-I) of the jni and jni for linux paths.
/usr/lib/jvm/java-1.5.0-sun-1.5.0.15/include/linux/ -o CProcessor.so CProcessor.c - Either in a method inside original Java class, or in a new calling class, create a static block to either load (System.load()) the .so library via its file path, or load (System.loadLibrary()) a registered library (e.g. dll on Windows) via system-specific addressing.
- Once the static block has loaded the library, the methods are available either statically or from an object as determined in 1.public class Caller {In this case our Processor in Java calls the CProcessor in C which adds the 2 doubles we passed it and returns a double. Here it is 2 + 3 with the output 5.
static {
System.load("/home/me/_projects/JNI/C/CProcessor.so");
}
public static void main(String[] args) {
double result = Processor.process(2, 3);
System.out.println(result);
}
}
printing from Windows virtual machine on linux host
Thursday, April 03, 2008
It's great to be able to use a printer that you have defined in your linux host from within virtualised Windows guest OS (where the printer is either connected directly to your box or over a network). This post assumes you've already setup networking between your guest and host.
Firstly in your printer settings on the host, make sure access hasn't been restricted (open access by default on Ubuntu).
Find the name of the printer that you want to access (ie not the Description which is what appears in network browsing)
Then on the virtual windows machine (for XP):
Choose Add Printer
Select network printer
Select Printer on Internet
For the url, use:
Should be away laughing!
This howto is has more direct CUPS fiddling than is needed for Ubuntu now, but I got key information from there to find out the above.
run a open-source virtual machine with qemu
I use the awesome qemu open-source processor emulator, that lets you run virtual OSs (guests) on a host computer (on my Xubuntu box, in my case). Qemu has the power to have guest os's think they're on a box with entirely different processor types (eg have a PowerPC guest on a x86 box). But what I've found awesome is that with the relatively new Kernel Based Virtual Machine (aka KVM) on linux, with a supported processor, virtualisation goes right down to the cpu level - so it's fast!
If you're on linux and want to check if your processor does support it, use:
set ear file's context root in WebSphere
Thursday, March 27, 2008
WebSphere lets you set the context root of a war file directly on page 1 of the update screens. ear files are different however:
Turns out when Updating an ear, you need to select on the first screen to show all build/config options.
Then skip to step 8 'Map context roots for Web modules'. There the context can be specified.
managing networks without gnome
Wednesday, March 26, 2008
Having Xubuntu on my machine, gnome's Network Manager is an option, but I try to avoid the bloat of gnome. A great alternative (which many say is better) is wicd. It successfully scans for wireless networks, handles WEP connections, and is the only way I could find to connect to WPA/WPA2 networks. Great product. (howto)
keep grub boot switches between kernel updates
Thursday, March 06, 2008
I have been frustrated on numerous Linux systems where I have to use custom boot switches in Grub, so add them to the relevant entry in /boot/grub/menu.lst, but then a new kernel version (which adds a new boot entry) then doesn't have this new option. This has been simply annoying in the past because I've had to go back in and add the text to the entry. But now I've built a machine for a paying customer and I can't go round every time there's a kernel update!
It turns out the solution is simple:
Between the flags
### BEGIN AUTOMAGIC KERNELS LIST
and
## ## End Default Options ##
are settings that the updater will read in order to create the new boot entries.
The one we want is
While I'm on the topic, another useful setting in this set is
lock hibernate session to avoid lazy loading exceptions in tests
Tuesday, March 04, 2008
//Lock this hibernate session so we don't get lazy loading exceptions
SessionFactory sessionFactory = (SessionFactory) appContext.getBean("sessionFactory");
Session session = SessionFactoryUtils.getSession(sessionFactory, true);
TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));