status_t BMediaFormats::GetFormatFor(const media_format_description& description, media_format* _format) { BAutolock locker(sLock); status_t status = update_media_formats(); if (status < B_OK) { ERROR("BMediaFormats: updating formats from server failed: %s!\n", strerror(status)); return status; } TRACE("search for description family = %d, a = 0x%" B_PRId32 "x, b = 0x%" B_PRId32 "x\n", description.family, description.u.misc.file_format, description.u.misc.codec); // search for a matching format description meta_format other(description); const meta_format* metaFormat = sFormats.BinarySearch(other, meta_format::CompareDescriptions); TRACE("meta format == %p\n", metaFormat); if (metaFormat == NULL) { memset(_format, 0, sizeof(*_format)); // clear to widlcard return B_MEDIA_BAD_FORMAT; } // found it! *_format = metaFormat->format; return B_OK; }