* Try decoding a stream. * * DecoderControl::mutex is not locked by caller. */
| 335 | * DecoderControl::mutex is not locked by caller. |
| 336 | */ |
| 337 | static DecodeResult |
| 338 | decoder_run_stream(DecoderBridge &bridge, const char *uri) |
| 339 | { |
| 340 | auto result = TryUriDecode(bridge, uri); |
| 341 | if (IsFinalDecodeResult(result)) |
| 342 | return result; |
| 343 | |
| 344 | DecoderControl &dc = bridge.dc; |
| 345 | |
| 346 | auto input_stream = bridge.OpenUri(uri); |
| 347 | assert(input_stream); |
| 348 | |
| 349 | MaybeLoadReplayGain(bridge, *input_stream); |
| 350 | |
| 351 | std::unique_lock lock{dc.mutex}; |
| 352 | |
| 353 | if (dc.command == DecoderCommand::STOP) |
| 354 | return DecodeResult::STOP; |
| 355 | |
| 356 | if (auto r = decoder_run_stream_locked(bridge, *input_stream, lock, uri); |
| 357 | r > result) { |
| 358 | result = r; |
| 359 | if (IsFinalDecodeResult(result)) |
| 360 | return result; |
| 361 | } |
| 362 | |
| 363 | /* fallback to mp3: this is needed for bastard streams that |
| 364 | don't have a suffix or set the mimeType */ |
| 365 | if (auto r = decoder_run_stream_fallback(bridge, *input_stream, lock); |
| 366 | r > result) { |
| 367 | result = r; |
| 368 | } |
| 369 | |
| 370 | return result; |
| 371 | } |
| 372 | |
| 373 | /** |
| 374 | * Decode a file with the given decoder plugin. |
no test coverage detected