QVariant QObjectXmlModel::typedValue(const QXmlNodeModelIndex &n) const { switch (toNodeType(n)) { case QObjectProperty: { const QVariant &candidate = toMetaProperty(n).read(asQObject(n)); if (isTypeSupported(candidate.type())) return candidate; else return QVariant(); } case MetaObjectClassName: return QVariant(static_cast<QMetaObject*>(n.internalPointer())->className()); case MetaObjectSuperClass: { const QMetaObject *const superClass = static_cast<QMetaObject*>(n.internalPointer())->superClass(); if (superClass) return QVariant(superClass->className()); else return QVariant(); } case QObjectClassName: return QVariant(asQObject(n)->metaObject()->className()); default: return QVariant(); } }
Int Shader::maxCombinedUniformComponents(const Type type) { #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::uniform_buffer_object>() || !isTypeSupported(type)) #else if(!isTypeSupported(type)) #endif return 0; const UnsignedInt index = typeToIndex(type); GLint& value = Context::current()->state().shader->maxCombinedUniformComponents[index]; /* Get the value, if not already cached */ constexpr static const GLenum what[] = { GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS, GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, #ifndef MAGNUM_TARGET_GLES /** @todo Fix this when glLoadGen has GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS enum */ 0x8A32 /*GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS*/, GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS, GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS, GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS #endif }; if(value == 0) glGetIntegerv(what[index], &value); return value; }
SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionCode& ec) { // 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#dom-addsourcebuffer // 1. If type is null or an empty then throw an INVALID_ACCESS_ERR exception and // abort these steps. if (type.isNull() || type.isEmpty()) { ec = INVALID_ACCESS_ERR; return 0; } // 2. If type contains a MIME type that is not supported ..., then throw a // NOT_SUPPORTED_ERR exception and abort these steps. if (!isTypeSupported(type)) { ec = NOT_SUPPORTED_ERR; return 0; } // 4. If the readyState attribute is not in the "open" state then throw an // INVALID_STATE_ERR exception and abort these steps. if (!m_private || m_readyState != openKeyword()) { ec = INVALID_STATE_ERR; return 0; } // 5. Create a new SourceBuffer object and associated resources. ContentType contentType(type); Vector<String> codecs = contentType.codecs(); OwnPtr<SourceBufferPrivate> sourceBufferPrivate; switch (m_private->addSourceBuffer(contentType.type(), codecs, &sourceBufferPrivate)) { case MediaSourcePrivate::Ok: { ASSERT(sourceBufferPrivate); RefPtr<SourceBuffer> buffer = SourceBuffer::create(sourceBufferPrivate.release(), this); // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object. m_sourceBuffers->add(buffer); m_activeSourceBuffers->add(buffer); // 7. Return the new object to the caller. return buffer.get(); } case MediaSourcePrivate::NotSupported: // 2 (cont). If type contains a MIME type ... that is not supported with the types // specified for the other SourceBuffer objects in sourceBuffers, then throw // a NOT_SUPPORTED_ERR exception and abort these steps. ec = NOT_SUPPORTED_ERR; return 0; case MediaSourcePrivate::ReachedIdLimit: // 3 (cont). If the user agent can't handle any more SourceBuffer objects then throw // a QUOTA_EXCEEDED_ERR exception and abort these steps. ec = QUOTA_EXCEEDED_ERR; return 0; } ASSERT_NOT_REACHED(); return 0; }
SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionCode& ec) { LOG(Media, "MediaSource::addSourceBuffer(%s) %p", type.ascii().data(), this); // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type // 1. If type is null or an empty then throw an INVALID_ACCESS_ERR exception and // abort these steps. if (type.isNull() || type.isEmpty()) { ec = INVALID_ACCESS_ERR; return nullptr; } // 2. If type contains a MIME type that is not supported ..., then throw a // NOT_SUPPORTED_ERR exception and abort these steps. if (!isTypeSupported(type)) { ec = NOT_SUPPORTED_ERR; return nullptr; } // 4. If the readyState attribute is not in the "open" state then throw an // INVALID_STATE_ERR exception and abort these steps. if (!isOpen()) { ec = INVALID_STATE_ERR; return nullptr; } // 5. Create a new SourceBuffer object and associated resources. ContentType contentType(type); RefPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate(contentType, ec); if (!sourceBufferPrivate) { ASSERT(ec == NOT_SUPPORTED_ERR || ec == QUOTA_EXCEEDED_ERR); // 2. If type contains a MIME type that is not supported ..., then throw a NOT_SUPPORTED_ERR exception and abort these steps. // 3. If the user agent can't handle any more SourceBuffer objects then throw a QUOTA_EXCEEDED_ERR exception and abort these steps return nullptr; } RefPtr<SourceBuffer> buffer = SourceBuffer::create(sourceBufferPrivate.releaseNonNull(), this); // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object. m_sourceBuffers->add(buffer); if (buffer->active()) m_activeSourceBuffers->add(buffer); // 7. Return the new object to the caller. return buffer.get(); }
SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& exceptionState) { WTF_LOG(Media, "MediaSource::addSourceBuffer(%s) %p", type.ascii().data(), this); // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type // 1. If type is an empty string then throw an InvalidAccessError exception // and abort these steps. if (type.isEmpty()) { exceptionState.throwDOMException(InvalidAccessError, "The type provided is empty."); return 0; } // 2. If type contains a MIME type that is not supported ..., then throw a // NotSupportedError exception and abort these steps. if (!isTypeSupported(type)) { exceptionState.throwDOMException(NotSupportedError, "The type provided ('" + type + "') is unsupported."); return 0; } // 4. If the readyState attribute is not in the "open" state then throw an // InvalidStateError exception and abort these steps. if (!isOpen()) { exceptionState.throwDOMException(InvalidStateError, "The MediaSource's readyState is not 'open'."); return 0; } // 5. Create a new SourceBuffer object and associated resources. ContentType contentType(type); Vector<String> codecs = contentType.codecs(); OwnPtr<WebSourceBuffer> webSourceBuffer = createWebSourceBuffer(contentType.type(), codecs, exceptionState); if (!webSourceBuffer) { ASSERT(exceptionState.code() == NotSupportedError || exceptionState.code() == QuotaExceededError); // 2. If type contains a MIME type that is not supported ..., then throw a NotSupportedError exception and abort these steps. // 3. If the user agent can't handle any more SourceBuffer objects then throw a QuotaExceededError exception and abort these steps return 0; } SourceBuffer* buffer = SourceBuffer::create(webSourceBuffer.release(), this, asyncEventQueue()); // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object. m_sourceBuffers->add(buffer); m_activeSourceBuffers->add(buffer); // 7. Return the new object to the caller. return buffer; }
WebKitSourceBuffer* WebKitMediaSource::addSourceBuffer(const String& type, ExceptionCode& ec) { // 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#dom-addsourcebuffer // 1. If type is null or an empty then throw an INVALID_ACCESS_ERR exception and // abort these steps. if (type.isNull() || type.isEmpty()) { ec = INVALID_ACCESS_ERR; return 0; } // 2. If type contains a MIME type that is not supported ..., then throw a // NOT_SUPPORTED_ERR exception and abort these steps. if (!isTypeSupported(type)) { ec = NOT_SUPPORTED_ERR; return 0; } // 4. If the readyState attribute is not in the "open" state then throw an // INVALID_STATE_ERR exception and abort these steps. if (!isOpen()) { ec = INVALID_STATE_ERR; return 0; } // 5. Create a new SourceBuffer object and associated resources. ContentType contentType(type); Vector<String> codecs = contentType.codecs(); OwnPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate(contentType.type(), codecs, ec); if (!sourceBufferPrivate) return 0; RefPtr<WebKitSourceBuffer> buffer = WebKitSourceBuffer::create(sourceBufferPrivate.release(), this); // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object. m_sourceBuffers->add(buffer); m_activeSourceBuffers->add(buffer); // 7. Return the new object to the caller. return buffer.get(); }
Int Shader::maxTextureImageUnits(const Type type) { if(!isTypeSupported(type)) return 0; const UnsignedInt index = typeToIndex(type); GLint& value = Context::current()->state().shader->maxTextureImageUnits[index]; /* Get the value, if not already cached */ constexpr static const GLenum what[] = { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, GL_MAX_TEXTURE_IMAGE_UNITS, #ifndef MAGNUM_TARGET_GLES GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS, GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS, GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS #endif }; if(value == 0) glGetIntegerv(what[index], &value); return value; }
Int Shader::maxUniformComponents(const Type type) { if(!isTypeSupported(type)) return 0; const UnsignedInt index = typeToIndex(type); GLint& value = Context::current()->state().shader->maxUniformComponents[index]; /* Get the value, if not already cached */ #ifndef MAGNUM_TARGET_GLES2 constexpr static const GLenum what[] = { GL_MAX_VERTEX_UNIFORM_COMPONENTS, GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, #ifndef MAGNUM_TARGET_GLES GL_MAX_GEOMETRY_UNIFORM_COMPONENTS, GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS, GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS, GL_MAX_COMPUTE_UNIFORM_COMPONENTS #endif }; if(value == 0) glGetIntegerv(what[index], &value); #else /* For ES2 we need to multiply _VECTORS by 4 */ constexpr static const GLenum what[] = { GL_MAX_VERTEX_UNIFORM_VECTORS, GL_MAX_FRAGMENT_UNIFORM_VECTORS }; if(value == 0) { GLint vectors; glGetIntegerv(what[index], &vectors); value = vectors*4; } #endif return value; }
SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionCode& ec) { LOG(MediaSource, "MediaSource::addSourceBuffer(%s) %p", type.ascii().data(), this); // 2.2 http://www.w3.org/TR/media-source/#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type // When this method is invoked, the user agent must run the following steps: // 1. If type is an empty string then throw a TypeError exception and abort these steps. if (type.isEmpty()) { ec = TypeError; return nullptr; } // 2. If type contains a MIME type that is not supported ..., then throw a // NOT_SUPPORTED_ERR exception and abort these steps. if (!isTypeSupported(type)) { ec = NOT_SUPPORTED_ERR; return nullptr; } // 4. If the readyState attribute is not in the "open" state then throw an // INVALID_STATE_ERR exception and abort these steps. if (!isOpen()) { ec = INVALID_STATE_ERR; return nullptr; } // 5. Create a new SourceBuffer object and associated resources. ContentType contentType(type); RefPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate(contentType, ec); if (!sourceBufferPrivate) { ASSERT(ec == NOT_SUPPORTED_ERR || ec == QUOTA_EXCEEDED_ERR); // 2. If type contains a MIME type that is not supported ..., then throw a NOT_SUPPORTED_ERR exception and abort these steps. // 3. If the user agent can't handle any more SourceBuffer objects then throw a QUOTA_EXCEEDED_ERR exception and abort these steps return nullptr; } Ref<SourceBuffer> buffer = SourceBuffer::create(sourceBufferPrivate.releaseNonNull(), this); // 6. Set the generate timestamps flag on the new object to the value in the "Generate Timestamps Flag" // column of the byte stream format registry [MSE-REGISTRY] entry that is associated with type. // NOTE: In the current byte stream format registry <http://www.w3.org/2013/12/byte-stream-format-registry/> // only the "MPEG Audio Byte Stream Format" has the "Generate Timestamps Flag" value set. bool shouldGenerateTimestamps = contentType.type() == "audio/aac" || contentType.type() == "audio/mpeg"; buffer->setShouldGenerateTimestamps(shouldGenerateTimestamps); // 7. If the generate timestamps flag equals true: // ↳ Set the mode attribute on the new object to "sequence". // Otherwise: // ↳ Set the mode attribute on the new object to "segments". buffer->setMode(shouldGenerateTimestamps ? SourceBuffer::AppendMode::Sequence : SourceBuffer::AppendMode::Segments, IGNORE_EXCEPTION); SourceBuffer* result = buffer.ptr(); // 8. Add the new object to sourceBuffers and fire a addsourcebuffer on that object. m_sourceBuffers->add(WTFMove(buffer)); regenerateActiveSourceBuffers(); // 9. Return the new object to the caller. return result; }
Int Shader::maxShaderStorageBlocks(const Type type) { if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::shader_storage_buffer_object>() || !isTypeSupported(type)) return 0; const UnsignedInt index = typeToIndex(type); GLint& value = Context::current()->state().shader->maxShaderStorageBlocks[index]; /* Get the value, if not already cached */ constexpr static const GLenum what[] = { GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS, GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS, GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS, GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS, GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS }; if(value == 0) glGetIntegerv(what[index], &value); return value; }
Int Shader::maxImageUniforms(const Type type) { if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::shader_image_load_store>() || !isTypeSupported(type)) return 0; const UnsignedInt index = typeToIndex(type); GLint& value = Context::current()->state().shader->maxImageUniforms[index]; /* Get the value, if not already cached */ constexpr static const GLenum what[] = { GL_MAX_VERTEX_IMAGE_UNIFORMS, GL_MAX_FRAGMENT_IMAGE_UNIFORMS, GL_MAX_GEOMETRY_IMAGE_UNIFORMS, GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS, GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS, GL_MAX_COMPUTE_IMAGE_UNIFORMS }; if(value == 0) glGetIntegerv(what[index], &value); return value; }
Int Shader::maxAtomicCounters(const Type type) { if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::shader_atomic_counters>() || !isTypeSupported(type)) return 0; const UnsignedInt index = typeToIndex(type); GLint& value = Context::current()->state().shader->maxAtomicCounters[index]; /* Get the value, if not already cached */ constexpr static const GLenum what[] = { GL_MAX_VERTEX_ATOMIC_COUNTERS, GL_MAX_FRAGMENT_ATOMIC_COUNTERS, GL_MAX_GEOMETRY_ATOMIC_COUNTERS, GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS, GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS, GL_MAX_COMPUTE_ATOMIC_COUNTERS }; if(value == 0) glGetIntegerv(what[index], &value); return value; }
bool LegacyAmixerControl::accessHW(bool receive, string &error) { CAutoLog autoLog(getConfigurableElement(), "ALSA", isDebugEnabled()); #ifdef SIMULATION if (receive) { memset(getBlackboardLocation(), 0, getSize()); } log_info("%s ALSA Element Instance: %s\t\t(Control Element: %s)", receive ? "Reading" : "Writing", getConfigurableElement()->getPath().c_str(), getControlName().c_str()); return true; #endif int ret; // Mixer handle snd_ctl_t *sndCtrl; uint32_t value; uint32_t index; uint32_t elementCount; snd_ctl_elem_id_t *id; snd_ctl_elem_info_t *info; snd_ctl_elem_value_t *control; logControlInfo(receive); // Check parameter type is ok (deferred error, no exceptions available :-() if (!isTypeSupported()) { error = "Parameter type not supported."; return false; } int cardNumber = getCardNumber(); if (cardNumber < 0) { error = "Card " + getCardName() + " not found. Error: " + strerror(cardNumber); return false; } #ifdef ANDROID if ((ret = snd_ctl_hw_open(&sndCtrl, NULL, cardNumber, 0)) < 0) { error = snd_strerror(ret); return false; } #else // Create device name ostringstream deviceName; deviceName << "hw:" << cardNumber; // Open sound control if ((ret = snd_ctl_open(&sndCtrl, deviceName.str().c_str(), 0)) < 0) { error = snd_strerror(ret); return false; } #endif // Allocate in stack snd_ctl_elem_id_alloca(&id); snd_ctl_elem_info_alloca(&info); snd_ctl_elem_value_alloca(&control); // Set interface snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); string controlName = getControlName(); // Set name or id if (isdigit(controlName[0])) { snd_ctl_elem_id_set_numid(id, asInteger(controlName)); } else { snd_ctl_elem_id_set_name(id, controlName.c_str()); } // Init info id snd_ctl_elem_info_set_id(info, id); // Get info if ((ret = snd_ctl_elem_info(sndCtrl, info)) < 0) { error = "ALSA: Unable to get element info " + controlName + ": " + snd_strerror(ret); // Close sound control snd_ctl_close(sndCtrl); return false; } // Get type snd_ctl_elem_type_t eType = snd_ctl_elem_info_get_type(info); // Get element count elementCount = snd_ctl_elem_info_get_count(info); uint32_t scalarSize = getScalarSize(); // If size defined in the PFW different from alsa mixer control size, return an error if (elementCount * scalarSize != getSize()) { error = "ALSA: Control element count (" + asString(elementCount) + ") and configurable scalar element count (" + asString(getSize() / scalarSize) + ") mismatch"; // Close sound control snd_ctl_close(sndCtrl); return false; } // Set value id snd_ctl_elem_value_set_id(control, id); if (receive) { // Read element if ((ret = snd_ctl_elem_read(sndCtrl, control)) < 0) { error = "ALSA: Unable to read element " + controlName + ": " + snd_strerror(ret); // Close sound control snd_ctl_close(sndCtrl); return false; } // Go through all indexes for (index = 0; index < elementCount; index++) { switch (eType) { case SND_CTL_ELEM_TYPE_BOOLEAN: value = snd_ctl_elem_value_get_boolean(control, index); break; case SND_CTL_ELEM_TYPE_INTEGER: value = snd_ctl_elem_value_get_integer(control, index); break; case SND_CTL_ELEM_TYPE_INTEGER64: value = snd_ctl_elem_value_get_integer64(control, index); break; case SND_CTL_ELEM_TYPE_ENUMERATED: value = snd_ctl_elem_value_get_enumerated(control, index); break; case SND_CTL_ELEM_TYPE_BYTES: value = snd_ctl_elem_value_get_byte(control, index); break; default: error = "ALSA: Unknown control element type while reading alsa element " + controlName; return false; } if (isDebugEnabled()) { log_info("Reading alsa element %s, index %u with value %u", controlName.c_str(), index, value); } // Write data to blackboard (beware this code is OK on Little Endian machines only) toBlackboard(value); } } else { // Go through all indexes for (index = 0; index < elementCount; index++) { // Read data from blackboard (beware this code is OK on Little Endian machines only) value = fromBlackboard(); if (isDebugEnabled()) { log_info("Writing alsa element %s, index %u with value %u", controlName.c_str(), index, value); } switch (eType) { case SND_CTL_ELEM_TYPE_BOOLEAN: snd_ctl_elem_value_set_boolean(control, index, value); break; case SND_CTL_ELEM_TYPE_INTEGER: snd_ctl_elem_value_set_integer(control, index, value); break; case SND_CTL_ELEM_TYPE_INTEGER64: snd_ctl_elem_value_set_integer64(control, index, value); break; case SND_CTL_ELEM_TYPE_ENUMERATED: snd_ctl_elem_value_set_enumerated(control, index, value); break; case SND_CTL_ELEM_TYPE_BYTES: snd_ctl_elem_value_set_byte(control, index, value); break; default: error = "ALSA: Unknown control element type while writing alsa element " + controlName; return false; } } // Write element if ((ret = snd_ctl_elem_write(sndCtrl, control)) < 0) { error = "ALSA: Unable to write element " + controlName + ": " + snd_strerror(ret); // Close sound control snd_ctl_close(sndCtrl); return false; } } // Close sound control snd_ctl_close(sndCtrl); return true; }
bool TinyAmixerControl::accessHW(bool receive, std::string &error) { CAutoLog autoLog(getConfigurableElement(), "ALSA", isDebugEnabled()); // Mixer handle struct mixer *mixer; // Mixer control handle struct mixer_ctl *mixerControl; uint32_t elementCount; std::string controlName = getControlName(); // Debug conditionnaly enabled in XML logControlInfo(receive); // Check parameter type is ok (deferred error, no exceptions available :-() if (!isTypeSupported()) { error = "Parameter type not supported."; return false; } // Check card number int32_t cardIndex = getCardNumber(); if (cardIndex < 0) { error = "Card " + getCardName() + " not found. Error: " + strerror(-cardIndex); return false; } // Open alsa mixer // getMixerHandle is non-const; we need to forcefully remove the constness // then, we need to cast the generic subsystem into a TinyAlsaSubsystem. mixer = static_cast<TinyAlsaSubsystem *>( const_cast<CSubsystem *>(getSubsystem()))->getMixerHandle(cardIndex); if (!mixer) { error = "Failed to open mixer for card: " + getCardName(); return false; } // Get control handle if (isdigit(controlName[0])) { mixerControl = mixer_get_ctl(mixer, asInteger(controlName)); } else { mixerControl = mixer_get_ctl_by_name(mixer, controlName.c_str()); } // Check control has been found if (!mixerControl) { error = "Failed to open mixer control: " + controlName; return false; } // Get element count elementCount = getNumValues(mixerControl); uint32_t scalarSize = getScalarSize(); // Check available size if (elementCount * scalarSize != getSize()) { error = "ALSA: Control element count (" + asString(elementCount) + ") and configurable scalar element count (" + asString(getSize() / scalarSize) + ") mismatch"; return false; } // Read/Write element bool success; if (receive) { success = readControl(mixerControl, elementCount, error); } else { success = writeControl(mixerControl, elementCount, error); } return success; }