docs(readme): check loop and context errors in the video example
- commit
- adcd7e54016728e72a3127d3fbfab0bb62f055b0
- author
- brice · · 2026-10-15 02:40 UTC
- parent
- d7dc935
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +11 -4
M README.md +11 -4
| @@ -115,9 +115,15 @@ if err != nil { | |||
| 115 | 115 | } | |
| 116 | 116 | defer rt.Deinit() | |
| 117 | 117 | ||
| 118 | - | loop, _ := rt.NewLoop() | |
| 118 | + | loop, err := rt.NewLoop() | |
| 119 | + | if err != nil { | |
| 120 | + | return err | |
| 121 | + | } | |
| 119 | 122 | defer loop.Destroy() | |
| 120 | - | ctx, _ := rt.NewContext(loop) | |
| 123 | + | ctx, err := rt.NewContext(loop) | |
| 124 | + | if err != nil { | |
| 125 | + | return err | |
| 126 | + | } | |
| 121 | 127 | defer ctx.Destroy() | |
| 122 | 128 | core, err := ctx.Connect() | |
| 123 | 129 | if err != nil { | |
| @@ -151,8 +157,9 @@ if b := src.Dequeue(); b != nil { // nil: no buffer is free, skip the frame | |||
| 151 | 157 | ||
| 152 | 158 | Buffers that PipeWire removes while you still hold them (renegotiation, | |
| 153 | 159 | `Resize`, `Destroy`, the consumer leaving) stay mapped until you hand them back | |
| 154 | - | with `Queue` or `Release`. `Resize` and `Destroy` are best called when no buffer | |
| 155 | - | is borrowed. A consumer that is not a plain `pipewiresrc` may need to declare | |
| 160 | + | with `Queue` or `Release`. `Resize` fails with `ErrVideoBorrowed` while a buffer | |
| 161 | + | is borrowed, and `Destroy` is best called when none is. Formats are BGRx and | |
| 162 | + | BGRA. A consumer that is not a plain `pipewiresrc` may need to declare | |
| 156 | 163 | `media.type=Video` (for example `pipewiresrc stream-properties=props,media.type=Video`) | |
| 157 | 164 | for WirePlumber to link it. | |
| 158 | 165 | ||
| @@ -115,9 +115,15 @@ if err != nil { | |||||
| 115 | } | 115 | } | ||
| 116 | defer rt.Deinit() | 116 | defer rt.Deinit() | ||
| 117 | 117 | ||||
| 118 | - | loop, _ := rt.NewLoop() | 118 | + | loop, err := rt.NewLoop() |
| 119 | + | if err != nil { | |||
| 120 | + | return err | |||
| 121 | + | } | |||
| 119 | defer loop.Destroy() | 122 | defer loop.Destroy() | ||
| 120 | - | ctx, _ := rt.NewContext(loop) | 123 | + | ctx, err := rt.NewContext(loop) |
| 124 | + | if err != nil { | |||
| 125 | + | return err | |||
| 126 | + | } | |||
| 121 | defer ctx.Destroy() | 127 | defer ctx.Destroy() | ||
| 122 | core, err := ctx.Connect() | 128 | core, err := ctx.Connect() | ||
| 123 | if err != nil { | 129 | if err != nil { | ||
| @@ -151,8 +157,9 @@ if b := src.Dequeue(); b != nil { // nil: no buffer is free, skip the frame | |||||
| 151 | 157 | ||||
| 152 | Buffers that PipeWire removes while you still hold them (renegotiation, | 158 | Buffers that PipeWire removes while you still hold them (renegotiation, | ||
| 153 | `Resize`, `Destroy`, the consumer leaving) stay mapped until you hand them back | 159 | `Resize`, `Destroy`, the consumer leaving) stay mapped until you hand them back | ||
| 154 | - | with `Queue` or `Release`. `Resize` and `Destroy` are best called when no buffer | 160 | + | with `Queue` or `Release`. `Resize` fails with `ErrVideoBorrowed` while a buffer |
| 155 | - | is borrowed. A consumer that is not a plain `pipewiresrc` may need to declare | 161 | + | is borrowed, and `Destroy` is best called when none is. Formats are BGRx and |
| 162 | + | BGRA. A consumer that is not a plain `pipewiresrc` may need to declare | |||
| 156 | `media.type=Video` (for example `pipewiresrc stream-properties=props,media.type=Video`) | 163 | `media.type=Video` (for example `pipewiresrc stream-properties=props,media.type=Video`) | ||
| 157 | for WirePlumber to link it. | 164 | for WirePlumber to link it. | ||
| 158 | 165 | ||||