[libcamera-devel] [PATCH/RFC 01/12] libcamera: camera: Fix std::ostringstream initialisation

Kieran Bingham kieran.bingham at ideasonboard.com
Sun May 19 12:39:42 CEST 2019


Hi Laurent,

On 18/05/2019 00:06, Laurent Pinchart wrote:
> We use the std::ostringstream class to generate log messages in the
> Camera class. The stream is initialised with initial content, but is not
> opened without seeking to the end, which results in the content being
> overwritten immediately. Fix it by opening the stream with
> std::ios_base::ate.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
>  src/libcamera/camera.cpp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> index fbc66dedba51..1a21acac9899 100644
> --- a/src/libcamera/camera.cpp
> +++ b/src/libcamera/camera.cpp
> @@ -560,7 +560,7 @@ Camera::streamConfiguration(const std::vector<StreamUsage> &usages)
>  
>  	CameraConfiguration config = pipe_->streamConfiguration(this, usages);
>  
> -	std::ostringstream msg("streams configuration:");
> +	std::ostringstream msg("streams configuration:", std::ios_base::ate);

>  	unsigned int index = 0;
>  
>  	for (Stream *stream : config) {
> @@ -614,7 +614,7 @@ int Camera::configureStreams(const CameraConfiguration &config)
>  		return -EINVAL;
>  	}
>  
> -	std::ostringstream msg("configuring streams:");
> +	std::ostringstream msg("configuring streams:", std::ios_base::ate);
>  	unsigned int index = 0;
>  
>  	for (Stream *stream : config) {

Should all of this be moved to the CameraConfiguration class as a
toString() or such? or will this be the only place we print a
CameraConfiguration...

> 

-- 
Regards
--
Kieran


More information about the libcamera-devel mailing list