Skip to content

Commit

Permalink
バッファーが空か確認するタイミングが間違っていたので修正する
Browse files Browse the repository at this point in the history
  • Loading branch information
enm10k committed Apr 16, 2024
1 parent dbb1227 commit d9077bb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/sora_audio_sink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,6 @@ void SoraAudioSinkImpl::AppendData(const int16_t* audio_data,
nb::tuple SoraAudioSinkImpl::Read(size_t frames, float timeout) {
std::unique_lock<std::mutex> lock(buffer_mtx_);

if (buffer_.size() == 0) {
// 返すものがない時は即座に返す
return nb::make_tuple(false, nb::none());
}
size_t num_of_samples;
if (frames > 0) {
// フレーム数のリクエストがある場合はリクエスト分が貯まるまで待つ
Expand All @@ -160,6 +156,9 @@ nb::tuple SoraAudioSinkImpl::Read(size_t frames, float timeout) {
}
} else {
// フレーム数のリクエストがない場合はあるだけ全部出す
if (buffer_.empty()) {
return nb::make_tuple(false, nb::none());
}
num_of_samples = buffer_.size();
}

Expand Down

0 comments on commit d9077bb

Please sign in to comment.