2009-08-09 21:16:39 +00:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* ***** BEGIN LGPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* Copyright 2009 Jörg Hermann Müller
|
|
|
|
*
|
|
|
|
* This file is part of AudaSpace.
|
|
|
|
*
|
|
|
|
* AudaSpace is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* AudaSpace is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* ***** END LGPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
// needed for INT64_C
|
2010-07-28 09:36:03 +00:00
|
|
|
#ifndef __STDC_CONSTANT_MACROS
|
2009-08-09 21:16:39 +00:00
|
|
|
#define __STDC_CONSTANT_MACROS
|
2010-07-28 09:36:03 +00:00
|
|
|
#endif
|
2009-08-09 21:16:39 +00:00
|
|
|
|
|
|
|
#include "AUD_FFMPEGReader.h"
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
#include <libavformat/avformat.h>
|
|
|
|
}
|
|
|
|
|
2010-07-28 09:36:03 +00:00
|
|
|
int AUD_FFMPEGReader::decode(AVPacket* packet, AUD_Buffer& buffer)
|
2009-08-09 21:16:39 +00:00
|
|
|
{
|
|
|
|
// save packet parameters
|
|
|
|
uint8_t *audio_pkg_data = packet->data;
|
|
|
|
int audio_pkg_size = packet->size;
|
|
|
|
|
2010-07-28 09:36:03 +00:00
|
|
|
int buf_size = buffer.getSize();
|
2009-08-09 21:16:39 +00:00
|
|
|
int buf_pos = 0;
|
|
|
|
|
|
|
|
int read_length, data_size;
|
|
|
|
|
|
|
|
// as long as there is still data in the package
|
|
|
|
while(audio_pkg_size > 0)
|
|
|
|
{
|
|
|
|
// resize buffer if needed
|
|
|
|
if(buf_size - buf_pos < AVCODEC_MAX_AUDIO_FRAME_SIZE)
|
|
|
|
{
|
2010-07-28 09:36:03 +00:00
|
|
|
buffer.resize(buf_size + AVCODEC_MAX_AUDIO_FRAME_SIZE, true);
|
2009-08-09 21:16:39 +00:00
|
|
|
buf_size += AVCODEC_MAX_AUDIO_FRAME_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// read samples from the packet
|
|
|
|
data_size = buf_size - buf_pos;
|
2010-08-16 18:13:26 +00:00
|
|
|
/*read_length = avcodec_decode_audio3(m_codecCtx,
|
2010-07-28 09:36:03 +00:00
|
|
|
(int16_t*)(((data_t*)buffer.getBuffer())+buf_pos),
|
2009-08-09 21:16:39 +00:00
|
|
|
&data_size,
|
2010-08-16 18:13:26 +00:00
|
|
|
packet);*/
|
|
|
|
read_length = avcodec_decode_audio2(m_codecCtx,
|
|
|
|
(int16_t*)(((data_t*)buffer.getBuffer()) + buf_pos),
|
|
|
|
&data_size,
|
|
|
|
audio_pkg_data,
|
|
|
|
audio_pkg_size);
|
2009-08-09 21:16:39 +00:00
|
|
|
|
|
|
|
// read error, next packet!
|
|
|
|
if(read_length < 0)
|
|
|
|
break;
|
|
|
|
|
2010-04-15 10:28:32 +00:00
|
|
|
buf_pos += data_size;
|
|
|
|
|
2009-08-09 21:16:39 +00:00
|
|
|
// move packet parameters
|
|
|
|
audio_pkg_data += read_length;
|
|
|
|
audio_pkg_size -= read_length;
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf_pos;
|
|
|
|
}
|
|
|
|
|
2010-08-03 08:07:21 +00:00
|
|
|
static const char* streaminfo_error = "AUD_FFMPEGReader: Stream info couldn't "
|
|
|
|
"be found.";
|
|
|
|
static const char* noaudio_error = "AUD_FFMPEGReader: File doesn't include an "
|
|
|
|
"audio stream.";
|
|
|
|
static const char* nodecoder_error = "AUD_FFMPEGReader: No decoder found for "
|
|
|
|
"the audio stream.";
|
|
|
|
static const char* codecopen_error = "AUD_FFMPEGReader: Codec couldn't be "
|
|
|
|
"opened.";
|
|
|
|
static const char* format_error = "AUD_FFMPEGReader: Unsupported sample "
|
|
|
|
"format.";
|
|
|
|
|
2010-01-01 05:09:30 +00:00
|
|
|
void AUD_FFMPEGReader::init()
|
2009-08-09 21:16:39 +00:00
|
|
|
{
|
|
|
|
m_position = 0;
|
|
|
|
m_pkgbuf_left = 0;
|
|
|
|
|
2010-01-01 05:09:30 +00:00
|
|
|
if(av_find_stream_info(m_formatCtx)<0)
|
2010-08-03 08:07:21 +00:00
|
|
|
AUD_THROW(AUD_ERROR_FFMPEG, streaminfo_error);
|
2009-08-09 21:16:39 +00:00
|
|
|
|
2010-01-01 05:09:30 +00:00
|
|
|
// find audio stream and codec
|
|
|
|
m_stream = -1;
|
2009-08-09 21:16:39 +00:00
|
|
|
|
2010-01-01 05:09:30 +00:00
|
|
|
for(unsigned int i = 0; i < m_formatCtx->nb_streams; i++)
|
2010-07-28 09:36:03 +00:00
|
|
|
{
|
2010-01-01 05:09:30 +00:00
|
|
|
if((m_formatCtx->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO)
|
|
|
|
&& (m_stream < 0))
|
|
|
|
{
|
|
|
|
m_stream=i;
|
|
|
|
break;
|
|
|
|
}
|
2010-07-28 09:36:03 +00:00
|
|
|
}
|
|
|
|
|
2010-01-01 05:09:30 +00:00
|
|
|
if(m_stream == -1)
|
2010-08-03 08:07:21 +00:00
|
|
|
AUD_THROW(AUD_ERROR_FFMPEG, noaudio_error);
|
2009-08-09 21:16:39 +00:00
|
|
|
|
2010-01-01 05:09:30 +00:00
|
|
|
m_codecCtx = m_formatCtx->streams[m_stream]->codec;
|
2009-08-09 21:16:39 +00:00
|
|
|
|
2010-01-01 05:09:30 +00:00
|
|
|
// get a decoder and open it
|
|
|
|
AVCodec *aCodec = avcodec_find_decoder(m_codecCtx->codec_id);
|
|
|
|
if(!aCodec)
|
2010-08-03 08:07:21 +00:00
|
|
|
AUD_THROW(AUD_ERROR_FFMPEG, nodecoder_error);
|
2009-08-09 21:16:39 +00:00
|
|
|
|
2010-01-01 05:09:30 +00:00
|
|
|
if(avcodec_open(m_codecCtx, aCodec)<0)
|
2010-08-03 08:07:21 +00:00
|
|
|
AUD_THROW(AUD_ERROR_FFMPEG, codecopen_error);
|
2009-08-09 21:16:39 +00:00
|
|
|
|
2010-01-01 05:09:30 +00:00
|
|
|
// XXX this prints file information to stdout:
|
|
|
|
//dump_format(m_formatCtx, 0, NULL, 0);
|
2009-08-09 21:16:39 +00:00
|
|
|
|
2010-01-01 05:09:30 +00:00
|
|
|
m_specs.channels = (AUD_Channels) m_codecCtx->channels;
|
2009-08-09 21:16:39 +00:00
|
|
|
|
2010-01-01 05:09:30 +00:00
|
|
|
switch(m_codecCtx->sample_fmt)
|
2009-08-09 21:16:39 +00:00
|
|
|
{
|
2010-01-01 05:09:30 +00:00
|
|
|
case SAMPLE_FMT_U8:
|
|
|
|
m_convert = AUD_convert_u8_float;
|
|
|
|
m_specs.format = AUD_FORMAT_U8;
|
|
|
|
break;
|
|
|
|
case SAMPLE_FMT_S16:
|
|
|
|
m_convert = AUD_convert_s16_float;
|
|
|
|
m_specs.format = AUD_FORMAT_S16;
|
|
|
|
break;
|
|
|
|
case SAMPLE_FMT_S32:
|
|
|
|
m_convert = AUD_convert_s32_float;
|
|
|
|
m_specs.format = AUD_FORMAT_S32;
|
|
|
|
break;
|
|
|
|
case SAMPLE_FMT_FLT:
|
|
|
|
m_convert = AUD_convert_copy<float>;
|
|
|
|
m_specs.format = AUD_FORMAT_FLOAT32;
|
|
|
|
break;
|
|
|
|
case SAMPLE_FMT_DBL:
|
|
|
|
m_convert = AUD_convert_double_float;
|
|
|
|
m_specs.format = AUD_FORMAT_FLOAT64;
|
|
|
|
break;
|
|
|
|
default:
|
2010-08-03 08:07:21 +00:00
|
|
|
AUD_THROW(AUD_ERROR_FFMPEG, format_error);
|
2009-08-09 21:16:39 +00:00
|
|
|
}
|
|
|
|
|
2010-01-01 05:09:30 +00:00
|
|
|
m_specs.rate = (AUD_SampleRate) m_codecCtx->sample_rate;
|
2009-08-09 21:16:39 +00:00
|
|
|
}
|
|
|
|
|
2010-08-03 08:07:21 +00:00
|
|
|
static const char* fileopen_error = "AUD_FFMPEGReader: File couldn't be "
|
|
|
|
"opened.";
|
|
|
|
|
2010-07-28 09:36:03 +00:00
|
|
|
AUD_FFMPEGReader::AUD_FFMPEGReader(std::string filename) :
|
|
|
|
m_pkgbuf(AVCODEC_MAX_AUDIO_FRAME_SIZE<<1),
|
|
|
|
m_byteiocontext(NULL)
|
2010-01-01 05:09:30 +00:00
|
|
|
{
|
|
|
|
// open file
|
2010-07-28 09:36:03 +00:00
|
|
|
if(av_open_input_file(&m_formatCtx, filename.c_str(), NULL, 0, NULL)!=0)
|
2010-08-03 08:07:21 +00:00
|
|
|
AUD_THROW(AUD_ERROR_FILE, fileopen_error);
|
2010-01-01 05:09:30 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
2010-07-28 09:36:03 +00:00
|
|
|
catch(AUD_Exception&)
|
2010-01-01 05:09:30 +00:00
|
|
|
{
|
|
|
|
av_close_input_file(m_formatCtx);
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-03 08:07:21 +00:00
|
|
|
static const char* streamopen_error = "AUD_FFMPEGReader: Stream couldn't be "
|
|
|
|
"opened.";
|
|
|
|
|
2010-07-28 09:36:03 +00:00
|
|
|
AUD_FFMPEGReader::AUD_FFMPEGReader(AUD_Reference<AUD_Buffer> buffer) :
|
|
|
|
m_pkgbuf(AVCODEC_MAX_AUDIO_FRAME_SIZE<<1),
|
|
|
|
m_membuffer(buffer)
|
2009-08-09 21:16:39 +00:00
|
|
|
{
|
|
|
|
m_byteiocontext = (ByteIOContext*)av_mallocz(sizeof(ByteIOContext));
|
|
|
|
|
2010-01-01 05:09:30 +00:00
|
|
|
if(init_put_byte(m_byteiocontext, (data_t*)buffer.get()->getBuffer(),
|
|
|
|
buffer.get()->getSize(), 0, NULL, NULL, NULL, NULL) != 0)
|
2010-07-28 09:36:03 +00:00
|
|
|
{
|
|
|
|
av_free(m_byteiocontext);
|
2010-08-03 08:07:21 +00:00
|
|
|
AUD_THROW(AUD_ERROR_FILE, fileopen_error);
|
2010-07-28 09:36:03 +00:00
|
|
|
}
|
2009-08-09 21:16:39 +00:00
|
|
|
|
|
|
|
AVProbeData probe_data;
|
|
|
|
probe_data.filename = "";
|
2010-01-01 05:09:30 +00:00
|
|
|
probe_data.buf = (data_t*)buffer.get()->getBuffer();
|
2009-08-21 19:39:28 +00:00
|
|
|
probe_data.buf_size = buffer.get()->getSize();
|
2009-08-09 21:16:39 +00:00
|
|
|
AVInputFormat* fmt = av_probe_input_format(&probe_data, 1);
|
|
|
|
|
|
|
|
// open stream
|
|
|
|
if(av_open_input_stream(&m_formatCtx, m_byteiocontext, "", fmt, NULL)!=0)
|
2010-07-28 09:36:03 +00:00
|
|
|
{
|
|
|
|
av_free(m_byteiocontext);
|
2010-08-03 08:07:21 +00:00
|
|
|
AUD_THROW(AUD_ERROR_FILE, streamopen_error);
|
2010-07-28 09:36:03 +00:00
|
|
|
}
|
2009-08-09 21:16:39 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2010-01-01 05:09:30 +00:00
|
|
|
init();
|
2009-08-09 21:16:39 +00:00
|
|
|
}
|
2010-07-28 09:36:03 +00:00
|
|
|
catch(AUD_Exception&)
|
2009-08-09 21:16:39 +00:00
|
|
|
{
|
|
|
|
av_close_input_stream(m_formatCtx);
|
2010-07-28 09:36:03 +00:00
|
|
|
av_free(m_byteiocontext);
|
2009-08-09 21:16:39 +00:00
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AUD_FFMPEGReader::~AUD_FFMPEGReader()
|
|
|
|
{
|
|
|
|
avcodec_close(m_codecCtx);
|
|
|
|
|
|
|
|
if(m_byteiocontext)
|
|
|
|
{
|
|
|
|
av_close_input_stream(m_formatCtx);
|
2010-07-28 09:36:03 +00:00
|
|
|
av_free(m_byteiocontext);
|
2009-08-09 21:16:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
av_close_input_file(m_formatCtx);
|
|
|
|
}
|
|
|
|
|
2010-07-28 09:36:03 +00:00
|
|
|
bool AUD_FFMPEGReader::isSeekable() const
|
2009-08-09 21:16:39 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AUD_FFMPEGReader::seek(int position)
|
|
|
|
{
|
|
|
|
if(position >= 0)
|
|
|
|
{
|
2010-11-01 18:13:10 +00:00
|
|
|
uint64_t st_time = m_formatCtx->start_time;
|
|
|
|
uint64_t seek_pos = position * AV_TIME_BASE / m_specs.rate;
|
2010-10-16 15:01:01 +00:00
|
|
|
|
|
|
|
if (seek_pos < 0) {
|
|
|
|
seek_pos = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (st_time != AV_NOPTS_VALUE) {
|
|
|
|
seek_pos += st_time;
|
|
|
|
}
|
|
|
|
|
2010-11-01 18:13:10 +00:00
|
|
|
double pts_time_base =
|
|
|
|
av_q2d(m_formatCtx->streams[m_stream]->time_base);
|
|
|
|
uint64_t pts_st_time =
|
|
|
|
((st_time != AV_NOPTS_VALUE) ? st_time : 0)
|
|
|
|
/ pts_time_base / (uint64_t) AV_TIME_BASE;
|
2010-10-16 15:01:01 +00:00
|
|
|
|
2009-08-09 21:16:39 +00:00
|
|
|
// a value < 0 tells us that seeking failed
|
2010-11-01 18:13:10 +00:00
|
|
|
if(av_seek_frame(m_formatCtx, -1, seek_pos,
|
2010-10-16 15:01:01 +00:00
|
|
|
AVSEEK_FLAG_BACKWARD | AVSEEK_FLAG_ANY) >= 0)
|
2009-08-09 21:16:39 +00:00
|
|
|
{
|
|
|
|
avcodec_flush_buffers(m_codecCtx);
|
|
|
|
m_position = position;
|
|
|
|
|
|
|
|
AVPacket packet;
|
|
|
|
bool search = true;
|
|
|
|
|
|
|
|
while(search && av_read_frame(m_formatCtx, &packet) >= 0)
|
|
|
|
{
|
|
|
|
// is it a frame from the audio stream?
|
|
|
|
if(packet.stream_index == m_stream)
|
|
|
|
{
|
|
|
|
// decode the package
|
|
|
|
m_pkgbuf_left = decode(&packet, m_pkgbuf);
|
|
|
|
search = false;
|
|
|
|
|
|
|
|
// check position
|
|
|
|
if(packet.pts != AV_NOPTS_VALUE)
|
|
|
|
{
|
|
|
|
// calculate real position, and read to frame!
|
2010-10-16 15:01:01 +00:00
|
|
|
m_position = (packet.pts -
|
2010-11-01 18:13:10 +00:00
|
|
|
pts_st_time) * pts_time_base * m_specs.rate;
|
2009-08-09 21:16:39 +00:00
|
|
|
|
|
|
|
if(m_position < position)
|
|
|
|
{
|
2010-07-28 09:36:03 +00:00
|
|
|
// read until we're at the right position
|
|
|
|
int length = AUD_DEFAULT_BUFFER_SIZE;
|
|
|
|
sample_t* buffer;
|
|
|
|
for(int len = position - m_position;
|
|
|
|
length == AUD_DEFAULT_BUFFER_SIZE;
|
|
|
|
len -= AUD_DEFAULT_BUFFER_SIZE)
|
|
|
|
{
|
|
|
|
if(len < AUD_DEFAULT_BUFFER_SIZE)
|
|
|
|
length = len;
|
|
|
|
read(length, buffer);
|
|
|
|
}
|
2009-08-09 21:16:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
av_free_packet(&packet);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-01 18:13:10 +00:00
|
|
|
fprintf(stderr, "seeking failed!\n");
|
2009-08-09 21:16:39 +00:00
|
|
|
// Seeking failed, do nothing.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-28 09:36:03 +00:00
|
|
|
int AUD_FFMPEGReader::getLength() const
|
2009-08-09 21:16:39 +00:00
|
|
|
{
|
|
|
|
// return approximated remaning size
|
|
|
|
return (int)((m_formatCtx->duration * m_codecCtx->sample_rate)
|
|
|
|
/ AV_TIME_BASE)-m_position;
|
|
|
|
}
|
|
|
|
|
2010-07-28 09:36:03 +00:00
|
|
|
int AUD_FFMPEGReader::getPosition() const
|
2009-08-09 21:16:39 +00:00
|
|
|
{
|
|
|
|
return m_position;
|
|
|
|
}
|
|
|
|
|
2010-07-28 09:36:03 +00:00
|
|
|
AUD_Specs AUD_FFMPEGReader::getSpecs() const
|
2009-08-09 21:16:39 +00:00
|
|
|
{
|
2010-01-01 05:09:30 +00:00
|
|
|
return m_specs.specs;
|
2009-08-09 21:16:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AUD_FFMPEGReader::read(int & length, sample_t* & buffer)
|
|
|
|
{
|
|
|
|
// read packages and decode them
|
|
|
|
AVPacket packet;
|
|
|
|
int data_size = 0;
|
|
|
|
int pkgbuf_pos;
|
|
|
|
int left = length;
|
2010-01-01 05:09:30 +00:00
|
|
|
int sample_size = AUD_DEVICE_SAMPLE_SIZE(m_specs);
|
2009-08-09 21:16:39 +00:00
|
|
|
|
|
|
|
// resize output buffer if necessary
|
2010-07-28 09:36:03 +00:00
|
|
|
if(m_buffer.getSize() < length * AUD_SAMPLE_SIZE(m_specs))
|
|
|
|
m_buffer.resize(length * AUD_SAMPLE_SIZE(m_specs));
|
2009-08-09 21:16:39 +00:00
|
|
|
|
2010-07-28 09:36:03 +00:00
|
|
|
buffer = m_buffer.getBuffer();
|
2009-08-09 21:16:39 +00:00
|
|
|
pkgbuf_pos = m_pkgbuf_left;
|
|
|
|
m_pkgbuf_left = 0;
|
|
|
|
|
|
|
|
// there may still be data in the buffer from the last call
|
|
|
|
if(pkgbuf_pos > 0)
|
|
|
|
{
|
|
|
|
data_size = AUD_MIN(pkgbuf_pos, left * sample_size);
|
2010-07-28 09:36:03 +00:00
|
|
|
m_convert((data_t*) buffer, (data_t*) m_pkgbuf.getBuffer(),
|
2010-01-01 05:09:30 +00:00
|
|
|
data_size / AUD_FORMAT_SIZE(m_specs.format));
|
|
|
|
buffer += data_size / AUD_FORMAT_SIZE(m_specs.format);
|
2009-08-09 21:16:39 +00:00
|
|
|
left -= data_size/sample_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
// for each frame read as long as there isn't enough data already
|
|
|
|
while((left > 0) && (av_read_frame(m_formatCtx, &packet) >= 0))
|
|
|
|
{
|
|
|
|
// is it a frame from the audio stream?
|
|
|
|
if(packet.stream_index == m_stream)
|
|
|
|
{
|
|
|
|
// decode the package
|
|
|
|
pkgbuf_pos = decode(&packet, m_pkgbuf);
|
|
|
|
|
|
|
|
// copy to output buffer
|
|
|
|
data_size = AUD_MIN(pkgbuf_pos, left * sample_size);
|
2010-07-28 09:36:03 +00:00
|
|
|
m_convert((data_t*) buffer, (data_t*) m_pkgbuf.getBuffer(),
|
2010-01-01 05:09:30 +00:00
|
|
|
data_size / AUD_FORMAT_SIZE(m_specs.format));
|
|
|
|
buffer += data_size / AUD_FORMAT_SIZE(m_specs.format);
|
2009-08-09 21:16:39 +00:00
|
|
|
left -= data_size/sample_size;
|
|
|
|
}
|
|
|
|
av_free_packet(&packet);
|
|
|
|
}
|
|
|
|
// read more data than necessary?
|
|
|
|
if(pkgbuf_pos > data_size)
|
|
|
|
{
|
|
|
|
m_pkgbuf_left = pkgbuf_pos-data_size;
|
2010-07-28 09:36:03 +00:00
|
|
|
memmove(m_pkgbuf.getBuffer(),
|
|
|
|
((data_t*)m_pkgbuf.getBuffer())+data_size,
|
2009-08-09 21:16:39 +00:00
|
|
|
pkgbuf_pos-data_size);
|
|
|
|
}
|
|
|
|
|
2010-07-28 09:36:03 +00:00
|
|
|
buffer = m_buffer.getBuffer();
|
2009-08-09 21:16:39 +00:00
|
|
|
|
|
|
|
if(left > 0)
|
|
|
|
length -= left;
|
|
|
|
m_position += length;
|
|
|
|
}
|