11///|
2- test " alsa fixed buffer 0 is invalid argument (best-effort) " {
3- if @moon_cpal .native_os() != @moon_cpal .NativeOs ::Linux {
2+ test " alsa fixed buffer 0 is stream_config_not_supported (best-effort) " {
3+ if @core .native_os() != @core .NativeOs ::Linux {
44 inspect(true , content="true ")
55 return
66 }
@@ -16,10 +16,10 @@ test "alsa fixed buffer 0 is invalid argument (best-effort)" {
1616 } noraise {
1717 x => x
1818 }
19- let sc = @moon_cpal .StreamConfig ::new(
19+ let sc = @core .StreamConfig ::new(
2020 cfg.channels(),
2121 cfg.sample_rate(),
22- @moon_cpal .BufferSize ::fixed(0),
22+ @core .BufferSize ::fixed(0),
2323 )
2424 try
2525 dev.build_output_stream_raw(
@@ -32,7 +32,7 @@ test "alsa fixed buffer 0 is invalid argument (best-effort)" {
3232 catch {
3333 e =>
3434 match e {
35- @moon_cpal .BuildStreamError ::InvalidArgument =>
35+ @core .BuildStreamError ::StreamConfigNotSupported =>
3636 inspect(true , content="true ")
3737 _ => inspect(false , content="true ")
3838 }
@@ -48,7 +48,7 @@ test "alsa fixed buffer 0 is invalid argument (best-effort)" {
4848
4949///|
5050test " alsa fixed buffer larger than supported range fails (best-effort) " {
51- if @moon_cpal .native_os() != @moon_cpal .NativeOs ::Linux {
51+ if @core .native_os() != @core .NativeOs ::Linux {
5252 inspect(true , content="true ")
5353 return
5454 }
@@ -64,11 +64,23 @@ test "alsa fixed buffer larger than supported range fails (best-effort)" {
6464 } noraise {
6565 x => x
6666 }
67- let big = 1000000000
68- let sc = @moon_cpal.StreamConfig ::new(
67+ let max_buf = match cfg.buffer_size() {
68+ @core.SupportedBufferSize ::Unknown => {
69+ inspect(true , content="true ")
70+ return
71+ }
72+ @core.SupportedBufferSize ::Range (max=mx, ..) => mx
73+ }
74+ // Avoid overflow when buffer size is effectively unbounded.
75+ if max_buf >= 2147483647 {
76+ inspect(true , content="true ")
77+ return
78+ }
79+ let want = max_buf + 1
80+ let sc = @core.StreamConfig ::new(
6981 cfg.channels(),
7082 cfg.sample_rate(),
71- @moon_cpal .BufferSize ::fixed(big ),
83+ @core .BufferSize ::fixed(want ),
7284 )
7385 let got = try
7486 dev.build_output_stream_raw(
@@ -79,7 +91,11 @@ test "alsa fixed buffer larger than supported range fails (best-effort)" {
7991 None ,
8092 )
8193 catch {
82- _ => None
94+ e =>
95+ match e {
96+ @core.BuildStreamError ::StreamConfigNotSupported => None
97+ _ => None
98+ }
8399 } noraise {
84100 s => Some (s)
85101 }
0 commit comments