コード例 #1
0
ファイル: speech.cpp プロジェクト: reupen/ipod_manager
	virtual HRESULT STDMETHODCALLTYPE Seek( 
		LARGE_INTEGER dlibMove,
		DWORD dwOrigin,
		ULARGE_INTEGER *plibNewPosition)
	{
		if (dwOrigin == STREAM_SEEK_CUR)
		{
			if (dlibMove.QuadPart + (LONGLONG)m_position < 0
				|| dlibMove.QuadPart + (LONGLONG)m_position > MAXDWORD)
				return STG_E_INVALIDFUNCTION;
			m_position += (t_size)dlibMove.QuadPart; //Cast should be OK by if condition
		}
		else if (dwOrigin == STREAM_SEEK_END)
		{
			if (dlibMove.QuadPart + (LONGLONG)m_data.get_size() < 0)
				return STG_E_INVALIDFUNCTION;
			m_position = m_data.get_size() - (t_size)dlibMove.QuadPart; //Cast should be OK by if condition
		}
		else if (dwOrigin == STREAM_SEEK_SET)
		{
			if ((ULONGLONG)dlibMove.QuadPart > MAXDWORD)
				return STG_E_INVALIDFUNCTION;
			m_position = (t_size)dlibMove.QuadPart; //Cast should be OK by if condition
		}
		else
			return STG_E_INVALIDFUNCTION;
		if (plibNewPosition)
			plibNewPosition->QuadPart = m_position;
		return S_OK;
	}
コード例 #2
0
ファイル: speech.cpp プロジェクト: reupen/ipod_manager
	virtual /* [local] */ HRESULT STDMETHODCALLTYPE Read( 
		/* [length_is][size_is][out] */ void *pv,
		/* [in] */ ULONG cb,
		/* [out] */ ULONG *pcbRead)
	{
		if (m_position > m_data.get_size())
			return STG_E_INVALIDFUNCTION;
		t_size read = min (cb, m_data.get_size() - m_position);
		memcpy(pv, &m_data.get_ptr()[m_position], read);
		m_position += read;
		if (pcbRead)
			*pcbRead = read;
		return S_OK;
	}
コード例 #3
0
static void fileSanitySeek(file::ptr f, pfc::array_t<uint8_t> const & content, size_t offset, abort_callback & aborter) {
	const size_t readAmount = 64 * 1024;
	pfc::array_staticsize_t<uint8_t> buf; buf.set_size_discard(readAmount);
	f->seek(offset, aborter);
	t_filesize positionGot = f->get_position(aborter);
	if (positionGot != offset) {
		FB2K_console_formatter() << "File sanity: at " << offset << " reported position became " << positionGot;
		throw std::runtime_error("Seek test failure");
	}
	size_t did = f->read(buf.get_ptr(), readAmount, aborter);
	size_t expected = pfc::min_t<size_t>(readAmount, content.get_size() - offset);
	if (expected != did) {
		FB2K_console_formatter() << "File sanity: at " << offset << " bytes, expected read size of " << expected << ", got " << did;
		if (did > expected) FB2K_console_formatter() << "Read past EOF";
		else  FB2K_console_formatter() << "Premature EOF";
		throw std::runtime_error("Seek test failure");
	}
	if (memcmp(buf.get_ptr(), content.get_ptr() + offset, did) != 0) {
		FB2K_console_formatter() << "File sanity: data mismatch at " << offset << " - " << (offset + did) << " bytes";
		throw std::runtime_error("Seek test failure");
	}
	positionGot = f->get_position(aborter);
	if (positionGot != offset + did) {
		FB2K_console_formatter() << "File sanity: at " << offset << "+" << did << "=" << (offset + did) << " reported position became " << positionGot;
		throw std::runtime_error("Seek test failure");
	}
}
コード例 #4
0
ファイル: speech.cpp プロジェクト: reupen/ipod_manager
	virtual HRESULT STDMETHODCALLTYPE CopyTo( 
		/* [unique][in] */ IStream *pstm,
		/* [in] */ ULARGE_INTEGER cb,
		/* [out] */ ULARGE_INTEGER *pcbRead,
		/* [out] */ ULARGE_INTEGER *pcbWritten)
	{
		if (cb.QuadPart > m_data.get_size() - m_position)
			return STG_E_INVALIDFUNCTION;
		t_size read = min ((t_size)cb.QuadPart, m_data.get_size() - m_position);
		ULONG pwritten = NULL;
		pstm->Write(&m_data.get_ptr()[m_position], read, &pwritten);
		m_position += read;
		if (pcbRead)
			pcbRead->QuadPart = read;
		if (pcbWritten)
			pcbWritten->QuadPart = pwritten;
		return S_OK;
	}
コード例 #5
0
	void get_info( file_info & p_info, abort_callback & p_abort )
	{
		ModPlugFile* m_info = ModPlug_Load(file_buffer.get_ptr(), file_buffer.get_size());
		p_info.info_set( "encoding", "synthesized" );
		int type_module = ModPlug_GetModuleType(m_info);
		p_info.info_set( "codec", "Module file" );
		p_info.info_set_int( "channels", 2 );
		p_info.meta_set( "title", pfc::stringcvt::string_utf8_from_ansi(  ModPlug_GetName(m_info)  ));
		int len = ModPlug_GetLength(m_info);
		len /= 1000;
		p_info.set_length( len );
		if(m_info)ModPlug_Unload(m_info);
	}
コード例 #6
0
ファイル: speech.cpp プロジェクト: reupen/ipod_manager
	virtual HRESULT STDMETHODCALLTYPE Stat( 
		/* [out] */ __RPC__out STATSTG *pstatstg,
		/* [in] */ DWORD grfStatFlag)
	{
		memset(pstatstg, 0, sizeof(STATSTG));
		pstatstg->cbSize.QuadPart = m_data.get_size();
		pstatstg->type = STGTY_STREAM;
		pstatstg->pwcsName = NULL;
		/*if (!(grfStatFlag & STATFLAG_NONAME))
		{
		if (pstatstg->pwcsName = (LPOLESTR)CoTaskMemAlloc(1*2))
		wcscpy_s(pstatstg->pwcsName, 5, L"AB.jpg");
		}*/
		return S_OK;
	}
コード例 #7
0
ファイル: input_ym.cpp プロジェクト: Crazybond/foobar2000
	void get_info( file_info & p_info, abort_callback & p_abort )
	{
		YMMUSIC *  m_info = ymMusicCreate();
		ymMusicLoadMemory(m_info,file_buffer.get_ptr(), file_buffer.get_size());
		ymMusicInfo_t info;
		ymMusicGetInfo(m_info,&info);

		p_info.info_set( "encoding", "synthesized" );
		p_info.info_set( "codec", "YM" );
		p_info.info_set_int( "channels", 1 );
		p_info.meta_set( "title", pfc::stringcvt::string_utf8_from_ansi( info.pSongName) );
		p_info.meta_set( "artist", pfc::stringcvt::string_utf8_from_ansi( info.pSongAuthor) );
		p_info.meta_set( "comment", pfc::stringcvt::string_utf8_from_ansi( info.pSongComment) );
		p_info.set_length( info.musicTimeInSec );

		ymMusicDestroy(m_info);
	}
コード例 #8
0
ファイル: speech.cpp プロジェクト: reupen/ipod_manager
	virtual /* [local] */ HRESULT STDMETHODCALLTYPE Write( 
		/* [size_is][in] */ const void *pv,
		/* [in] */ ULONG cb,
		/* [out] */ ULONG *pcbWritten)
	{
		t_size old_size = m_data.get_size(), new_size = m_position + cb;
		if (new_size > old_size)
		{
			m_data.grow_size(new_size);
			memset(&m_data.get_ptr()[old_size], 0,new_size-new_size);
		}
		memcpy(&m_data.get_ptr()[m_position], pv, cb);
		m_position += cb;
		if (pcbWritten)
			*pcbWritten = cb;
		return S_OK;
	}
コード例 #9
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);
	}
コード例 #10
0
ファイル: speech.cpp プロジェクト: reupen/ipod_manager
	t_size get_size() const {return m_data.get_size();};
コード例 #11
0
ファイル: speech.cpp プロジェクト: reupen/ipod_manager
	virtual HRESULT STDMETHODCALLTYPE Clone( 
		/* [out] */ __RPC__deref_out_opt IStream **ppstm)
	{
		*ppstm = new IStream_memblock_v2<IStream>(m_data.get_ptr(), m_data.get_size());
		return S_OK;
	}