Monday, December 10, 2012
[Androidx86] How to run Angry Birds on Android x86 ICS (A to Z)
Note that we use Android x86 ICS for this post.
Step 1: Prepare the Linux environment to build Android x86 ISO file. I use Ubuntu 10.4 in this case.
(Following my previous post to install some necessary tools)
Step 2: Now I start from step Download Android x86 Source :
# cd ~
# mkdir android_src
# cd android_src
# repo init -u http://git.android-x86.org/manifest -b ics-x86
# repo sync
Step 3:
# cd android_src
# sudo make iso_img TARGET_PRODUCT=generic_x86
(This step will take around 4~5 hours)
Step 4:
Because i run Virtual Box on Windows 7 , then i copy ISO file in "out" folder to Windows 7.
Run Virtual Box and create new VM with the ISO we copied.
Follow the install steps Android x86 in Virtual Box (http://www.android-x86.org/documents/installhowto)
***Note: Choose "Yes" in the below box:
Step 5:
After finish install Androidx86 in Virtual Box, run it.
Because ICS does not enable eth0, we have to enable it as follows:
Use "Alt" + "F1" to enter the console mode.
//Setting static IP
# ifconfig eth0 "IP_Address" netmask 255.255.255.0 up
# route add default gw "Gateway_Address" dev eth0
OR: (dynamic IP : 10.0.x.x)
# netcfg eth0 up
# netcfg eth0 dhcp
# setprop net.dns1 8.8.8.8
Now go back the graphic mode by "Alt" + "F7", connect internet succesful
Step 6:
Since i used static IP, then i will use "IP_Address" to connect in this step.
Due to Androidx86_ICS cannot download any files or apps from internet. Then i try to use ADB (Android Debug Bridge) to install software into Androidx86.
Download adt-bundle-windows-x86 from http://developer.android.com/sdk/index.html
Go to adt-bundle-windows-x86\sdk, Shift + Right Click on Platform-Tool , Choose "Open Command Windows here"
Try: download : Andftp (http://www.lysesoft.com/products/andftp/) and AngryBirds Rio 1.4.3 (http://download.pandaapp.com/android-app/angry-birds-rio1.4.2-id6743.html#.UUBf2DeHfTo) and put all the downloaded "files.apk" in the same folder with adb.exe
# adb.exe connect "IP_Address"
# adb.exe install Andftp.apk
# adb.exe install AngryBirds.apk
Step 7: Now Your Androidx86 already installed FtpClient and AngryBirds. But you can not run AngyBird now.
In order to run Angry Birds, we need to add library "houdini" into Androidx86 file system.
In Windows 7: Download the below libs from http://android-x86.sceners.org/en/?p=536
- libhoudini.so
- libdvm_houdini.so
- arm libs
Now, create FTP server in your Windows 7. From Android x86, use FtpClient to connect FtpServer and download all above libs into /sdcard/Download.
Type Alt + F1:
# cd /sdcard/Download
# cp libhoudini.so /system/lib
# cp libdvm_houdini.so /system/lib
# mkdir /system/lib/arm
# cp arm_lib/* /system/lib/arm
Reboot Androidx86 and try to run Angry Birds. It will be something like this:
However, the speed is quite slow due to the ARM binary translations.
(Please feel free to ask if you cannot follow any steps).
Wednesday, June 6, 2012
[Linux] Understanding Shared Libraries
---------------- programmerFunction.h------------------
//This header defines the programmer function which just returns
//A value for an integer.
#ifndef PROGRAMMERFUNCTION_H
#define PROGRAMMERFUNCTION_H
#ifndef _cplusplus
extern "C"
{
#endif
void returnInteger(int*);
#ifndef _cplusplus
}
#endif
#endif
------------------------------------------------------------------------
--------------- programmerFunction.cpp------------------
//Here is the actual code to return an integer.
//As you can see nothing fancy
#include "programmerFunction.h"
void returnInteger(int * eger)
{
*eger=58008;
}
#endif
------------------------------------------------------------------------
------------------- userProgram.cpp ----------------------
//Here is the main program which just includes the
//The programmer defined function and prints out
//The value of the function
#include < stdio.h >
#include "programmerFunction.h"
int main()
{
int eger;
returnInteger(&eger);
printf("This is the value in eger: %d\n",eger);
return 0;
}
------------------------------------------------------------------------
As you can see there is nothing really to these programs and it was designed for simplicities sake.
First thing we have to do is turn the programmerFunction.cpp into an object file by typing in this command:
" g++ -Wall -fPIC -c programmerFunction.cpp "
This creates the object file that will enable us to create our shared library from.
Now in order to create a shared library we are going to enter in this command:
" g++ -shared -Wl,-soname,libmylib.so.1 -o libmylib.so.1.0 programmerFunction.o "
This creates our shared object file called libmylib.so.1.0. From here we are going to move in into this path (or another suitable path of your choice) which is /opt/lib/.
" sudo mv libmylib.so.1.0 /opt/lib/. "
The next thing we have to do is create two soft links that point to the libmylib.so.1.0 shared library.
" sudo ln -sf /opt/lib/libmylib.so.1.0 /opt/lib/libmylib.so "
" sudo ln -sf /opt/lib/libmylib.so.1.0 /opt/lib/libmylib.sh.1 " and
" sudo ln -sf /opt/lib/libmylib.so.1.0 /opt/lib/libmylib.so.1 "
Next we are going to compile our userProgramm.cpp and link our shared library with it.
" g++ -Wall -L/opt/lib userProgram.cpp -lmylib -o compiledProgram "
Now in order for the program to run we need to export the path of /opt/lib to the environment variable
LD_LIBRARY_PATH. We will do this by entering this command:
" export LD_LIBRARY_PATH=/opt/lib:$LD_LIBRARY_PATH "
Now finally to run our program and get it's output.
" ./compiledProgram "
After you run this command you should get the number " 58008 ".
So after you have done all this why would we want to create a shared or dynamic link? Well for such a small program we may not actually need it but to show the power of a shared library we will change the value of the integer without having to recompile our main program. This is what makes shared libraries powerful. You can update the shared libraries without having to redo massive compilations and might actually end up saving you time in the end.
Lets begin by changing our programmerFunction.cpp. change the value eger by replacing it with the value of " 123456 ".
Now run these commands:
" g++ -Wall -fPIC -c programmerFunction.cpp "
" g++ -shared -Wl,-soname,libmylib.so.1 -o libmylib.so.1.0 programmerFunction.o "
" sudo mv libmylib.so.1.0 /opt/lib/. "
What this effectively does is recompiles your programmerFunction.cpp file into a new object file. We also recreate the shared library and replace your old shared library with the new one. Now rerun your program by typing in this:
" ./compiledProgram "
You should now see the new number of " 123456 ". If you see this number congrats! You now know a little bit about shared libraries and maybe see some use for them.
Thanks,
Almightybeeij
From OKCLugNuts
Tuesday, June 5, 2012
[FreeRDP] How to install FreeRDP on Ubuntu
- sudo apt-get install build-essential git-core cmake libssl-dev libx11-dev libxext-dev libxinerama-dev libxcursor-dev libxdamage-dev libxv-dev libxkbfile-dev libasound2-dev libcups2-dev libxml2 libxml2-dev
- sudo apt-get install libavutil-dev libavcodec-dev
- sudo apt-get install libcunit1-dev libdirectfb-dev xmlto doxygen libxtst-dev
- cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_SSE2=ON
- Before making Makefile, you should enable CLIENT or SERVER in CMakeList.txt and continue the following steps:
- sudo make clean
- sudo make
- sudo make install
- sudo ldconfig
Wednesday, May 16, 2012
I'm sorry if (clause)
I'm sorry if anyone is offended by my remarks.
(someone) feels excluded
(someone) feels ignored
it's not my job to (do something)
- someone is expecting you to do something
- you don't think you should be expected to do it
It's not my job to clean up after you!
babysit (an adult)
- making sure that the person doesn't make a mistake in their job
- making sure that a socially awkward friend or partner is having fun at a party
I don't have time to babysit you. Figure it out on your own!
Wednesday, April 11, 2012
[Android x86] Streaming audio PCM from Server Android x86 to Android Mobile phone using Socket
Now, i have the audio PCM files which i want to dispatch to client(android phone). Alternately, i wrote the server app for android x-86 and the client app for android phone by using Socket as the network communication.
Thursday, March 22, 2012
C/C++ : Combination (n,k)
Tuesday, March 20, 2012
How to build ISO android-x86 in Ubuntu
Linux C++ : Append int to char*
A Method to Capture Android-x86 System Audio
(From BY: XZPETER - 20TH, 2011 )
I have just posted a note about a month ago about video capturing in android system (that post is written in Chinese). This time I will talk something about audio capture.
Actually, I have looking into the issue for some days, and I didn’t find a good way to do that. There are indeed some articles talked about different ways to do audio recording in android by all kinds of APIs, like OpenSLES (this should be supported after gingerbread) orMediaRecorder which belongs to android SDK API. However nearly all of them were recording the mic input, rather than the system output. Meanwhile, I have seen many posts on android-dev asking for the same question, and it seems that there is currently no valid answer on this. So I hope my method will at least make some sense for those whoreally want to capture the system output and don’t know how, like me.
My method is not good, since you have to recompile the android tree, however this is currently the only way for me to achieve my goal. Please tell me if you know other ways to do that. So download the android source tree will be the first step here. And the main idea of the work is: since there is no API for system audio capture, we have to capture it by ourselves, in a lower level, e.g., the android framework.
The source.android.com is the best place for you if you don’t have a android source tree, andUbuntu is highly suggested as the compiling environment. After you have read that, you should have a workable android source tree. here workable means you should be able to compile the tree and launch emulator successfully with the android kernel you just compiled. To achieve that, you may have to establish the environment first (e.g. to installsun-java-6, not the one called openjdk, which may cause strange compilation errors), run some scripts to initialize macros for compilation (like source build/envsetup.sh andlunch), and finally run make -j8 under your android source root. (if you don’t use -j8, which means enable parallel compilation with eight threads, you will possibly have to wait for a really long time before the compilation is done)
1. Play some audio
Before we try to capture the system sound, we do have to find some audio to play, so that we can know we have captured something. This is really a easy task. Just find any mp3 file (e.g. music.mp3), put it under the android /sdcard/ dir with adb push (CAUTION here: you have to use mksdcard command to create a sdcard image, and then use -sdcard option when launching the emulator. By default, the emulator will have no sdcard mounted).
Then, use the Media Scanner of dev tools in the android system to activate the scan process of audio files. After that, in the application called Music there should be a mp3 file ready for you to play. By playing the song, You should be able to hear the sound on your host, although it is actually played on the emulator.
2. Do the system audio capture
Comes to the main part of this article. first of all let’s see the android audio system in the graph.
I am not a expert on android system, but we can see here that the lowest level of audio system goes to /dev/eac device file, and there is an AudioHardwareInterface, which is possibly hardware related, to access this file directly. And here AudioFlinger seems to be the best part for us to hack, since it is not depending on hardware, and it should has the final mixer output, which is what we want (we don’t want any single sound track, we need the overall system output, isn’t it?). Actually, here AudioFlinger did not only the mixer work, and also resampling stuff.
AudioFlinger is implemented under dir frameworks/base/services/audioflinger/ (Here I assume that we are currently under the root of android source tree). What we are going to do is to find the mixer output. In the file AudioFlinger.cpp, we can seeAudioFlinger::MixerThread::threadLoop(), which is the working thread of the mixer, and this MixerThread is inherited from AudioFlinger::BaseThread. Then, just search the keyword mOutput->write with your best editor (vim, emacs, gedit, whatever), and we will find something like this under the threadLoop() function:
... mLastWriteTime = systemTime(); mInWrite = true ; mBytesWritten += mixBufferSize; int bytesWritten = ( int )mOutput->write(mMixBuffer, mixBufferSize); if (bytesWritten < 0) mBytesWritten -= mixBufferSize; mNumWrites++; mInWrite = false ; ... |
That is the very point that mixer output buffer is transferred to hardware related codes I think, and the audio clip is in mMixbuffer, with size mixBufferSize. In this buffer, there are PCM raw audio data with 44100Hz sampling rate, 2 channels and 16 bits little endian as its param.
If you write this buffer out to a file, like /data/wav.raw, you can just use adb pull to retrieve the data file to your host machine and play it with aplay:
$ aplay -t raw -c 2 -f S16_LE -r 44100 wav.raw |