* Decode a file with the given decoder plugin. * * DecoderControl::mutex is not locked by caller. */
| 376 | * DecoderControl::mutex is not locked by caller. |
| 377 | */ |
| 378 | static DecodeResult |
| 379 | TryDecoderFile(DecoderBridge &bridge, Path path_fs, std::string_view suffix, |
| 380 | InputStream &input_stream, |
| 381 | const DecoderPlugin &plugin) |
| 382 | { |
| 383 | if (!plugin.SupportsSuffix(suffix)) |
| 384 | return DecodeResult::NO_PLUGIN; |
| 385 | |
| 386 | bridge.Reset(); |
| 387 | |
| 388 | DecoderControl &dc = bridge.dc; |
| 389 | |
| 390 | if (plugin.file_decode != nullptr) { |
| 391 | const std::lock_guard protect{dc.mutex}; |
| 392 | return decoder_file_decode(plugin, bridge, path_fs); |
| 393 | } else if (plugin.stream_decode != nullptr) { |
| 394 | std::unique_lock lock{dc.mutex}; |
| 395 | return decoder_stream_decode(plugin, bridge, input_stream, |
| 396 | lock); |
| 397 | } else |
| 398 | return DecodeResult::NO_STREAM_PLUGIN; |
| 399 | } |
| 400 | |
| 401 | /** |
| 402 | * Decode a container file with the given decoder plugin. |
no test coverage detected