Skip to content

Commit ffd1653

Browse files
committed
Fixed Opus webstream crash.
1 parent 91a02b7 commit ffd1653

2 files changed

Lines changed: 22 additions & 10 deletions

File tree

‎examples/uos.pas‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10941,12 +10941,17 @@ procedure Tuos_Player.ReadUrl(x: integer);
1094110941
writeln('===> Before op_read_x.');
1094210942
{$ENDIF}
1094310943

10944+
if StreamIn[x].Data.channels <= 0 then StreamIn[x].Data.channels := 2;
10945+
10946+
StreamIn[x].Data.Wantframes := 6144;
10947+
setlength(StreamIn[x].Data.Buffer, 6144 * StreamIn[x].Data.channels);
10948+
10949+
1094410950
case StreamIn[x].Data.SampleFormat of
1094510951
0:
1094610952
begin
1094710953
StreamIn[x].Data.outframes := cint(op_read_float(StreamIn[x].Data.HandleOP,
10948-
@StreamIn[x].Data.Buffer[0], cint(StreamIn[x].Data.Wantframes
10949-
Div StreamIn[x].Data.channels), Nil));
10954+
Pointer(StreamIn[x].Data.Buffer), cint(StreamIn[x].Data.Wantframes), Nil));
1095010955
end;
1095110956
1:
1095210957
begin
@@ -10955,17 +10960,18 @@ procedure Tuos_Player.ReadUrl(x: integer);
1095510960
Div StreamIn[x].Data.channels), Nil));
1095610961

1095710962
// no int32 format with opus => need a conversion from float32 to int32.
10963+
if StreamIn[x].Data.outframes > 0 then
1095810964
StreamIn[x].Data.Buffer := Cvfloat32ToInt32fl(StreamIn[x].Data.Buffer,
1095910965
StreamIn[x].Data.outframes * StreamIn[x].Data.Channels);
1096010966
end;
1096110967
2:
1096210968
begin
1096310969
StreamIn[x].Data.outframes := cint(op_read(StreamIn[x].Data.HandleOP,
10964-
@StreamIn[x].Data.Buffer[0], cint(StreamIn[x].Data.Wantframes
10965-
Div StreamIn[x].Data.channels), Nil));
10970+
Pointer(StreamIn[x].Data.Buffer), cint(StreamIn[x].Data.Wantframes), Nil));
10971+
1096610972
end;
1096710973
end;
10968-
10974+
1096910975
setlength(StreamIn[x].data.Buffer, StreamIn[x].Data.outframes * StreamIn[x].Data.Channels);
1097010976

1097110977
{$IF DEFINED(uos_debug) and DEFINED(unix)}

‎src/uos.pas‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10941,12 +10941,17 @@ procedure Tuos_Player.ReadUrl(x: integer);
1094110941
writeln('===> Before op_read_x.');
1094210942
{$ENDIF}
1094310943

10944+
if StreamIn[x].Data.channels <= 0 then StreamIn[x].Data.channels := 2;
10945+
10946+
StreamIn[x].Data.Wantframes := 6144;
10947+
setlength(StreamIn[x].Data.Buffer, 6144 * StreamIn[x].Data.channels);
10948+
10949+
1094410950
case StreamIn[x].Data.SampleFormat of
1094510951
0:
1094610952
begin
1094710953
StreamIn[x].Data.outframes := cint(op_read_float(StreamIn[x].Data.HandleOP,
10948-
@StreamIn[x].Data.Buffer[0], cint(StreamIn[x].Data.Wantframes
10949-
Div StreamIn[x].Data.channels), Nil));
10954+
Pointer(StreamIn[x].Data.Buffer), cint(StreamIn[x].Data.Wantframes), Nil));
1095010955
end;
1095110956
1:
1095210957
begin
@@ -10955,17 +10960,18 @@ procedure Tuos_Player.ReadUrl(x: integer);
1095510960
Div StreamIn[x].Data.channels), Nil));
1095610961

1095710962
// no int32 format with opus => need a conversion from float32 to int32.
10963+
if StreamIn[x].Data.outframes > 0 then
1095810964
StreamIn[x].Data.Buffer := Cvfloat32ToInt32fl(StreamIn[x].Data.Buffer,
1095910965
StreamIn[x].Data.outframes * StreamIn[x].Data.Channels);
1096010966
end;
1096110967
2:
1096210968
begin
1096310969
StreamIn[x].Data.outframes := cint(op_read(StreamIn[x].Data.HandleOP,
10964-
@StreamIn[x].Data.Buffer[0], cint(StreamIn[x].Data.Wantframes
10965-
Div StreamIn[x].Data.channels), Nil));
10970+
Pointer(StreamIn[x].Data.Buffer), cint(StreamIn[x].Data.Wantframes), Nil));
10971+
1096610972
end;
1096710973
end;
10968-
10974+
1096910975
setlength(StreamIn[x].data.Buffer, StreamIn[x].Data.outframes * StreamIn[x].Data.Channels);
1097010976

1097110977
{$IF DEFINED(uos_debug) and DEFINED(unix)}

0 commit comments

Comments
 (0)