Skip to content

Commit

Permalink
Support all sample rate available on GUI.
Browse files Browse the repository at this point in the history
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 14, 2019
1 parent aa3ecaf commit 738494a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/common/ffmpeg.cpp
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/wx/panel.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 738494a

Please sign in to comment.