Skip to content

Commit

Permalink
writer の close 処理時に fd も閉じるようにする
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexa committed Jan 6, 2025
1 parent 8e506ff commit 386af77
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,13 @@ func opus2ogg(ctx context.Context, opusCh chan opusChannel, sampleRate uint32, c
writers := []io.Writer{}
writers = append(writers, oggWriter)

var f *os.File
if c.EnableOggFileOutput {
fileName := fmt.Sprintf("%s_%s.ogg", header.SoraSessionID, header.SoraConnectionID)
filePath := path.Join(c.OggDir, fileName)
f, err := os.Create(filePath)

var err error
f, err = os.Create(filePath)
if err != nil {
return nil, err
}
Expand All @@ -489,6 +492,10 @@ func opus2ogg(ctx context.Context, opusCh chan opusChannel, sampleRate uint32, c
}
defer o.Close()

if c.EnableOggFileOutput {
o.fd = f
}

for {
select {
case <-ctx.Done():
Expand Down

0 comments on commit 386af77

Please sign in to comment.