File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
src/AvTranscoder/data/decoded Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,11 @@ std::string AudioFrame::getChannelLayoutDesc() const
57
57
return std::string (buf);
58
58
}
59
59
60
+ AudioFrame::~AudioFrame ()
61
+ {
62
+ freeAVSample ();
63
+ }
64
+
60
65
size_t AudioFrame::getSize () const
61
66
{
62
67
if (getSampleFormat () == AV_SAMPLE_FMT_NONE)
@@ -104,6 +109,11 @@ void AudioFrame::allocateAVSample(const AudioFrameDesc& desc)
104
109
}
105
110
}
106
111
112
+ void AudioFrame::freeAVSample ()
113
+ {
114
+ av_freep (&_frame->data [0 ]);
115
+ }
116
+
107
117
void AudioFrame::assign (const unsigned char value)
108
118
{
109
119
// Create the audio buffer
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ class AvExport AudioFrame : public Frame
41
41
*/
42
42
AudioFrame (const AudioFrameDesc& ref);
43
43
AudioFrame (const Frame& otherFrame);
44
+ ~AudioFrame ();
44
45
45
46
size_t getSampleRate () const { return av_frame_get_sample_rate (_frame); }
46
47
size_t getNbChannels () const { return av_frame_get_channels (_frame); }
@@ -69,9 +70,16 @@ class AvExport AudioFrame : public Frame
69
70
private:
70
71
/* *
71
72
* @brief Allocate the audio buffer of the frame.
73
+ * @warning The allocated data should be freed by the caller.
74
+ * @see freeAVSample
72
75
*/
73
76
void allocateAVSample (const AudioFrameDesc& ref);
74
77
78
+ /* *
79
+ * @brief Free the audio buffer of the frame.
80
+ */
81
+ void freeAVSample ();
82
+
75
83
/* *
76
84
* @note To allocate new audio buffer if needed.
77
85
* @see allocateAVSample
You can’t perform that action at this time.
0 commit comments