this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix Building Against Newer Version Of FFmpeg

When building against a newer version:
* Use `ch_layout.order` & `ch_layout.nb_channels` instead of `channel_layout` & `channels`.
* Workaround `read_probe` no longer being exposed by calling `av_probe_input_format`

Thomas A 9655d559 773e9874

+38 -8
+8 -4
src/CoreAudio/AFAVFormatComponent/AudioFileFormatGeneric.cpp
··· 81 81 82 82 UncertainResult AudioFileFormatGeneric::FileDataIsThisFormat(UInt32 inDataByteSize, const void* inData) 83 83 { 84 - const AVInputFormat* fmt = av_find_input_format(m_avformatShortName); 85 - if (!fmt) 86 - return false; 87 - 88 84 std::vector<uint8_t> buf; 89 85 AVProbeData probeData; 90 86 ··· 96 92 probeData.buf = buf.data(); 97 93 probeData.buf_size = inDataByteSize; 98 94 95 + #warning "TODO: Remove old `read_probe` call once we no longer support older distros" 96 + #if LIBAVCODEC_VERSION_MAJOR >= 61 97 + return av_probe_input_format(&probeData, false) != nullptr ? kTrue : kFalse; 98 + #else 99 + const AVInputFormat* fmt = av_find_input_format(m_avformatShortName); 100 + if (!fmt) 101 + return false; 99 102 return fmt->read_probe(&probeData) ? kTrue : kFalse; 103 + #endif 100 104 } 101 105 102 106 AudioFileObject* AudioFileFormatGeneric::New()
+30 -4
src/CoreAudio/AudioToolbox/AudioConverterImpl.cpp
··· 100 100 101 101 if (inSourceFormat->mFormatID == kAudioFormatLinearPCM) 102 102 { 103 + #warning "TODO: Remove deprecated 'channels' once we no longer support older distros" 104 + #if LIBAVCODEC_VERSION_MAJOR >= 61 105 + cIn->ch_layout.nb_channels = inSourceFormat->mChannelsPerFrame; 106 + #else 103 107 cIn->channels = inSourceFormat->mChannelsPerFrame; 108 + #endif 104 109 cIn->sample_rate = inSourceFormat->mSampleRate; 105 - 110 + 111 + #if LIBAVCODEC_VERSION_MAJOR >= 61 112 + std::cout << "Converting from PCM with " << cIn->ch_layout.nb_channels << " channels at " << cIn->sample_rate << " Hz\n"; 113 + #else 106 114 std::cout << "Converting from PCM with " << cIn->channels << " channels at " << cIn->sample_rate << " Hz\n"; 115 + #endif 107 116 } 108 117 109 118 if (avcodec_open2((*out)->m_decoder, codecIn, nullptr) < 0) ··· 131 140 132 141 m_encoder->codec_type = AVMEDIA_TYPE_AUDIO; 133 142 m_encoder->bit_rate = m_outBitRate; 143 + #warning "TODO: Remove deprecated 'channels' once we no longer support older distros" 144 + #if LIBAVCODEC_VERSION_MAJOR >= 61 145 + m_encoder->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; 146 + m_encoder->ch_layout.nb_channels = m_destinationFormat.mChannelsPerFrame; 147 + #else 134 148 m_encoder->channels = m_destinationFormat.mChannelsPerFrame; 135 - m_encoder->sample_rate = m_destinationFormat.mSampleRate; 136 149 m_encoder->channel_layout = CAChannelCountToLayout(m_destinationFormat.mChannelsPerFrame); 150 + #endif 151 + m_encoder->sample_rate = m_destinationFormat.mSampleRate; 137 152 m_encoder->sample_fmt = CACodecSampleFormat(&m_destinationFormat); 138 153 139 154 #ifdef DEBUG_AUDIOCONVERTER ··· 161 176 162 177 m_audioFrame->nb_samples = ENCODER_FRAME_SAMPLES; 163 178 m_audioFrame->format = m_encoder->sample_fmt; 179 + 180 + #warning "TODO: Remove deprecated 'channels' once we no longer support older distros" 181 + #if LIBAVCODEC_VERSION_MAJOR >= 61 182 + m_audioFrame->ch_layout.order = m_encoder->ch_layout.order; 183 + m_audioFrame->ch_layout.nb_channels = m_encoder->ch_layout.nb_channels; 184 + int audioSampleBuffer_size = av_samples_get_buffer_size(nullptr, m_encoder->ch_layout.nb_channels, m_audioFrame->nb_samples, m_encoder->sample_fmt, 0); 185 + #else 164 186 m_audioFrame->channel_layout = m_encoder->channel_layout; 165 - 166 - 167 187 int audioSampleBuffer_size = av_samples_get_buffer_size(nullptr, m_encoder->channels, m_audioFrame->nb_samples, m_encoder->sample_fmt, 0); 188 + #endif 168 189 void* audioSampleBuffer = (uint8_t*) av_malloc(audioSampleBuffer_size); 169 190 170 191 if (!audioSampleBuffer) ··· 174 195 } 175 196 176 197 // Setup the data pointers in the AVFrame 198 + #if LIBAVCODEC_VERSION_MAJOR >= 61 199 + if (int err = avcodec_fill_audio_frame(m_audioFrame, m_encoder->ch_layout.nb_channels, m_encoder->sample_fmt, 200 + (const uint8_t*) audioSampleBuffer, audioSampleBuffer_size, 0 ); err < 0) 201 + #else 177 202 if (int err = avcodec_fill_audio_frame(m_audioFrame, m_encoder->channels, m_encoder->sample_fmt, 178 203 (const uint8_t*) audioSampleBuffer, audioSampleBuffer_size, 0 ); err < 0) 204 + #endif 179 205 { 180 206 std::cerr << "AudioConverter::allocateBuffers(): Could not set up audio frame\n"; 181 207 throw std::runtime_error("AudioConverter::allocateBuffers(): Could not set up audio frame");