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; }
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(); }
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; } }
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; }
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; }
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; }
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; }
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; }
bool CVideoPlayerAudio::OpenStream(CDVDStreamInfo hints) { CLog::Log(LOGNOTICE, "Finding audio codec for: %i", hints.codec); bool allowpassthrough = !CServiceBroker::GetSettings().GetBool(CSettings::SETTING_VIDEOPLAYER_USEDISPLAYASCLOCK); if (m_processInfo.IsRealtimeStream()) allowpassthrough = false; CAEStreamInfo::DataType streamType = m_audioSink.GetPassthroughStreamType(hints.codec, hints.samplerate); CDVDAudioCodec* codec = CDVDFactoryCodec::CreateAudioCodec(hints, m_processInfo, allowpassthrough, m_processInfo.AllowDTSHDDecode(), streamType); 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; }
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; }
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; }
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(); }
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; }
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; }
HRESULT CClientSession::DoListDir( const string& strPath, EnumNetfEntryProc pEnumProc ) { //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*>* pMsgList = (CMessage1Param<char*>*)CMessageBase::Alloc( sizeof(CMessageBase)+strPath.length()+1 ); pMsgList->Init( NCM_LISTDIR, GetAddr(), GetServAddr(), strPath.c_str() ); CMessageTrash trash1(pMsgList); m_pClntProxy->SendMessage( pMsgList ); CMessageBase* pMsgAck = WaitForMessage( NCF_ACK|NCM_LISTDIR ); CMessageTrash trash2(pMsgAck); if( !pMsgAck->IsSucceeded() )return pMsgAck->GetResult(); //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(); }*/ NETF_ENTRY entry; int nLen = 0; while( true ){ if( RecvBuffer( sock_stream, (char*)&entry, sizeof(NETF_ENTRY) )<sizeof(NETF_ENTRY) )break; (*pEnumProc)( &entry ); nLen += sizeof(NETF_ENTRY); } 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(); }
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); } }
//============================== // 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; }
bool CRTSPClient::Play(double fStart,double fDuration) { LogDebug("CRTSPClient::Play from %f / %f", (float)fStart,(float)fDuration); m_bPaused=false; m_fStart=fStart; m_fDuration=fDuration; if (m_BufferThreadActive) { Stop(); m_buffer.Clear(); if (Initialize()==false) { shutdown(); return false; } if (OpenStream(m_url)==false) { shutdown(); return false; } } if (m_ourClient==NULL||m_session==NULL) { m_buffer.Clear(); if (Initialize()==false) { shutdown(); return false; } if (OpenStream(m_url)==false) { shutdown(); return false; } } if (!startPlayingStreams()) { shutdown(); return false; } StartBufferThread(); return true; }
//============================== // ovrFileSysLocal::ReadFile bool ovrFileSysLocal::ReadFile( char const * uri, MemBufferT< uint8_t > & outBuffer ) { ovrStream * stream = OpenStream( uri, OVR_STREAM_MODE_READ ); if ( stream == NULL ) { return false; } bool success = stream->ReadFile( uri, outBuffer ); CloseStream( stream ); return success; }
void cSoundStream::BindFile(const std::string &path, ALenum format) { if(!IsValid()) return; m_Format = format; DeleteChunks(); if(OpenStream(path)) CreateChunks(); };
_CGUL_EXPORT CGUL::PortAudio::SineWave::SineWave(Device device) : Stream() { for (unsigned int i = 0; i < 200; i++) { sine[i] = (float)CGUL::Math::Sin(((double)i/200.0)*CGUL::Math::pi * 2.0); } position = 0; framesPerBuffer = 64; OpenStream(device); }
bool OMXPlayerVideo::OpenStream(CDVDStreamInfo &hints) { /* if(IsRunning()) CloseStream(false); */ m_hints = hints; m_Deinterlace = ( CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode == VS_DEINTERLACEMODE_OFF ) ? false : true; m_hdmi_clock_sync = (g_guiSettings.GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF); m_started = false; m_flush = false; m_stalled = m_messageQueue.GetPacketCount(CDVDMsg::DEMUXER_PACKET) == 0; m_autosync = 1; m_iSleepEndTime = DVD_NOPTS_VALUE; // force SetVideoRect to be called initially m_dst_rect.SetRect(0, 0, 0, 0); m_audio_count = m_av_clock->HasAudio(); if (!m_DllBcmHost.Load()) return false; if(!OpenDecoder()) { return false; } if(m_messageQueue.IsInited()) m_messageQueue.Put(new COMXMsgVideoCodecChange(hints, NULL), 0); else { if(!OpenStream(hints, NULL)) return false; CLog::Log(LOGNOTICE, "Creating video thread"); m_messageQueue.Init(); Create(); } /* if(!OpenStream(hints, NULL)) return false; CLog::Log(LOGNOTICE, "Creating video thread"); m_messageQueue.Init(); Create(); */ m_open = true; m_send_eos = false; return true; }
bool CVideoPlayerVideo::OpenStream(CDVDStreamInfo hint) { if (hint.flags & AV_DISPOSITION_ATTACHED_PIC) return false; if (hint.extrasize == 0) { // codecs which require extradata if (hint.codec == AV_CODEC_ID_NONE || hint.codec == AV_CODEC_ID_MPEG1VIDEO || hint.codec == AV_CODEC_ID_MPEG2VIDEO || hint.codec == AV_CODEC_ID_H264 || hint.codec == AV_CODEC_ID_HEVC || hint.codec == AV_CODEC_ID_MPEG4 || hint.codec == AV_CODEC_ID_WMV3 || hint.codec == AV_CODEC_ID_VC1) return false; } CLog::Log(LOGNOTICE, "Creating video codec with codec id: %i", hint.codec); if (m_messageQueue.IsInited()) { if (m_pVideoCodec && !m_processInfo.IsVideoHwDecoder()) { hint.codecOptions |= CODEC_ALLOW_FALLBACK; } CDVDVideoCodec* codec = CDVDFactoryCodec::CreateVideoCodec(hint, m_processInfo); if (!codec) { CLog::Log(LOGINFO, "CVideoPlayerVideo::OpenStream - could not open video codec"); } SendMessage(new CDVDMsgVideoCodecChange(hint, codec), 0); } else { m_processInfo.ResetVideoCodecInfo(); hint.codecOptions |= CODEC_ALLOW_FALLBACK; CDVDVideoCodec* codec = CDVDFactoryCodec::CreateVideoCodec(hint, m_processInfo); if (!codec) { CLog::Log(LOGERROR, "CVideoPlayerVideo::OpenStream - could not open video codec"); return false; } OpenStream(hint, codec); CLog::Log(LOGNOTICE, "Creating video thread"); m_messageQueue.Init(); m_processInfo.SetLevelVQ(0); Create(); } return true; }
void emAvFileModel::SetPlayState(PlayStateType playState) { if (GetFileState()!=FS_LOADED) return; if (PlayState==playState) return; PlayState=playState; Signal(PlayStateSignal); if (PlayState==PS_STOPPED) { RemoveFromActiveList(); CloseStream(); PlayPos=0; Signal(PlayPosSignal); Image.Empty(); Signal(ImageSignal); } else { AddToActiveList(); if (GetStreamState()!=STREAM_OPENING && GetStreamState()!=STREAM_OPENED) { if (!WarningText.IsEmpty() || !ErrorText.IsEmpty()) { WarningText.Empty(); ErrorText.Empty(); Signal(InfoSignal); } OpenStream("auto","emAv",GetFilePath()); SetProperty("audio_volume",emString::Format("%d",AudioVolume)); SetProperty("audio_mute",AudioMute?"on":"off"); if (AudioVisu>=0 && AudioVisu<AudioVisus.GetCount()) { SetProperty("audio_visu",AudioVisus[AudioVisu].Get()); } SetProperty("pos",emString::Format("%d",PlayPos)); #if 0 // ??? This did not function. if (AudioChannel>=0 && AudioChannel<AudioChannels.GetCount()) { SetProperty("audio_channel",AudioChannels[AudioChannel].Get()); } if (SpuChannel>=0 && SpuChannel<SpuChannels.GetCount()) { SetProperty("spu_channel",SpuChannels[SpuChannel].Get()); } #endif } SetProperty( "state", PlayState==PS_PAUSED ? "paused" : PlayState==PS_SLOW ? "slow" : PlayState==PS_FAST ? "fast" : "normal" ); } SaveFileState(); }
bool OMXPlayerVideo::OpenStream(CDVDStreamInfo &hints) { /* if(IsRunning()) CloseStream(false); */ m_hints = hints; m_Deinterlace = ( g_settings.m_currentVideoSettings.m_DeinterlaceMode == VS_DEINTERLACEMODE_OFF ) ? false : true; m_flush = false; m_hdmi_clock_sync = g_guiSettings.GetBool("videoplayer.adjustrefreshrate"); m_started = false; m_stalled = m_messageQueue.GetPacketCount(CDVDMsg::DEMUXER_PACKET) == 0; m_autosync = 1; m_audio_count = m_av_clock->HasAudio(); if (!m_DllBcmHost.Load()) return false; if(!OpenDecoder()) { return false; } if(m_messageQueue.IsInited()) m_messageQueue.Put(new COMXMsgAudioCodecChange(hints, NULL), 0); else { if(!OpenStream(hints, NULL)) return false; CLog::Log(LOGNOTICE, "Creating video thread"); m_messageQueue.Init(); Create(); } /* if(!OpenStream(hints, NULL)) return false; CLog::Log(LOGNOTICE, "Creating video thread"); m_messageQueue.Init(); Create(); */ m_open = true; return true; }
int OPLMIDIDevice::Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata) { if (io == NULL || 0 == (NumChips = io->OPLinit(opl_numchips, FullPan, true))) { return 1; } int ret = OpenStream(14, (FullPan || io->IsOPL3) ? 0 : SoundStream::Mono, callback, userdata); if (ret == 0) { OPLstopMusic(); OPLplayMusic(100); DEBUGOUT("========= New song started ==========\n", 0, 0, 0); } return ret; }
INT CPlayer::OpenVsFile(HWND hWnd, LPCTSTR szFile) { m_hRenderWnd = hWnd; if (szFile != NULL) { m_strPlayFileName = szFile; } else return -1; try { NAME(PlayM4_RegisterDrawFun)(m_index, OnDrawFun, (LONG)this); NAME(PlayM4_SetEncChangeMsg)(m_index, m_hRenderWnd, WM_ENC_CHANGE); //NAME(PlayM4_SetFileEndCallback)(m_index, FileEndCallBack, this); m_bStreamType = m_strPlayFileName.Right(3).CompareNoCase(_T(".vs")) == 0; if(m_bStreamType) { OpenStream(); } else { HKOpenFile(); } //NAME(PlayM4_SetPicQuality)(m_index, m_bPicQuality); //NAME(PlayM4_SetDeflash)(m_index, m_bDeflash); //NAME(PlayM4_GetPictureSize)(m_index, &m_nWidth, &m_nHeight); /*if( (m_nWidth == WIDTH*2) && (m_nHeight <= HEIGHT_PAL) ) { m_nHeight *= 2; }*/ } catch(...) { CloseVsFile(); } return m_index; }
void PulseAudioPlayer::Play(int64_t start,int64_t count) { //printf("Starting PulseAudio playback\n"); if (!open) OpenStream(); if (is_playing) { // If we're already playing, do a quick "reset" is_playing = false; pa_threaded_mainloop_lock(mainloop); pa_operation *op = pa_stream_flush(stream, (pa_stream_success_cb_t)pa_stream_success, this); pa_threaded_mainloop_unlock(mainloop); stream_success.Wait(); pa_operation_unref(op); if (!stream_success_val) { paerror = pa_context_errno(context); printf("PulseAudio player: Error flushing stream: %s (%d)\n", pa_strerror(paerror), paerror); } } start_frame = start; cur_frame = start; end_frame = start + count; //printf("start=%lu end=%lu\n", start_frame, end_frame); is_playing = true; play_start_time = 0; pa_threaded_mainloop_lock(mainloop); paerror = pa_stream_get_time(stream, (pa_usec_t*) &play_start_time); pa_threaded_mainloop_unlock(mainloop); if (paerror) { printf("PulseAudio player: Error getting stream time: %s (%d)\n", pa_strerror(paerror), paerror); } PulseAudioPlayer::pa_stream_write(stream, pa_stream_writable_size(stream), this); pa_threaded_mainloop_lock(mainloop); pa_operation *op = pa_stream_trigger(stream, (pa_stream_success_cb_t)pa_stream_success, this); pa_threaded_mainloop_unlock(mainloop); stream_success.Wait(); pa_operation_unref(op); if (!stream_success_val) { paerror = pa_context_errno(context); printf("PulseAudio player: Error triggering stream: %s (%d)\n", pa_strerror(paerror), paerror); } }
void debug_stream_test_cb (puObject* obj) { SStream* s = new SStream; strncpy (s->filename, "teststream.txt",(PATH_MAX-1)); strncpy (s->mode, "w",3); OpenStream (s); WriteComment ("Comment...testing testing testing", s); WriteComment ("", s); WriteTag ('bgno', "---- object ----", s); WriteTag ('bgno', "---- nested Object ----", s); WriteTag ('int_', "---- int ----", s); int i = 500; WriteInt (&i, s); WriteTag ('uint', "---- unsigned int ----", s); unsigned int ui = 12345678; WriteUInt (&ui, s); float f = 12345.67f; WriteTag ('flot', "---- float ----", s); WriteFloat (&f, s); double d = 987654.3210; WriteTag ('dubl', "---- double ----", s); WriteDouble (&d, s); WriteTag ('stng', "---- string ----", s); WriteString ("This a string", s); SVector v; v.x = 1.0; v.y = 2.0; v.z = 3.0; WriteTag ('vect', "--- vector ----", s); WriteVector (&v, s); SPosition pos; pos.lat = 1000.0; pos.lon = 2000.0; pos.alt = 3000.0; WriteTag ('posn', "---- position ----", s); WritePosition (&pos, s); SMessage mesg; WriteTag ('mesg', "---- message ----", s); WriteMessage (&mesg, s); WriteTag ('endo', s); WriteTag ('endo', s); CloseStream (s); delete s; }
int JackPortAudioDriver::SetBufferSize(jack_nframes_t buffer_size) { PaError err; if ((err = Pa_CloseStream(fStream)) != paNoError) { jack_error("Pa_CloseStream error = %s", Pa_GetErrorText(err)); return -1; } err = OpenStream(buffer_size); if (err != paNoError) { jack_error("Pa_OpenStream error %d = %s", err, Pa_GetErrorText(err)); return -1; } else { JackAudioDriver::SetBufferSize(buffer_size); // Generic change, never fails return 0; } }