コード例 #1
0
ファイル: IDataObjectUtils.cpp プロジェクト: 9060/columns_ui
HRESULT IDataObjectUtils::STGMEDIUMToDataBlock(const STGMEDIUM & med, pfc::array_t<t_uint8> & out) {
	switch(med.tymed) {
		case TYMED_HGLOBAL:
			{
				CGlobalLockScope lock(med.hGlobal);
				out.set_data_fromptr( (const t_uint8*) lock.GetPtr(), lock.GetSize() );
			}
			return S_OK;
		case TYMED_ISTREAM:
			{
				HRESULT state;
				IStream * stream = med.pstm;
				LARGE_INTEGER offset = {};
				STATSTG stats = {};
				if (FAILED( state = stream->Stat(&stats,STATFLAG_NONAME ) ) ) return state;
				t_size toRead = pfc::downcast_guarded<t_size>(stats.cbSize.QuadPart);
				out.set_size(toRead);
				if (FAILED( state = stream->Seek(offset,STREAM_SEEK_SET,NULL) ) ) return state;
				ULONG cbRead = 0;
				if (FAILED( state = stream->Read(out.get_ptr(), pfc::downcast_guarded<ULONG>(toRead), &cbRead) ) ) return state;
				if (cbRead != toRead) return E_UNEXPECTED;
			}
			return S_OK;
		default:
			return DV_E_TYMED;
	}
}
コード例 #2
0
	void cleanup()
	{
		filter.set_size( 0 );
		srate = 0;
		nch = 0;
		channel_config = 0;
	}
コード例 #3
0
ファイル: speech.cpp プロジェクト: reupen/ipod_manager
	virtual HRESULT STDMETHODCALLTYPE SetSize( 
		ULARGE_INTEGER libNewSize)
	{
		if (libNewSize.QuadPart > MAXDWORD)
			return STG_E_INVALIDFUNCTION;
		m_data.set_size((t_size)libNewSize.QuadPart);
		return S_OK;
	}
コード例 #4
0
	void init()
	{
		filter.set_size( nch );
		for ( unsigned h = 0; h < nch; h++ )
		{
			//these do not matter, only samplerate does
			filter[ h ].setFrequency(400);
			filter[ h ].setQuality(0);
			filter[ h ].setGain(0);
			filter[ h ].init(srate,RIAA_CD);
		}
	}
コード例 #5
0
	void open( service_ptr_t<file> m_file, const char * p_path, t_input_open_reason p_reason, abort_callback & p_abort )
	{
		if ( p_reason == input_open_info_write ) throw exception_io_data();
		input_open_file_helper( m_file, p_path, p_reason, p_abort );
		m_stats = m_file->get_stats( p_abort );
		t_uint8            * ptr;
		unsigned             size;
		t_filesize size64 = m_file->get_size_ex( p_abort );
		if ( size64 > ( 1 << 24 ) )
			throw exception_io_data();
		size = (unsigned) size64;
		file_buffer.set_size( size );
		ptr = file_buffer.get_ptr();
		m_file->read_object( ptr, size, p_abort );
		m_player = ModPlug_Load(ptr, size);
		if ( !m_player ) throw exception_io_data();
	}
コード例 #6
0
void stream_to_mem_block(stream_reader * p_source, pfc::array_t<t_uint8> & p_out,abort_callback & p_abort, unsigned p_sizehint, bool b_reset)
{
	if (b_reset)
		p_out.set_size(0);

	enum {min_buffer = 256};
	const unsigned buffer_size = max (min_buffer, p_sizehint);
	pfc::array_t<t_uint8> buffer;
	buffer.set_size(buffer_size);

	for(;;)
	{
		unsigned delta_done = 0;
		delta_done = p_source->read(buffer.get_ptr(),buffer_size,p_abort);
		p_out.append_fromptr(buffer.get_ptr(),delta_done);
		if (delta_done < buffer_size) break;
	}
}
コード例 #7
0
ファイル: mp4.cpp プロジェクト: reupen/ipod_manager
	//void readboxfull(service_ptr_t<file> & p_file, abort_callback & p_abort)
	//{
	//	readbox(p_file, p_abort);
	//	p_file->skip(4, p_abort);
	//}
	void readdata(stream_reader * p_file, abort_callback & p_abort)
	{
		m_data.set_size(pfc::downcast_guarded<t_size>(get_data_size()));
		p_file->read(m_data.get_ptr(), m_data.get_size(), p_abort);
	}
コード例 #8
0
ファイル: playlist_view.cpp プロジェクト: ASopH/columns_ui
unsigned playlist_view::get_column_widths(pfc::array_t<int, pfc::alloc_fast_aggressive> & out) const
{
	const bit_array & p_mask = g_cache.active_get_columns_mask();
	unsigned n,t = columns.get_count(),nw=0,i;

	unsigned ac = 0;
	for (n=0;n<t;n++) if  (p_mask[n]) ac++;

	out.set_size(ac);

	RECT hd;
	SetRectEmpty(&hd);
	
	if (cfg_nohscroll && wnd_playlist && GetClientRect(wnd_playlist, &hd))
	{

		int tw=0,total_parts=0;

		pfc::array_t<unsigned> columns_parts;
		
		columns_parts.set_size(t);

		out.fill(0);

		for (n=0,i=0;n<t;n++)
		if (p_mask[n])
		{
			tw += columns[n]->width;
			unsigned part = columns[n]->parts;
			total_parts += part;
			columns_parts[n] = part;
			i++;
		}

		int excess = hd.right-hd.left-tw;

		bool first_pass = true;

		while ( (excess && total_parts) || first_pass)
		{
			first_pass= false;
			int parts = total_parts;


			for (n=0,i=0;n<t;n++)
			if (p_mask[n])
			{
				int part = columns_parts[n];
				int e = ((parts && part) ?  MulDiv(part,(excess),parts) : 0);
				int f = columns[n]->width;

				parts -= part;
				excess -= e;
				if (e < f*-1)
				{
					e = f*-1;
					total_parts -= columns_parts[n];
					columns_parts[n]=0;
				}
				int w = f + e;

				out[i++] += w;
				nw += w;
			}
		}
	}
	else
	{
		for (n=0,i=0;n<t;n++) 
		{
			if (p_mask[n])
			{
				out[i] = columns[n]->width;
				nw += out[i++];
			}
		}
	}
	return nw;
}