Skip to content

Commit

Permalink
[ci] More build fixes for older libav
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Jan 25, 2024
1 parent 5cff2e4 commit b6ab4a8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/plugins/score-plugin-gfx/Gfx/Libav/LibavEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ int LibavEncoder::start()

int LibavEncoder::add_frame(tcb::span<ossia::float_vector> vec)
{
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 24, 100)
if(!m_formatContext)
return 1;

Expand Down Expand Up @@ -152,6 +153,8 @@ int LibavEncoder::add_frame(tcb::span<ossia::float_vector> vec)
stream.encoder->add_frame(*next_frame, resample_outf);
}
return stream.write_audio_frame(m_formatContext, next_frame);
#endif
return 1;
}

int LibavEncoder::add_frame(
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/score-plugin-gfx/Gfx/Libav/LibavOutputStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ struct OutputStream

void init_audio(const LibavOutputSettings& set, AVCodecContext* c)
{
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 24, 100)
c->sample_fmt = av_get_sample_fmt(set.audio_converted_smpfmt.toStdString().c_str());

if(codec->supported_samplerates)
Expand All @@ -148,6 +149,7 @@ struct OutputStream
c->time_base = AVRational{1, c->sample_rate};
c->framerate = AVRational{c->sample_rate, 1};
qDebug() << "Opening audio encoder with: rate: " << c->sample_rate;
#endif
}

void init_video(const LibavOutputSettings& set, AVCodecContext* c)
Expand Down Expand Up @@ -460,6 +462,7 @@ struct OutputStream

int write_video_frame(AVFormatContext* fmt_ctx, AVFrame* input_frame)
{
#if LIBSWSCALE_VERSION_INT >= AV_VERSION_INT(7, 5, 100)
// scale the frame
int ret = sws_scale_frame(sws_ctx, tmp_frame, input_frame);
if(ret < 0)
Expand Down Expand Up @@ -505,6 +508,8 @@ struct OutputStream
}

return ret == AVERROR_EOF ? 1 : 0;
#endif
return 1;
}

// #define SRC_RATE SAMPLE_RATE_TEST
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/score-plugin-gfx/score_plugin_gfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ std::vector<score::InterfaceBase*> score_plugin_gfx::factories(
{
return instantiate_factories<
score::ApplicationContext,
FW<Device::ProtocolFactory, Gfx::WindowProtocolFactory, Gfx::CameraProtocolFactory,
FW<Device::ProtocolFactory, Gfx::WindowProtocolFactory, Gfx::CameraProtocolFactory
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 24, 100)
,
Gfx::LibavOutputProtocolFactory
#endif
#if defined(SCORE_HAS_SHMDATA)
,
Gfx::Shmdata::InputFactory, Gfx::ShmdataOutputProtocolFactory
Expand Down

0 comments on commit b6ab4a8

Please sign in to comment.