• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ov_open_callbacks函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: file

OggSoundFile::OggSoundFile(PHYSFS_file* file_, double loop_begin_, double loop_at_) :
  file(),
  vorbis_file(),
  loop_begin(),
  loop_at(),
  normal_buffer_loop()
{
  this->file = file_;

  ov_callbacks callbacks = { cb_read, cb_seek, cb_close, cb_tell };
  ov_open_callbacks(file, &vorbis_file, 0, 0, callbacks);

  vorbis_info* vi = ov_info(&vorbis_file, -1);

  channels        = vi->channels;
  rate            = vi->rate;
  bits_per_sample = 16;
  size            = static_cast<size_t> (ov_pcm_total(&vorbis_file, -1) * 2);

  double samples_begin = loop_begin_ * rate;
  double sample_loop   = loop_at_ * rate;

  this->loop_begin     = (ogg_int64_t) samples_begin;
  if(loop_begin_ < 0) {
    this->loop_at = (ogg_int64_t) -1;
  } else {
    this->loop_at = (ogg_int64_t) sample_loop;
  }
}
开发者ID:ACMEware,项目名称:Paper-Hurricane,代码行数:29,代码来源:ogg_sound_file.cpp


示例2: StreamingBuffer

//----------------------------------------------------------------------------//
OggStream::OggStream(const Ogre::String& name, SoundSource* source, int bufferCount) :
    StreamingBuffer(name, source, bufferCount)
{
    ov_callbacks vorbisCallbacks;

    // read file to memory
    mStream = Ogre::ResourceGroupManager::getSingleton().openResource(name);

    // open ogg stream
    vorbisCallbacks.read_func = OggBuffer::vorbisRead;
    vorbisCallbacks.close_func = OggBuffer::vorbisClose;
    vorbisCallbacks.seek_func = OggBuffer::vorbisSeek;
    vorbisCallbacks.tell_func = OggBuffer::vorbisTell;
    if (ov_open_callbacks(&mStream, &mOggStream, nullptr, 0, vorbisCallbacks) < 0)
    {
        throw Ogre::Exception(1, "Could not open Ogg stream.",__FUNCTION__);
    }

    mVorbisInfo = ov_info(&mOggStream, -1);
    mVorbisComment = ov_comment(&mOggStream, -1);

    mChannels = mVorbisInfo->channels;
    mFrequency = mVorbisInfo->rate;
    mDuration = float(ov_time_total(&mOggStream, -1));
    mBits = 16;

    if(mChannels == 1)
        mFormat = AL_FORMAT_MONO16;
    else
        mFormat = AL_FORMAT_STEREO16;
    mSize = mDuration * float(mBits * mFrequency * mChannels) /  8.0f;
}
开发者ID:drwbns,项目名称:1stperson,代码行数:33,代码来源:SoundStreamingBuffer.cpp


示例3: memset

RageSoundReader_FileReader::OpenResult RageSoundReader_Vorbisfile::Open( RageFileBasic *pFile )
{
	m_pFile = pFile;
	vf = new OggVorbis_File;
	memset( vf, 0, sizeof(*vf) );

	ov_callbacks callbacks;
	callbacks.read_func  = OggRageFile_read_func;
	callbacks.seek_func  = OggRageFile_seek_func;
	callbacks.close_func = OggRageFile_close_func;
	callbacks.tell_func  = OggRageFile_tell_func;

	int ret = ov_open_callbacks( pFile, vf, NULL, 0, callbacks );
	if( ret < 0 )
	{
		SetError( ov_ssprintf(ret, "ov_open failed") );
		delete vf;
		vf = NULL;
		switch( ret )
		{
		case OV_ENOTVORBIS:
			return OPEN_UNKNOWN_FILE_FORMAT;
		default:
			return OPEN_FATAL_ERROR;
		}
	}

	eof = false;
	read_offset = (int) ov_pcm_tell(vf);

	vorbis_info *vi = ov_info( vf, -1 );
	channels = vi->channels;

	return OPEN_OK;
}
开发者ID:AratnitY,项目名称:stepmania,代码行数:35,代码来源:RageSoundReader_Vorbisfile.cpp


示例4: ogg_vorbis_open

/*!
 * \brief Create a new OGG/Vorbis filestream and set it up for reading.
 * \param s File that points to on disk storage of the OGG/Vorbis data.
 * \return The new filestream.
 */
static int ogg_vorbis_open(struct ast_filestream *s)
{
	int result;
	struct ogg_vorbis_desc *desc = (struct ogg_vorbis_desc *) s->_private;

	/* initialize private description block */
	memset(desc, 0, sizeof(struct ogg_vorbis_desc));
	desc->writing = 0;

	/* actually open file */
	result = ov_open_callbacks(s->f, &desc->ov_f, NULL, 0, OV_CALLBACKS_NOCLOSE);
	if (result != 0) {
		ast_log(LOG_ERROR, "Error opening Ogg/Vorbis file stream.\n");
		return -1;
	}

	/* check stream(s) type */
	if (desc->ov_f.vi->channels != 1) {
		ast_log(LOG_ERROR, "Only monophonic OGG/Vorbis files are currently supported!\n");
		ov_clear(&desc->ov_f);
		return -1;
	}

	if (desc->ov_f.vi->rate != DEFAULT_SAMPLE_RATE) {
		ast_log(LOG_ERROR, "Only 8000Hz OGG/Vorbis files are currently supported!\n");
		ov_clear(&desc->ov_f);
		return -1;
	}

	return 0;
}
开发者ID:bugrahantopall,项目名称:asterisk,代码行数:36,代码来源:format_ogg_vorbis.c


示例5: Decoder

	VorbisDecoder::VorbisDecoder(Data * data, const std::string & ext, int bufferSize)
		: Decoder(data, ext, bufferSize)
	{
		// Initialize callbacks
		vorbisCallbacks.close_func = vorbisClose;
		vorbisCallbacks.seek_func  = vorbisSeek;
		vorbisCallbacks.read_func  = vorbisRead;
		vorbisCallbacks.tell_func  = vorbisTell;

		// Check endianness
#ifdef LOVE_BIG_ENDIAN
		endian = 1;
#else
		endian = 0;
#endif

		// Initialize OGG file
		oggFile.dataPtr = (char *) data->getData();
		oggFile.dataSize = data->getSize();
		oggFile.dataRead = 0;

		// Open Vorbis handle
		if(ov_open_callbacks(&oggFile, &handle, NULL, 0, vorbisCallbacks) < 0)
			throw love::Exception("Could not read Ogg bitstream");

		// Get info and comments
		vorbisInfo = ov_info(&handle, -1);
		vorbisComment = ov_comment(&handle, -1);
	}
开发者ID:leafo,项目名称:moonscript-love,代码行数:29,代码来源:VorbisDecoder.cpp


示例6: ov_open_callbacks

unsigned int OggResourceLoader::VGetLoadedResourceSize(char *rawBuffer, unsigned int rawSize){
	OggVorbis_File vf;

	ov_callbacks oggCallbacks;

	OggMemoryFile *vorbisMemoryFile = new OggMemoryFile;
	vorbisMemoryFile->dataRead = 0;
	vorbisMemoryFile->dataSize = rawSize;
	vorbisMemoryFile->dataPtr = (unsigned char *)rawBuffer;

	oggCallbacks.read_func = VorbisRead;
	oggCallbacks.close_func = VorbisClose;
	oggCallbacks.seek_func = VorbisSeek;
	oggCallbacks.tell_func = VorbisTell;

	int ov_ret = ov_open_callbacks(vorbisMemoryFile, &vf, NULL, 0, oggCallbacks);
	//DEBUG_LOG(ov_ret >= 0);

	//read in vorbis
	vorbis_info *vi = ov_info(&vf, -1);
	DWORD size = 4096 * 16;
	DWORD pos = 0;
	int sec = 0;
	int ret = 1;

	DWORD bytes = (DWORD)ov_pcm_total(&vf, -1);
	bytes *= 2 * vi->channels;

	ov_clear(&vf);

	SafeDelete(vorbisMemoryFile);

	return bytes;
}
开发者ID:ljkd,项目名称:SAGE,代码行数:34,代码来源:SoundResource.cpp


示例7: logg_open_file_for_streaming

static int logg_open_file_for_streaming(LOGG_Stream* s)
{
	FILE* file;
	vorbis_info* vi;

	file = fopen(s->filename, "rb");
	if (!file) {
		uszprintf(allegro_error, ALLEGRO_ERROR_SIZE, "Unable to open file: %s", s->filename);
		return 1;
	}

	if (ov_open_callbacks(file, &s->ovf, 0, 0, OV_CALLBACKS_DEFAULT) != 0) {
		strncpy(allegro_error, "ov_open_callbacks failed.", ALLEGRO_ERROR_SIZE);
		fclose(file);
		return 1;
	}

	vi = ov_info(&s->ovf, -1);

	s->bits = 16;
	s->stereo = vi->channels > 1 ? 1 : 0;
	s->freq = vi->rate;
	s->len = ov_pcm_total(&s->ovf, -1);

	return 0;
}
开发者ID:AntonLanghoff,项目名称:whitecatlib,代码行数:26,代码来源:logg.c


示例8: CI_ASSERT

void SourceFileImplOggVorbis::init()
{
	CI_ASSERT( mDataSource );
	if( mDataSource->isFilePath() ) {
		int status = ov_fopen( mDataSource->getFilePath().string().c_str(), &mOggVorbisFile );
		if( status )
			throw AudioFileExc( string( "Failed to open Ogg Vorbis file with error: " ), (int32_t)status );
	}
	else {
		mStream = mDataSource->createStream();

		ov_callbacks callbacks;
		callbacks.read_func = readFn;
		callbacks.seek_func = seekFn;
		callbacks.close_func = closeFn;
		callbacks.tell_func = tellFn;

		int status = ov_open_callbacks( this, &mOggVorbisFile, NULL, 0, callbacks );
		CI_ASSERT( status == 0 );
	}

	vorbis_info *info = ov_info( &mOggVorbisFile, -1 );
    mSampleRate = mNativeSampleRate = info->rate;
    mNumChannels = mNativeNumChannels = info->channels;

	ogg_int64_t totalFrames = ov_pcm_total( &mOggVorbisFile, -1 );
    mNumFrames = mFileNumFrames = static_cast<uint32_t>( totalFrames );
}
开发者ID:tmatma,项目名称:Cinder-Audio2,代码行数:28,代码来源:FileOggVorbis.cpp


示例9: CreateFromMemory

OggAudio* OggAudio::CreateFromMemory(const FileIdRef& fileId, MemoryData data)
{

    ov_callbacks callbacks;
    callbacks.read_func = ogg_read_func;
    callbacks.seek_func = ogg_seek_func;
    callbacks.close_func = ogg_close_func;
    callbacks.tell_func = ogg_tell_func;

    OggVorbis_File vf;
    MemoryStream oggStream = MemoryStream::OpenRead(data);
    if (ov_open_callbacks(&oggStream, &vf, nullptr, 0, callbacks))
    {
        Log::FormatError("{} does not appear to be an Ogg bitstream.", fileId.Name);
        return nullptr;
    }

    vorbis_info* vi = ov_info(&vf, -1);
    uintp sampleCount = (uintp)ov_pcm_total(&vf, -1);
    bool seekable = ov_seekable(&vf)!=0;

    uint bigEndian = !BitConverter::IsLittle();
    int currentSection = 0;

    uintp pcmSize = sampleCount*vi->channels*sizeof(short);
    MemoryStream pcmSteam(pcmSize);

    while (true)
    {
        long readSize = ov_read(&vf, (char*)pcmSteam.MutablePtr(), (int)pcmSteam.LeftLength(), bigEndian, 2, 1, &currentSection);
        if (readSize == 0)
        {
            //end of file
            break;
        }
        else if (readSize > 0)
        {
            pcmSteam.Seek(readSize, SeekOrigin::Current);
        }
        else
        {
            if (readSize == OV_EBADLINK)
            {
                Log::FormatError("{} Corrupt bitstream section!", fileId.Name);
                return nullptr;

            }
        }
    }

    auto audioData = pcmSteam.CurrentBuffer();

    OggAudio* audio = new OggAudio(audioData, fileId);
    audio->SetSampleCount(sampleCount);
    audio->SetChannelCount(vi->channels);
    audio->SetSampleRate(vi->rate);
    audio->SetBitsPerSample(16);
    audio->SetSeekable(seekable);
    return audio;
}
开发者ID:fjz13,项目名称:Medusa,代码行数:60,代码来源:OggAudio.cpp


示例10: _inStream

VorbisStream::VorbisStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose) :
    _inStream(inStream),
    _disposeAfterUse(dispose),
    _length(0, 1000),
    _bufferEnd(_buffer + ARRAYSIZE(_buffer)) {

    int res = ov_open_callbacks(inStream, &_ovFile, NULL, 0, g_stream_wrap);
    if (res < 0) {
        warning("Could not create Vorbis stream (%d)", res);
        _pos = _bufferEnd;
        return;
    }

    // Read in initial data
    if (!refill())
        return;

    // Setup some header information
    _isStereo = ov_info(&_ovFile, -1)->channels >= 2;
    _rate = ov_info(&_ovFile, -1)->rate;

#ifdef USE_TREMOR
    _length = Timestamp(ov_time_total(&_ovFile, -1), getRate());
#else
    _length = Timestamp(uint32(ov_time_total(&_ovFile, -1) * 1000.0), getRate());
#endif
}
开发者ID:bluddy,项目名称:scummvm,代码行数:27,代码来源:vorbis.cpp


示例11: memset

	void OggWrapper::LoadFromMemory(char * data, int dataSize, SoundInfo * soundinfo)
	{
		oggFile_.curPtr = oggFile_.filePtr = data;
		oggFile_.fileSize = dataSize;

		ovFile_ = new OggVorbis_File;
		memset(ovFile_, 0, sizeof OggVorbis_File);

		ov_open_callbacks((void*)&oggFile_, ovFile_, nullptr, -1, callbacks_ogg);

		vorbis_info * vorbisinfo = ov_info(ovFile_, -1);
		memset(soundinfo, 0, sizeof SoundInfo);

		soundinfo->channels = vorbisinfo->channels;
		soundinfo->bitrateLower = vorbisinfo->bitrate_lower;
		soundinfo->bitrateUpper = vorbisinfo->bitrate_upper;
		soundinfo->bitrateNominal = vorbisinfo->bitrate_nominal;
		soundinfo->bitrateWindow = vorbisinfo->bitrate_window;
		soundinfo->frequency = vorbisinfo->rate;
		soundinfo->bpc = 16;

		if (ov_seekable(ovFile_) == 0)
		{
			soundinfo->seekable = false;
			seekable_ = false;
		}
		else
		{
			soundinfo->seekable = true;
			seekable_ = true;
		}
	}
开发者ID:Blake-Lead,项目名称:MyEngine,代码行数:32,代码来源:OggWrapper.cpp


示例12: vorbis_stream_decoder_open

int
vorbis_stream_decoder_open(decoder_t * dec, http_session_t * session) {

	vorbis_pdata_t * pd = (vorbis_pdata_t *)dec->pdata;
	file_decoder_t * fdec = dec->fdec;

	ov_callbacks ov_cb;
        ov_cb.read_func = read_vorbis_stream;
        ov_cb.seek_func = seek_vorbis_stream;
        ov_cb.close_func = close_vorbis_stream;
        ov_cb.tell_func = tell_vorbis_stream;

	if (ov_open_callbacks((void *)session, &(pd->vf), NULL, 0, ov_cb) != 0) {
		/* not an Ogg Vorbis stream */
		return DECODER_OPEN_BADLIB;
	}

	fdec->is_stream = 1;

	pd->session = session;
	dec->pause = pause_vorbis_stream;
	dec->resume = resume_vorbis_stream;

	return vorbis_decoder_finish_open(dec);
}
开发者ID:alex1818,项目名称:aqualung,代码行数:25,代码来源:dec_vorbis.c


示例13: VorbisAudioIO_loadOggVorbisData

PCMAudio * VorbisAudioIO_loadOggVorbisData(const void * data, size_t length) {
	struct memreadContext readContext;
	ov_callbacks callbacks;
	OggVorbis_File file;
	int status;
	vorbis_info * info;
	unsigned int channelCount;
	unsigned int sampleRate;
	unsigned int sampleCount;
	long readResult;
	struct memwriteContext writeContext;
	char buffer[BUFFER_SIZE];
	int currentSection;
	PCMAudio * audio;
	
	readContext = memreadContextInit(data, length);
	callbacks.read_func = VorbisAudioIO_memreadFunc;
	callbacks.seek_func = VorbisAudioIO_memseekFunc;
	callbacks.close_func = NULL;
	callbacks.tell_func = VorbisAudioIO_memtellFunc;
	status = ov_open_callbacks(&readContext, &file, NULL, 0, callbacks);
	if (status != 0) {
		fprintf(stderr, "Error: ov_open_callbacks returned %d\n", status);
		return NULL;
	}
	
	info = ov_info(&file, -1);
	if (info == NULL) {
		fprintf(stderr, "Error: ov_info returned NULL\n");
		return NULL;
	}
	channelCount = info->channels;
	sampleRate = info->rate;
	
	sampleCount = ov_pcm_total(&file, -1);
	
	writeContext = memwriteContextInit(malloc(1), 0, 1, true);
	for (;;) {
		readResult = ov_read(&file, buffer, BUFFER_SIZE, OV_READ_ENDIANNESS, 2, 1, &currentSection);
		if (readResult == 0) {
			break;
		}
		if (readResult < 0) {
			fprintf(stderr, "Error: ov_read returned %ld\n", readResult);
			break;
		}
		memwrite(&writeContext, readResult, buffer);
	}
	
	ov_clear(&file);
	if (readResult < 0) {
		free(writeContext.data);
		return NULL;
	}
	
	audio = PCMAudio_create(2, channelCount, sampleRate, sampleCount, writeContext.data, true);
	free(writeContext.data);
	return audio;
}
开发者ID:svn2github,项目名称:libstem,代码行数:59,代码来源:VorbisAudioIO.c


示例14: sizeof

void AudioSourceOJM::parseM30()
{
    M30Header Head;
    size_t sizeLeft;
    ifile->read(reinterpret_cast<char*>(&Head), sizeof(M30Header));

    std::vector<char> Buffer(Head.payload_size);
    sizeLeft = Head.payload_size;

    for (int i = 0; i < Head.sample_count; i++)
    {
        if (sizeLeft < 52)
            break; // wrong number of samples

        M30Entry Entry;
        ifile->read(reinterpret_cast<char*>(&Entry), sizeof(M30Entry));
        sizeLeft -= sizeof(M30Entry);

        sizeLeft -= Entry.sample_size;

        int OJMIndex = Entry.ref;
        if (Entry.codec_code == 0)
            OJMIndex += 1000;
        else if (Entry.codec_code != 5) continue; // Unknown sample id type.

        std::vector<char> SampleData(Entry.sample_size);
        ifile->read(&SampleData[0], Entry.sample_size);

        if (Head.encryption_flag & 16)
            NamiXOR(&SampleData[0], Entry.sample_size);
        else if (Head.encryption_flag & 32)
            F412XOR(&SampleData[0], Entry.sample_size);

        // Sample data is done. Now the bits that are specific to raindrop..
        auto NewSample = std::make_shared<SoundSample>();

        SFM30 ToLoad;
        ToLoad.Buffer = std::move(SampleData);
        ToLoad.DataLength = Entry.sample_size;

        OggVorbis_File vf;

        ov_open_callbacks(&ToLoad, &vf, nullptr, 0, M30InterfaceOgg);
        TemporaryState.File = &vf;
        TemporaryState.Info = vf.vi;

        if (vf.vi)
        {
            TemporaryState.Enabled = OJM_OGG;
            NewSample->SetPitch(Speed);
            NewSample->Open(this);
            TemporaryState.Enabled = 0;
        }

        ov_clear(&vf);

        Arr[OJMIndex] = NewSample;
    }
}
开发者ID:TomoAlien,项目名称:raindrop,代码行数:59,代码来源:AudioSourceOJM.cpp


示例15: S_OpenBackgroundTrack

/*
=================
S_OpenBackgroundTrack
=================
*/
static qboolean S_OpenBackgroundTrack (char *name, bgTrack_t *track)
{
	OggVorbis_File	*vorbisFile;
	vorbis_info		*vorbisInfo;
	ov_callbacks	vorbisCallbacks = {ovc_read, ovc_seek, ovc_close, ovc_tell};
#ifdef OGG_DIRECT_FILE
	char	filename[1024];
	char	*path = NULL;
#endif

//	Com_Printf("Opening background track: %s\n", name);

#ifdef OGG_DIRECT_FILE
	do {
		path = FS_NextPath( path );
		Com_sprintf( filename, sizeof(filename), "%s/%s", path, name );
		if ( (track->file = fopen(filename, "rb")) != 0)
			break;
	} while ( path );
#else
	FS_FOpenFile(name, &track->file);
#endif
	if (!track->file)
	{
		Com_Printf("S_OpenBackgroundTrack: couldn't find %s\n", name);
		return false;
	}

	track->vorbisFile = vorbisFile = Z_Malloc(sizeof(OggVorbis_File));

//	Com_Printf("Opening callbacks for background track\n");

	// bombs out here- ovc_read, FS_Read 0 bytes error
	if (ov_open_callbacks(track, vorbisFile, NULL, 0, vorbisCallbacks) < 0)
	{
		Com_Printf("S_OpenBackgroundTrack: couldn't open OGG stream (%s)\n", name);
		return false;
	}

//	Com_Printf("Getting info for background track\n");

	vorbisInfo = ov_info(vorbisFile, -1);
	if (vorbisInfo->channels != 1 && vorbisInfo->channels != 2)
	{
		Com_Printf("S_OpenBackgroundTrack: only mono and stereo OGG files supported (%s)\n", name);
		return false;
	}

	track->start = ov_raw_tell(vorbisFile);
	track->rate = vorbisInfo->rate;
	track->width = 2;
	track->channels = vorbisInfo->channels; // Knightmare added
	track->format = (vorbisInfo->channels == 2) ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16;

//	Com_Printf("Vorbis info: frequency: %i channels: %i bitrate: %i\n",
//		vorbisInfo->rate, vorbisInfo->channels, vorbisInfo->bitrate_nominal);

	return true;
}
开发者ID:qbism,项目名称:Quake2-colored-refsoft,代码行数:64,代码来源:snd_stream.c


示例16: main

int main(){
  OggVorbis_File vf;
  int eof=0;
  int current_section;

#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */
  /* Beware the evil ifdef. We avoid these where we can, but this one we 
     cannot. Don't add any more, you'll probably go to hell if you do. */
  _setmode( _fileno( stdin ), _O_BINARY );
  _setmode( _fileno( stdout ), _O_BINARY );
#endif

  if(ov_open_callbacks(stdin, &vf, NULL, 0, OV_CALLBACKS_NOCLOSE) < 0) {
      fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
      exit(1);
  }

  /* Throw the comments plus a few lines about the bitstream we're
     decoding */
  {
    char **ptr=ov_comment(&vf,-1)->user_comments;
    vorbis_info *vi=ov_info(&vf,-1);
    while(*ptr){
      fprintf(stderr,"%s\n",*ptr);
      ++ptr;
    }
    fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate);
    fprintf(stderr,"\nDecoded length: %ld samples\n",
            (long)ov_pcm_total(&vf,-1));
    fprintf(stderr,"Encoded by: %s\n\n",ov_comment(&vf,-1)->vendor);
  }
  
  while(!eof){
    long ret=ov_read(&vf,pcmout,sizeof(pcmout),0,2,1,&current_section);
    if (ret == 0) {
      /* EOF */
      eof=1;
    } else if (ret < 0) {
      if(ret==OV_EBADLINK){
        fprintf(stderr,"Corrupt bitstream section! Exiting.\n");
        exit(1);
      }

      /* some other error in the stream.  Not a problem, just reporting it in
         case we (the app) cares.  In this case, we don't. */
    } else {
      /* we don't bother dealing with sample rate changes, etc, but
         you'll have to*/
      fwrite(pcmout,1,ret,stdout);
    }
  }

  /* cleanup */
  ov_clear(&vf);
    
  fprintf(stderr,"Done.\n");
  return(0);
}
开发者ID:0w,项目名称:moai-dev,代码行数:58,代码来源:vorbisfile_example.c


示例17: S_VORBIS_CodecOpenStream

static qboolean S_VORBIS_CodecOpenStream (snd_stream_t *stream)
{
	OggVorbis_File *ovFile;
	vorbis_info *ovf_info;
	long numstreams;
	int res;

	ovFile = (OggVorbis_File *) Z_Malloc(sizeof(OggVorbis_File), Z_MAINZONE);
	stream->priv = ovFile;
	res = ov_open_callbacks(&stream->fh, ovFile, NULL, 0, ovc_qfs);
	if (res != 0)
	{
		Con_Printf("%s is not a valid Ogg Vorbis file (error %i).\n",
				stream->name, res);
		goto _fail;
	}

	if (!ov_seekable(ovFile))
	{
		Con_Printf("Stream %s not seekable.\n", stream->name);
		goto _fail;
	}

	ovf_info = ov_info(ovFile, 0);
	if (!ovf_info)
	{
		Con_Printf("Unable to get stream info for %s.\n", stream->name);
		goto _fail;
	}

	/* FIXME: handle section changes */
	numstreams = ov_streams(ovFile);
	if (numstreams != 1)
	{
		Con_Printf("More than one (%ld) stream in %s.\n",
					numstreams, stream->name);
		goto _fail;
	}

	if (ovf_info->channels != 1 && ovf_info->channels != 2)
	{
		Con_Printf("Unsupported number of channels %d in %s\n",
					ovf_info->channels, stream->name);
		goto _fail;
	}

	stream->info.rate = ovf_info->rate;
	stream->info.channels = ovf_info->channels;
	stream->info.bits = VORBIS_SAMPLEBITS;
	stream->info.width = VORBIS_SAMPLEWIDTH;

	return true;
_fail:
	if (res == 0)
		ov_clear(ovFile);
	Z_Free(ovFile);
	return false;
}
开发者ID:svn2github,项目名称:uhexen2,代码行数:58,代码来源:snd_vorbis.c


示例18: while

int AudioStreamPlaybackOGGVorbis::mix(int16_t* p_bufer,int p_frames) {

	if (!playing)
		return 0;

	int total=p_frames;
	while (true) {

		int todo = p_frames;

		if (todo==0 || todo<MIN_MIX) {
			break;
		}

		//printf("to mix %i - mix me %i bytes\n",to_mix,to_mix*stream_channels*sizeof(int16_t));

		#ifdef BIG_ENDIAN_ENABLED
		long ret=ov_read(&vf,(char*)p_bufer,todo*stream_channels*sizeof(int16_t), 1, 2, 1, &current_section);
		#else
		long ret=ov_read(&vf,(char*)p_bufer,todo*stream_channels*sizeof(int16_t), 0, 2, 1, &current_section);
		#endif

		if (ret<0) {

			playing = false;
			ERR_EXPLAIN("Error reading OGG Vorbis File: "+file);
			ERR_BREAK(ret<0);
		} else if (ret==0) { // end of song, reload?

			ov_clear(&vf);

			_close_file();

			if (!has_loop()) {

				playing=false;
				repeats=1;
				break;
			}

			f=FileAccess::open(file,FileAccess::READ);

			int errv = ov_open_callbacks(f,&vf,NULL,0,_ov_callbacks);
			if (errv!=0) {
				playing=false;
				break;; // :(
			}

			if (loop_restart_time) {
				bool ok = ov_time_seek(&vf,loop_restart_time)==0;
				if (!ok) {
					playing=false;
					//ERR_EXPLAIN("loop restart time rejected");
					ERR_PRINT("loop restart time rejected")
				}

				frames_mixed=stream_srate*loop_restart_time;
			} else {
开发者ID:lonesurvivor,项目名称:godot,代码行数:58,代码来源:audio_stream_ogg_vorbis.cpp


示例19: ov_open_callbacks

bool OggStream::open(const MessageAudio &ma)
{
    mCallbacks.read_func = MessageAudio_read;
    mCallbacks.close_func = MessageAudio_close;
    mCallbacks.seek_func = MessageAudio_seek;
    mCallbacks.tell_func = MessageAudio_tell;

    currentAudio = ma;
    int audioid = ma.getAudioid();
    int error = ov_open_callbacks(&currentAudio, &mStream, NULL, 0, mCallbacks);

    ostringstream oss;
    oss << "MessageAudio:" << audioid;
    mStreamInfo = oss.str();

    if(error) {
        switch(error) {
            case OV_EREAD:
                LOG4CXX_ERROR(narratorOsLog, "MessageAudio id: " << audioid << " A read from media returned an error");
                break;
            case OV_ENOTVORBIS:
                LOG4CXX_ERROR(narratorOsLog, "MessageAudio id: " << audioid << " Bitstream is not Vorbis data");
                break;
            case OV_EVERSION:
                LOG4CXX_ERROR(narratorOsLog, "MessageAudio id: " << audioid << " Vorbis version mismatch");
                break;
            case OV_EBADHEADER:
                LOG4CXX_ERROR(narratorOsLog, "MessageAudio id: " << audioid << " Invalid Vorbis bitstream header");
                break;
            case OV_EFAULT:
                LOG4CXX_ERROR(narratorOsLog, "MessageAudio id: " << audioid<< " Internal logic fault");
                break;
            default:
                LOG4CXX_ERROR(narratorOsLog, "MessageAudio id: " << audioid << " unknown error occurred");
                break;
        }
        return false;
    }

    vorbis_info *vi = ov_info(&mStream,-1);

    isOpen = true;
    mChannels = vi->channels;
    mRate = vi->rate;

    /*
       char **ptr = ov_comment(&mStream,-1)->user_comments;
       while(*ptr){
       LOG4CXX_DEBUG(narratorOsLog, "comment: " << *ptr);
       ++ptr;
       }

       size_t total_size = ov_pcm_total(&mStream, -1);
       LOG4CXX_DEBUG(narratorOsLog, "total size: " << total_size);
       */
    return true;
}
开发者ID:nossrf,项目名称:libkolibre-narrator,代码行数:57,代码来源:OggStream.cpp


示例20: Sound_OpenBGTrack

/**
 * \brief OGG read Callback.
 * \param[in] name File name to open.
 * \param[in/out] Music track data structure.
 * \return False on error, otherwise true.
 * \note
 */
PRIVATE _boolean Sound_OpenBGTrack( const char *name, musicTrack_t *track )
{
	OggVorbis_File	*vorbisFile;
	vorbis_info		*vorbisInfo;
	ov_callbacks	vorbisCallbacks = {ovc_read, ovc_seek, ovc_close, ovc_tell};
	int ret;

	track->hFile = FS_OpenFile( name, 0 );
	if( ! track->hFile )
	{
		return false;
	}


	track->vorbisFile = vorbisFile = Z_Malloc( sizeof( OggVorbis_File ) );

	if( (ret = ov_open_callbacks( track, vorbisFile, NULL, 0, vorbisCallbacks )) < 0 )
	{
		switch( ret )
		{
			case OV_EREAD:
				Com_DPrintf( "A read from media returned an error.(%s)\n", name );
				break;
			case OV_ENOTVORBIS:
				Com_DPrintf( "Bitstream is not Vorbis data.(%s)\n", name );
				break;
			case OV_EVERSION:
				Com_DPrintf( "Vorbis version mismatch.(%s)\n", name );
				break;
			case OV_EBADHEADER:
				Com_DPrintf( "Invalid Vorbis bitstream header.(%s)\n", name );
				break;
			case OV_EFAULT:
				Com_DPrintf( "Internal logic fault; indicates a bug or heap/stack corruption.(%s)\n", name );
				break;

		}
		Com_DPrintf( "Could not open OGG stream (%s)\n", name );

		return false;
	}

	vorbisInfo = ov_info( vorbisFile, -1 );
	if( vorbisInfo->channels != 1 && vorbisInfo->channels != 2 )
	{
		Com_DPrintf( "Only mono and stereo OGG files supported (%s)\n", name );

		return false;
	}

	track->start = ov_raw_tell( vorbisFile );
	track->rate = vorbisInfo->rate;
	track->format = (vorbisInfo->channels == 2) ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16;

	return true;
}
开发者ID:Oppen,项目名称:Wolf3DRedux,代码行数:63,代码来源:sound_stream.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ov_pcm_seek函数代码示例发布时间:2022-05-30
下一篇:
C++ ov_open函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap