| 122 | } |
| 123 | |
| 124 | static bool |
| 125 | flac_decoder_initialize(FlacDecoder *data, FLAC__StreamDecoder *sd) noexcept |
| 126 | { |
| 127 | if (!FLAC__stream_decoder_process_until_end_of_metadata(sd)) { |
| 128 | if (FLAC__stream_decoder_get_state(sd) != FLAC__STREAM_DECODER_END_OF_STREAM) |
| 129 | LogWarning(flac_domain, "problem reading metadata"); |
| 130 | return false; |
| 131 | } |
| 132 | |
| 133 | if (data->initialized) { |
| 134 | /* done */ |
| 135 | return true; |
| 136 | } |
| 137 | |
| 138 | if (data->GetInputStream().IsSeekable()) |
| 139 | /* allow the workaround below only for nonseekable |
| 140 | streams*/ |
| 141 | return false; |
| 142 | |
| 143 | /* no stream_info packet found; try to initialize the decoder |
| 144 | from the first frame header */ |
| 145 | FLAC__stream_decoder_process_single(sd); |
| 146 | return data->initialized; |
| 147 | } |
| 148 | |
| 149 | static DecoderCommand |
| 150 | FlacSubmitToClient(DecoderClient &client, FlacDecoder &d) noexcept |