Skip to content
Permalink
Browse files

Support all sample rate available on GUI.

Before we could only use `44100`. Now we can use all available on GUI
for the supported codecs.
  • Loading branch information
denisfa authored and rkitover committed Aug 6, 2019
1 parent aa3ecaf commit 738494a23284f8a75d2f67ea54597db139009f83
Showing with 11 additions and 3 deletions.
  1. +9 −3 src/common/ffmpeg.cpp
  2. +2 −0 src/wx/panel.cpp
@@ -106,15 +106,21 @@ recording::MediaRet recording::MediaRecorder::setup_audio_stream()
aenc->sample_fmt = acodec->sample_fmts ? acodec->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
aenc->bit_rate = 128000; // mp3
aenc->sample_rate = sampleRate;
// this might be useful to check if the codec suports the
// sample rate, but it is not strictly needed for now
bool isSupported = false;
if (acodec->supported_samplerates)
{
aenc->sample_rate = acodec->supported_samplerates[0];
for (int i = 0; acodec->supported_samplerates[i]; ++i)
{
if (acodec->supported_samplerates[i] == 44100)
aenc->sample_rate = 44100;
if (acodec->supported_samplerates[i] == sampleRate)
{
isSupported = true;
break;
}
}
}
if (!isSupported) return MRET_ERR_NOCODEC;
aenc->channels = av_get_channel_layout_nb_channels(aenc->channel_layout);
aenc->channel_layout = AV_CH_LAYOUT_STEREO;
if (acodec->channel_layouts)
@@ -2340,6 +2340,7 @@ void GameArea::StartVidRecording(const wxString& fname)
{
recording::MediaRet ret;

vid_rec.SetSampleRate(soundGetSampleRate());
if ((ret = vid_rec.Record(fname.mb_str(), basic_width, basic_height,
systemColorDepth))
!= recording::MRET_OK)
@@ -2370,6 +2371,7 @@ void GameArea::StartSoundRecording(const wxString& fname)
{
recording::MediaRet ret;

snd_rec.SetSampleRate(soundGetSampleRate());
if ((ret = snd_rec.Record(fname.mb_str())) != recording::MRET_OK)
wxLogError(_("Unable to begin recording to %s (%s)"), fname.mb_str(),
media_err(ret));

0 comments on commit 738494a

Please sign in to comment.
You can’t perform that action at this time.