diff --git a/plugins/win-dshow/win-dshow.cpp b/plugins/win-dshow/win-dshow.cpp index 344745de0..3b3d3a2d2 100644 --- a/plugins/win-dshow/win-dshow.cpp +++ b/plugins/win-dshow/win-dshow.cpp @@ -116,6 +116,7 @@ public: inline ~Decoder() {ffmpeg_decode_free(&decode);} inline operator ffmpeg_decode*() {return &decode;} + inline ffmpeg_decode *operator->() {return &decode;} }; class CriticalSection { @@ -509,21 +510,30 @@ void DShowInput::OnEncodedAudioData(enum AVCodecID id, } } - bool got_output; - int len = ffmpeg_decode_audio(audio_decoder, data, size, - &audio, &got_output); - if (len < 0) { - blog(LOG_WARNING, "Error decoding audio"); - return; - } + do { + bool got_output; + int len = ffmpeg_decode_audio(audio_decoder, data, size, + &audio, &got_output); + if (len < 0) { + blog(LOG_WARNING, "Error decoding audio"); + return; + } - if (got_output) { - audio.timestamp = (uint64_t)ts * 100; + if (got_output) { + audio.timestamp = (uint64_t)ts * 100; #if LOG_ENCODED_AUDIO_TS - blog(LOG_DEBUG, "audio ts: %llu", audio.timestamp); + blog(LOG_DEBUG, "audio ts: %llu", audio.timestamp); #endif - obs_source_output_audio(source, &audio); - } + obs_source_output_audio(source, &audio); + } else { + break; + } + + ts += int64_t(audio_decoder->frame->nb_samples) * 10000000LL / + int64_t(audio_decoder->frame->sample_rate); + size -= (size_t)len; + data += len; + } while (size > 0); } void DShowInput::OnAudioData(const AudioConfig &config,