| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_GPU_AVDA_RETURN_ON_FAILURE_H_ | |
| 6 #define MEDIA_GPU_AVDA_RETURN_ON_FAILURE_H_ | |
| 7 | |
| 8 #include "media/video/video_decode_accelerator.h" | |
| 9 | |
| 10 // Helper macros for dealing with failure. If |result| evaluates false, emit | |
| 11 // |log| to ERROR, register |error| with the decoder, and return. This will | |
| 12 // also transition to the error state, stopping further decoding. | |
| 13 // This is meant to be used only within AndroidVideoDecoder and the various | |
| 14 // backing strategies. |provider| must support PostError. The varargs | |
| 15 // can be used for the return value. | |
| 16 #define RETURN_ON_FAILURE(provider, result, log, error, ...) \ | |
| 17 do { \ | |
| 18 if (!(result)) { \ | |
| 19 DLOG(ERROR) << log; \ | |
| 20 provider->PostError(FROM_HERE, VideoDecodeAccelerator::error); \ | |
| 21 return __VA_ARGS__; \ | |
| 22 } \ | |
| 23 } while (0) | |
| 24 | |
| 25 // Similar to the above, with some handy boilerplate savings. The varargs | |
| 26 // can be used for the return value. | |
| 27 #define RETURN_IF_NULL(ptr, ...) \ | |
| 28 RETURN_ON_FAILURE(state_provider_, ptr, "Got null for " << #ptr, \ | |
| 29 ILLEGAL_STATE, ##__VA_ARGS__); | |
| 30 | |
| 31 // Return null if !ptr. | |
| 32 #define RETURN_NULL_IF_NULL(ptr) RETURN_IF_NULL(ptr, 0) | |
| 33 | |
| 34 #endif // MEDIA_GPU_AVDA_RETURN_ON_FAILURE_H_ | |
| OLD | NEW |