Skip to content

Commit

Permalink
reader 取得箇所を修正する
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexa committed Nov 7, 2024
1 parent a8e23cf commit 74ae761
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,30 +351,25 @@ func opus2ogg(ctx context.Context, opusReader io.Reader, oggWriter io.Writer, sa
return err
}

var r io.Reader
if c.AudioStreamingHeader {
r, err = readPacketWithHeader(opusReader)
if err != nil {
return err
}
} else {
r = opusReader
}

for {
buf := make([]byte, FrameSize)
var n int
if c.AudioStreamingHeader {
r, err := readPacketWithHeader(opusReader)
if err != nil {
return err
}

n, err = r.Read(buf)
if err != nil {
if w, ok := oggWriter.(*io.PipeWriter); ok {
w.CloseWithError(err)
}
return err
}
} else {
n, err = opusReader.Read(buf)
if err != nil {
if w, ok := oggWriter.(*io.PipeWriter); ok {
w.CloseWithError(err)
}
return err
n, err = r.Read(buf)
if err != nil {
if w, ok := oggWriter.(*io.PipeWriter); ok {
w.CloseWithError(err)
}
return err
}

if n > 0 {
Expand Down

0 comments on commit 74ae761

Please sign in to comment.