当前位置: 首页>>代码示例>>C++>>正文


C++ OpenStream函数代码示例

本文整理汇总了C++中OpenStream函数的典型用法代码示例。如果您正苦于以下问题:C++ OpenStream函数的具体用法?C++ OpenStream怎么用?C++ OpenStream使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了OpenStream函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Initialize

	void Initialize(bool StartThread)
	{
		RingbufData = new char[BUFF_SIZE*sizeof(float)];

		WaitForRingbufferSpace = false;

		PaUtil_InitializeRingBuffer(&RingBuf, sizeof(float), BUFF_SIZE, RingbufData);

		Threaded = StartThread;
		Stream = nullptr;

		if (StartThread)
		{
			thread(&PaMixer::Run, this).detach();
		}
#ifdef WIN32
		if (UseWasapi)
		{
			OpenStream(&Stream, GetWasapiDevice(), 44100, (void*) this, Latency, Mix);

			if (!Stream)
			{
				// This was a Wasapi problem. Retry without it.
				Log::Logf("Problem initializing WASAPI. Falling back to default API.");
				UseWasapi = false;
				OpenStream(&Stream, Pa_GetDefaultOutputDevice(), 44100, (void*) this, Latency, Mix);
			}

		}
		else
		{
			OpenStream(&Stream, DefaultDSDevice, 44100, (void*) this, Latency, Mix);
		}
#else
		OpenStream( &Stream, Pa_GetDefaultOutputDevice(), 44100, (void*) this, Latency, Mix );

#endif

		if (Stream)
		{
			Pa_StartStream(Stream);
			std::this_thread::sleep_for(std::chrono::milliseconds(16));
			Latency = Pa_GetStreamInfo(Stream)->outputLatency;
			Log::Logf("AUDIO: Latency after opening stream = %f \n", Latency);
		}

		ConstFactor = 1.0;
	}
开发者ID:Sp3ct3r2k11,项目名称:raindrop,代码行数:48,代码来源:Audio.cpp

示例2: print_stream

static void
print_stream(const char *fname) {
	fprintf(OutputFile, "File %s:", fname);
	if (!OpenStream(fname)) {
		fprintf(OutputFile, " cannot open\n");
		return;
	}

	fprintf(OutputFile, " showing token stream:\nnl_cnt, tk_cnt: tokens");

	lex_token = EOL;
	do {
		if (TOKEN_EQ(lex_token, EOL)) {
			fprintf(OutputFile, "\n%u,%u:",
				lex_nl_cnt, lex_tk_cnt
			);
		}
		else {
			print_token(OutputFile, lex_token);
		}
	} while (NextStreamTokenObtained());

	fprintf(OutputFile, "\n");

	CloseStream();

}
开发者ID:AristotleProject,项目名称:freepascal,代码行数:27,代码来源:sim.c

示例3: OpenStream

HRESULT MuPDFDoc::InitDocument(unsigned char *buffer, int bufferLen, const char *mimeType)
{
	fz_stream *stream = OpenStream(buffer, bufferLen);
	if (!stream)
	{
		return E_OUTOFMEMORY;
	}
	else
	{
		fz_try(m_context)
		{
			m_document = fz_open_document_with_stream(m_context, mimeType, stream);
			m_outline = fz_load_outline(m_document);
			//AlertsInit();
		}
		fz_always(m_context)
		{
			fz_close(stream);
		}
		fz_catch(m_context)
		{
			return E_INVALIDARG;
		}
		return S_OK;
	}
}
开发者ID:KhalidElSayed,项目名称:windows8,代码行数:26,代码来源:MuPDFDoc.cpp

示例4: CDVDMsgAudioCodecChange

bool CVideoPlayerAudio::OpenStream(CDVDStreamInfo &hints)
{
  m_processInfo.ResetAudioCodecInfo();

  CLog::Log(LOGNOTICE, "Finding audio codec for: %i", hints.codec);
  bool allowpassthrough = !CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOPLAYER_USEDISPLAYASCLOCK);
  if (hints.realtime)
    allowpassthrough = false;
  CDVDAudioCodec* codec = CDVDFactoryCodec::CreateAudioCodec(hints, m_processInfo, allowpassthrough, m_processInfo.AllowDTSHDDecode());
  if(!codec)
  {
    CLog::Log(LOGERROR, "Unsupported audio codec");
    return false;
  }

  if(m_messageQueue.IsInited())
    m_messageQueue.Put(new CDVDMsgAudioCodecChange(hints, codec), 0);
  else
  {
    OpenStream(hints, codec);
    m_messageQueue.Init();
    CLog::Log(LOGNOTICE, "Creating audio thread");
    Create();
  }
  return true;
}
开发者ID:jtrensberger,项目名称:xbmc,代码行数:26,代码来源:VideoPlayerAudio.cpp

示例5: jack_error

int JackPortAudioDriver::SetBufferSize(jack_nframes_t buffer_size)
{
    PaError err;

    if (fStream && (err = Pa_CloseStream(fStream)) != paNoError) {
        jack_error("Pa_CloseStream error = %s", Pa_GetErrorText(err));
        goto error;
    }

    // It seems that some ASIO drivers (like ASIO4All) needs this to restart correctly;
    delete fPaDevices;
    fPaDevices = new PortAudioDevices();

    err = OpenStream(buffer_size);
    if (err != paNoError) {
        jack_error("Pa_OpenStream error = %s", Pa_GetErrorText(err));
        goto error;
    } else {
        JackAudioDriver::SetBufferSize(buffer_size); // Generic change, never fails
        return 0;
    }

error:
    fStream = NULL;
    return -1;
}
开发者ID:agraf,项目名称:jack2,代码行数:26,代码来源:JackPortAudioDriver.cpp

示例6: COMXAudioCodecOMX

bool OMXPlayerAudio::OpenStream(CDVDStreamInfo hints)
{
  m_bad_state = false;

  m_processInfo.ResetAudioCodecInfo();
  COMXAudioCodecOMX *codec = new COMXAudioCodecOMX(m_processInfo);

  if(!codec || !codec->Open(hints))
  {
    CLog::Log(LOGERROR, "Unsupported audio codec");
    delete codec; codec = NULL;
    return false;
  }

  if(m_messageQueue.IsInited())
    m_messageQueue.Put(new COMXMsgAudioCodecChange(hints, codec), 0);
  else
  {
    OpenStream(hints, codec);
    m_messageQueue.Init();
    CLog::Log(LOGNOTICE, "Creating audio thread");
    Create();
  }

  return true;
}
开发者ID:micahg,项目名称:xbmc,代码行数:26,代码来源:OMXPlayerAudio.cpp

示例7:

long LogClient::LogFile_ForThread::BufToFile(void)
{
	if (0 == _str_buf.size())
	{
		return 1;
	}
	if(!_ofstream.is_open())
	{
		if(!OpenStream())
		{
			if(1024 * 1024 <  _str_buf.size())
			{
				_str_buf.clear();
				PutLogInfo("本地日志文件不能写入,超过缓冲数量,进行清除");
			}
			return 1;
		}
	}
	string tmp;
	EnterCriticalSection(&_critical_section);
	tmp = _str_buf;
	_str_buf.clear();
	_buf_is_null = true;
	LeaveCriticalSection(&_critical_section);

	_ofstream<<tmp;
	return 0;
}
开发者ID:xiongshaogang,项目名称:mmo-resourse,代码行数:28,代码来源:LogClient.cpp

示例8: OpenStream

PageCond plRegistryPageNode::IVerify()
{
    // Check the checksum values first, to make sure the files aren't corrupt
    uint32_t ourChecksum = 0;
    hsStream* stream = OpenStream();
    if (stream)
    {
        ourChecksum = stream->GetEOF() - fPageInfo.GetDataStart();
        CloseStream();
    }
    if (ourChecksum != fPageInfo.GetChecksum())
        return kPageCorrupt;

    // If major version out-of-date, entire location is screwed
    if (fPageInfo.GetMajorVersion() > plVersion::GetMajorVersion())
        return kPageTooNew;
    else if (fPageInfo.GetMajorVersion() < plVersion::GetMajorVersion())
        return kPageOutOfDate;

    // Check the minor versions
    const plPageInfo::ClassVerVec& classVersions = fPageInfo.GetClassVersions();
    for (int i = 0; i < classVersions.size(); i++)
    {
        const plPageInfo::ClassVersion& cv = classVersions[i];
        uint16_t curVersion = plVersion::GetCreatableVersion(cv.Class);

        if (curVersion > cv.Version)
            return kPageOutOfDate;
        else if (curVersion < cv.Version)
            return kPageTooNew;
    }

    return kPageOk;
}
开发者ID:branan,项目名称:Plasma,代码行数:34,代码来源:plRegistryNode.cpp

示例9: while

STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
{
  UInt32 realProcessedSize = 0;
  while ((_fileIndex < _numFiles || _fileIsOpen) && size > 0)
  {
    if (_fileIsOpen)
    {
      UInt32 localProcessedSize;
      RINOK(_inStreamWithHash->Read(
          ((Byte *)data) + realProcessedSize, size, &localProcessedSize));
      if (localProcessedSize == 0)
      {
        RINOK(CloseStream());
        continue;
      }
      realProcessedSize += localProcessedSize;
      _filePos += localProcessedSize;
      size -= localProcessedSize;
      break;
    }
    else
    {
      RINOK(OpenStream());
    }
  }
  if (processedSize != 0)
    *processedSize = realProcessedSize;
  return S_OK;
}
开发者ID:4ft35t,项目名称:firmware-mod-kit,代码行数:29,代码来源:7zFolderInStream.cpp

示例10: while

STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
{
  UInt32 realProcessedSize = 0;
  while ((_curIndex < _refItem.NumItems || _fileIsOpen) && size > 0)
  {
    if (_fileIsOpen)
    {
      UInt32 localProcessedSize;
      RINOK(_stream->Read(
          ((Byte *)data) + realProcessedSize, size, &localProcessedSize));
      _crc = CrcUpdate(_crc, ((Byte *)data) + realProcessedSize, localProcessedSize);
      if (localProcessedSize == 0)
      {
        RINOK(CloseStream());
        continue;
      }
      realProcessedSize += localProcessedSize;
      size -= localProcessedSize;
      break;
    }
    else
    {
      RINOK(OpenStream());
    }
  }
  if (processedSize != 0)
    *processedSize = realProcessedSize;
  return S_OK;
}
开发者ID:Ando02,项目名称:wubiuefi,代码行数:29,代码来源:RarVolumeInStream.cpp

示例11: DoPassive

HRESULT CClientSession::DoPutFile( const string& strSrcFile, const string& strDstFile )
{
	if( !IsFileExist( strSrcFile.c_str() ) ){
		return E_NOENT;
	}

	//step 1. request passive mode to get the data channel address
	u_int nPasPort = 0;
	HRESULT hRet = DoPassive( nPasPort );
	if( FAILED(hRet) )return hRet;

	//step 2. send the put file command.
	CMessage1Param<char*>* pMsgPut = (CMessage1Param<char*>*)CMessageBase::Alloc( sizeof(CMessageBase)+strDstFile.length()+1 );
	pMsgPut->Init( NCM_PUTFILE, GetAddr(), GetServAddr(), strDstFile.c_str() );
	CMessageTrash trash1(pMsgPut);
	m_pClntProxy->SendMessage( pMsgPut );

	CMessage1Param<int>* pMsgAck = (CMessage1Param<int>*)WaitForMessage( NCF_ACK|NCM_PUTFILE );
	CMessageTrash trash2(pMsgAck);
	if( !pMsgAck->IsSucceeded() )return pMsgAck->GetResult();

	pMsgAck->ntoh( false );
	int nFileMode = pMsgAck->GetParam();

	//step 3. now the server agrees on the file transfer, connect the data channel and send file
	SOCKET sock_stream = OpenStream( nPasPort );
	if( sock_stream==INVALID_SOCKET )return E_OPENSTREAM;

	//open the data stream channel.
/*	CMessageBase msg;
	msg.Init( NCM_OPENSTREAM, GetAddr(), GetServAddr() );
	SendMessage( sock_stream, &msg );
	CMessageBase* pMsg = RecvMessage<CMessageBase>( sock_stream );
	if( pMsg==NULL ){
		closesocket( sock_stream );
		return E_OPENSTREAM;
	}

	CMessageTrash trash3(pMsg);
	if( pMsg->IsFailed() ){
		closesocket( sock_stream );
		return pMsg->GetResult();
	}*/

	//send the file stream
	int nLen = SendFileEx( sock_stream, strSrcFile.c_str(), nFileMode );
	shutdown( sock_stream, SD_BOTH );
	closesocket( sock_stream );

	//step 4. exchange the error code.
	CMessageBase msg;
	msg.Init( NCM_STREAMLENGTH, GetAddr(), GetServAddr(), nLen );
	m_pClntProxy->SendMessage( &msg );

	CMessageBase* pMsg = WaitForMessage( NCF_ACK|NCM_STREAMLENGTH );
	CMessageTrash trash4(pMsg);

	return pMsg->GetResult();
}
开发者ID:EISALab,项目名称:AMGAgroundwater,代码行数:59,代码来源:clntkel.cpp

示例12:

DWORD MP3decoder::GetTotalTime(char * pcfilename)			// 1/1000 sec
{
	int ntmp = 0;

	if(!OpenStream(pcfilename, &ntmp, &ntmp, &ntmp, NULL, &ntmp))
		return 0;
	CloseStream();
	return m_length;
}
开发者ID:diogenesmonteiro,项目名称:carbotan,代码行数:9,代码来源:MP3decoder.cpp

示例13: XN_VALIDATE_INPUT_PTR

XnStatus PlayerNode::SetInputStream(void *pStreamCookie, XnPlayerInputStreamInterface *pStream)
{
	XN_VALIDATE_INPUT_PTR(pStream);
	m_pStreamCookie = pStreamCookie;
	m_pInputStream = pStream;
	XnStatus nRetVal = OpenStream();
	XN_IS_STATUS_OK(nRetVal);
	return XN_STATUS_OK;
}
开发者ID:3david,项目名称:OpenNI,代码行数:9,代码来源:PlayerNode.cpp

示例14: throw

attachment::attachment(message& mapi_message, const uint32_t attach_num) throw(mapi_exception)
: object(mapi_message.get_session(), "attachment"), m_attach_num(attach_num), m_bin_data(NULL), m_data_size(0), m_filename("")
{
	if (OpenAttach(&mapi_message.data(), attach_num, &m_object) != MAPI_E_SUCCESS)
		throw mapi_exception(GetLastError(), "attachment::attachment : OpenAttach");

	property_container properties = get_property_container();
	properties << PR_ATTACH_FILENAME << PR_ATTACH_LONG_FILENAME << PR_ATTACH_SIZE << PR_ATTACH_DATA_BIN << PR_ATTACH_METHOD;
	properties.fetch();

	const char* filename = static_cast<const char*>(properties[PR_ATTACH_LONG_FILENAME]);
	if (!filename) {
		filename = static_cast<const char*>(properties[PR_ATTACH_FILENAME]);
	}

	if (filename)
		m_filename = filename;

	m_data_size = *(static_cast<const uint32_t*>(properties[PR_ATTACH_SIZE]));

	const Binary_r* attachment_data = static_cast<const Binary_r*>(properties[PR_ATTACH_DATA_BIN]);

	// Don't load PR_ATTACH_DATA_BIN if it's embedded in message.
	// NOTE: Use RopOpenEmbeddedMessage when it is implemented.
	const uint32_t attach_method = *static_cast<const uint32_t*>(properties[PR_ATTACH_METHOD]);
	if (attach_method != ATTACH_BY_VALUE)
		return;

	// Get Binary Data.
	if (attachment_data) {
		m_data_size = attachment_data->cb;
		m_bin_data = new uint8_t[m_data_size];
		memcpy(m_bin_data, attachment_data->lpb, attachment_data->cb);
	} else {
		mapi_object_t obj_stream;
		mapi_object_init(&obj_stream);
		if (OpenStream(&m_object, (enum MAPITAGS)PidTagAttachDataBinary, OpenStream_ReadOnly, &obj_stream) != MAPI_E_SUCCESS)
			throw mapi_exception(GetLastError(), "attachment::attachment : OpenStream");

		if (GetStreamSize(&obj_stream, &m_data_size) != MAPI_E_SUCCESS)
			throw mapi_exception(GetLastError(), "attachment::attachment : GetStreamSize");

		m_bin_data = new uint8_t[m_data_size];

		uint32_t pos = 0;
		uint16_t bytes_read = 0;
		do {
			if (ReadStream(&obj_stream, m_bin_data+pos, 1024, &bytes_read) != MAPI_E_SUCCESS)
				throw mapi_exception(GetLastError(), "attachment::attachment : ReadStream");

			pos += bytes_read;

		} while (bytes_read && pos < m_data_size);

		mapi_object_release(&obj_stream);
	}
}
开发者ID:EasyLinux,项目名称:Openchange,代码行数:57,代码来源:attachment.cpp

示例15: OpenStream

//==============================
// ovrFileSysLocal::FileExists
bool ovrFileSysLocal::FileExists( char const * uri )
{
	ovrStream * stream = OpenStream( uri, OVR_STREAM_MODE_READ );
	if ( stream == NULL )
	{
		return false;
	}
	CloseStream( stream );
	return true;
}
开发者ID:ejeinc,项目名称:Meganekko,代码行数:12,代码来源:OVR_FileSys.cpp


注:本文中的OpenStream函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。