mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1127554 - Get rid of infallible allocation in MP4Sample copy constructor. v2 r=mattwoodrow
This commit is contained in:
parent
c49136f108
commit
c2399ec33b
@ -466,11 +466,15 @@ nsresult
|
||||
AppleATDecoder::GetImplicitAACMagicCookie(const mp4_demuxer::MP4Sample* aSample)
|
||||
{
|
||||
// Prepend ADTS header to AAC audio.
|
||||
mp4_demuxer::MP4Sample adtssample(*aSample);
|
||||
nsAutoPtr<mp4_demuxer::MP4Sample> adtssample(aSample->Clone());
|
||||
if (!adtssample) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
bool rv = mp4_demuxer::Adts::ConvertSample(mConfig.channel_count,
|
||||
mConfig.frequency_index,
|
||||
mConfig.aac_profile,
|
||||
&adtssample);
|
||||
adtssample);
|
||||
if (!rv) {
|
||||
NS_WARNING("Failed to apply ADTS header");
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -488,8 +492,8 @@ AppleATDecoder::GetImplicitAACMagicCookie(const mp4_demuxer::MP4Sample* aSample)
|
||||
}
|
||||
|
||||
OSStatus status = AudioFileStreamParseBytes(mStream,
|
||||
adtssample.size,
|
||||
adtssample.data,
|
||||
adtssample->size,
|
||||
adtssample->data,
|
||||
0 /* discontinuity */);
|
||||
if (status) {
|
||||
NS_WARNING("Couldn't parse sample");
|
||||
|
@ -76,7 +76,10 @@ GonkDecoderManager::Input(mp4_demuxer::MP4Sample* aSample)
|
||||
// Current valid sample can't be sent into OMX, adding the clone one into queue
|
||||
// for next round.
|
||||
if (!sample) {
|
||||
sample = new mp4_demuxer::MP4Sample(*aSample);
|
||||
sample = aSample->Clone();
|
||||
if (!sample) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
mQueueSample.AppendElement(sample);
|
||||
|
||||
|
@ -210,19 +210,24 @@ MP4Sample::MP4Sample()
|
||||
{
|
||||
}
|
||||
|
||||
MP4Sample::MP4Sample(const MP4Sample& copy)
|
||||
: mMediaBuffer(nullptr)
|
||||
, decode_timestamp(copy.decode_timestamp)
|
||||
, composition_timestamp(copy.composition_timestamp)
|
||||
, duration(copy.duration)
|
||||
, byte_offset(copy.byte_offset)
|
||||
, is_sync_point(copy.is_sync_point)
|
||||
, size(copy.size)
|
||||
, crypto(copy.crypto)
|
||||
, extra_data(copy.extra_data)
|
||||
MP4Sample*
|
||||
MP4Sample::Clone() const
|
||||
{
|
||||
extra_buffer = data = new uint8_t[size];
|
||||
memcpy(data, copy.data, size);
|
||||
nsAutoPtr<MP4Sample> s(new MP4Sample());
|
||||
s->decode_timestamp = decode_timestamp;
|
||||
s->composition_timestamp = composition_timestamp;
|
||||
s->duration = duration;
|
||||
s->byte_offset = byte_offset;
|
||||
s->is_sync_point = is_sync_point;
|
||||
s->size = size;
|
||||
s->crypto = crypto;
|
||||
s->extra_data = extra_data;
|
||||
s->extra_buffer = s->data = new (fallible) uint8_t[size];
|
||||
if (!s->extra_buffer) {
|
||||
return nullptr;
|
||||
}
|
||||
memcpy(s->data, data, size);
|
||||
return s.forget();
|
||||
}
|
||||
|
||||
MP4Sample::~MP4Sample()
|
||||
|
@ -155,8 +155,8 @@ class MP4Sample
|
||||
{
|
||||
public:
|
||||
MP4Sample();
|
||||
MP4Sample(const MP4Sample& copy);
|
||||
virtual ~MP4Sample();
|
||||
MP4Sample* Clone() const;
|
||||
void Update(int64_t& aMediaTime);
|
||||
void Pad(size_t aPaddingBytes);
|
||||
|
||||
@ -178,6 +178,8 @@ public:
|
||||
void Replace(const uint8_t* aData, size_t aSize);
|
||||
|
||||
nsAutoArrayPtr<uint8_t> extra_buffer;
|
||||
private:
|
||||
MP4Sample(const MP4Sample&); // Not implemented
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user