Playback of Streams Are Taking Longer with Android KitKat (AudioTrack + MediaCodec Solution) - android-4.4-kitkat

I am using MediaCodec + AudioTrack solution to stream MP3 music. It was working fine until the recent KitKat update. With KitKat, the playback begins after approximately 14-15 seconds, whereas on JellyBean it was taking no more than a few seconds. What has been changed with the KitKat regarding the MediaCodec and/or AudioTrack?
Here's the log output:
04-07 23:49:33.582: V/ChromiumHTTPDataSource(8055): ChromiumHTTPDataSource jni::getJavaVM()
04-07 23:49:34.742: I/NuCachedSource2(8055): mDisconnectAtHighwatermark = 0, cacheConfig is NULL(1)
04-07 23:49:34.747: I/NuCachedSource2(8055): readAt: mIsMetadataRetriever == 0
04-07 23:49:36.477: D/HTTPBase(8055): [1] Network BandWidth = 0 Kbps
04-07 23:49:36.477: D/NuCachedSource2(8055): Remaining (64K), HighWaterThreshold (20480)
04-07 23:49:36.477: I/NuCachedSource2(8055): readAt: waiting end ( player case )
04-07 23:49:36.477: V/ChromiumHTTPDataSource(8055): mContentSize is undefined or network might be disconnected
04-07 23:49:36.477: V/ChromiumHTTPDataSource(8055): mContentSize is undefined or network might be disconnected
04-07 23:49:36.502: I/NuCachedSource2(8055): readAt: mIsMetadataRetriever == 0
04-07 23:49:38.502: I/NuCachedSource2(8055): readAt: waiting end ( player case )
04-07 23:49:38.502: E/NuCachedSource2(8055): readAt:Timeout ( player case )
04-07 23:49:38.502: I/NuCachedSource2(8055): readAt: mIsMetadataRetriever == 0
04-07 23:49:40.502: I/NuCachedSource2(8055): readAt: waiting end ( player case )
04-07 23:49:40.502: E/NuCachedSource2(8055): readAt:Timeout ( player case )
04-07 23:49:40.502: I/NuCachedSource2(8055): readAt: mIsMetadataRetriever == 0
04-07 23:49:42.502: I/NuCachedSource2(8055): readAt: waiting end ( player case )
04-07 23:49:42.502: E/NuCachedSource2(8055): readAt:Timeout ( player case )
04-07 23:49:42.502: I/NuCachedSource2(8055): readAt: mIsMetadataRetriever == 0
04-07 23:49:44.502: I/NuCachedSource2(8055): readAt: waiting end ( player case )
04-07 23:49:44.502: E/NuCachedSource2(8055): readAt:Timeout ( player case )
04-07 23:49:44.502: I/NuCachedSource2(8055): readAt: mIsMetadataRetriever == 0
04-07 23:49:46.507: I/NuCachedSource2(8055): readAt: waiting end ( player case )
04-07 23:49:46.507: E/NuCachedSource2(8055): readAt:Timeout ( player case )
04-07 23:49:46.507: I/NuCachedSource2(8055): readAt: mIsMetadataRetriever == 0
04-07 23:49:48.507: I/NuCachedSource2(8055): readAt: waiting end ( player case )
04-07 23:49:48.507: E/NuCachedSource2(8055): readAt:Timeout ( player case )
04-07 23:49:48.507: I/NuCachedSource2(8055): readAt: mIsMetadataRetriever == 0
04-07 23:49:50.507: I/NuCachedSource2(8055): readAt: waiting end ( player case )
04-07 23:49:50.507: E/NuCachedSource2(8055): readAt:Timeout ( player case )
04-07 23:49:50.507: I/NuCachedSource2(8055): readAt: mIsMetadataRetriever == 0
04-07 23:49:52.447: D/HTTPBase(8055): [2] Network BandWidth = 59 Kbps
04-07 23:49:52.447: D/NuCachedSource2(8055): Remaining (127K), HighWaterThreshold (20480)
04-07 23:49:52.447: D/NuCachedSource2(8055): readInternal - late!!!
04-07 23:49:52.447: I/NuCachedSource2(8055): readAt: waiting end ( player case )
04-07 23:49:52.447: V/ChromiumHTTPDataSource(8055): mContentSize is undefined or network might be disconnected
04-07 23:49:52.447: V/ChromiumHTTPDataSource(8055): mContentSize is undefined or network might be disconnected
04-07 23:49:52.452: D/StreamPlayerService(8055): MIME TYPE: audio/mpeg
04-07 23:49:52.452: I/ACodec(8055): [] Now uninitialized
04-07 23:49:52.452: I/OMXClient(8055): Using client-side OMX mux.
04-07 23:49:52.457: I/ACodec(8055): [OMX.SEC.mp3.dec] Now Loaded
04-07 23:49:52.457: I/ACodec(8055): [OMX.SEC.mp3.dec] Now Loaded->Idle
04-07 23:49:52.462: I/ACodec(8055): [OMX.SEC.mp3.dec] Now Idle->Executing
04-07 23:49:52.467: I/ACodec(8055): [OMX.SEC.mp3.dec] Now Executing
04-07 23:49:52.472: D/StreamPlayerService(8055): Output format has changed to {sample-rate=22050, channel-count=2, what=1869968451, mime=audio/raw}

Related

Modbus Error: [Input/Output] No Response received from the remote unit/Unable to decode response

I' trying to connect from raspberry 3 B to a Modbus device (sensor temperature) using a serial connection using a USB RS485 converter .This is my code:
from pymodbus.constants import Endian
from pymodbus.payload import BinaryPayloadDecoder
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
from pymodbus.constants import Defaults
Defaults.RetryOnEmpty = True
import time
import logging
FORMAT = ('%(asctime)-15s %(threadName)-15s '
'%(levelname)-8s %(module)-15s:%(lineno)-8s %(message)s')
logging.basicConfig(format=FORMAT)
log = logging.getLogger()
log.setLevel(logging.DEBUG)
def run_sync_client():
while True:
#try:
client = ModbusClient(method='rtu', port='/dev/ttyUSB0', timeout=9, baudrate=9600, parity='N', stopbits=1, bytesize=8,reset_socket=False) # Implementation of the SHT31 as a modbus serial client
if client.connect():
print("connected")
print ("begin reading")
#for i in range(0 ,100):
request = client.read_holding_registers(address=0 , count=2, unit=4)
if request.isError():
print(request)
else:
print("Read OK! " + str(request.registers[1]))
time.sleep(1)
print(request)
result = request.registers
print(result)
temp= BinaryPayloadDecoder.fromRegisters(result, Endian.little, wordorder=Endian.little )
temperature= temp.decode_16bit_int()
print( temperature)
time.sleep(4)
# except:
#print("An exception occurred")
client.close()
while True:
if __name__ == "__main__":
run_sync_client()
The output in the console is:
connected
begin reading
2022-02-24 14:56:37,901 MainThread DEBUG transaction :139 Current transaction state - IDLE
2022-02-24 14:56:37,902 MainThread DEBUG transaction :144 Running transaction 1
2022-02-24 14:56:37,904 MainThread DEBUG transaction :273 SEND: 0x4 0x3 0x0 0x1 0x0 0x2 0x95 0x9e
2022-02-24 14:56:37,905 MainThread DEBUG sync :76 New Transaction state 'SENDING'
2022-02-24 14:56:37,906 MainThread DEBUG transaction :287 Changing transaction state from 'SENDING' to 'WAITING FOR REPLY'
2022-02-24 14:56:38,068 MainThread DEBUG transaction :375 Changing transaction state from 'WAITING FOR REPLY' to 'PROCESSING REPLY'
2022-02-24 14:56:38,069 MainThread DEBUG transaction :297 RECV: 0x4 0x3 0x2 0x17 0x58 0x2c 0x2e 0x3f 0x88
2022-02-24 14:56:38,071 MainThread DEBUG rtu_framer :237 Frame check failed, ignoring!!
2022-02-24 14:56:38,072 MainThread DEBUG rtu_framer :119 Resetting frame - Current Frame in buffer - 0x4 0x3 0x2 0x17 0x58 0x2c 0x2e 0x3f 0x88
2022-02-24 14:56:38,073 MainThread DEBUG transaction :465 Getting transaction 4
2022-02-24 14:56:38,074 MainThread DEBUG transaction :224 Changing transaction state from 'PROCESSING REPLY' to 'TRANSACTION_COMPLETE'
Modbus Error: [Input/Output] No Response received from the remote unit/Unable to decode response
I would love to have a little help understanding the error I'm getting. Thanks

amqsbcg not getting messages from MQ Client

I managed to send a message from an MQ Client to a MQ Server. In the MQ Client I amqsputc [queue_local] [name_qmgr] and after typing the message it return Sample AMQSPUT0 end which means it was sent properly. But when I try to see the message in the MQ Server with amqsbcg [queue_local] [name_qmgr] it throws me an error message:
Sample AMQSGET0 start
MQCONNX ended with reason code 2058
This error appears when the queue manager doesn't exist or when the name is misspelled, but this is not the case.
When I verify the local queue it shows CURDEPTH(1), this means that there is one message on the queue(it was delivered). But I don't know why it doesn't allow me to get the message. In the queue manager error file it only shows something like:
the channel AMQ.... connection ended
I checked the channel I configured for this test:
AMQ8414: Display Channel details.
CHANNEL(A03ZCIWAS) CHLTYPE(SVRCONN)
ALTDATE(2017-09-07) ALTTIME(00.35.17)
CERTLABL( ) COMPHDR(NONE)
COMPMSG(NONE)
DESCR(Server-connection to ...)
DISCINT(0) HBINT(300)
KAINT(AUTO) MAXINST(100)
MAXINSTC(90) MAXMSGL(4194304)
MCAUSER(nobody) MONCHL(QMGR)
RCVDATA( ) RCVEXIT( )
SCYDATA( ) SCYEXIT( )
SENDDATA( ) SENDEXIT( )
SHARECNV(10) SSLCAUTH(REQUIRED)
SSLCIPH( ) SSLPEER( )
TRPTYPE(TCP)
AMQ8414: Display Channel details.
CHANNEL(A03ZCIWAS) CHLTYPE(CLNTCONN)
AFFINITY(PREFERRED) ALTDATE(2017-09-07)
ALTTIME(02.40.42) CERTLABL( )
CLNTWGHT(0) COMPHDR(NONE)
COMPMSG(NONE) CONNAME(XX.XX.XX.XX)
DEFRECON(NO)
DESCR(Client connection to ....)
HBINT(300) KAINT(AUTO)
LOCLADDR( ) MAXMSGL(4194304)
MODENAME( ) PASSWORD( )
QMNAME(AEDMQ03A) RCVDATA( )
RCVEXIT( ) SCYDATA( )
SCYEXIT( ) SENDDATA( )
SENDEXIT( ) SHARECNV(10)
SSLCIPH( ) SSLPEER( )
TPNAME( ) TRPTYPE(TCP)
USERID( )
The CONNAME(xx.xx.xx.xx) is the right IP adress for the MQServer and the variable MQSERVER is set like:
MQSERVER=[channel_svrconn]/tcp/'ip_adress_MQServer(1414)'
The port is also fine.
The output you provide indicates you are executing amqsget not amqsbcgc.
I note that your question mentions amqsbcg not amqsbcgc. The c at the end of the sample name indicates it is the client version of the program.
amqsbcg = Server Binding version
amqsbcgc = Client version
If you execute either amqsget or amqsbcg and specify a queue manager that is not local on the same server you will receive a 2058.
Solution is to use amqsgetc or amqsbcgc instead of amqsget or amqsbcg

For the un-finished 3-way TCP handshake, why the windows OS report the FD_ACCEPT event to the application

Test Scenario
I had written a windows program which I simply called it "simpleServer.exe". This program is just a simulation of a very basic server application. It listens on a port, and wait for incoming messages. The listening Socket was defined to be a TCP Stream Socket. that's all that this program is doing.
I had been deploying this exact same program on 2 different machines, both running on windows 7 professional 64bit. This machine will act as a host. and they are stationed in the same network area.
then, using the program "nmap", I used another machine on the same network, to act as a client. using the "-sS" parameter on "nmap", I do a Syn Scan, to the IP and Port of the listening simpleServer on both machine (one attempt at a time).
(note that the 2 hosts already had "wireshark" started, and is monitoring on tcp packets from the client's IP and to the listening port.)
In the "wireshark" entry, on both machine, I saw the expected tcp packet for Syn Scan:
client ----(SYN)----> host
client <--(SYN/ACK)-- host
client ----(RST)----> host
the above packet exchange suggests that the connection was not established.
But on the "simpleServer.exe", only one of it had "new incoming connection" printed in the logs, while the other instance was not alerted of any new incoming connection, hence no logs at all.
Code Snippets
iRetVal = WSAEventSelect (m_Socket, m_hSocketEvent, FD_ACCEPT);
if (SOCKET_ERROR == iRetVal)
{
if (WSAGetLastError()==WSAENOTSOCK)
{
return E_SOCKET_INVALID;
}
CHKLOGGER (m_pLogger->Log (LOGGER_LOG_ERROR,"GHLSocket::OnAccept() Error while WSAEventSelect(). Error code: ", WSAGetLastError() ));
#if defined GHLSOCKET_DEBUG_VERSION
printf ("Error while WSAEventSelect(). Error code: %ld\n", WSAGetLastError() );
#endif
return E_FAILED_RECV_DATA;
}
// Wait for Network Events to occcur
dwRetVal = WSAWaitForMultipleEvents ( 1,
&m_hSocketEvent,
FALSE,
lTimeout,
TRUE);
if ( WSA_WAIT_TIMEOUT == dwRetVal )
{
return E_TIMEOUT;
goto CleanUp;
}
if ( WSA_WAIT_FAILED == dwRetVal)
{
CHKLOGGER (m_pLogger->Log (LOGGER_LOG_ERROR,"GHLSocket::OnAccept() WSAWaitForMultipleEvents() failed. Error code: ", WSAGetLastError() ));
#if defined GHLSOCKET_DEBUG_VERSION
printf ("Error in WSAWaitForMultipleEvents() failed. Error code: %ld\n", WSAGetLastError() );
#endif
dwReturn = E_FAILED_RECV_DATA;
goto CleanUp;
}
// Parse the Results from the Network Events.
iRetVal = WSAEnumNetworkEvents (m_Socket, m_hSocketEvent, &mEvents);
if (SOCKET_ERROR == iRetVal)
{
CHKLOGGER (m_pLogger->Log (LOGGER_LOG_ERROR,"GHLSocket::OnAccept() Error while WSAEnumNetworkEvents(). Error code: ", WSAGetLastError() ));
#if defined GHLSOCKET_DEBUG_VERSION
printf ("Error while WSAEnumNetworkEvents(). Error code: %ld\n", WSAGetLastError() );
#endif
dwReturn = E_FAILED_RECV_DATA;
goto CleanUp;
}
// ACCEPT event Detected.
if (mEvents.lNetworkEvents & FD_ACCEPT)
{
// Perform accept operation.
*p_SOCKET = accept (m_Socket, NULL,NULL);
}
Help That I Needed
why is the different behavior from the 2 same of the same application on a different machine with the same OS?

How to send buffer bigger than 256kByte with boost asio on OSX, works fine on WIN

I have a simple client server approach sending char buffers using tcp socket with boost asio on OSX. When I use a buffer bigger than 256kBytes I get a Memory Access error. It seems to happen on the Server side. But nonetheless, the exact same code with bigger buffer sizes than 256kBytes is working perfectly on Windows!
gdb on OSX tells me
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x00000001002bebb8
[Switching to process 15955 thread 0x2003]
0x0000000100012920 in connectionThread::operator() ()
I'm wondering if there is a OS specific memory allocation issue I have to be aware of. Boost Asio docs weren't really helpful.
I do not want to split the buffer! I want to send an entire buffer, which could have a size up to 921600Bytes. Which already works perfectly on windows with boost asio.
Message
char data[307200];
Client side SEND msg
void send( boost::asio::ip::tcp::socket& s ) const {
try {
boost::asio::write( s, boost::asio::buffer( data, data_size));
}
catch( std::exception e ) {
throw std::runtime_error("message send error | " + std::string( e.what() ) );
}
}
Server side READ msg
void read( boost::asio::ip::tcp::socket& s ) {
try {
// Read data
boost::asio::read( s, boost::asio::buffer( &data, data_size ));
}
catch( std::exception e ) {
throw std::runtime_error( "message read error | " + std::string( e.what() ) );
}
}
backtrace
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x00000001002bebb8
[Switching to process 17916 thread 0x2003]
0x0000000100012920 in connectionThread::operator() ()
(gdb) backtrace
#0 0x0000000100012920 in connectionThread::operator() ()
#1 0x000000010000679d in boost::_mfi::mf1<void, connectionThread, boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >&>::operator() ()
#2 0x00000001000068ca in boost::_bi::list2<boost::_bi::value<connectionThread*>, boost::_bi::value<boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > > > >::operator()<boost::_mfi::mf1<void, connectionThread, boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >&>, boost::_bi::list0> ()
#3 0x000000010000690a in boost::_bi::bind_t<void, boost::_mfi::mf1<void, connectionThread, boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >&>, boost::_bi::list2<boost::_bi::value<connectionThread*>, boost::_bi::value<boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > > > > >::operator() ()
#4 0x0000000100006928 in boost::detail::thread_data<boost::_bi::bind_t<void, boost::_mfi::mf1<void, connectionThread, boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >&>, boost::_bi::list2<boost::_bi::value<connectionThread*>, boost::_bi::value<boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > > > > > >::run ()
#5 0x000000010006b699 in thread_proxy (param=<value temporarily unavailable, due to optimizations>) at libs/thread/src/pthread/thread.cpp:121
#6 0x00007fff8094cfd6 in _pthread_start ()
#7 0x00007fff8094ce89 in thread_start ()
(gdb)
Thanks for any ideas

Is my loop wrong ? Do I misuse ReadFile() and I/O completion port ?

I want to implement a server/client using named pipes (for IPC).I'm using async (overlapped) connections and I/O completion port (I searched a lot and it seems that it is the most efficient way to do that).
First here are the codes:
server: http://pastebin.com/XxeXdunC
and client: http://pastebin.com/fbCH2By8
The problem is in the server (i can improve the client but i will do that when the server works).
I use I/O completion port like that : basically, I run a thread in which I call ReadFile(). If it returns TRUE, I get all the data, if it returns FALSE, and the error is ERROR_IO_PENDING, I wait with GetQueuedCompletionStatus().
What is strange is that, even if I read all the data, the last ReadFile() call fails and the error is ERROR_IO_PENDING
The thread in which I call ReadFile() is beginning line 64 of the server code.
The client sends 24 bytes (the string "salut, c'est le client !") and the ReadFile() buffer is of length 5 bytes (to check how my server deals data that is larger than the Readfile() buffer)
The output is:
waiting for client...
WaitForMultipleObjects : 0
client connected (1)
ReadFile 1 msg (5 -> 05) : salut
ReadFile 2 msg (5 -> 10) : salut, c'e
ReadFile 2 msg (5 -> 15) : salut, c'est le
ReadFile 2 msg (5 -> 20) : salut, c'est le clie
ReadFile 2 msg (4 -> 24) : salut, c'est le client !
ReadFile2: ERROR_IO_PENDING
GQCIOS 0 255 003D3A18
ReadFile3: ERROR_IO_PENDING
ReadFile1: ERROR_IO_PENDING
GQCIOS 5 255 003D3A2C
ReadFile3: ERROR_IO_PENDING
ReadFile1: ERROR_IO_PENDING
GQCIOS 5 255 003D3A2C
ReadFile3: ERROR_IO_PENDING
ReadFile1: ERROR_IO_PENDING
GQCIOS 5 255 003D3A2C
ReadFile3: ERROR_IO_PENDING
ReadFile1: ERROR_IO_PENDING
GQCIOS 5 255 003D3A2C
ReadFile3: ERROR_IO_PENDING
ReadFile1: ERROR_IO_PENDING
GQCIOS 4 255 003D3A2C
ReadFile3: ERROR_IO_PENDING
ReadFile1: ERROR_IO_PENDING
What I do not understand is that even if I read all the data, ReadFile() still returns a pending operation (it's the "ReadFile2: ERROR_IO_PENDING" error message after the last "msg" output)
Is my loop wrong ? Do I misuse ReadFile() / GetQueuedCompletionStatus() ?
thank you
Where is your write related function? it seems that your code is in wrong order. In the _read_data_cb routine, GetQueuedCompletionStatus should be called first, then depending on the lpOverlapped parameter, the received data should be ready in the buffer that you specified in the ReadFile function. Since you're calling Readfile without checking whether OVERLAPPED is a overlapped structure for the send context or recv context, you're not getting the expected output. The following code should clear things up:
while(TRUE)
{
bReturnValue=GetQueuedCompletionStatus(pIOCPServer->m_pIOCP, &dwBytesTransferred,(DWORD *)pClient,reinterpret_cast<LPOVERLAPPED*>(&pOverlapped),INFINITE);
if(!bReturnValue)
{
if(NULL==pOverlapped)
continue;
else
break;
}
else
{
if(pOverlapped==NULL)
continue;
}
if(dwBytesTransferred==0)
break;
if(lpOverlapped==&(pClient->m_pRecvContext->overlapped))
pClient->handleRecvEvent(dwBytesTransferred)
else if(lpOverlapped==&(pClient->m_pSendContext->overlapped))
pClient->handleSendEvent(dwBytesTransferred)
}
...

Resources