修改接口

This commit is contained in:
ziyue 2021-06-29 18:19:05 +08:00
parent 013109796d
commit 11e993d870
3 changed files with 3 additions and 3 deletions

View File

@ -122,7 +122,7 @@ int AudioPlayer::getPCMData(char *buf, int size) {
return size;
}
void AudioPlayer::inputFrame(const char *data, size_t size) {
void AudioPlayer::playPCM(const char *data, size_t size) {
lock_guard<mutex> lck(_mtx);
_buffer.append(data, size);
}

View File

@ -68,7 +68,7 @@ public:
~AudioPlayer() override;
void setup(int sample_rate, int channel, SDL_AudioFormat format);
void inputFrame(const char *data, size_t size);
void playPCM(const char *data, size_t size);
private:
SDL_AudioFormat getPCMFormat() override;

View File

@ -98,7 +98,7 @@ int main(int argc, char *argv[]) {
//FFmpeg解码时已经统一转换为16位整型pcm
audio_player->setup(audioTrack->getAudioSampleRate(), audioTrack->getAudioChannel(), AUDIO_S16);
decoder->setOnDecode([audio_player](const FFmpegFrame::Ptr &pcm) {
audio_player->inputFrame((const char *) (pcm->get()->data[0]), pcm->get()->linesize[0]);
audio_player->playPCM((const char *) (pcm->get()->data[0]), pcm->get()->linesize[0]);
});
auto audio_delegate = std::make_shared<FrameWriterInterfaceHelper>( [decoder](const Frame::Ptr &frame) {
decoder->inputFrame(frame);