summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cam/buffer_writer.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/cam/buffer_writer.cpp b/src/cam/buffer_writer.cpp
index 1c044b06..c33e99c5 100644
--- a/src/cam/buffer_writer.cpp
+++ b/src/cam/buffer_writer.cpp
@@ -14,12 +14,14 @@
#include "buffer_writer.h"
+using namespace libcamera;
+
BufferWriter::BufferWriter(const std::string &pattern)
: pattern_(pattern)
{
}
-int BufferWriter::write(libcamera::Buffer *buffer, const std::string &streamName)
+int BufferWriter::write(Buffer *buffer, const std::string &streamName)
{
std::string filename;
size_t pos;
@@ -40,8 +42,8 @@ int BufferWriter::write(libcamera::Buffer *buffer, const std::string &streamName
if (fd == -1)
return -errno;
- libcamera::BufferMemory *mem = buffer->mem();
- for (libcamera::Plane &plane : mem->planes()) {
+ BufferMemory *mem = buffer->mem();
+ for (Plane &plane : mem->planes()) {
void *data = plane.mem();
unsigned int length = plane.length();
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * object.cpp - Object tests
 */

#include <iostream>

#include <libcamera/object.h>

#include "libcamera/internal/message.h"
#include "libcamera/internal/thread.h"

#include "test.h"

using namespace std;
using namespace libcamera;

class InstrumentedObject : public Object
{
public:
	enum Status {
		NoMessage,
		MessageReceived,
	};

	InstrumentedObject(Object *parent = nullptr)
		: Object(parent), status_(NoMessage)
	{
	}

	Status status() const { return status_; }
	void reset() { status_ = NoMessage; }

protected:
	void message(Message *msg) override
	{
		if (msg->type() == Message::ThreadMoveMessage)
			status_ = MessageReceived;

		Object::message(msg);
	}

private:
	Status status_;
};

class ObjectTest : public Test
{
protected:
	int init()
	{
		/*
		 * Create a hierarchy of objects:
		 * A -> B -> C
		 *   \->D
		 * E
		 */
		a_ = new InstrumentedObject();
		b_ = new InstrumentedObject(a_);
		c_ = new InstrumentedObject(b_);
		d_ = new InstrumentedObject(a_);
		e_ = new InstrumentedObject();
		f_ = nullptr;

		return TestPass;
	}

	int run()
	{
		/* Verify the parent-child relationships. */
		if (a_->parent() != nullptr || b_->parent() != a_ ||
		    c_->parent() != b_ || d_->parent() != a_ ||
		    e_->parent() != nullptr) {
			cout << "Incorrect parent-child relationships" << endl;
			return TestFail;
		}

		/*
		 * Verify that moving an object with no parent to a different
		 * thread succeeds.
		 */
		e_->moveToThread(&thread_);