[Galaxy S I9000 Android Development] orenzah:
For the begging,

I found out that the problem for 2-way is on the libaudio.so, than I downloaded the source code from the github of samsung aries.

I found the file AudioHardware.cpp as the main one.

I googled the web and found a same file with 2-way and there is the code which do that

//wxj add for voice recorder
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
#include <poll.h>
//wxj add end

//-------------- wxj add for voice recorder ----------------
#if RECORDER_MOMEM
/*
AT^DAUDREC=<ON/OFF>
<ON/OFF> 0 turn off record
1 turn on record
*/
#define MODEM_RECORD_INCALL_ON "at+audr=1\r"
#define MODEM_RECORD_INCALL_OFF "at+audr=0\r"

//define pty device for send at command
#define AUDIO_AT_PATH "/dev/ttymux4"
#define AUDIO_DATA_PATH "/dev/ttymux4"

#define NUM_ELEMS(a) (sizeof (a) / sizeof (a)[0])

static const char * s_finalResponsesError[] = {
"ERROR",
"+CMS ERROR:",
"+CME ERROR:",
};

/**
* returns 1 if line is a final response indicating success
* See 27.007 annex B
* WARNING: NO CARRIER and others are sometimes unsolicited
*/
static const char * s_finalResponsesSuccess[] = {
"OK",
};

static Mutex audioLockMutex;

static int isFinalResponseError(const char *line)
{
size_t i;

for (i = 0 ; i < NUM_ELEMS(s_finalResponsesError) ; i++) {
if (strcasestr(line, s_finalResponsesError[i])) {
return 1;
}
}

return 0;
}

static int isFinalResponseSuccess(const char *line)
{
size_t i;

for (i = 0 ; i < NUM_ELEMS(s_finalResponsesSuccess) ; i++) {
if (strcasestr(line, s_finalResponsesSuccess[i])) {
return 1;
}
}

return 0;
}

/**
* returns 1 if line is a final response, either error or success
* See 27.007 annex B
* WARNING: NO CARRIER and others are sometimes unsolicited
*/
static int isFinalResponse(const char *line)
{
return isFinalResponseSuccess(line) || isFinalResponseError(line);
}

static int s_fd = -1;
static int WriteATCommand(const char *s)
{
AutoMutex lock(audioLockMutex);
//int s_fd = open(AUDIO_AT_PATH,O_RDWR | O_NONBLOCK);
if ( s_fd < 0 ) {
LOGE(" AudioHardware ERROR OPEN AT interface, errno = %d ,s_fd = %d",errno,s_fd);
return -3;
}

size_t cur = 0;
size_t len = strlen(s);
ssize_t written;

LOGV(" AudioHardware AT> %s\n", s);

/* the main string */
while (cur < len) {
do {
written = write (s_fd, s + cur, len - cur);
} while (written < 0 && errno == EINTR);

if (written < 0) {
LOGE("AudioHardware write str error, errno = %d ",errno);
close(s_fd);
s_fd = 0;
return -1;
}

cur += written;
}

#if 0
/* the \r */
do {
written = write (s_fd, "\r" , 1);
} while ((written < 0 && errno == EINTR));

if (written < 0) {
LOGE(" AudioHardware write r error, errno = %d ",errno);
close(s_fd);
s_fd = 0;
return -1;
}
#endif

const int buf_len = 1024;
int readLen = 0, count = 0;
char* buffer = new char[buf_len];
//buffer[0] = '\0';
memset((void*)buffer, 0, buf_len);
bool final = false;
int tryTimes = 0;
int pollResult = 0;

for(;;){
while (0 == pollResult){
struct pollfd fpolls;
fpolls.fd = s_fd;
fpolls.events = POLLIN;
fpolls.revents = 0;

pollResult = poll(&fpolls, 1, 1000); //timeout 5 seconds

//data ready to be read
if (pollResult > 0 && POLLIN == fpolls.revents ){
LOGD(" AudioHardware data is available %d \n",__LINE__);
break;
}else if (pollResult < 0){
LOGD(" AudioHardware pollResult < 0 %d \n",__LINE__);
if (errno == EINTR){
continue;
}else{
break;
}
}else{
LOGE("timeout, but no data available");
if (tryTimes < 5){
tryTimes++;
}else{
LOGE("timeout, exit this command ");
delete []buffer;
close(s_fd);
s_fd = 0;
return -1;
}
}
}

do {
readLen = read (s_fd, buffer + count, buf_len - count);
} while ((readLen < 0 && errno == EINTR));

if (readLen > 0){
count += readLen;
}

if (isFinalResponse(buffer)){
final = true;
LOGD("at result=%s", buffer);
break;
}

tryTimes++;

if (tryTimes > 5){
break;
}
}

LOGV("AudioHardware AT>%s sucess", s);
delete []buffer;
//close(s_fd);

return 0;
}
#endif
//----------------- wxj add end for voice recorder -----------

I don't have linux or other way to compile the files, and I wish someone with more experience from me will compile it and I'm sure we will fine volunteers to test that.

the full cpp files are attached.

By the way, the lib file will be good even to the other ICS roms which based on samsung aries of CM