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


C++ ov_pcm_seek函数代码示例

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


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

示例1: while

// Write sample data into the supplied PCM sample buffers
void CWinGlkOGGSound::WriteSampleData(unsigned char* pSample, int iSampleLen)
{
  int iStream, iCurrent = 0;
  while (iCurrent < iSampleLen)
  {
    long lRead =
      ov_read(&m_Stream,(char*)(pSample+iCurrent),(iSampleLen-iCurrent),0,2,1,&iStream);
    if (lRead > 0)
      iCurrent += lRead;
    else
    {
      if (m_iRepeat > 0)
      {
        ov_pcm_seek(&m_Stream,0);
        m_iRepeat--;
      }
      else if (m_iRepeat == -1)
        ov_pcm_seek(&m_Stream,0);
      else
      {
        while (iCurrent < iSampleLen)
          pSample[iCurrent++] = 0;
      }
    }
  }
}
开发者ID:DavidKinder,项目名称:Windows-Glk,代码行数:27,代码来源:GlkSoundOGG.cpp

示例2: OGGDATA

 unsigned long OggDecoder::Render( unsigned long size, void *buf )
 {
     OggDecoderData *data = OGGDATA(this);
     
     if (!data){
         outOfData = true;
         return 0;
     }
     
     int ret = 1;
     unsigned long pos=0;
     
     if (seekOffset != -1)
     {
         long seek = (long)(((float)seekOffset/1000.0f) * (float)samplerate);
         ov_pcm_seek(&data->vf, seek);
         seekOffset = -1;
         outOfData = false;
     }
     
     while(ret && pos<size)
     {
         ret = ov_read(&data->vf, (char*)buf+pos, size-pos, 0, 2, 1, &data->sec);
         pos += ret;
     }
     
     // reached the end?
     if (!ret && (loopsRemaining!=0))
     {
         // we are looping so restart from the beginning
         ret = 1;
         ov_pcm_seek(&data->vf, 0);  // Loop back position, TODO: If we want to loop to a specific point, here is the code for that!
         while(ret && pos<size)
         {
             ret = ov_read(&data->vf, (char*)buf+pos, size-pos, 0, 2, 1, &data->sec);
             pos += ret;
         }
         
         // Decrease from Loops Remaining (don't touch the -1 infinite loop stuff)
         if (loopsRemaining > 0)
             loopsRemaining--;
     }
     else if (!ret && (loopsRemaining==0)){
         outOfData = true;
     }
     
     return pos;
 }
开发者ID:amackworth,项目名称:Monocle-Engine,代码行数:48,代码来源:OggDecoder.cpp

示例3: ov_pcm_seek

void
SoundD3D::RewindOggStream()
{
	if (!ov_file || !buffer)
	return;

	// rewind the stream and keep going...
	eos_written = false;
	eos_latch   = 0;
	read_size   = wfex.nAvgBytesPerSec / 2;

	// set the stream pointer back to the beginning:
	ov_pcm_seek(ov_file, 0);

	// find the size of the file:
	stream_left    = (DWORD) ov_pcm_total(ov_file,-1);
	stream_offset  = 0;

	total_time     = (double) stream_left /
	(double) wfex.nAvgBytesPerSec;

	if (stream_left < read_size) {
		status = DONE;
		buffer->Stop();
	}
}
开发者ID:lightgemini78,项目名称:Starshatter-Rearmed,代码行数:26,代码来源:SoundD3D.cpp

示例4: while

    int OggStream::decodeNextBlock(bool looped, void* data, int bufferSize)
    {
        unsigned int bytesUnpacked = 0;

        int p = (int)ov_pcm_tell(&_vorbisFile);

        while (1)
        {
            int r = (int)ov_read(&_vorbisFile, (char*)data, bufferSize, &_section);
            if (!r)
            {
                if (looped)
                {
                    ov_pcm_seek(&_vorbisFile, 0);

                }
                else
                {
                    _streamEnded = true;
                    break;
                }
            }

            data = (char*)data + r;
            bufferSize -= r;

            bytesUnpacked += r;
            if (bufferSize == 0)
                break;
        }

        p = int(ov_pcm_tell(&_vorbisFile)) - p;

        return bytesUnpacked;
    }
开发者ID:Aizter,项目名称:oxygine-sound,代码行数:35,代码来源:OggStream.cpp

示例5: while

	bool SPOggFile::NextStreamData( BYTE* pData, DWORD length, DWORD &readBytes, bool &eof )
	{
		if (!isLoaded)
		{
			return false;
		}

		DWORD pos = 0;
		int sec = 0;
		int ret = 1;

		while(ret && pos < length)
		{
			ret = ov_read(&vf, (char*)pData + pos, length - pos, 0, 2, 1, &sec);
			pos += ret;
		}

		readBytes = pos;

		if (!ret)
		{
			eof = true;
			ov_pcm_seek(&vf, 0);
		}
		else
		{
			eof = false;
		}

		return true;
	}
开发者ID:weimingtom,项目名称:spengine-1,代码行数:31,代码来源:SPOggFile.cpp

示例6: ov_pcm_seek

bool RealSoundOgg::ServiceBuffer()
{
	if( m_bMute ) return true;
	if (m_pDSB == NULL) return false;

	DWORD pos = 0;
	m_pDSB->GetCurrentPosition(&pos, NULL);
	m_nCurSection = ((int)pos < m_nBufSize) ? 0:1;

	if (m_nCurSection != m_nLastSection)
	{
		if (m_bDone && !m_bLoop) 
		{
			if (m_bOpened)
			{
				if (m_bPlaying)
				{
					ov_pcm_seek(&m_vf, 0);
					m_pDSB->Stop();
					m_bPlaying = false;
				}
			}

			return false;
		}
		if (m_bAlmostDone && !m_bLoop) m_bDone = true;

		WriteStream(m_nBufSize);
	}

	return true;
}
开发者ID:MagistrAVSH,项目名称:node3d,代码行数:32,代码来源:RealSoundOgg.cpp

示例7: ov_pcm_seek

	void OGG_Source::rewind()
	{
		if (this->streamOpen)
		{
			ov_pcm_seek(&this->oggStream, 0);
		}
	}
开发者ID:Ioleynikov,项目名称:libxal,代码行数:7,代码来源:OGG_Source.cpp

示例8: ov_info

	bool OGG_Source::open()
	{
		Source::open();
		if (!this->streamOpen)
		{
			return false;
		}
		// setting the special callbacks
		ov_callbacks callbacks;
		callbacks.read_func = &_dataRead;
		callbacks.seek_func = &_dataSeek;
		callbacks.close_func = &_dataClose; // may not be NULL because it may crash on Android otherwise
		callbacks.tell_func = &_dataTell;
		if (ov_open_callbacks((void*)this->stream, &this->oggStream, NULL, 0, callbacks) == 0)
		{
			vorbis_info* info = ov_info(&this->oggStream, -1);
			this->channels = (int)info->channels;
			this->samplingRate = (int)info->rate;
			this->bitsPerSample = 16; // always 16 bit data
			int logicalSamples = (int)ov_pcm_total(&this->oggStream, -1);
			this->size = logicalSamples * this->channels * this->bitsPerSample / 8;
			this->duration = (float)logicalSamples / this->samplingRate;
			ov_pcm_seek(&this->oggStream, 0); // make sure the PCM stream is at the beginning to avoid nasty surprises
		}
		else
		{
			hlog::error(logTag, "OGG: error reading data!");
			this->close();
		}
		return this->streamOpen;
	}
开发者ID:Ioleynikov,项目名称:libxal,代码行数:31,代码来源:OGG_Source.cpp

示例9: Stop

bool C4MusicFileOgg::Play(bool loop)
{
	// Valid file?
	if (!loaded) return false;
	// stop previous
	Stop();
	// Get channel to use
	alGenSources(1, (ALuint*)&channel);
	if (!channel) return false;

	playing = true;
	streaming_done = false;
	this->loop = loop;
	byte_pos_total = 0;

	// initial volume setting
	SetVolume(float(::Config.Sound.MusicVolume) / 100.0f);

	// prepare read
	ogg_info.sound_data.resize(num_buffers * buffer_size);
	alGenBuffers(num_buffers, buffers);
	ov_pcm_seek(&ogg_file, 0);

	// Fill initial buffers
	for (size_t i=0; i<num_buffers; ++i)
		if (!FillBuffer(i)) break; // if this fails, the piece is shorter than the initial buffers

	// play!
	alErrorCheck(alSourcePlay(channel));
	
	return true;
}
开发者ID:Meowtimer,项目名称:openclonk,代码行数:32,代码来源:C4MusicFile.cpp

示例10: qDebug

long SoundSourceOggVorbis::seek(long filepos)
{
    // In our speak, filepos is a sample in the file abstraction (i.e. it's
    // stereo no matter what). filepos/2 is the frame we want to seek to.
    if (filepos % 2 != 0) {
        qDebug() << "SoundSourceOggVorbis got non-even seek target.";
        filepos--;
    }

    if (ov_seekable(&vf)) {
        if (ov_pcm_seek(&vf, filepos/2) != 0) {
            // This is totally common (i.e. you're at EOF). Let's not leave this
            // qDebug on.

            // qDebug() << "ogg vorbis: Seek ERR on seekable.";
        }

        // Even if an error occured, return them the current position because
        // that's what we promised. (Double it because ov_pcm_tell returns
        // frames and we pretend to the world that everything is stereo)
        return ov_pcm_tell(&vf) * 2;
    } else {
        qDebug() << "ogg vorbis: Seek ERR at file " << getFilename();
        return 0;
    }
}
开发者ID:calabrhoouse,项目名称:mixxx,代码行数:26,代码来源:soundsourceoggvorbis.cpp

示例11: requestSize

	//-------------------------------------------------------------------------------------------------------
	//
	std::shared_ptr<char> ogg_reader::read(size_t bufferSize, uint64_t *readBytes) {
		char* buffer = new char[bufferSize];
		int requestSize(bufferSize);
		int bitStream(0);
		long readSize(0);
		uint32_t comSize(0);
		while (true) {
			readSize = ov_read(&vorbisFile_, buffer + comSize, requestSize, 0, 2, 1, &bitStream);
			// 曲が終わってた
			if (!readSize) {
				ov_pcm_seek(&vorbisFile_, 0);
				break;
			}

			// 書き込んだサイズを加える
			comSize += readSize;
			
			// 波形データ配列の次の書き込み位置がバッファサイズを超えてたらループを抜ける
			if (comSize >= bufferSize) {
				break;
			}
			// バッファを全部書き込んでなかったら次の書き込み要求サイズをバッファサイズから書き込んだサイズを引いたものにする
			if (bufferSize - comSize < 4096) {
				requestSize = bufferSize - comSize;
			}
		}
		*readBytes = comSize;
		//スマートポインタの管理下に置く
		return std::shared_ptr<char>(
			buffer, std::default_delete<char[]>());
	}
开发者ID:thayamizu,项目名称:Nyx,代码行数:33,代码来源:OggReader.cpp

示例12: cvorbis_seek_sample

static int
cvorbis_seek_sample (DB_fileinfo_t *_info, int sample) {
    ogg_info_t *info = (ogg_info_t *)_info;
    if (sample < 0) {
        trace ("vorbis: negative seek sample - ignored, but it is a bug!\n");
        return -1;
    }
    if (!info->info.file) {
        trace ("vorbis: file is NULL on seek\n");
        return -1;
    }
    if (sample == 0) {
        deadbeef->pl_lock ();
        const char *filetype = deadbeef->pl_find_meta_raw(info->it, ":FILETYPE");
        if (filetype && strncmp(filetype, "Ogg Vorbis", 10)) {
            sample = 1; // workaround libvorbis bug #1486 (ddb issue #1116)
        }
        deadbeef->pl_unlock ();
    }
    sample += info->it->startsample;
    trace ("vorbis: seek to sample %d\n", sample);
    int res = ov_pcm_seek (&info->vorbis_file, sample);
    if (res != 0 && res != OV_ENOSEEK) {
        trace ("vorbis: error %x seeking to sample %d\n", res, sample);
        return -1;
    }
    int tell = ov_pcm_tell (&info->vorbis_file);
    if (tell != sample) {
        trace ("vorbis: failed to do sample-accurate seek (%d->%d)\n", sample, tell);
    }
    trace ("vorbis: seek successful\n")
    _info->readpos = (float)(sample - info->it->startsample)/_info->fmt.samplerate;
    info->next_update = -2;
    return 0;
}
开发者ID:saivert,项目名称:deadbeef,代码行数:35,代码来源:vorbis.c

示例13: l

void OggAudioSource::setDecoderPosition(Int64 startFrame)
{
	RScopedLock l(&mDecodeLock);

	ov_pcm_seek(&mOggFile, startFrame * getNumChannels());
	if(startFrame < getLength() * getSampleRate())
		mEOF = false;
}
开发者ID:Chenhx,项目名称:moai-dev,代码行数:8,代码来源:OggAudioSource.cpp

示例14: SeekVorbisStream

void SeekVorbisStream(MFAudioStream *pStream, float seconds)
{
	MFVorbisStream *pVS = (MFVorbisStream*)pStream->pStreamData;
#if defined(VORBIS_TREMOR)
	ov_pcm_seek(&pVS->vorbisFile, (ogg_int64_t)(seconds*(float)pVS->pInfo->rate));
#else
	ov_time_seek(&pVS->vorbisFile, seconds);
#endif
}
开发者ID:RemedyGameJam,项目名称:fuji,代码行数:9,代码来源:MFSound_Vorbis.cpp

示例15: alGenBuffers

        void OggFileStream::init(const ALuint& source,
                                 const int& position_in_file,
                                 const int& position_in_buffer,
                                 const bool& is_event)
        {
          // create buffers for reading in flip mode
          alGenBuffers(2,m_buffers) ;
          
          InternalMessage("Sound", "enter oggreader Init") ;

          // Create Ogg Stream on the file
          m_stream = new OggVorbis_File() ;
          int error = ov_fopen((char*)m_file_name.c_str(),m_stream) ;
          if (error < 0)
          {
            ErrorMessage("[OpenAL::OggReader] Can't read the samples") ;
            return ;
          }

          // Get sound information
          vorbis_info* Infos = ov_info(m_stream,-1) ;

          m_sample_rate = Infos->rate ;
          m_samples_by_buffer = (ALsizei)(Infos->channels * Infos->rate * m_update_time) ;
          switch (Infos->channels)
          {
          case 1:
            m_format = AL_FORMAT_MONO16 ;
            break;
          case 2:
            m_format = AL_FORMAT_STEREO16 ;
            break;
          default:
            ErrorMessage("[OpenAL::OggReader] Audio Format audio not supported (more than 2 channel)") ;
            return ;
          }

          int pos = 0 ;
          if (position_in_file > 0)
          {
            pos = position_in_file-m_samples_by_buffer+position_in_buffer+1 ;
          }
          ov_pcm_seek(m_stream,pos) ;

          // Load the buffers
          loadBuffer(m_buffers[0],is_event) ;
          loadBuffer(m_buffers[1],is_event) ;
          alSourceQueueBuffers(source,2,m_buffers) ;
          if (alGetError() != AL_NO_ERROR)
          {
            InformationMessage("Sound",
                "[OpenAL::OggReader] Impossible to queue the buffers") ;
            return ;
          }

          InternalMessage("Sound", "leave oggreader Init") ;
        }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:57,代码来源:ogg_file_stream.cpp


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