本文整理汇总了C++中AudioStream::SetBlockAlign方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioStream::SetBlockAlign方法的具体用法?C++ AudioStream::SetBlockAlign怎么用?C++ AudioStream::SetBlockAlign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioStream
的用法示例。
在下文中一共展示了AudioStream::SetBlockAlign方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetMediaReffed
//.........这里部分代码省略.........
ReportErrorOccurred ("Could not open Mp3 demuxer: invalid ID3 tag.");
return;
}
size = (size << 7) | buffer[6 + i];
}
if ((buffer[5] & (1 << 4))) {
// add additional 10 bytes for footer
size += 20;
} else
size += 10;
// MPEG stream data starts at the end of the ID3 tag
stream_start = (gint64) size;
} else {
stream_start = 0;
}
/* Seek to the stream start */
if (stream_start > 0) {
/* We're still at position 0, so no need to do anything if stream_start is also 0 */
if (stream_start > open_source->GetSize ()) {
/* Not enough data, request more */
if (!RequestMoreData (OpenDemuxerCallback)) {
ReportErrorOccurred ("Could not open Mp3 demuxer: could not seek to end of ID3 tag.");
return;
}
}
open_source->SeekOffset (stream_start);
}
// There can be an "arbitrary" amount of garbage at the
// beginning of an mp3 stream, so we need to find the first
// MPEG sync header by scanning.
vbr.type = MpegNoVBRHeader;
if (!Mp3FrameReader::FindMpegHeader (&mpeg, &vbr, open_source)) {
/* Could not find a header with the available data */
/* Seek back to 0, read more data, and try again */
/* TODO: store the current state and only read new data to avoid seeking back here */
open_source->SeekSet (0);
if (!RequestMoreData (OpenDemuxerCallback)) {
/* This should not happen, we should be able to seek back to 0 */
ReportErrorOccurred ("Could not open Mp3 demuxer: error while seeking to start point.");
}
return;
}
if (vbr.type == MpegNoVBRHeader) {
// calculate the frame length
len = mpeg_frame_length (&mpeg);
if ((end = source->GetSize ()) != -1) {
// estimate the number of frames
nframes = ((double) end - (double) stream_start) / (double) len;
} else {
nframes = 0;
}
} else {
// calculate the frame length
len = mpeg_frame_length (&mpeg);
nframes = vbr.nframes;
}
// calculate the duration of the first frame
duration = mpeg_frame_duration (&mpeg);
media = GetMediaReffed ();
stream = audio = new AudioStream (media);
media->unref ();
media = NULL;
reader = new Mp3FrameReader (this, source, audio, stream_start, len, duration, nframes);
audio->SetCodecId (CODEC_MP3);
audio->SetDuration (duration * nframes);
audio->SetBitRate (mpeg.bit_rate);
audio->SetChannels (mpeg.channels);
audio->SetSampleRate (mpeg.sample_rate);
audio->SetBlockAlign (mpeg_block_size (&mpeg));
audio->SetBitsPerSample (mpeg.layer == 1 ? 32 : 8);
audio->SetExtraData (NULL);
audio->SetExtraDataSize (0);
streams = g_new (IMediaStream *, 2);
streams[0] = stream;
streams[1] = NULL;
stream_count = 1;
SetStreams (streams, stream_count);
stream->unref ();
this->current_source = open_source;
this->current_source->ref ();
LOG_MP3 ("Mp3Demuxer::OpenDemuxer (): Version: %s Layer: %u VBR: %s Duration: %" G_GUINT64_FORMAT " ms Bit rate: %u Channels: %u Sample Rate: %u Block Align: %u Bits per sample: %u Number of frames: %.2f Frame length: %.2f\n",
mpeg.version == 3 ? "2.5" : (mpeg.version == 2 ? "2" : "1"), mpeg.layer, vbr.type == MpegNoVBRHeader ? "No" : (vbr.type == MpegXingHeader ? "Xing" : "VBRI"), MilliSeconds_FromPts (audio->GetDuration ()), audio->GetBitRate (), audio->GetChannels (), audio->GetSampleRate (), audio->GetBlockAlign (), audio->GetBitsPerSample (), nframes, len);
ReportOpenDemuxerCompleted ();
}