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.
This commit is contained in:
parent
aa3ecaf701
commit
738494a232
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue