Correctly returning the sample rate

This commit is contained in:
WolverinDEV 2021-03-27 21:29:47 +01:00
parent 768e9b7bbb
commit b475b6db45
3 changed files with 5 additions and 6 deletions

View File

@ -11,8 +11,7 @@ namespace tc::audio::pa {
class PortAudioPlayback : public AudioDevicePlayback { class PortAudioPlayback : public AudioDevicePlayback {
public: public:
static constexpr auto kChannelCount{2}; static constexpr auto kChannelCount{2};
static constexpr auto kSampleRate{44100}; static constexpr auto kSampleRate{48000};
static constexpr auto kTimeSpan{0.01};
explicit PortAudioPlayback(PaDeviceIndex index, const PaDeviceInfo* info); explicit PortAudioPlayback(PaDeviceIndex index, const PaDeviceInfo* info);
virtual ~PortAudioPlayback(); virtual ~PortAudioPlayback();
@ -35,7 +34,7 @@ namespace tc::audio::pa {
class PortAudioRecord : public AudioDeviceRecord { class PortAudioRecord : public AudioDeviceRecord {
public: public:
static constexpr auto kChannelCount{2}; static constexpr auto kChannelCount{2};
static constexpr auto kSampleRate{44100}; static constexpr auto kSampleRate{48000};
explicit PortAudioRecord(PaDeviceIndex index, const PaDeviceInfo* info); explicit PortAudioRecord(PaDeviceIndex index, const PaDeviceInfo* info);
virtual ~PortAudioRecord(); virtual ~PortAudioRecord();

View File

@ -63,7 +63,7 @@ bool PortAudioPlayback::impl_start(std::string &error) {
nullptr, nullptr,
&parameters, &parameters,
(double) kSampleRate, (double) kSampleRate,
(unsigned long) (kSampleRate * kTimeSpan), paFramesPerBufferUnspecified,
paClipOff, paClipOff,
proxied_write_callback, proxied_write_callback,
this this
@ -100,7 +100,7 @@ void PortAudioPlayback::impl_stop() {
} }
size_t PortAudioPlayback::sample_rate() const { size_t PortAudioPlayback::sample_rate() const {
return (size_t) this->info->defaultSampleRate; return (size_t) kSampleRate;
} }
void PortAudioPlayback::write_callback(void *output, unsigned long frameCount, void PortAudioPlayback::write_callback(void *output, unsigned long frameCount,

View File

@ -98,7 +98,7 @@ void PortAudioRecord::impl_stop() {
} }
size_t PortAudioRecord::sample_rate() const { size_t PortAudioRecord::sample_rate() const {
return (size_t) this->info->defaultSampleRate; return kSampleRate;
} }
void PortAudioRecord::read_callback(const void *input, unsigned long frameCount, void PortAudioRecord::read_callback(const void *input, unsigned long frameCount,