161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti/*-------------------------------------------------------------------------- 261e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiCopyright (c) 2010, The Linux Foundation. All rights reserved. 361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 461e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiRedistribution and use in source and binary forms, with or without 561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletimodification, are permitted provided that the following conditions are met: 661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * Redistributions of source code must retain the above copyright 761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti notice, this list of conditions and the following disclaimer. 861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * Redistributions in binary form must reproduce the above copyright 961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti notice, this list of conditions and the following disclaimer in the 1061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti documentation and/or other materials provided with the distribution. 1161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * Neither the name of The Linux Foundation nor 1261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti the names of its contributors may be used to endorse or promote 1361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti products derived from this software without specific prior written 1461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti permission. 1561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 1661e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 1761e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1861e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiIMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 1961e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiNON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 2061e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 2161e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiEXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 2261e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 2361e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiOR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 2461e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 2561e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiOTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 2661e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti--------------------------------------------------------------------------*/ 2861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include <stdio.h> 2961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include <stdlib.h> 3061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include <string.h> 3161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 3261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include <fcntl.h> 3361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include <errno.h> 3461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 3561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include <aenc_svr.h> 3661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 3761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti/** 3861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti @brief This function processes posted messages 3961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 4061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti Once thread is being spawned, this function is run to 4161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti start processing commands posted by client 4261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 4361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti @param info pointer to context 4461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 4561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti */ 4661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletivoid *omx_amr_msg(void *info) 4761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti{ 4861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti struct amr_ipc_info *amr_info = (struct amr_ipc_info*)info; 4961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti unsigned char id; 5061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti ssize_t n; 5161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 5261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti DEBUG_DETAIL("\n%s: message thread start\n", __FUNCTION__); 5361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti while (!amr_info->dead) 5461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti { 5561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti n = read(amr_info->pipe_in, &id, 1); 5661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti if (0 == n) break; 5761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti if (1 == n) 5861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti { 5961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti DEBUG_DETAIL("\n%s-->pipe_in=%d pipe_out=%d\n", 6061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info->thread_name, 6161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info->pipe_in, 6261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info->pipe_out); 6361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 6461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info->process_msg_cb(amr_info->client_data, id); 6561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti } 6661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti if ((n < 0) && (errno != EINTR)) break; 6761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti } 6861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti DEBUG_DETAIL("%s: message thread stop\n", __FUNCTION__); 6961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 7061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti return 0; 7161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti} 7261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 7361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletivoid *omx_amr_events(void *info) 7461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti{ 7561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti struct amr_ipc_info *amr_info = (struct amr_ipc_info*)info; 7661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti unsigned char id = 0; 7761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 7861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti DEBUG_DETAIL("%s: message thread start\n", amr_info->thread_name); 7961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info->process_msg_cb(amr_info->client_data, id); 8061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti DEBUG_DETAIL("%s: message thread stop\n", amr_info->thread_name); 8161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti return 0; 8261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti} 8361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 8461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti/** 8561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti @brief This function starts command server 8661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 8761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti @param cb pointer to callback function from the client 8861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti @param client_data reference client wants to get back 8961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti through callback 9061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti @return handle to msging thread 9161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti */ 9261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletistruct amr_ipc_info *omx_amr_thread_create( 9361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti message_func cb, 9461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti void* client_data, 9561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti char* th_name) 9661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti{ 9761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti int r; 9861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti int fds[2]; 9961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti struct amr_ipc_info *amr_info; 10061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 10161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info = calloc(1, sizeof(struct amr_ipc_info)); 10261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti if (!amr_info) 10361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti { 10461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti return 0; 10561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti } 10661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 10761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info->client_data = client_data; 10861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info->process_msg_cb = cb; 10961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti strlcpy(amr_info->thread_name, th_name, sizeof(amr_info->thread_name)); 11061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 11161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti if (pipe(fds)) 11261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti { 11361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti DEBUG_PRINT_ERROR("\n%s: pipe creation failed\n", __FUNCTION__); 11461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti goto fail_pipe; 11561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti } 11661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 11761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info->pipe_in = fds[0]; 11861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info->pipe_out = fds[1]; 11961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 12061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti r = pthread_create(&amr_info->thr, 0, omx_amr_msg, amr_info); 12161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti if (r < 0) goto fail_thread; 12261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 12361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti DEBUG_DETAIL("Created thread for %s \n", amr_info->thread_name); 12461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti return amr_info; 12561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 12661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 12761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletifail_thread: 12861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti close(amr_info->pipe_in); 12961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti close(amr_info->pipe_out); 13061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 13161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletifail_pipe: 13261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti free(amr_info); 13361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 13461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti return 0; 13561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti} 13661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 13761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti/** 13861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * @brief This function starts command server 13961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * 14061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * @param cb pointer to callback function from the client 14161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * @param client_data reference client wants to get back 14261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * through callback 14361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * @return handle to msging thread 14461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * */ 14561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletistruct amr_ipc_info *omx_amr_event_thread_create( 14661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti message_func cb, 14761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti void* client_data, 14861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti char* th_name) 14961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti{ 15061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti int r; 15161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti int fds[2]; 15261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti struct amr_ipc_info *amr_info; 15361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 15461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info = calloc(1, sizeof(struct amr_ipc_info)); 15561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti if (!amr_info) 15661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti { 15761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti return 0; 15861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti } 15961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 16061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info->client_data = client_data; 16161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info->process_msg_cb = cb; 16261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti strlcpy(amr_info->thread_name, th_name, sizeof(amr_info->thread_name)); 16361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 16461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti if (pipe(fds)) 16561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti { 16661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti DEBUG_PRINT("\n%s: pipe creation failed\n", __FUNCTION__); 16761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti goto fail_pipe; 16861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti } 16961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 17061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info->pipe_in = fds[0]; 17161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info->pipe_out = fds[1]; 17261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 17361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti r = pthread_create(&amr_info->thr, 0, omx_amr_events, amr_info); 17461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti if (r < 0) goto fail_thread; 17561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 17661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti DEBUG_DETAIL("Created thread for %s \n", amr_info->thread_name); 17761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti return amr_info; 17861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 17961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 18061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletifail_thread: 18161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti close(amr_info->pipe_in); 18261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti close(amr_info->pipe_out); 18361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 18461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletifail_pipe: 18561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti free(amr_info); 18661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 18761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti return 0; 18861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti} 18961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 19061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletivoid omx_amr_thread_stop(struct amr_ipc_info *amr_info) { 19161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti DEBUG_DETAIL("%s stop server\n", __FUNCTION__); 19261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti close(amr_info->pipe_in); 19361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti close(amr_info->pipe_out); 19461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti pthread_join(amr_info->thr,NULL); 19561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info->pipe_out = -1; 19661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info->pipe_in = -1; 19761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti DEBUG_DETAIL("%s: message thread close fds%d %d\n", amr_info->thread_name, 19861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti amr_info->pipe_in,amr_info->pipe_out); 19961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti free(amr_info); 20061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti} 20161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti 20261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletivoid omx_amr_post_msg(struct amr_ipc_info *amr_info, unsigned char id) { 20361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti DEBUG_DETAIL("\n%s id=%d\n", __FUNCTION__,id); 20461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti write(amr_info->pipe_out, &id, 1); 20561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti} 206