static void *StartDevSoundThread(void *threadarg) { GstDevsoundSrc *devsoundsrc= GST_DEVSOUND_SRC (threadarg); int buffersize; TUint8* gBuffer; GstBuffer* pushBuffer= NULL; //gst_debug_log(devsound_debug, GST_LEVEL_LOG, "", "", 0, (GObject *) devsoundsrc, "StartDevSoundThread ",NULL); int ret = open_devsound(&(devsoundsrc->handle)); if( KErrNone != ret ) { pthread_mutex_lock(&(create_mutex1)); return_error = ret; pthread_cond_signal(&(create_condition1)); pthread_mutex_unlock(&(create_mutex1)); pthread_exit(NULL); } getsupporteddatatypes(devsoundsrc); // TODO obtain mutex to update variable here??? consumer_thread_state = CONSUMER_THREAD_INITIALIZED; //pre_init_setconf(devsoundsrc); //gst_debug_log(devsound_debug, GST_LEVEL_LOG, "", "", 0, (GObject *) devsoundsrc, "After Record Init ",NULL); pthread_mutex_lock(&(create_mutex1)); return_error = ret; pthread_cond_signal(&(create_condition1)); pthread_mutex_unlock(&(create_mutex1)); // Wait until we receive a command from the main thread // TODO obtain mutex to read variable here??? while ( cmd == OPEN ) { pthread_mutex_lock(&create_mutex1); pthread_cond_wait(&create_condition1, &create_mutex1); pthread_mutex_unlock(&create_mutex1); } // This could happen if client creates sink and deletes it // without putting it to play state if ( cmd != CLOSE ) { gst_update_devsound_speech_bitrate(devsoundsrc); ret = initialize_devsound(devsoundsrc); if( KErrNone == ret ) { ret = recordinit(devsoundsrc->handle); if( KErrNone == ret ) initproperties(devsoundsrc); } /// if initialization of devsound failed, return error, /// on return other thread will send CLOSE cmd to exit from thread. if( ret ) { pthread_mutex_lock(&(create_mutex1)); return_error = ret; pthread_cond_signal(&(create_condition1)); pthread_mutex_unlock(&(create_mutex1)); pthread_mutex_lock(&create_mutex1); pthread_cond_wait(&create_condition1, &create_mutex1); pthread_mutex_unlock(&create_mutex1); } } while (TRUE) { switch (cmd) { case PAUSE: pause_devsound(devsoundsrc); break; case RESUME: resume_devsound(devsoundsrc); break; case STOP: stop_devsound(devsoundsrc); break; case RECORDING: { pre_init_setconf(devsoundsrc); // gst_Apply_SpeechEncoder_Update(devsoundsrc); gst_Apply_G711Encoder_Update(devsoundsrc); gst_Apply_G729Encoder_Update(devsoundsrc ); gst_Apply_IlbcEncoder_Update(devsoundsrc ); populateproperties(devsoundsrc); supportedbitrates = devsoundsrc->supportedbitrates; //numofbitrates = devsoundsrc->numofbitrates; speechbitrate = devsoundsrc->speechbitrate; speechvadmode = devsoundsrc->speechvadmode; g711vadmode = devsoundsrc->g711vadmode; g729vadmode = devsoundsrc->g729vadmode; ilbcvadmode = devsoundsrc->ilbcvadmode; buffersize = get_databuffer_size(devsoundsrc->handle); get_databuffer(devsoundsrc->handle, &gBuffer); pushBuffer = gst_buffer_new_and_alloc(buffersize); memcpy(GST_BUFFER_DATA(pushBuffer),gBuffer,buffersize); GST_OBJECT_LOCK(devsoundsrc); g_queue_push_head (dataqueue,pushBuffer); GST_OBJECT_UNLOCK(devsoundsrc); record_data(devsoundsrc->handle); } break; case CLOSE: { //gst_debug_log(devsound_debug, GST_LEVEL_LOG, "", "", 0, (GObject *) devsoundsrc, "Before Close DevSound ",NULL); close_devsound(devsoundsrc); //gst_debug_log(devsound_debug, GST_LEVEL_LOG, "", "", 0, (GObject *) devsoundsrc, "After Close DevSound ",NULL); devsoundsrc->handle= NULL; //gst_debug_log(devsound_debug, GST_LEVEL_LOG, "", "", 0, (GObject *) devsoundsrc, "After handle NULL ",NULL); pthread_mutex_lock(&(create_mutex1)); pthread_cond_signal(&(create_condition1)); pthread_mutex_unlock(&(create_mutex1)); // TODO obtain mutex here consumer_thread_state = CONSUMER_THREAD_UNINITIALIZED; pthread_exit(NULL); } break; default: // TODO obtain mutex here consumer_thread_state = CONSUMER_THREAD_UNINITIALIZED; pthread_exit(NULL); break; } pthread_mutex_lock(&(create_mutex1)); return_error = call_back_error(devsoundsrc->handle); pthread_cond_signal(&(create_condition1)); pthread_mutex_unlock(&(create_mutex1)); pthread_mutex_lock(&create_mutex1); pthread_cond_wait(&create_condition1, &create_mutex1); pthread_mutex_unlock(&create_mutex1); } }
name[len] = '\0'; x = getenv(name); rc = KDataBufferMake( *rslt, 8, (uint32_t)( len = strlen( x ) ) ); if (rc) return rc; memcpy((**rslt).base, x, len); return 0; } /* function utf8 environment:read #1.0 < ascii name > (); */ VTRANSFACT_BUILTIN_IMPL(environment_read, 1, 0, 0) (const void *Self, const VXfactInfo *info, VFuncDesc *rslt, const VFactoryParams *cp, const VFunctionParams *dp ) { rc_t rc; KDataBuffer *value; rc = get_databuffer(&value, cp->argv[0].data.ascii, cp->argv[0].count); if (rc == 0) { rslt->self = value; rslt->whack = (void (*)(void *))KDataBufferWhack; rslt->variant = vftRow; rslt->u.rf = environment_read_func; } return rc; }