What the Jumper settings will do ?
Jumper is used to make short circuites between two or more pins.
One of the real usage is Primary and secondary hard disk is configured via jumper settings.
tools/ directory of the SDK. DDMS works with both the emulator and a connected device. If both are connected and running simultaneously, DDMS defaults to the emulator.ddms (or ./ddms on Mac/Linux) from thetools/ directoryadb and DDMS, which notifies DDMS when a VM on the device is started or terminated. Once a VM is running, DDMS retrieves the the VM's process ID (pid), via adb, and opens a connection to the VM's debugger, through the adb daemon (adbd) on the device. DDMS can now talk to the VM using a custom wire protocol
if the system is 32 bit system,
we are allocating memory like this:
struct test
{
char a;
int b;
};
It will allocate 8 bytes of memory in 32 bit system. For char,compiler
will allocate the 4 bytes. [char may be 1 or 2 bytes]
this is called data alignment. Data alignment means putting the data
at a memory offset equal to some multiple of the word size,
which increases the system's performance due to the way the CPU handles memory.
For char, 4 bytes are allocated. it will use only 1 bytes.Rest of the
bytes are filled with junk values. this is called structure padding.
For example, in 32 bit system,the data to be read should be at a
memory offset which is some multiple of 4.
if the data starts from the 18th byte, computer has to read two 4
bytes chunks to read the data.
if the data starts from multiple of 4[4,8,12,16,20], computer can read
4 byte chunk once to read the data.
If the read is from two virtual memory pages, then it will take more
time than expected.
In this way, padding improves performance.
if the data members are declared in descending order it will give
minimal wastage of bytes.
struct Test
{
char a;
int b;
char c;
};
sizeof(Test) is 12 bytes.
But if we declared like this, 8 bytes will be allocated for structure "Test".
struct Test
{
int b;
char c;
char a;
};
How to avoid structure paddding?
if we dont want to waste memory & tradeoff the performance,
we need to use pragma pack to align data.
Qualcomm and NVIDIA processors will have built-in hardware codecs support.
They will provide the OMX components too. Their OMX core will be
loaded from libstagefrighthw.so .
This libstagefrighthw.so library will be loaded by stagefright in
OMXMaster.cpp in
addPlugin("libstagefrighthw.so");
vertical sync - indicates when a new image is starting
horizontal sync -indicates when a new scanline is starting
Each still is composed of series of scanlines.
Interlaced vs Progressive:
For displays that "paint" an image on the screen, such as a CRT,
Interlaced-each image is displayed starting at the top left corner of
the display, moving to the right edge of the display.
Interlacing: First odd number of pixels are sent to display and then
even number of pixels are sent to display the image.
Advantage: we can reduce memory transfered to display by half for every image.
Progressive: pixels are displayed by sequence of lines.For Higher
resolution, we go for progressive.
Interlaced: First half of image is displayed on screen and then next
half of image is displayed
PseudoCode:
==============
#define MAX_FILENAME 8
#define TwoContinuousDots 0
#define SingleCharBetweenTwoDots 1
#define MAX_FILE_EXT 11
#define EndsWithDot 0
#define MAX_EXT 3
1.read the string input
2.Identify the dot & break the loop
3.if (stringBeginsWith == Dot) return NO;
4.if (CurrentCharPosition > MAX_FILENAME) //DotPosition exceeds
MAX_FILENAME allowed || Dot is not available within 8 character
return NO;
5.Store the ++LastDotPos
6.start loop through the string till EOS reached
7.if [ currentDotPos - lastDotPos == TwoContinuousDots ] { return NO;}
8.if ( CurrentDotPos - lastDotPos == SingleCharBetweenTwoDots ) { return NO;}
9.if ( CurrentDotPos - lastDotPos > MAX_FILE_EXT ) return NO;
At Last of the string,
10.if( CurrentDotPos - lastDotPos == EndsWithDot ) return NO;
11.if( CurrentDotPos - lastDotPos > MAX_EXT ) return NO; //Last
extension exceeds MAXIMUM_EXTENSION size
12.Yes... we are going to parse the valid String
13.create loop1... Search First Dot
14.if (char == FirstDOT) create loop2 and look for SecondDOT
15.if no second DOT and EOS reached,print string. [Ex: t.txt]
16.if(TwoDotsDiff <= MAX_EXT) printf( secondDot + 1 char);Move i by 1
17.else print (3 characters) Move i by 3
1)Prepare the testcases from the given problem statement
2)Prepare test samples
3)Prepare design
4)Check if any datastructure can be used & what will be the cons & pros
5)If multiple datastructure can be used, Identify the best
suitable datastructure
6) Sometimes tradeoff clarity/simplicity over efficiency
7) Once completed the code, test with test samples
8) if anyone has already submitted the problem, we can see the
testcases used for testing the solution.
we can check our code with codeforces simple testinputs
This will clarify if we misunderstood the problem statement.
[Ex: For Cd and PWd commands problem, from the problem
statement, I assumed that .. or / wont come at end.
But from the testsamples,I came to know this as a valid input]
9) Think on how to improve the code
After seeing others code,
1) Prepare testcases from code
2) Prepare testsamples to break the code
3) Randomly remove some lines of code and try to fix it...
This will give a chance to understand/read others code.
4.Identify any language functions/features used in code for
addressing particular scenarion & think of it
how to use it
5.Check the efficient code[less execution time] written by others
6.Check others code which is having clarity and simplicity
Usually we will do like this:
char szString[100]={0};
scanf("%s",szString);
for(int i = 0; i <strlen(szString); i++);
{
printf("%c",szString[i];
}
without knowing strlen(), we can print the same thing as below:
char szString[100]={0};
scanf("%s",szString);
for(int i = 0; szString[i]; i++);
{
printf("%c",szString[i];
}
if szString reaches NULL, it will returns zero, so for loop will be
terminated for that case.
Input : 6 = 2 * 3 * 4 * 5 = 120 = Trailing zeros = 1
Output : 1
For more detailed tutorial :
http://www.purplemath.com/modules/factzero.htm
#include <stdio.h>
void main()
{
long n =0;
long div = 5;
long sum = 0;
printf("Enter N! value:");
scanf("%ld",&n);
while(n >= div)
{
sum += n/div;
div *= 5;
}
printf(" Output is :%ld", sum);
}
Importance of finding the trailing zeros will be useful in floating
point representation.
It will be used to represent floating numbers
as 2 * (10 ^ 3)
mantissa: 2
exponent: 3
Same will be used to represent negative numbers in floating point
representation;
2 * (10 ^ -3)
1. AV sync is undetectable if sound is rendered -100ms to +25 ms to video
- Sound Delayed
+ Sound advanced
2.How android audio flinger is mixing two or more tracks in mixer thread ?
[How to mix two or more audio streams/tracks together ?]
If you want to mix streams A & B, you simply sum the corresponding samples: A1+B1=C1, A2+C2=B2... An+Bn=Cn...
Of course, both streams must have the same sample rate (and with integer formats, both must have the same bit-depth) before you sum.
With integer formats you have to scale the input streams before summing (i.e. divide by 2), or you need to allow for
larger numbers (more bits) in the output stream. Even with 32-bit floating point, you'll normally want to scale before or after mixing to avoid clipping.
(The 32-bit data won't clip, but you can clip the DAC output.)
And frequently with audio mixing, you'll want to scale the input levels because you don't always want a 1:1 mix... You may want one signal to be louder in the mix. Audio flinger is mixing one or more tracks as mentioned above.
From:http://www.hydrogenaudio.org/forums/index.php?showtopic=79430
How localplayback errors are notified from C++ to java mediaplayer/ mediarecorder layer/Application in android ?
Java layer will have
MediaPlayer
{
public static void postEventFromNative() { Notifies Error or Information events to Application thru InfoListener or ErrorListener }
};
JNI:
=====
JNIMediaPlayerListener/ JNIMediaRecorderListener is passed to underlying c++ mediaplayer or mediarecorder [libmedia] object.
whenver C++ mediaplayer or media recorder encounters errors it will call JNIMediaPlayerListener's notify () fn.
JNIMediaPlayerListener's notify/JNIMediaRecorderListener's notify is implemented in JNI.
void JNIMediaPlayerListener/JNIMediaRecorderListener::notify(int msg, int ext1, int ext2, const Parcel *obj)
{
fields.post_event = env->GetStaticMethodID(clazz, "postEventFromNative",
"(Ljava/lang/Object;IIILjava/lang/Object;)V");
env->CallStaticVoidMethod(mClass, fields.post_event, mObject,
msg, ext1, ext2, NULL); //This will call the postEventFromNative() fn in Java...
}
How to detect if one of the linked list pointer is corrupted or not ?
0.In case of doubly linked list, by checking the prev/next pointer, we can identify whether the pointer is valid or not...
1.We can add some extra field to store the count of the linked list node from 1,2,... and so on. For any node we can check the value with previous node value
2.we can make use of virtualquery() fn in windows to check whether the given address is valid or not.
In the same way, in linux, we will be having mprotect() fn. if we are passing the invalid address in mprotect(), it will notifies the application
with SIGSEGV signal, Application need to catch this signal and do the necessary things.
Lock based synchronization provides the following problems
1.Deadlock
2.LiveLock
3.Priority Inversions
4.Caravan Formation
To avoid these problems, we are going for lock free synchronization. AsynchronousProgramming is a typical technique for achieving lock free synchronization.
Example: Android Stagefright is having lock based synchronization mechanism
PV's OpenCORE is having lock free synchronization mechanism
within Android.mk,
ENABLE_CODEC =1
ifeq(ENABLE_CODEC,true)
$(warning SUNDARA::ENABLE_CODEC is true)
else
$(warning SUNDARA::ENABLE_CODEC is false)
endif
#How to print the variable from Android.mk
TARGET_PLATFORM := MSM7227
$(warning SUNDARA::Target Plarform is '$(TARGET_PLATFORM)')
output:
SUNDARA::ENABLE_CODEC is true
Target Plarform is MSM7227
Tao Te Ching. Although it's a philosophy book and not a programming book, some of it's principles are very applicable to programming:
"Know when it's time to stop. If you don't know then stop when you are done."
Translation: Knowing your requirements means you know when to stop. If you don't know when to stop, you need to stop because the requirements have yet to be defined.
"The harder one tries, the more resistance one creates for oneself."
Translation: How many times have you worked on a problem for several hours, only to find the answer after taking a 15-minute break? The more you hammer at a problem, the harder it is going to be for you to solve it.
"One whose needs are simple can fulfill them easily."
Translation: Simple requirements lead to simple designs.
"When we lose the fundamentals, we supplant them with increasingly inferior values which we pretend are the true values."
Translation: Hubris is never a good substitute for good programming standards. If you get lax, no amount of design patterns will ever substitute for the lack of quality in your code.
Tricks of Gmail:
===================
1.if your gmail id is something like this.
Then you can login gmail as asundara or a.s.u.n.d.a.r.a@gmail.com [Any number of dots in between your mail user ID]
if anyone is sending mail to asundara@gmail.com, then you will receive mail in your inbox.
Problem:
Solution:
we can give compilation command | tee log.txt and redirects the compilation output to file log.txt. Once the compilation is done, the compilation message /errors will be stored in log.txt. From this log.txt, we can figure out whether compilation is completed or not.
Harvesting techniques to use right side of the brain:
1.Free Form Journaling – Writing is a great way to relax your mind and allow your R-mode thoughts and ideas to escape your brain and present themselves onto paper. When ideas pop into your head, write them down, and then elaborate on those ideas. Simple brainstorming on paper can give you the opportunity to clarify your thoughts.
2.Walking – Sometimes the best way to come up with ideas is to simply step away from your desk, relax your mind, and go for a walk. While you're walking though, try not to think about anything, especially the problem you are trying to solve. The goal is to silence your L-mode and give your R-mode the chance to do some work.
3.Image Streaming – This is the process of deliberately observing images in your mind and paying close attention to them. First, pose a problem to yourself or ask yourself a question. Then shut your eyes and relax. As images start to cross your mind describe them out loud. Try to describe as many details as you can using all five senses. This type of thinking can help you discover fresh insights to the problem or question you presented yourself.
Try the PQ RAR reading-study method as you read or teach your next textbook chapter.
P-First of all, preview the reading selection. Try to limit the reading selection to a manageable size. Overly long chapters, say over six pages for
elementary students, eight for middle school students, twelve for high school students, and sixteen for college students should be "chunked" into manageable
reading sections.
1. Preview the first and last paragraphs of the chapter and the chapter review, if one is provided.
2. Preview all subtitles and any book study helps at the beginning of the chapter.
3. Preview all graphics such as photographs, charts, maps, etc. and their captions.
Q-Secondly, make use of text-based questions to read textbooks effectively. Good questions produce good answers and significantly increase expository
comprehension. Determining questions before reading provides a purpose for reading, that is-to find the answers as you read.
1. Develop questions from the subtitles and write these down on binder paper or on your computer, skipping lines between each question. Try "What," "How,"
and "Why" question-starters. Avoid the "Who" and "When" questions, as these tend to focus attention on the minor details of expository text.
2. Write down any chapter review questions not covered by your subtitle questions, skipping lines between each question.
R-Read the chapter and "talk to the text" by taking notes in the textbook margins. Use yellow stickies and paste them in the textbook margins, if you can't
write in the textbook. Write down comments, questions, predictions, and connections to other parts of the reading and your own life experiences. List
examples, key details, and important terms with their definitions. Internal monitoring of the author's train of thought and the connection to your own
knowledge and experience increases comprehension as you read textbooks.
A-Answer both the subtitle questions and the book questions as you read. Write down your answers underneath your questions. Don't be concerned if the
textbook did not answer some of your reader-generated questions.
SQ3R is a simple strategy that can be used to actively engage yourself in whatever it is you are reading. The SQ3R process is as follows:
Survey – Scan the chapter headings and summaries for an overview.
Question – Note any questions you have.
Read – Read in its entirety.
Recite – Summarize, take notes, and put in your own words.
Review – Reread, expand notes, and discuss with colleagues.
A tourist visiting England's Eton College asked the gardener how he got the lawns so perfect. "That's easy,"
he replied, "You just brush off the dew every morning, mow them every other day, and roll them once a
week."
"Is that all?" asked the tourist.
"Absolutely," replied the gardener. "Do that for 500 years and you'll have a nice lawn, too."
Great lawns need small amounts of daily care, and so do great programmers.
"Kaizen" is a Japanese term that captures the concept of continuously making
many small improvements. It was considered to be one of the main reasons for the dramatic gains in productivity and
quality in Japanese manufacturing and was widely copied throughout the world. Kaizen applies to individuals, too.
Every day, work to refine the skills you have and to add new tools to your repertoire. Unlike the Eton lawns, you'll
start seeing results in a matter of days. Over the years, you'll be amazed at how your experience has blossomed and
your skills have grown.
MutexLock hangs in StageFright:
1.This might happens due to invalid use of[if we have added any] the mutex lock / invalid call sequence.
We observed mutex lock hang for the below scenario:
mPlayer.SeekTo(10);
mPlayer.Start();
We should call like this:
mPlayer.SeekTo(10);
mPlayer.OnSeekCompletionListener()
{
mPlayer.Start();
}
or
mPlayer.SeekTo(10);
WaitForEvent();
mPlayer.Start();
OnSeekCompletionListener()
{
TriggerEvent();
}
What is the source of your energy ?
Simple. I love what I do
-Vasanthi , RJ
Illegal stack operations can lead to hard to detect crashes. This typically takes place when a program passes a pointer of the wrong type to a function. The example given below shows a case of a function expecting an integer pointer and the caller passes a pointer to a character.
http://www.eventhelix.com/realtimemantra/Basics/debugging_software_crashes.htm
| char pointer/int pointer mixup |
|
I joke, but one really is better than the other. :-)
There really is no easy way to say this, so I'll just blurt it out: your computer might have been storing bytes in reverse order behind your back. I know! No one wanted to have to tell you.
The thing is, everyone in the Internet world has generally agreed that if you want to represent the two-byte hex number, say b34f, you'll store it in two sequential bytes b3 followed by 4f. Makes sense, and, as Wilford Brimley would tell you, it's the Right Thing To Do. This number, stored with the big end first, is called Big-Endian.
Unfortunately, a few computers scattered here and there throughout the world, namely anything with an Intel or Intel-compatible processor, store the bytes reversed, so b34f would be stored in memory as the sequential bytes 4f followed by b3. This storage method is called Little-Endian.
But wait, I'm not done with terminology yet! The more-sane Big-Endian is also called Network Byte Order because that's the order us network types like.
Your computer stores numbers in Host Byte Order. If it's an Intel 80x86, Host Byte Order is Little-Endian. If it's a Motorola 68k, Host Byte Order is Big-Endian. If it's a PowerPC, Host Byte Order is... well, it depends!
A lot of times when you're building packets or filling out data structures you'll need to make sure your two- and four-byte numbers are in Network Byte Order. But how can you do this if you don't know the native Host Byte Order?
Good news! You just get to assume the Host Byte Order isn't right, and you always run the value through a function to set it to Network Byte Order. The function will do the magic conversion if it has to, and this way your code is portable to machines of differing endianness.
All righty. There are two types of numbers that you can convert: short (two bytes) and long (four bytes). These functions work for the unsigned variations as well. Say you want to convert a short from Host Byte Order to Network Byte Order. Start with "h" for "host", follow it with "to", then "n" for "network", and "s" for "short": h-to-n-s, or htons() (read: "Host to Network Short").
It's almost too easy...
You can use every combination of "n", "h", "s", and "l" you want, not counting the really stupid ones. For example, there is NOT a stolh() ("Short to Long Host") function—not at this party, anyway. But there are:
host to network short | |
host to network long | |
network to host short | |
network to host long |
Basically, you'll want to convert the numbers to Network Byte Order before they go out on the wire, and convert them to Host Byte Order as they come in off the wire.