3 * Copyright (C) Texas Instruments - http://www.ti.com/
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 /* =============================================================================
22 * Texas Instruments OMAP (TM) Platform Software
23 * (c) Copyright Texas Instruments, Incorporated. All Rights Reserved.
25 * Use of this software is controlled by the terms and conditions found
26 * in the license agreement under which this software has been supplied.
27 * =========================================================================== */
29 * @file OMX_G726Dec_CompThread.c
31 * This file implements the component thread functionality that receives
32 * commands and buffers from application and LCML.
34 * @path $(CSLPATH)\OMAPSW_MPU\linux\audio\src\openmax_il\g726_dec\src
38 /* ----------------------------------------------------------------------------
41 *! ===================================
42 *! This is newest file
43 * =========================================================================== */
44 /* ------compilation control switches -------------------------*/
45 /****************************************************************
47 ****************************************************************/
48 /* ----- system and platform files ----------------------------*/
57 #include <sys/types.h>
58 #include <sys/types.h>
61 #include <sys/select.h>
66 #include <sys/select.h>
73 #include "OMX_G726Dec_Utils.h"
75 /* ================================================================================= * */
77 * @fn G726DEC_ComponentThread() This is component thread that keeps listening for
78 * commands or event/messages/buffers from application or from LCML.
80 * @param pThreadData This is thread argument.
86 * @return OMX_ErrorNone = Always
90 /* ================================================================================ * */
91 void* G726DEC_ComponentThread (void* pThreadData)
98 OMX_ERRORTYPE eError = OMX_ErrorNone;
99 G726DEC_COMPONENT_PRIVATE* pComponentPrivate = (G726DEC_COMPONENT_PRIVATE*)pThreadData;
100 OMX_COMPONENTTYPE *pHandle = pComponentPrivate->pHandle;
102 G726DEC_DPRINT (":: Entering ComponentThread \n");
104 fdmax = pComponentPrivate->cmdPipe[0];
106 if (pComponentPrivate->dataPipe[0] > fdmax) {
107 fdmax = pComponentPrivate->dataPipe[0];
113 FD_SET (pComponentPrivate->cmdPipe[0], &rfds);
114 FD_SET (pComponentPrivate->dataPipe[0], &rfds);
121 sigaddset (&set, SIGALRM);
122 status = pselect (fdmax+1, &rfds, NULL, NULL, &tv, &set);
124 status = select (fdmax+1, &rfds, NULL, NULL, &tv);
127 if (pComponentPrivate->bExitCompThrd == 1) {
128 G726DEC_DPRINT(":: Comp Thrd Exiting here...\n");
133 G726DEC_DPRINT("\n\n\n!!!!! Component Time Out !!!!!!!!!!!! \n");
134 if (pComponentPrivate->bExitCompThrd == 1) {
135 G726DEC_EPRINT(":: Comp Thrd Exiting here...\n");
139 } else if (-1 == status) {
140 G726DEC_DPRINT (":: Error in Select\n");
141 pComponentPrivate->cbInfo.EventHandler (
142 pHandle,pHandle->pApplicationPrivate,
143 OMX_EventError,OMX_ErrorInsufficientResources, 0,
144 "Error from COmponent Thread in select");
145 eError = OMX_ErrorInsufficientResources;
147 } else if ((FD_ISSET (pComponentPrivate->dataPipe[0], &rfds))) {
150 OMX_BUFFERHEADERTYPE *pBufHeader = NULL;
152 G726DEC_DPRINT (":: DATA pipe is set in Component Thread\n");
153 ret = read(pComponentPrivate->dataPipe[0], &pBufHeader, sizeof(pBufHeader));
155 G726DEC_DPRINT (":: Error while reading from the pipe\n");
158 eError = G726DEC_HandleDataBuf_FromApp (pBufHeader,pComponentPrivate);
159 if (eError != OMX_ErrorNone) {
160 G726DEC_DPRINT (":: Error From HandleDataBuf_FromApp\n");
163 } else if (FD_ISSET (pComponentPrivate->cmdPipe[0], &rfds)) {
164 G726DEC_DPRINT (":: CMD pipe is set in Component Thread\n");
166 nRet = G726DEC_HandleCommand (pComponentPrivate);
167 if (nRet == EXIT_COMPONENT_THRD) {
168 G726DEC_DPRINT ("Exiting from Component thread\n");
169 G726DEC_CleanupInitParams(pHandle);
170 G726DEC_STATEPRINT("****************** Component State Set to Loaded\n\n");
172 pComponentPrivate->curState = OMX_StateLoaded;
174 if (pComponentPrivate->bPreempted == 0) {
175 pComponentPrivate->cbInfo.EventHandler(
176 pHandle, pHandle->pApplicationPrivate,
177 OMX_EventCmdComplete,
178 OMX_ErrorNone,pComponentPrivate->curState, NULL);
181 pComponentPrivate->cbInfo.EventHandler(
182 pHandle, pHandle->pApplicationPrivate,
184 OMX_ErrorResourcesLost,pComponentPrivate->curState, NULL);
185 pComponentPrivate->bPreempted = 0;
194 pComponentPrivate->bCompThreadStarted = 0;
196 G726DEC_DPRINT (":: Exiting ComponentThread \n");
197 return (void*)eError;