-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
コールバックで音声を受け取る SoraAudioStreamSink の追加 #32
Conversation
SoraAudioSink2 という名前が良くないので変更をお願い。 |
SoraAudioStreamSink に改名しました! |
@tnoho ドキュメントも PR ください。 |
@@ -44,6 +47,22 @@ PyType_Slot audio_sink_slots[] = { | |||
{Py_tp_traverse, (void*)audio_sink_tp_traverse}, | |||
{0, nullptr}}; | |||
|
|||
int audio_sink2_tp_traverse(PyObject* self, visitproc visit, void* arg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここの sink2 は変更もれでしょうか?(stream_sink になるべき?)
SoraTrackInterface* track_; | ||
const int output_sample_rate_; | ||
const size_t output_channels_; | ||
// ACMResampler の前に std::unique_ptr がなんでも良いので無いと何故かビルドが通らない |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔
@@ -0,0 +1,201 @@ | |||
#ifndef SORA_AUDIO_SINK2_H_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここも "SINK2" になってますね
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nits
現在用意されている SoraAudioSink は SoraAudioSinkImpl 内のバッファに受け取った音声データを溜め込み、任意のタイミングで音声を取り出すことができるようにしてあります。
これは、SoraVideoSink のように AudioTrack から音声データを受け取るたびにコールバックを呼び出す形で実装すると 10ms という非常に短い間隔でコールバックが呼び出されるために Python 側で実装に配慮が必要になることを想定しそのようにしました。
しかしながら SoraVideoSink 同様に AudioTrack から音声データを受け取るたびにコールバックで呼び出す形の SoraAudioSink もあった方がリアルタイム処理などでの利便性が高いと考えたことから、これを実装した SoraAudioStreamSink を追加したいと思います。
SoraAudioSink にも同じ形を実装しようとしたコードがあるのですが、 1 つのクラスに 2 つの機能は難しいと考え分けることとしました、これがマージされた後に SoraAudioSink の当該部分は削除したいと思います。
前述のコールバックが非常に短くなる点への配慮として、コールバックにより渡される SoraAudioFrame は pickle できるようになっており、 multiprocessing.Queue などで別プロセスへのオフロードが可能になっています。
必須ではない割と大きめの機能追加なので、フォークしたリポジトリからの PR としました。レビューいただければと思います。