void vjpegAddEncBuffer(void) { sysDisableIRQ (); listAttach(&g_vpJPEG.listEncodedJPEG, &g_vpJPEG.pJPEGEncodeBuffer->list); g_vpJPEG.pJPEGEncodeBuffer = NULL; sysEnableIRQ (); }
link_list_t* DLLCALL listInit(link_list_t* list, long flags) { if((flags&LINK_LIST_MALLOC) || list==NULL) { if((list=(link_list_t*)malloc(sizeof(link_list_t)))==NULL) return(NULL); flags |= LINK_LIST_MALLOC; } memset(list,0,sizeof(link_list_t)); list->flags = flags; #if defined(LINK_LIST_THREADSAFE) if(list->flags&LINK_LIST_MUTEX) { list->mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; memset(&list->tid, 0xff, sizeof(list->tid)); } if(list->flags&LINK_LIST_SEMAPHORE) sem_init(&list->sem,0,0); #endif if(flags&LINK_LIST_ATTACH) listAttach(list); return(list); }
/* Return: NULL, failed other, the message pushed. */ static TT_BMSG_T *tt_bmsg_push (TT_BMSG_QUEUE_T *msg_queue, void *msg_data) { LIST_T *msg_node = memNew (msg_queue->queue.msg_buffer); if (msg_node == NULL) return NULL; else { TT_BMSG_T *msg = GetParentAddr (msg_node, TT_BMSG_T, list); memcpy(&msg->msg_data[0], msg_data, msg_queue->each_msg_size); listAttach (&msg_queue->queue.msg_used, &msg->list); return msg; } }
/* Return: NULL, failed other, the message pushed. */ static TT_MSG_T *tt_msg_push (TT_MSG_QUEUE_T *msg_queue, FUN_TT_MSG_PROC msg_proc, void *msg_data) { LIST_T *msg_node = memNew (msg_queue->msg_buffer); if (msg_node == NULL) return NULL; else { TT_MSG_T *msg = GetParentAddr (msg_node, TT_MSG_T, list); msg->msg_proc = msg_proc; msg->msg_data = msg_data; listAttach (&msg_queue->msg_used, &msg->list); return msg; } }
void thread_read_audio(cyg_addrword_t data) { VP_BUFFER_TEST_AUDIO_BITSTREAM_T *ptestaudio; int audiocount = 0; cyg_tick_count_t timeBegin, timeEnd; int iRt; IO_THREAD_READ_T readarg; int i = 0; timeBegin = cyg_current_time(); while(1) { readarg.txlen = BUFFER_SIZE; iRt = iothread_ReadAudio(&readarg); if(iRt == -1) { diag_printf("Encode Core quit\n"); cyg_thread_exit(); } else if(iRt == 0) { diag_printf("%d buffer too small\n", readarg.mediatype); continue; } else { switch(readarg.mediatype) { case MEDIA_TYPE_AUDIO: audiocount++; cyg_semaphore_wait(&g_testaudio.pcAudio.producer); ptestaudio = bufTestAudioNew(); if(ptestaudio == NULL) { diag_printf("No audio read buffer!!!\n"); while(1); } if( readarg.txlen <= sizeof(ptestaudio->aucAudio)) { memcpy(ptestaudio->aucAudio, readarg.txbuf, readarg.txlen); ptestaudio->iAudioLen = readarg.txlen; listAttach(&g_testaudio.listAudio, &ptestaudio->list); cyg_semaphore_post(&g_testaudio.pcAudio.consumer); } else { bufTestAudioDecRef(ptestaudio); diag_printf("audio too large %d>%d\n", readarg.txlen, sizeof(ptestaudio->aucAudio)); cyg_semaphore_post(&g_testaudio.pcAudio.producer); } iothread_ReadAudio_Complete(&readarg); //readarg.txbuf = (unsigned char*)g_mpDataBuffer; #if 0 /* Decode law to pcm */ { DecodeLAW_T decode_info; decode_info.dfSrcFormat = DecodeLAW_FORMAT_ALAW; decode_info.dfDstFormat = DecodeLAW_FORMAT_LINEAR; decode_info.ucSrcData = g_mpDataBuffer; decode_info.iSrcDataSize = readarg.txlen; decode_info.ucDstData = g_mpAudioDataBuffer; decode_info.iDstDataSize = sizeof(g_mpAudioDataBuffer); readarg.txlen = DecodeLAW(&decode_info); if(readarg.txlen == -1) { diag_printf("decode law failed\n"); continue; } readarg.mediatype = MEDIA_TYPE_AUDIO; readarg.txbuf = g_mpAudioDataBuffer; } #endif iothread_Write(&readarg); //diag_printf("get audio, len=%d\n", readarg.txlen); break; default: diag_printf("unknown type %d\n", readarg.mediatype); break; } } if(audiocount >= 500 && audiocount % 500 == 0) { int timeoffset; timeEnd = cyg_current_time(); timeoffset = timeEnd-timeBegin; diag_printf("audiocount=%d\n", audiocount); if(timeoffset != 0 && timeoffset > 100) diag_printf("audiorate=%d\n", audiocount/(timeoffset/100)); } } cyg_thread_exit(); }