예제 #1
0
//=================================================================================================
void eve::thr::profiler::get_sample(eve::thr::profiler_sample & p_sample) const noexcept
{
	p_sample.name_			  = get_name();
	p_sample.sample_time_	  = get_sample_time();
	p_sample.time_elapsed_	  = get_elapsed_time();
	p_sample.clock_cycle_num_ = get_clock_cycle_num();
}
예제 #2
0
static inline void mix_child(obs_source_t *transition, float *out, float *in,
                             size_t count, size_t sample_rate, uint64_t ts,
                             obs_transition_audio_mix_callback_t mix)
{
    void *context_data = transition->context.data;

    for (size_t i = 0; i < count; i++) {
        float t = get_sample_time(transition, sample_rate, i, ts);
        out[i] += in[i] * mix(context_data, t);
    }
}
예제 #3
0
void copy_sample_data(FILE *fin,
	const uint32_t chunk_index,  //[0, end) 标识为第几个Chunk
	std::string name, 
	int num,
	CMp4_root_box root,
	 int& nSampleId
	)
{
	_fseeki64(fin, root.co[num].chunk_offset_from_file_begin[chunk_index],
		SEEK_SET);

	//获取当前chunk中有多少个sample
	uint32_t sample_num_in_cur_chunk_ = get_sample_num_in_cur_chunk(root.sc[num], chunk_index+1);  //@a mark获取chunk中sample的数目
	uint32_t sample_index_ =  get_sample_index(root.sc[num], chunk_index+1);//chunk中第一个sample的序号
	unsigned int cur=_ftelli64(fin);
	for(int i = 0; i < sample_num_in_cur_chunk_; i++)
	{


		uint32_t sample_size_ = get_sample_size(root.sz[num], sample_index_+i);//获取当前sample的大小
		_fseeki64(fin,cur,SEEK_SET);
		char *ptr=new char [sample_size_];
		fread(ptr, sample_size_, 1, fin);
		
		uint32_t sample_time = get_sample_time(root.ts[num], nSampleId );
		
		char char_num[260];
		sprintf(char_num, "%u_%u", nSampleId, sample_time);
		//sprintf(char_num, "E:/%s/%u_%u", name.c_str(),nSampleId,sample_time);

	

		FILE *fout =	fopen(std::string(name + "//" + name + char_num).c_str(), "w");

		if(fout == (FILE*)0){
			printf("error\n");
			std::exit(-1);
		}
	
		//写一帧数据 --- 可以直接进行网络推送
		fwrite(ptr, sample_size_, 1, fout);

		delete [] ptr;
		cur+=sample_size_;
		nSampleId++;

		fclose(fout);
	}
}
예제 #4
0
//=================================================================================================
void eve::thr::profiler::store_sample(void)
{
	eve::thr::profiler_sample s;
	s.name_					= get_name();
	s.sample_time_			= get_sample_time();
	s.time_elapsed_			= get_elapsed_time();
	s.clock_cycle_num_		= get_clock_cycle_num();

	// FIFO storage.
	if (samples_.size() > samples_num_)
	{
		samples_.erase(samples_.begin());
	}
	samples_.emplace_back(std::move(s));
}
예제 #5
0
/**
 * Callback for pulse which gets executed when new audio data is available
 *
 * @warning The function may be called even after disconnecting the stream
 */
static void pulse_stream_read(pa_stream *p, size_t nbytes, void *userdata)
{
	UNUSED_PARAMETER(p);
	UNUSED_PARAMETER(nbytes);
	PULSE_DATA(userdata);

	const void *frames;
	size_t bytes;

	if (!data->stream)
		goto exit;

	pa_stream_peek(data->stream, &frames, &bytes);

	// check if we got data
	if (!bytes)
		goto exit;

	if (!frames) {
		blog(LOG_ERROR, "Got audio hole of %u bytes",
			(unsigned int) bytes);
		pa_stream_drop(data->stream);
		goto exit;
	}

	struct obs_source_audio out;
	out.speakers        = data->speakers;
	out.samples_per_sec = data->samples_per_sec;
	out.format          = pulse_to_obs_audio_format(data->format);
	out.data[0]         = (uint8_t *) frames;
	out.frames          = bytes / data->bytes_per_frame;
	out.timestamp       = get_sample_time(out.frames,
	                                      out.samples_per_sec);

	if (!data->first_ts)
		data->first_ts = out.timestamp + STARTUP_TIMEOUT_NS;

	if (out.timestamp > data->first_ts)
		obs_source_output_audio(data->source, &out);

	data->packets++;
	data->frames += out.frames;

	pa_stream_drop(data->stream);
exit:
	pulse_signal(0);
}