pcm.!default {
type hw
card 1
}
ctl.!default {
type hw
card 1
}
Sunday, December 21, 2008
Make a sound card as default in Linux
In the case that we have more than one sound-card, but to select one of them as the default sound-card, copy the following to ~/.asoundrc. In the example below, it makes the card 1 as the default (type "aplay -l" from shell to see all the cards installed and their associated card #).
Sunday, November 30, 2008
OS-X Bootcamp Missing or Corrupt Issue
I got my OS-X Leopard 10.5 a few days ago. After OSX installation, I went to Preference->Utilities->Boot Camp Assistant and then configured it. After reboot and installed the Windows XP, when my MacBook rebooted, it always failed and showed a message as below:
I've tried various attempts with no success. I searched Google but nothing really helped solving the issue. Finally, I retried again by restoring the OSX into single partition and repartitioned it using The Bootcamp and chose 32 GB FAT32 partition for the Windows. During Windows Installation, I did not delete the partition created by the Bootcamp, but instead just chose NTFS Quick format. Out of my suprise, It worked.
So, the main issue before was that I should hadn't deleted the BOOTCAMP partition I shouldn't had used Windows' Partitioner) and just straightly reformat it and install the Windows.
It works now, except it couldn't find the audio driver (all the other devices were recognized and installed through the OSX CD).
Windows could not start because the following file is missing or corrupt:\system32\hal.dll
Please re-install a copy of the above file
I've tried various attempts with no success. I searched Google but nothing really helped solving the issue. Finally, I retried again by restoring the OSX into single partition and repartitioned it using The Bootcamp and chose 32 GB FAT32 partition for the Windows. During Windows Installation, I did not delete the partition created by the Bootcamp, but instead just chose NTFS Quick format. Out of my suprise, It worked.
So, the main issue before was that I should hadn't deleted the BOOTCAMP partition I shouldn't had used Windows' Partitioner) and just straightly reformat it and install the Windows.
It works now, except it couldn't find the audio driver (all the other devices were recognized and installed through the OSX CD).
Tuesday, November 25, 2008
AVI to MPEG mass conversion
Need a FFMPEG installed.
The following command will convert all *.AVI files into SVCD-format (with MP3 audio) files:
To see all supported format on FFMPEG:
The following command will convert all *.AVI files into SVCD-format (with MP3 audio) files:
find . -iwholename *.avi -exec ffmpeg -target ntsc-svcd -acodec mp3 -y -i '{}' '{}.mpg' \;
To see all supported format on FFMPEG:
ffmpeg -formats
Wednesday, November 19, 2008
Using Vector template
#if defined(__cplusplus)
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#else
error "must be CPP-enabled compiler to compile this program"
#endif
using namespace std;
class CPoint {
public:
CPoint(double a, double b) { x = a; y = b; };
friend std::ostream& operator<< (std::ostream& os, const CPoint& val);
double getX() { return x; };
double getY() { return y; };
private:
double x;
double y;
};
std::ostream& operator<< (ostream& os, const CPoint& pt)
{
return os << "(" << pt.x << ", " << pt.y << ")" ;
}
int main()
{
vector<CPoint> points;
vector<CPoint>::iterator it;
int i;
it = points.begin();
for (i=0; i<10; i++) {
it = points.insert( it, CPoint(10.5+double(i)/11, 22.7 - double(i)/13) );
}
cout << "Vector Demo" << endl << "-------------" << endl;
cout << "Vector size = " << points.size() << endl;
for (it = points.begin(), i=0; it < points.end(); it++,i++)
{
// cout << "points[" <<>x;
cout << " " << *it;
cout << endl;
}
for (i=0; i< points.size(); i++)
{
cout << "points[" << i << "] = " << points[i] << endl;
}
return 0;
}
Friday, November 14, 2008
Making Linux running SUSE as a Bridge
- Make sure bridge module is installed in the Kernel
- Run the bridge module: sudo modprobe bridge
- Install bridge-utils (download it from http://bridge.sourceforge.net) and copy brctl into /sbin (the ifup script is hardcoded to call it from /sbin)
- create a new bridge instance (in this example, the bridge name is called br0): sudo brctl addbr br0
- Add the interface(s) to be members of this bridge: sudo brctl addif br0 ethx (where x = 0, 1, ...)
- To make it permanent, copy /etc/sysconfig/network/ifcfg-template to ifcfg-br0
- Modify the content and let have it as below (IPADDR is chosen here as 192.168.1.4):
- restart network: sudo /etc/init.d/network restart
IPADDR=192.168.1.4
NETMASK=255.255.255.0
NETWORK=
BROADCAST=
STARTMODE=auto
USERCONTROL=no
BRIDGE='yes'
BRIDGE_PORTS='eth0 eth1 eth2'
BRIDGE_AGEINGTIME='300'
BRIDGE_FORWARDDELAY='0'
BRIDGE_HELLOTIME='2'
BRIDGE_MAXAGE='20'
BRIDGE_PATHCOSTS='19'
BRIDGE_PORTPRIORITIES=
BRIDGE_PRIORITY=
BRIDGE_STP='on'
Sunday, October 26, 2008
How to figure out Linux Devices and Drivers
These are the steps to know if our devices have drivers installed and what they are.
$ less /proc/devices
Character devices:
1 mem
2 pty
3 ttyp
4 /dev/vc/0
4 tty
4 ttyS
5 /dev/tty
5 /dev/console
5 /dev/ptmx
6 lp
7 vcs
10 misc
13 input
14 sound
21 sg
29 fb
81 video4linux
116 alsa
128 ptm
136 pts
180 usb
189 usb_device
195 nvidia
253 usb_endpoint
254 rtc
Block devices:
1 ramdisk
2 fd
3 ide0
7 loop
8 sd
9 md
22 ide1
65 sd
66 sd
67 sd
68 sd
69 sd
70 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
253 device-mapper
254 mdp
For example, to see what devices the video4linux driver has:
ls -artl /dev | grep 81
crw-rw---- 1 root root 253, 1 2008-10-26 17:17 usbdev1.1_ep81
crw-rw---- 1 root video 81, 1 2008-10-26 17:17 vbi0
crw-rw---- 1 root video 81, 0 2008-10-26 17:17 video0
To see what devices my NVidia driver has:
ls -artl /dev | grep 195
crw-rw---- 1 root video 195, 255 2008-10-26 17:18 nvidiactl
crw-rw---- 1 root video 195, 0 2008-10-26 17:18 nvidia
The major version is the one that we're interested. It's the first number showed when we do 'ls /dev' as well as the numbers showed in /proc/devices
$ less /proc/devices
Character devices:
1 mem
2 pty
3 ttyp
4 /dev/vc/0
4 tty
4 ttyS
5 /dev/tty
5 /dev/console
5 /dev/ptmx
6 lp
7 vcs
10 misc
13 input
14 sound
21 sg
29 fb
81 video4linux
116 alsa
128 ptm
136 pts
180 usb
189 usb_device
195 nvidia
253 usb_endpoint
254 rtc
Block devices:
1 ramdisk
2 fd
3 ide0
7 loop
8 sd
9 md
22 ide1
65 sd
66 sd
67 sd
68 sd
69 sd
70 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
253 device-mapper
254 mdp
For example, to see what devices the video4linux driver has:
ls -artl /dev | grep 81
crw-rw---- 1 root root 253, 1 2008-10-26 17:17 usbdev1.1_ep81
crw-rw---- 1 root video 81, 1 2008-10-26 17:17 vbi0
crw-rw---- 1 root video 81, 0 2008-10-26 17:17 video0
To see what devices my NVidia driver has:
ls -artl /dev | grep 195
crw-rw---- 1 root video 195, 255 2008-10-26 17:18 nvidiactl
crw-rw---- 1 root video 195, 0 2008-10-26 17:18 nvidia
The major version is the one that we're interested. It's the first number showed when we do 'ls /dev' as well as the numbers showed in /proc/devices
Subscribe to:
Posts (Atom)