Example #1
0
status_t 
ESDSinkNode::SetBufferGroup(const media_source& for_source, BBufferGroup* newGroup)
{
	CALLED();

	node_output *channel = FindOutput(for_source);
	
	// is this our output?
	if (channel == NULL)
	{
		fprintf(stderr, "ESDSinkNode::SetBufferGroup returning B_MEDIA_BAD_SOURCE\n");
		return B_MEDIA_BAD_SOURCE;
	}

	// Are we being passed the buffer group we're already using?
	if (newGroup == channel->fBufferGroup) return B_OK;

	// Ahh, someone wants us to use a different buffer group.  At this point we delete
	// the one we are using and use the specified one instead.  If the specified group is
	// NULL, we need to recreate one ourselves, and use *that*.  Note that if we're
	// caching a BBuffer that we requested earlier, we have to Recycle() that buffer
	// *before* deleting the buffer group, otherwise we'll deadlock waiting for that
	// buffer to be recycled!
	delete channel->fBufferGroup;		// waits for all buffers to recycle
	if (newGroup != NULL)
	{
		// we were given a valid group; just use that one from now on
		channel->fBufferGroup = newGroup;
	}
	else
	{
		// we were passed a NULL group pointer; that means we construct
		// our own buffer group to use from now on
		size_t size = channel->fOutput.format.u.raw_audio.buffer_size;
		int32 count = int32(fLatency / BufferDuration() + 1 + 1);
		channel->fBufferGroup = new BBufferGroup(size, count);
	}

	return B_OK;
}
Example #2
0
status_t
SoftPipeRenderer::CopyPixelsOut(BPoint location, BBitmap *bitmap)
{
	CALLED();
	color_space scs = fBitmap->ColorSpace();
	color_space dcs = bitmap->ColorSpace();

	if (scs != dcs && (scs != B_RGBA32 || dcs != B_RGB32)) {
		fprintf(stderr, "%s::CopyPixelsOut(): incompatible color space: %s != %s\n",
			__FUNCTION__, color_space_name(scs), color_space_name(dcs));
		return B_BAD_TYPE;
	}

	BRect sr = fBitmap->Bounds();
	BRect dr = bitmap->Bounds();

//	int32 w1 = sr.IntegerWidth();
//	int32 h1 = sr.IntegerHeight();
//	int32 w2 = dr.IntegerWidth();
//	int32 h2 = dr.IntegerHeight();

	sr = sr & dr.OffsetBySelf(location);
	dr = sr.OffsetByCopy(-location.x, -location.y);

	uint8 *ps = (uint8 *) fBitmap->Bits();
	uint8 *pd = (uint8 *) bitmap->Bits();
	uint32 *s, *d;
	uint32 y;
	for (y = (uint32) sr.top; y <= (uint32) sr.bottom; y++) {
		s = (uint32 *)(ps + y * fBitmap->BytesPerRow());
		s += (uint32) sr.left;

		d = (uint32 *)(pd + (y + (uint32)(dr.top - sr.top))
			* bitmap->BytesPerRow());
		d += (uint32) dr.left;
		memcpy(d, s, dr.IntegerWidth() * 4);
	}

	return B_OK;
}
Example #3
0
void
BTimeSource::FinishCreate()
{
	CALLED();
	//printf("BTimeSource::FinishCreate(), id %ld\n", ID());

	char name[32];
	sprintf(name, "__timesource_buf_%" B_PRId32, ID());
	fArea = create_area(name, reinterpret_cast<void **>(const_cast<BPrivate::media::TimeSourceTransmit **>(&fBuf)), B_ANY_ADDRESS, TS_AREA_SIZE, B_FULL_LOCK, B_READ_AREA | B_WRITE_AREA);
	if (fArea <= 0) {
		ERROR("BTimeSource::BTimeSource couldn't create area, node %" B_PRId32
			"\n", ID());
		fBuf = NULL;
		return;
	}
	fBuf->readindex = 0;
	fBuf->writeindex = 1;
	fBuf->realtime[0] = 0;
	fBuf->perftime[0] = 0;
	fBuf->drift[0] = 1.0f;
	fBuf->isrunning = fStarted;
}
Example #4
0
status_t
ESDEndpoint::SendDefaultCommand()
{
	status_t err;
	struct {
		esd_format_t format;
		esd_rate_t rate;
		char name[ESD_MAX_NAME];
	} c;
	CALLED();
	if (fDefaultCommandSent)
		return EALREADY;
	c.format = fDefaultFormat;
	c.rate = fDefaultRate;
	strcpy(c.name, "BeOS/Haiku/ZETA Media Kit output");
	err = SendCommand(fDefaultCommand, (uint8 *)&c, sizeof(c), NULL, 0);
	if (err < B_OK)
		return err;
	PRINT(("SendCommand: %s\n", strerror(err)));
	fDefaultCommandSent = true;
	return B_OK;
}
Example #5
0
status_t 
FireWireDVNode::FormatProposal(const media_source& source, 
	media_format* format)
{
	CALLED();	
	/* The connection process:
	 * we are here => BBufferProducer::FormatProposal
	 *                BBufferConsumer::AcceptFormat
	 *                BBufferProducer::PrepareToConnect
	 *                BBufferConsumer::Connected
	 *                BBufferProducer::Connect
	 *
	 * What we need to do:
	 * - if the format contains a wildcard AND we have a requirement for that
	 *   field, set it to the value we need.
	 * - if a field has a value that is not wildcard and not supported by us,
	 *   we don't change it, and return B_MEDIA_BAD_FORMAT
	 * - after we are done, the format may still contain wildcards.
	 */
	
	if (source.port != ControlPort()) {
		fprintf(stderr, "FireWireDVNode::FormatProposal returning "
			"B_MEDIA_BAD_SOURCE\n");
		return B_MEDIA_BAD_SOURCE;
	}

	media_type requestedType = format->type;
	*format = fDefaultFormatEncVideo;

	if (requestedType != B_MEDIA_UNKNOWN_TYPE
		&& requestedType != B_MEDIA_ENCODED_VIDEO) {
		fprintf(stderr, "FireWireDVNode::FormatProposal returning "
			"B_MEDIA_BAD_FORMAT\n");
		return B_MEDIA_BAD_FORMAT;
	}
	
	// encoded video or wildcard type, either is okay by us
	return B_OK;
}
Example #6
0
void
BMediaFile::_InitReader(BDataIO* source, const BUrl* url, int32 flags)
{
	CALLED();

	if (source == NULL && url == NULL) {
		fErr = B_NO_MEMORY;
		return;
	}

	if (source != NULL) {
		if (BFile* file = dynamic_cast<BFile*>(source)) {
			fErr = file->InitCheck();
			if (fErr != B_OK)
				return;
		}
		fExtractor = new(std::nothrow) MediaExtractor(source, flags);
	} else
		fExtractor = new(std::nothrow) MediaExtractor(*url, flags);

	if (fExtractor == NULL)
		fErr = B_NO_MEMORY;
	else
		fErr = fExtractor->InitCheck();
	if (fErr != B_OK)
		return;

	// Get the actual source from the extractor
	fSource = fExtractor->Source();

	fExtractor->GetFileFormatInfo(&fMFI);
	fTrackNum = fExtractor->StreamCount();
	fTrackList = (BMediaTrack**)malloc(fTrackNum * sizeof(BMediaTrack*));
	if (fTrackList == NULL) {
		fErr = B_NO_MEMORY;
		return;
	}
	memset(fTrackList, 0, fTrackNum * sizeof(BMediaTrack*));
}
Example #7
0
status_t
ESDEndpoint::SendCommand(esd_command_t cmd, const uint8 *obuf, size_t olen, uint8 *ibuf, size_t ilen)
{
	status_t err;
	CALLED();
	err = send(fSocket, &cmd, sizeof(cmd), 0);
	if (err < B_OK)
		return errno;
	if (obuf && olen) {
		err = send(fSocket, obuf, olen, 0);
		if (err < B_OK)
			return errno;
	}
	err = B_OK;
	if (ibuf && ilen) {
		err = recv(fSocket, ibuf, ilen, 0);
		if (err < B_OK)
			return errno;
		/* return received len */
	}
	return err;
}
Example #8
0
status_t
BMediaTrack::ReadChunk(char** _buffer, int32* _size, media_header* _header)
{
	CALLED();

	if (fExtractor == NULL)
		return B_NO_INIT;

	if (_buffer == NULL || _size == NULL)
		return B_BAD_VALUE;

	media_header header;
	if (_header == NULL)
		_header = &header;

	// Always clear the header first, as the extractor may not set all fields.
	memset(_header, 0, sizeof(media_header));

	const void* buffer;
	size_t size;
	status_t result = fExtractor->GetNextChunk(fStream, &buffer, &size,
		_header);

	if (result == B_OK) {
		*_buffer = const_cast<char*>(static_cast<const char*>(buffer));
			// TODO: Change the pointer type when we break the API.
		*_size = size;
		// TODO: This changes the meaning of fCurrentTime from pointing
		// to the next chunk start time (i.e. after seeking) to the start time
		// of the last chunk. Asking the extractor for the current time will
		// not work so well because of the chunk cache. But providing a
		// "duration" field in the media_header could be useful.
		fCurrentTime = _header->start_time;
		fCurrentFrame = (int64)(fCurrentTime * _FrameRate() / 1000000LL);

	}

	return result;
}
Example #9
0
status_t
Unregister(const BMessenger& notifyHandler, const media_node& node,
	int32 notification)
{
	CALLED();

	if (notification == B_MEDIA_SERVER_STARTED
		|| notification == B_MEDIA_SERVER_QUIT) {
		BMessage msg(MEDIA_ROSTER_CANCEL_NOTIFICATIONS);
		msg.AddInt32(NOTIFICATION_PARAM_WHAT, notification);
		msg.AddMessenger(NOTIFICATION_PARAM_MESSENGER, notifyHandler);
		return BPrivate::media::dataexchange::SendToRoster(&msg);
	}

	BMessage msg(MEDIA_SERVER_CANCEL_NOTIFICATIONS);
	msg.AddInt32(NOTIFICATION_PARAM_WHAT, notification);
	msg.AddInt32(NOTIFICATION_PARAM_TEAM, BPrivate::current_team());
	msg.AddMessenger(NOTIFICATION_PARAM_MESSENGER, notifyHandler);
	msg.AddData("node", B_RAW_TYPE, &node, sizeof(node));

	return BPrivate::media::dataexchange::SendToServer(&msg);
}
Example #10
0
status_t 
BMediaEncoder::SetTo(const media_format* outputFormat)
{
	CALLED();

	status_t err = B_ERROR;
	ReleaseEncoder();

	if (outputFormat == NULL)
		return fInitStatus;

	media_format format = *outputFormat;
	err = gPluginManager.CreateEncoder(&fEncoder, format);
	if (fEncoder != NULL && err == B_OK) {
		err = _AttachToEncoder();
		if (err == B_OK)
			return err;
	}
	ReleaseEncoder();
	fInitStatus = err;
	return err;
}
status_t
BMediaTrack::FindKeyFrameForFrame(int64* _frame, int32 flags) const
{
    CALLED();
    if (fExtractor == NULL)
        return B_NO_INIT;
    if (_frame == NULL)
        return B_BAD_VALUE;

    // Make sure flags are valid
    flags = (flags & B_MEDIA_SEEK_DIRECTION_MASK) | B_MEDIA_SEEK_TO_FRAME;

    bigtime_t time = 0;
    // dummy time, will be ignored because of flags
    status_t result = fExtractor->FindKeyFrame(fStream, flags, _frame, &time);
    if (result != B_OK) {
        ERROR("BMediaTrack::FindKeyFrameForFrame: extractor seek failed: %s\n",
              strerror(result));
    }

    return result;
}
BMediaTrack::BMediaTrack(BPrivate::media::MediaWriter* writer,
                         int32 streamIndex, media_format* format,
                         const media_codec_info* codecInfo)
{
    CALLED();

    fWorkaroundFlags = 0;
    fEncoder = NULL;
    fEncoderID = -1;
    // TODO: Not yet sure what this was needed for...
    fWriter = writer;
    fStream = streamIndex;
    fInitStatus = B_OK;

    SetupWorkaround();

    if (codecInfo != NULL) {
        status_t ret = fWriter->CreateEncoder(&fEncoder, codecInfo, format);
        if (ret != B_OK) {
            TRACE("BMediaTrack::BMediaTrack: Error: creating decoder failed: "
                  "%s\n", strerror(ret));
            // We do not set fInitStatus here, because WriteChunk should still
            // work.
            fEncoder = NULL;
        } else {
            fCodecInfo = *codecInfo;
            fInitStatus = fEncoder->SetUp(format);
        }
    }

    fFormat = *format;

    // not used:
    fCurrentFrame = 0;
    fCurrentTime = 0;
    fDecoder = NULL;
    fRawDecoder = NULL;
    fExtractor = NULL;
}
Example #13
0
VirtioRNGDevice::VirtioRNGDevice(device_node *node)
	:
	fNode(node),
	fVirtio(NULL),
	fVirtioDevice(NULL),
	fStatus(B_NO_INIT),
	fOffset(BUFFER_SIZE)
{
	CALLED();

	B_INITIALIZE_SPINLOCK(&fInterruptLock);
	fInterruptCondition.Init(this, "virtio rng transfer");

	get_memory_map(fBuffer, BUFFER_SIZE, &fEntry, 1);

	// get the Virtio device from our parent's parent
	device_node *parent = gDeviceManager->get_parent_node(node);
	device_node *virtioParent = gDeviceManager->get_parent_node(parent);
	gDeviceManager->put_node(parent);

	gDeviceManager->get_driver(virtioParent, (driver_module_info **)&fVirtio,
		(void **)&fVirtioDevice);
	gDeviceManager->put_node(virtioParent);

	fVirtio->negociate_features(fVirtioDevice,
		0, &fFeatures, &get_feature_name);

	fStatus = fVirtio->alloc_queues(fVirtioDevice, 1, &fVirtioQueue);
	if (fStatus != B_OK) {
		ERROR("queue allocation failed (%s)\n", strerror(fStatus));
		return;
	}

	fStatus = fVirtio->setup_interrupt(fVirtioDevice, NULL, this);
	if (fStatus != B_OK) {
		ERROR("interrupt setup failed (%s)\n", strerror(fStatus));
		return;
	}
}
Example #14
0
status_t MediaReader::HandleMessage(
				int32 message,
				const void * data,
				size_t size)
{
	CALLED();

	status_t status = B_OK;

	switch (message) {
		// no special messages for now
		default:
			status = BBufferProducer::HandleMessage(message,data,size);
			if (status == B_OK) {
				break;
			}
			status = AbstractFileInterfaceNode::HandleMessage(message,data,size);
			break;
	}

	return status;
}
Example #15
0
void
SoundPlayNode::NodeRegistered()
{
	CALLED();

	if (fInitStatus != B_OK) {
		ReportError(B_NODE_IN_DISTRESS);
		return;
	}

	SetPriority(B_URGENT_PRIORITY);

	fOutput.format.type = B_MEDIA_RAW_AUDIO;
	fOutput.format.u.raw_audio = media_multi_audio_format::wildcard;
	fOutput.destination = media_destination::null;
	fOutput.source.port = ControlPort();
	fOutput.source.id = 0;
	fOutput.node = Node();
	strcpy(fOutput.name, Name());

	Run();
}
Example #16
0
void
BMenuField::_InitMenuBar(BMenu* menu, BRect frame, bool fixedSize)
{
	CALLED();

	fMenu = menu;
	InitMenu(menu);

	if ((Flags() & B_SUPPORTS_LAYOUT)) {
		fMenuBar = new _BMCMenuBar_(fixedSize, this);
	} else {
		frame.left = _MenuBarOffset();
		frame.top = kVMargin;
		frame.right -= kVMargin;
		frame.bottom -= kVMargin;

		TRACE("frame(%.1f, %.1f, %.1f, %.1f) (%.2f, %.2f)\n",
			frame.left, frame.top, frame.right, frame.bottom,
			frame.Width(), frame.Height());

		fMenuBar = new _BMCMenuBar_(frame, fixedSize, this);
	}

	if (fixedSize) {
		// align the menu bar in the full available space
		fMenuBar->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
			B_ALIGN_VERTICAL_UNSET));
	} else {
		// align the menu bar left in the available space
		fMenuBar->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
			B_ALIGN_VERTICAL_UNSET));
	}

	AddChild(fMenuBar);
	fMenuBar->AddItem(menu);

	fMenuBar->SetFont(be_plain_font);
}
Example #17
0
void
BMenuField::DrawLabel(BRect bounds, BRect update)
{
	CALLED();

	_ValidateLayoutData();
	font_height& fh = fLayoutData->font_info;

	if (Label()) {
		SetLowColor(ViewColor());

		// horizontal alignment
		float x;
		switch (fAlign) {
			case B_ALIGN_RIGHT:
				x = fDivider - fLayoutData->label_width - 3.0;
				break;

			case B_ALIGN_CENTER:
				x = fDivider - fLayoutData->label_width / 2.0;
				break;

			default:
				x = 0.0;
				break;
		}

		// vertical alignment
		float y = Bounds().top
			+ (Bounds().Height() + 1 - fh.ascent - fh.descent) / 2
			+ fh.ascent;
		y = floor(y + 0.5);

		SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
			IsEnabled() ? B_DARKEN_MAX_TINT : B_DISABLED_LABEL_TINT));
		DrawString(Label(), BPoint(x, y));
	}
}
Example #18
0
status_t OpenSoundDeviceEngine::PreferredFormatFor(int fmt, media_format &format, bool rec)
{
	status_t err;
	CALLED();
	fmt &= rec ? Info()->iformats : Info()->oformats;
	if (fmt == 0)
		return B_MEDIA_BAD_FORMAT;
	err = WildcardFormatFor(fmt, format);
	if (err < B_OK)
		return err;
	if (format.type == B_MEDIA_RAW_AUDIO) {
		media_multi_audio_format &raw = format.u.raw_audio;
		//format.u.raw_audio.channel_count = Info()->max_channels;
		raw.byte_order = B_MEDIA_HOST_ENDIAN;
		raw.frame_rate = OpenSoundDevice::convert_oss_rate_to_media_rate(Info()->max_rate);		// measured in Hertz
		raw.buffer_size = DEFAULT_BUFFER_SIZE;
		/*if (rec)
			raw.buffer_size = 2048;*/
/*
		format.u.raw_audio.byte_order = B_MEDIA_HOST_ENDIAN;
		format.u.raw_audio.frame_rate = OpenSoundDevice::convert_oss_rate_to_media_rate(Info()->max_rate);		// measured in Hertz
		format.u.raw_audio.buffer_size = DEFAULT_BUFFER_SIZE;
*/
	} else if (format.type == B_MEDIA_ENCODED_AUDIO) {
		media_raw_audio_format &raw = format.u.encoded_audio.output;
		//format.u.encoded_audio.output.channel_count = Info()->max_channels;
		raw.byte_order = B_MEDIA_HOST_ENDIAN;
		// single rate supported
		if (Info()->min_rate == Info()->max_rate)
			raw.frame_rate = OpenSoundDevice::convert_oss_rate_to_media_rate(Info()->max_rate);		// measured in Hertz
		raw.buffer_size = DEFAULT_BUFFER_SIZE;
	} else
		return EINVAL;
	char buf[1024];
	string_for_format(format, buf, 1024);
	PRINT(("%s: %s\n", __FUNCTION__, buf));
	return B_OK;
}
Example #19
0
	BMediaIOWrapper(BDataIO* source)
		:
		fData(NULL),
		fPosition(NULL),
		fMedia(NULL),
		fFile(NULL),
		fFallbackBuffer(NULL),
		fErr(B_NO_ERROR)
	{
		CALLED();

		fPosition = dynamic_cast<BPositionIO*>(source);
		fMedia = dynamic_cast<BMediaIO*>(source);
		fFile = dynamic_cast<BFile*>(source);
		fData = source;

		// No need to do additional buffering if we have
		// a BBufferIO or a BMediaIO.
		if (dynamic_cast<BBufferIO *>(source) == NULL) {
			// Source needs to be at least a BPositionIO to wrap with a BBufferIO
			if (IsSeekable()) {
				fPosition = new(std::nothrow) BBufferIO(fPosition, 65536, true);
				if (fPosition == NULL) {
					fErr = B_NO_MEMORY;
					return;
				}
				// We have to reset our BDataIO reference too
				fData = dynamic_cast<BDataIO*>(fPosition);
			} else {
				// In this case we have to supply our own form
				// of pseudo-seekable object from a non-seekable
				// BDataIO.
				fFallbackBuffer = new BMallocIO();
				fFallbackBuffer->SetBlockSize(BLOCK_SIZE);
				TRACE("Unable to improve performance with a BufferIO\n");
			}
		}
	}
Example #20
0
static void
NS(test_main)(void *arg)
{
  int expected, actual;
  (void)arg;

  NS_MOCK(tls_get_write_overhead_ratio);
  NS_MOCK(we_are_hibernating);
  NS_MOCK(public_server_mode);
  NS_MOCK(get_uptime);
  NS_MOCK(get_bytes_read);
  NS_MOCK(get_bytes_written);
  NS_MOCK(logv);
  NS_MOCK(server_mode);
  NS_MOCK(accounting_is_enabled);
  log_global_min_severity_ = LOG_DEBUG;

  stats_n_data_bytes_packaged = RELAY_PAYLOAD_SIZE;
  stats_n_data_cells_packaged = 2;
  expected = 0;
  actual = log_heartbeat(0);

  tt_int_op(actual, OP_EQ, expected);
  tt_int_op(CALLED(logv), OP_EQ, 2);

  done:
    stats_n_data_bytes_packaged = 0;
    stats_n_data_cells_packaged = 0;
    NS_UNMOCK(tls_get_write_overhead_ratio);
    NS_UNMOCK(we_are_hibernating);
    NS_UNMOCK(public_server_mode);
    NS_UNMOCK(get_uptime);
    NS_UNMOCK(get_bytes_read);
    NS_UNMOCK(get_bytes_written);
    NS_UNMOCK(logv);
    NS_UNMOCK(server_mode);
    NS_UNMOCK(accounting_is_enabled);
}
Example #21
0
int64
OpenSoundDeviceEngine::GetCurrentOPtr(int32* fifoed, size_t* fragmentPos)
{
	CALLED();

	if (!(fOpenMode & OPEN_WRITE)) {
		if (fifoed != NULL)
			*fifoed = 0;
		return 0;
	}

	oss_count_t info;
	memset(&info, 0, sizeof(oss_count_t));

	if (ioctl(fFD, SNDCTL_DSP_CURRENT_OPTR, &info, sizeof(oss_count_t)) < 0) {
		PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
				__FUNCTION__, "SNDCTL_DSP_CURRENT_OPTR", strerror(errno)));

		return 0;
	}

	if (fragmentPos != NULL) {
		count_info cinfo;
		if (ioctl(fFD, SNDCTL_DSP_GETOPTR, &cinfo, sizeof(count_info)) < 0) {
			PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
					__FUNCTION__, "SNDCTL_DSP_GETOPTR", strerror(errno)));
			return 0;
		}
		*fragmentPos = cinfo.ptr;
	}

//	PRINT(("OpenSoundDeviceEngine::%s: OPTR: { samples=%Ld, "
//		"fifo_samples=%d }\n", __FUNCTION__, info->samples,
//		info->fifo_samples));
	if (fifoed != NULL)
		*fifoed = info.fifo_samples;
	return info.samples;
}
Example #22
0
EGLBoolean
init_haiku(_EGLDriver *drv, _EGLDisplay *disp)
{
	_EGLDevice *dev;
	CALLED();

	dev = _eglAddDevice(-1, true);
	if (!dev) {
		_eglError(EGL_NOT_INITIALIZED, "DRI2: failed to find EGLDevice");
		return EGL_FALSE;
	}
	disp->Device = dev;

	TRACE("Add configs\n");
	if (!haiku_add_configs_for_visuals(disp))
		return EGL_FALSE;

	disp->Version = 14;

	TRACE("Initialization finished\n");

	return EGL_TRUE;
}
Example #23
0
_EGLContext*
haiku_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
	_EGLContext *share_list, const EGLint *attrib_list)
{
	CALLED();

	struct haiku_egl_context* context;
	context = (struct haiku_egl_context*) calloc(1, sizeof (*context));
	if (!context) {
		_eglError(EGL_BAD_ALLOC, "haiku_create_context");
		return NULL;
	}

	if (!_eglInitContext(&context->ctx, disp, conf, attrib_list))
		goto cleanup;

	TRACE("Context created\n");
	return &context->ctx;

cleanup:
	free(context);
	return NULL;
}
Example #24
0
status_t
BMediaFiles::GetAudioGainFor(const char* type, const char* item, float* _gain)
{
	CALLED();

	if (type == NULL || item == NULL || _gain == NULL)
		return B_BAD_VALUE;

	server_get_item_audio_gain_request request;
	strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
	strncpy(request.item, item, B_MEDIA_NAME_LENGTH);

	server_get_item_audio_gain_reply reply;
	status_t status = QueryServer(SERVER_GET_ITEM_AUDIO_GAIN, &request,
		sizeof(request), &reply, sizeof(reply));
	if (status != B_OK) {
		ERROR("BMediaFiles::GetRefFor: failed: %s\n", strerror(status));
		return status;
	}

	*_gain = reply.gain;
	return B_OK;
}
Example #25
0
void
BMenuField::InitObject(const char* label)
{
	CALLED();

	fLabel = NULL;
	fMenu = NULL;
	fMenuBar = NULL;
	fAlign = B_ALIGN_LEFT;
	fEnabled = true;
	fSelected = false;
	fTransition = false;
	fFixedSizeMB = false;
	fMenuTaskID = -1;
	fLayoutData = new LayoutData;

	SetLabel(label);

	if (label)
		fDivider = (float)floor(Frame().Width() / 2.0f);
	else
		fDivider = 0;
}
Example #26
0
status_t
BMediaFiles::GetRefFor(const char* type, const char* item, entry_ref* _ref)
{
	CALLED();

	if (type == NULL || item == NULL || _ref == NULL)
		return B_BAD_VALUE;

	server_get_ref_for_request request;
	strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
	strncpy(request.item, item, B_MEDIA_NAME_LENGTH);

	server_get_ref_for_reply reply;
	status_t status = QueryServer(SERVER_GET_REF_FOR, &request, sizeof(request),
		&reply, sizeof(reply));
	if (status != B_OK) {
		ERROR("BMediaFiles::GetRefFor: failed: %s\n", strerror(status));
		return status;
	}

	*_ref = reply.ref;
	return B_OK;
}
Example #27
0
void
Pipe::Enable(bool enable)
{
	CALLED();

	addr_t pipeReg = INTEL_DISPLAY_A_PIPE_CONTROL + fPipeOffset;
	addr_t planeReg = INTEL_DISPLAY_A_CONTROL + fPlaneOffset;

	// Planes always have to operate on an enabled pipe

	if (enable) {
		write32(pipeReg, read32(pipeReg) | INTEL_PIPE_ENABLED);
		wait_for_vblank();
		write32(planeReg, read32(planeReg) | DISPLAY_CONTROL_ENABLED);
	} else {
		write32(planeReg, read32(planeReg) & ~DISPLAY_CONTROL_ENABLED);
		wait_for_vblank();
		write32(pipeReg, read32(pipeReg) & ~INTEL_PIPE_ENABLED);
	}

	read32(INTEL_DISPLAY_A_BASE);
		// flush the eventually cached PCI bus writes
}
Example #28
0
status_t
BAdapterIO::_EvaluateWait(off_t pos, off_t size)
{
	CALLED();

	off_t totalSize = 0;
	if (GetSize(&totalSize) != B_OK)
		TRACE("BAdapterIO::ReadAt: Can't get our size!\n");

	TRACE("BAdapterIO::_EvaluateWait TS %" B_PRId64 " P %" B_PRId64
		" S %" B_PRId64 "\n", totalSize, pos, size);

	status_t err = fBuffer->EvaluatePosition(pos, totalSize);

	TRACE("BAdapterIO::_EvaluateWait: %s\n", strerror(err));

	if (err != B_OK && err != B_WOULD_BLOCK)
		return err;

	TRACE("BAdapterIO::_EvaluateWait: waiting for data\n");

	return fBuffer->WaitForData(pos, size);
}
Example #29
0
status_t
OpenSoundDevice::AddEngine(oss_audioinfo *info)
{
	status_t err;
	/* discard shadow/hidden engines (!?) */
	CALLED();
/*
	if (info->caps & PCM_CAP_SHADOW)
		return B_OK;
	if (info->caps & PCM_CAP_HIDDEN)
		return B_OK;
*/
	OpenSoundDeviceEngine *engine = new OpenSoundDeviceEngine(info);
	if (!engine)
		return ENOMEM;
	err = engine->InitCheck();
	if (err < B_OK) {
		delete engine;
		return err;
	}
	fEngines.AddItem(engine);	
	return B_OK;
}
Example #30
0
void MediaReader::Disconnect(
				const media_source & what,
				const media_destination & where)
{
	CALLED();

	if (output.destination != where) {
		PRINT("\t<- B_MEDIA_BAD_DESTINATION\n");
		return;
	}
	if (output.source != what) {
		PRINT("\t<- B_MEDIA_BAD_SOURCE\n");
		return;
	}

	output.destination = media_destination::null;
	GetFormat(&output.format);
	if (fBufferGroup != 0) {
		BBufferGroup * group = fBufferGroup;
		fBufferGroup = 0;
		delete group;
	}	
}