Exemple #1
0
void vehReturn() {
   EXCEPTION_RECORD rec;
   
   //need to check eax here to see if exception was handled
   //or if it needs to be kicked up to next SEH handler
   unsigned int res = eax;
   
   esp += 3 * SIZE_DWORD;  //clear off exception pointers
   
   popExceptionRecord(&rec);

   popContext();
   contextToCpu();
   //eip is now restored to pre exception location
   
   //need to fake an iret here
   doInterruptReturn();  //this clobbers EIP, CS, EFLAGS
   //so restore them here from ctx values
   cpu.eip = ctx.Eip;
   cpu.eflags = ctx.EFlags;
   _cs = ctx.SegCs;
   msg("Performing VEH return\n");

   if (res == EXCEPTION_CONTINUE_EXECUTION) {
      currentVehHandler = 0;
   }
   else {  //res == EXCEPTION_CONTINUE_SEARCH
      doException(&rec);
   }
}
static guint
gst_openal_sink_delay (GstAudioSink * asink)
{
    GstOpenALSink *openal = GST_OPENAL_SINK (asink);
    ALint queued, state, offset, delay;
    ALCcontext *old;

    if (!openal->context)
        return 0;

    GST_OPENAL_SINK_LOCK (openal);
    old = pushContext (openal->context);

    delay = 0;
    alGetSourcei (openal->sID, AL_BUFFERS_QUEUED, &queued);
    /* Order here is important. If the offset is queried after the state and an
     * underrun occurs in between the two calls, it can end up with a 0 offset
     * in a playing state, incorrectly reporting a len*queued/bps delay. */
    alGetSourcei (openal->sID, AL_BYTE_OFFSET, &offset);
    alGetSourcei (openal->sID, AL_SOURCE_STATE, &state);

    /* Note: state=stopped is an underrun, meaning all buffers are processed
     * and there's no delay when writing the next buffer. Pre-buffering is
     * state=initial, which will introduce a delay while writing. */
    if (checkALError () == AL_NO_ERROR && state != AL_STOPPED)
        delay = ((queued * openal->bID_length) - offset) / openal->bytes_per_sample;

    popContext (old, openal->context);
    GST_OPENAL_SINK_UNLOCK (openal);

    return delay;
}
static gboolean
gst_openal_sink_unprepare (GstAudioSink * asink)
{
    GstOpenALSink *openal = GST_OPENAL_SINK (asink);
    ALCcontext *old;

    if (!openal->context)
        return TRUE;

    old = pushContext (openal->context);

    alSourceStop (openal->sID);
    alSourcei (openal->sID, AL_BUFFER, 0);

    if (!openal->custom_sID)
        alDeleteSources (1, &openal->sID);
    openal->sID = 0;

    alDeleteBuffers (openal->bID_count, openal->bIDs);
    g_free (openal->bIDs);
    openal->bIDs = NULL;
    openal->bID_idx = 0;
    openal->bID_count = 0;
    openal->bID_length = 0;

    checkALError ();
    popContext (old, openal->context);
    if (!openal->custom_ctx)
        alcDestroyContext (openal->context);
    openal->context = NULL;

    return TRUE;
}
static gboolean
gst_openal_sink_unprepare (GstAudioSink * audiosink)
{
  GstOpenALSink *sink = GST_OPENAL_SINK (audiosink);
  ALCcontext *old;

  if (!sink->default_context)
    return TRUE;

  old = pushContext (sink->default_context);

  alSourceStop (sink->default_source);
  alSourcei (sink->default_source, AL_BUFFER, 0);

  if (!sink->user_source)
    alDeleteSources (1, &sink->default_source);
  sink->default_source = 0;

  alDeleteBuffers (sink->buffer_count, sink->buffers);
  g_free (sink->buffers);
  sink->buffers = NULL;
  sink->buffer_idx = 0;
  sink->buffer_count = 0;
  sink->buffer_length = 0;

  checkALError ();
  popContext (old, sink->default_context);
  if (!sink->user_context)
    alcDestroyContext (sink->default_context);
  sink->default_context = NULL;

  return TRUE;
}
void ScriptEngine::importProgram(const QScriptProgram &program, const QScriptValue &scope,
                               QScriptValue &targetObject)
{
    QSet<QString> globalPropertyNames;
    {
        QScriptValueIterator it(globalObject());
        while (it.hasNext()) {
            it.next();
            globalPropertyNames += it.name();
        }
    }

    pushContext();
    if (scope.isObject())
        currentContext()->pushScope(scope);
    QScriptValue result = evaluate(program);
    QScriptValue activationObject = currentContext()->activationObject();
    if (scope.isObject())
        currentContext()->popScope();
    popContext();
    if (Q_UNLIKELY(hasErrorOrException(result)))
        throw ErrorInfo(tr("Error when importing '%1': %2").arg(program.fileName(), result.toString()));

    // If targetObject is already an object, it doesn't get overwritten but enhanced by the
    // contents of the .js file.
    // This is necessary for library imports that consist of multiple js files.
    if (!targetObject.isObject())
        targetObject = newObject();

    // Copy every property of the activation object to the target object.
    // We do not just save a reference to the activation object, because QScriptEngine contains
    // special magic for activation objects that leads to unanticipated results.
    {
        QScriptValueIterator it(activationObject);
        while (it.hasNext()) {
            it.next();
            if (debugJSImports)
                qDebug() << "[ENGINE] Copying property " << it.name();
            targetObject.setProperty(it.name(), it.value());
        }
    }

    // Copy new global properties to the target object and remove them from
    // the global object. This is to support direct variable assignments
    // without the 'var' keyword in JavaScript files.
    QScriptValueIterator it(globalObject());
    while (it.hasNext()) {
        it.next();
        if (globalPropertyNames.contains(it.name()))
            continue;

        if (debugJSImports) {
            qDebug() << "[ENGINE] inserting global property "
                     << it.name() << " " << it.value().toString();
        }

        targetObject.setProperty(it.name(), it.value());
        it.remove();
    }
}
Exemple #6
0
void Interpreter::doReturn() {
	popContext();
    assert(stackTrace.size() > 0);
    CallInfo ci = stackTrace.top();
    stackTrace.pop();
    _bc = ci._bc;
    _insPtr = ci._insPtr;
}
Exemple #7
0
void ParserEngine::parseExternal(XML_Parser extParser, InputSource* pInputSource)
{
	pushContext(extParser, pInputSource);
	if (pInputSource->getCharacterStream())
		parseExternalCharInputStream(extParser, *pInputSource->getCharacterStream());
	else if (pInputSource->getByteStream())
		parseExternalByteInputStream(extParser, *pInputSource->getByteStream());
	else throw XMLException("Input source has no stream");
	popContext();
}
void
OutputContextStack::reset()
{
    while(m_stackPosition != m_stack.begin())
    {
        popContext();
    }

    assert(empty() == true);
}
Exemple #9
0
void ParserEngine::parse(const char* pBuffer, std::size_t size)
{
	init();
	resetContext();
	InputSource src;
	pushContext(_parser, &src);
	if (_pContentHandler) _pContentHandler->setDocumentLocator(this);
	if (_pContentHandler) _pContentHandler->startDocument();
	if (!XML_Parse(_parser, pBuffer, static_cast<int>(size), 1))
		handleError(XML_GetErrorCode(_parser));
	if (_pContentHandler) _pContentHandler->endDocument();
	popContext();
}
void Generator::visitCursorChildren(CXCursor cursor, Generator::Visitor callback) const
{
    VisitorWrapper wrapper = [&callback, this](const CXCursor &self, const CXCursor &parent) {
        pushContext(self, parent);
        auto ret = callback();
        popContext();
        return ret;
    };

    CXClientData data = reinterpret_cast<CXClientData>(&wrapper);
    clang_visitChildren(cursor,
                        childVisitor,
                        data);
}
Exemple #11
0
void GemWindow::render(void){
  if(!makeCurrent()) {
    error("unable to switch to current window (do you have one?), cannot render!");
    return;
  }
  if(!pushContext()) {
    error("unable to switch to current context, cannot render!");
    return;
  }
  bang();
  if(m_buffer==2)
    swapBuffers();

  popContext();
}
Exemple #12
0
void ParserEngine::parse(InputSource* pInputSource)
{
	init();
	resetContext();
	pushContext(_parser, pInputSource);
	if (_pContentHandler) _pContentHandler->setDocumentLocator(this);
	if (_pContentHandler) _pContentHandler->startDocument();
	if (pInputSource->getCharacterStream())
		parseCharInputStream(*pInputSource->getCharacterStream());
	else if (pInputSource->getByteStream())
		parseByteInputStream(*pInputSource->getByteStream());
	else throw XMLException("Input source has no stream");
	if (_pContentHandler) _pContentHandler->endDocument();
	popContext();
}
static void
gst_openal_sink_reset (GstAudioSink * audiosink)
{
  GstOpenALSink *sink = GST_OPENAL_SINK (audiosink);
  ALCcontext *old;

  GST_OPENAL_SINK_LOCK (sink);
  old = pushContext (sink->default_context);

  sink->write_reset = AL_TRUE;
  alSourceStop (sink->default_source);
  alSourceRewind (sink->default_source);
  alSourcei (sink->default_source, AL_BUFFER, 0);
  checkALError ();

  popContext (old, sink->default_context);
  GST_OPENAL_SINK_UNLOCK (sink);
}
static void
gst_openal_sink_reset (GstAudioSink * asink)
{
    GstOpenALSink *openal = GST_OPENAL_SINK (asink);
    ALCcontext *old;

    GST_OPENAL_SINK_LOCK (openal);
    old = pushContext (openal->context);

    openal->write_reset = AL_TRUE;
    alSourceStop (openal->sID);
    alSourceRewind (openal->sID);
    alSourcei (openal->sID, AL_BUFFER, 0);
    checkALError ();

    popContext (old, openal->context);
    GST_OPENAL_SINK_UNLOCK (openal);
}
void ParserEngine::parse(const char* pBuffer, std::size_t size)
{
	init();
	resetContext();
	InputSource src;
	pushContext(_parser, &src);
	if (_pContentHandler) _pContentHandler->setDocumentLocator(this);
	if (_pContentHandler) _pContentHandler->startDocument();
	std::size_t processed = 0;
	while (processed < size)
	{
		const int bufferSize = processed + PARSE_BUFFER_SIZE < size ? PARSE_BUFFER_SIZE : static_cast<int>(size - processed);
		if (!XML_Parse(_parser, pBuffer + processed, bufferSize, 0))
			handleError(XML_GetErrorCode(_parser));
		processed += bufferSize;
	}
	if (!XML_Parse(_parser, pBuffer+processed, 0, 1))
		handleError(XML_GetErrorCode(_parser));
	if (_pContentHandler) _pContentHandler->endDocument();
	popContext();
}
static guint
gst_openal_sink_delay (GstAudioSink * audiosink)
{
  GstOpenALSink *sink = GST_OPENAL_SINK (audiosink);
  ALint queued, state, offset, delay;
  ALCcontext *old;

  if (!sink->default_context)
    return 0;

  GST_OPENAL_SINK_LOCK (sink);
  old = pushContext (sink->default_context);

  delay = 0;
  alGetSourcei (sink->default_source, AL_BUFFERS_QUEUED, &queued);
  /* Order here is important. If the offset is queried after the state and an
   * underrun occurs in between the two calls, it can end up with a 0 offset
   * in a playing state, incorrectly reporting a len*queued/bps delay. */
  alGetSourcei (sink->default_source, AL_BYTE_OFFSET, &offset);
  alGetSourcei (sink->default_source, AL_SOURCE_STATE, &state);

  /* Note: state=stopped is an underrun, meaning all buffers are processed
   * and there's no delay when writing the next buffer. Pre-buffering is
   * state=initial, which will introduce a delay while writing. */
  if (checkALError () == AL_NO_ERROR && state != AL_STOPPED)
    delay =
        ((queued * sink->buffer_length) -
        offset) / sink->bytes_per_sample / sink->channels / GST_MSECOND;

  popContext (old, sink->default_context);
  GST_OPENAL_SINK_UNLOCK (sink);

  if (G_UNLIKELY (delay < 0)) {
    /* make sure we never return a negative delay */
    GST_WARNING_OBJECT (openal_debug, "negative delay");
    delay = 0;
  }

  return delay;
}
Exemple #17
0
bool XLIFFHandler::endElement(const QString& namespaceURI,
                              const QString& localName, const QString& /*qName*/ )
{
    if (namespaceURI == m_URI || namespaceURI == m_URI12) {
        if (localName == QLatin1String("xliff")) {
            popContext(XC_xliff);
        } else if (localName == QLatin1String("source")) {
            m_source = accum;
        } else if (localName == QLatin1String("target")) {
            translations.append(accum);
        } else if (localName == QLatin1String("context-group")) {
            popContext(XC_context_group);
        } else if (currentContext() == XC_context_linenumber && localName == QLatin1String("context")) {
            bool ok;
            m_lineNumber = accum.trimmed().toInt(&ok);
            if (!ok)
                m_lineNumber = -1;
            popContext(XC_context_linenumber);
        } else if (localName == QLatin1String("note")) {
            m_comment = accum;
        } else if (localName == QLatin1String("ph")) {
            m_ctype.clear();
            popContext(XC_ph);
        } else if (localName == QLatin1String("trans-unit")) {
            if (!hasContext(XC_restype_plurals)) {
                tor->insert( TranslatorMessage(m_context.toUtf8(), m_source.toUtf8(),
                                                m_comment.toUtf8(), "", m_fileName, m_lineNumber,
                                                translations, true, m_type, false) );
                translations.clear();
                m_lineNumber = -1;
            }
        } else if (localName == QLatin1String("group")) {
            if (hasContext(XC_restype_plurals)) {
                tor->insert( TranslatorMessage(m_context.toUtf8(), m_source.toUtf8(),
                                                m_comment.toUtf8(), "", m_fileName, m_lineNumber,
                                                translations, true, m_type, true) );
                popContext(XC_restype_plurals);
                translations.clear();
                m_lineNumber = -1;
            }
            popContext(XC_group);
        }
        return true;
    }
    return false;
}
Exemple #18
0
void CEvaluator::visit ( CApply* e )
{
	CFunction *f= getFunction(e->getFunction());
	if(!f) {
		throw(EvaluationError("function \""+e->getFunction()+"\" is not defined."));
	}
	if(!f || (f->getNumArguments() != e->getNumArguments())) {
		throw(EvaluationError("number of arguments for function \""+e->getFunction()+"\" does not match declaration."));
	}
	map<string,int> *newContext= new map<string,int>();
	for(int i=0; i<f->getNumArguments();i++) {
		string tmp=f->getArgument(i)->getName();
		e->getArgument(i)->accept(this);
		int value=result;
	//	cout << "  "<< tmp <<"="<<value<<endl;
		(*newContext)[tmp]=value;
	}
	pushContext(newContext);
	CExpr *e2 = f->getExpression();
	e2->accept(this);
	delete popContext();
	//return result;
}
static gint
gst_openal_sink_write (GstAudioSink * audiosink, gpointer data, guint length)
{
  GstOpenALSink *sink = GST_OPENAL_SINK (audiosink);
  ALint processed, queued, state;
  ALCcontext *old;
  gulong rest_us;

  g_assert (length == sink->buffer_length);

  old = pushContext (sink->default_context);

  rest_us =
      (guint64) (sink->buffer_length / sink->bytes_per_sample) *
      G_USEC_PER_SEC / sink->rate / sink->channels;
  do {
    alGetSourcei (sink->default_source, AL_SOURCE_STATE, &state);
    alGetSourcei (sink->default_source, AL_BUFFERS_QUEUED, &queued);
    alGetSourcei (sink->default_source, AL_BUFFERS_PROCESSED, &processed);
    if (checkALError () != AL_NO_ERROR) {
      GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
          ("Source state error detected"));
      length = 0;
      goto out_nolock;
    }

    if (processed > 0 || queued < sink->buffer_count)
      break;
    if (state != AL_PLAYING)
      alSourcePlay (sink->default_source);
    g_usleep (rest_us);
  }
  while (1);

  GST_OPENAL_SINK_LOCK (sink);
  if (sink->write_reset != AL_FALSE) {
    sink->write_reset = AL_FALSE;
    length = 0;
    goto out;
  }

  queued -= processed;
  while (processed-- > 0) {
    ALuint bid;
    alSourceUnqueueBuffers (sink->default_source, 1, &bid);
  }
  if (state == AL_STOPPED) {
    /* "Restore" from underruns (not actually needed, but it keeps delay
     * calculations correct while rebuffering) */
    alSourceRewind (sink->default_source);
  }

  alBufferData (sink->buffers[sink->buffer_idx], sink->format,
      data, sink->buffer_length, sink->rate);
  alSourceQueueBuffers (sink->default_source, 1,
      &sink->buffers[sink->buffer_idx]);
  sink->buffer_idx = (sink->buffer_idx + 1) % sink->buffer_count;
  queued++;

  if (state != AL_PLAYING && queued == sink->buffer_count)
    alSourcePlay (sink->default_source);

  if (checkALError () != AL_NO_ERROR) {
    GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
        ("Source queue error detected"));
    goto out;
  }

out:
  GST_OPENAL_SINK_UNLOCK (sink);
out_nolock:
  popContext (old, sink->default_context);
  return length;
}
static gboolean
gst_openal_sink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec)
{
    GstOpenALSink *openal = GST_OPENAL_SINK (asink);
    ALCcontext *ctx, *old;

    if (openal->context && !gst_openal_sink_unprepare (asink))
        return FALSE;

    if (openal->custom_ctx)
        ctx = openal->custom_ctx;
    else {
        ALCint attribs[3] = { 0, 0, 0 };

        /* Don't try to change the playback frequency of an app's device */
        if (!openal->custom_dev) {
            attribs[0] = ALC_FREQUENCY;
            attribs[1] = spec->rate;
            attribs[2] = 0;
        }

        ctx = alcCreateContext (openal->device, attribs);
        if (!ctx) {
            GST_ELEMENT_ERROR (openal, RESOURCE, FAILED,
                               ("Unable to prepare device."), GST_ALC_ERROR (openal->device));
            return FALSE;
        }
    }

    old = pushContext (ctx);

    if (openal->custom_sID) {
        if (!openal->custom_ctx || !alIsSource (openal->custom_sID)) {
            GST_ELEMENT_ERROR (openal, RESOURCE, NOT_FOUND, (NULL),
                               ("Invalid source ID specified for context"));
            goto fail;
        }
        openal->sID = openal->custom_sID;
    } else {
        ALuint sourceID;

        alGenSources (1, &sourceID);
        if (checkALError () != AL_NO_ERROR) {
            GST_ELEMENT_ERROR (openal, RESOURCE, NO_SPACE_LEFT, (NULL),
                               ("Unable to generate source"));
            goto fail;
        }
        openal->sID = sourceID;
    }

    gst_openal_sink_parse_spec (openal, spec);
    if (openal->format == AL_NONE) {
        GST_ELEMENT_ERROR (openal, RESOURCE, SETTINGS, (NULL),
                           ("Unable to get type %d, format %d, and %d channels",
                            spec->type, spec->format, spec->channels));
        goto fail;
    }

    openal->bIDs = g_malloc (openal->bID_count * sizeof (*openal->bIDs));
    if (!openal->bIDs) {
        GST_ELEMENT_ERROR (openal, RESOURCE, FAILED, ("Out of memory."),
                           ("Unable to allocate buffer IDs"));
        goto fail;
    }

    alGenBuffers (openal->bID_count, openal->bIDs);
    if (checkALError () != AL_NO_ERROR) {
        GST_ELEMENT_ERROR (openal, RESOURCE, NO_SPACE_LEFT, (NULL),
                           ("Unable to generate %d buffers", openal->bID_count));
        goto fail;
    }
    openal->bID_idx = 0;

    popContext (old, ctx);
    openal->context = ctx;
    return TRUE;

fail:
    if (!openal->custom_sID && openal->sID)
        alDeleteSources (1, &openal->sID);
    openal->sID = 0;

    g_free (openal->bIDs);
    openal->bIDs = NULL;
    openal->bID_count = 0;
    openal->bID_length = 0;

    popContext (old, ctx);
    if (!openal->custom_ctx)
        alcDestroyContext (ctx);
    return FALSE;
}
static gboolean
gst_openal_sink_prepare (GstAudioSink * audiosink,
    GstAudioRingBufferSpec * spec)
{
  GstOpenALSink *sink = GST_OPENAL_SINK (audiosink);
  ALCcontext *context, *old;

  if (sink->default_context && !gst_openal_sink_unprepare (audiosink))
    return FALSE;

  if (sink->user_context)
    context = sink->user_context;
  else {
    ALCint attribs[3] = { 0, 0, 0 };

    /* Don't try to change the playback frequency of an app's device */
    if (!sink->user_device) {
      attribs[0] = ALC_FREQUENCY;
      attribs[1] = GST_AUDIO_INFO_RATE (&spec->info);
      attribs[2] = 0;
    }

    context = alcCreateContext (sink->default_device, attribs);
    if (!context) {
      GST_ELEMENT_ERROR (sink, RESOURCE, FAILED,
          ("Unable to prepare device."), GST_ALC_ERROR (sink->default_device));
      return FALSE;
    }
  }

  old = pushContext (context);

  if (sink->user_source) {
    if (!sink->user_context || !alIsSource (sink->user_source)) {
      GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND, (NULL),
          ("Invalid source specified for context"));
      goto fail;
    }
    sink->default_source = sink->user_source;
  } else {
    ALuint source;

    alGenSources (1, &source);
    if (checkALError () != AL_NO_ERROR) {
      GST_ELEMENT_ERROR (sink, RESOURCE, NO_SPACE_LEFT, (NULL),
          ("Unable to generate source"));
      goto fail;
    }
    sink->default_source = source;
  }

  gst_openal_sink_parse_spec (sink, spec);
  if (sink->format == AL_NONE) {
    GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, (NULL),
        ("Unable to get type %d, format %d, and %d channels", spec->type,
            GST_AUDIO_INFO_FORMAT (&spec->info),
            GST_AUDIO_INFO_CHANNELS (&spec->info)));
    goto fail;
  }

  sink->buffers = g_malloc (sink->buffer_count * sizeof (*sink->buffers));
  if (!sink->buffers) {
    GST_ELEMENT_ERROR (sink, RESOURCE, FAILED, ("Out of memory."),
        ("Unable to allocate buffers"));
    goto fail;
  }

  alGenBuffers (sink->buffer_count, sink->buffers);
  if (checkALError () != AL_NO_ERROR) {
    GST_ELEMENT_ERROR (sink, RESOURCE, NO_SPACE_LEFT, (NULL),
        ("Unable to generate %d buffers", sink->buffer_count));
    goto fail;
  }
  sink->buffer_idx = 0;

  popContext (old, context);
  sink->default_context = context;
  return TRUE;

fail:
  if (!sink->user_source && sink->default_source)
    alDeleteSources (1, &sink->default_source);
  sink->default_source = 0;

  g_free (sink->buffers);
  sink->buffers = NULL;
  sink->buffer_count = 0;
  sink->buffer_length = 0;

  popContext (old, context);
  if (!sink->user_context)
    alcDestroyContext (context);
  return FALSE;
}
static GstCaps *
gst_openal_helper_probe_caps (ALCcontext * context)
{
  static const struct
  {
    gint count;
    GstAudioChannelPosition positions[8];
  } chans[] = {
    {
      1, {
      GST_AUDIO_CHANNEL_POSITION_MONO}
    }, {
      2, {
      GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
            GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
    }, {
      4, {
      GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
            GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
            GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
            GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}
    }, {
      6, {
      GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
            GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
            GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
            GST_AUDIO_CHANNEL_POSITION_LFE1,
            GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
            GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}
    }, {
      7, {
      GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
            GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
            GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
            GST_AUDIO_CHANNEL_POSITION_LFE1,
            GST_AUDIO_CHANNEL_POSITION_REAR_CENTER,
            GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
            GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}
    }, {
      8, {
      GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
            GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
            GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
            GST_AUDIO_CHANNEL_POSITION_LFE1,
            GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
            GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
            GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
            GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}
  },};
  GstStructure *structure;
  guint64 channel_mask;
  GstCaps *caps;
  ALCcontext *old;

  old = pushContext (context);

  caps = gst_caps_new_empty ();

  if (alIsExtensionPresent ("AL_EXT_MCFORMATS")) {
    const char *fmt32[] = {
      "AL_FORMAT_MONO_FLOAT32",
      "AL_FORMAT_STEREO_FLOAT32",
      "AL_FORMAT_QUAD32",
      "AL_FORMAT_51CHN32",
      "AL_FORMAT_61CHN32",
      "AL_FORMAT_71CHN32",
      NULL
    }, *fmt16[] = {
    "AL_FORMAT_MONO16",
          "AL_FORMAT_STEREO16",
          "AL_FORMAT_QUAD16",
          "AL_FORMAT_51CHN16",
          "AL_FORMAT_61CHN16", "AL_FORMAT_71CHN16", NULL}, *fmt8[] = {
    "AL_FORMAT_MONO8",
          "AL_FORMAT_STEREO8",
          "AL_FORMAT_QUAD8",
          "AL_FORMAT_51CHN8", "AL_FORMAT_61CHN8", "AL_FORMAT_71CHN8", NULL};
    int i;

    if (alIsExtensionPresent ("AL_EXT_FLOAT32")) {
      for (i = 0; fmt32[i]; i++) {
        ALenum value = alGetEnumValue (fmt32[i]);
        if (checkALError () != AL_NO_ERROR || value == 0 || value == -1)
          continue;

        structure =
            gst_structure_new ("audio/x-raw", "format", G_TYPE_STRING,
            GST_AUDIO_NE (F32), "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE,
            OPENAL_MAX_RATE, "channels", G_TYPE_INT, chans[i].count, NULL);
        if (chans[i].count > 2) {
          gst_audio_channel_positions_to_mask (chans[i].positions,
              chans[i].count, FALSE, &channel_mask);
          gst_structure_set (structure, "channel-mask", GST_TYPE_BITMASK,
              channel_mask, NULL);
        }
        gst_caps_append_structure (caps, structure);
      }
    }

    for (i = 0; fmt16[i]; i++) {
      ALenum value = alGetEnumValue (fmt16[i]);
      if (checkALError () != AL_NO_ERROR || value == 0 || value == -1)
        continue;

      structure =
          gst_structure_new ("audio/x-raw", "format", G_TYPE_STRING,
          GST_AUDIO_NE (S16), "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE,
          OPENAL_MAX_RATE, "channels", G_TYPE_INT, chans[i].count, NULL);
      if (chans[i].count > 2) {
        gst_audio_channel_positions_to_mask (chans[i].positions, chans[i].count,
            FALSE, &channel_mask);
        gst_structure_set (structure, "channel-mask", GST_TYPE_BITMASK,
            channel_mask, NULL);
      }
      gst_caps_append_structure (caps, structure);
    }
    for (i = 0; fmt8[i]; i++) {
      ALenum value = alGetEnumValue (fmt8[i]);
      if (checkALError () != AL_NO_ERROR || value == 0 || value == -1)
        continue;

      structure =
          gst_structure_new ("audio/x-raw", "format", G_TYPE_STRING,
          G_STRINGIFY (U8), "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE,
          OPENAL_MAX_RATE, "channels", G_TYPE_INT, chans[i].count, NULL);
      if (chans[i].count > 2) {
        gst_audio_channel_positions_to_mask (chans[i].positions, chans[i].count,
            FALSE, &channel_mask);
        gst_structure_set (structure, "channel-mask", GST_TYPE_BITMASK,
            channel_mask, NULL);
      }
      gst_caps_append_structure (caps, structure);
    }
  } else {
    if (alIsExtensionPresent ("AL_EXT_FLOAT32")) {
      structure =
          gst_structure_new ("audio/x-raw", "format", G_TYPE_STRING,
          GST_AUDIO_NE (F32), "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE,
          OPENAL_MAX_RATE, "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
      gst_caps_append_structure (caps, structure);
    }

    structure =
        gst_structure_new ("audio/x-raw", "format", G_TYPE_STRING,
        GST_AUDIO_NE (S16), "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE,
        OPENAL_MAX_RATE, "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
    gst_caps_append_structure (caps, structure);

    structure =
        gst_structure_new ("audio/x-raw", "format", G_TYPE_STRING,
        G_STRINGIFY (U8), "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE,
        OPENAL_MAX_RATE, "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
    gst_caps_append_structure (caps, structure);
  }

  if (alIsExtensionPresent ("AL_EXT_double")) {
    structure =
        gst_structure_new ("audio/x-raw", "format", G_TYPE_STRING,
        GST_AUDIO_NE (F64), "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE,
        OPENAL_MAX_RATE, "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
    gst_caps_append_structure (caps, structure);
  }

  if (alIsExtensionPresent ("AL_EXT_IMA4")) {
    structure =
        gst_structure_new ("audio/x-adpcm", "layout", G_TYPE_STRING, "ima",
        "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE, OPENAL_MAX_RATE,
        "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
    gst_caps_append_structure (caps, structure);
  }

  if (alIsExtensionPresent ("AL_EXT_ALAW")) {
    structure =
        gst_structure_new ("audio/x-alaw", "rate", GST_TYPE_INT_RANGE,
        OPENAL_MIN_RATE, OPENAL_MAX_RATE, "channels", GST_TYPE_INT_RANGE, 1, 2,
        NULL);
    gst_caps_append_structure (caps, structure);
  }

  if (alIsExtensionPresent ("AL_EXT_MULAW_MCFORMATS")) {
    const char *fmtmulaw[] = {
      "AL_FORMAT_MONO_MULAW",
      "AL_FORMAT_STEREO_MULAW",
      "AL_FORMAT_QUAD_MULAW",
      "AL_FORMAT_51CHN_MULAW",
      "AL_FORMAT_61CHN_MULAW",
      "AL_FORMAT_71CHN_MULAW",
      NULL
    };
    int i;

    for (i = 0; fmtmulaw[i]; i++) {
      ALenum value = alGetEnumValue (fmtmulaw[i]);
      if (checkALError () != AL_NO_ERROR || value == 0 || value == -1)
        continue;

      structure =
          gst_structure_new ("audio/x-mulaw", "rate", GST_TYPE_INT_RANGE,
          OPENAL_MIN_RATE, OPENAL_MAX_RATE, "channels", G_TYPE_INT,
          chans[i].count, NULL);
      if (chans[i].count > 2) {
        gst_audio_channel_positions_to_mask (chans[i].positions, chans[i].count,
            FALSE, &channel_mask);
        gst_structure_set (structure, "channel-mask", GST_TYPE_BITMASK,
            channel_mask, NULL);
      }
      gst_caps_append_structure (caps, structure);
    }
  } else if (alIsExtensionPresent ("AL_EXT_MULAW")) {
    structure =
        gst_structure_new ("audio/x-mulaw", "rate", GST_TYPE_INT_RANGE,
        OPENAL_MIN_RATE, OPENAL_MAX_RATE, "channels", GST_TYPE_INT_RANGE, 1, 2,
        NULL);
    gst_caps_append_structure (caps, structure);
  }

  popContext (old, context);

  return caps;
}
void NetMessageReader::parse()
{
	while (!isEndOfBuffer()) {
		if (std::isprint(currentChar())) {
			TRACE("parse: '%c' (%d) %s", currentChar(), static_cast<int>(state()), state_str());
		} else {
			TRACE("parse: 0x%02X (%d) %s", currentChar(), static_cast<int>(state()), state_str());
		}

		switch (state()) {
			case MESSAGE_BEGIN:
				// Syntetic state. Go straight to TYPE.
			case MESSAGE_TYPE:
				switch (currentChar()) {
					case '+':
					case '-':
					case ':':
						currentContext_->type = static_cast<NetMessage::Type>(currentChar());
						setState(MESSAGE_LINE_BEGIN);
						nextChar();
						break;
					case '$':
						currentContext_->type = NetMessage::String;
						setState(BULK_BEGIN);
						break;
					case '*':
						currentContext_->type = NetMessage::Array;
						setState(MESSAGE_NUM_ARGS);
						nextChar();
						break;
					default:
						currentContext_->type = NetMessage::Nil;
						setState(SYNTAX_ERROR);
						return;
				}
				break;
			case MESSAGE_LINE_BEGIN:
				if (currentChar() == '\r') {
					setState(SYNTAX_ERROR);
					return;
				}
				setState(MESSAGE_LINE_OR_CR);
				begin_ = pos_;
				nextChar();
				break;
			case MESSAGE_LINE_OR_CR:
				if (currentChar() == '\n') {
					setState(SYNTAX_ERROR);
					return;
				}

				if (currentChar() == '\r')
					setState(MESSAGE_LINE_LF);

				nextChar();
				break;
			case MESSAGE_LINE_LF: {
				if (currentChar() != '\n') {
					setState(SYNTAX_ERROR);
					return;
				}
				BufferRef value = buffer_->ref(begin_, pos_ - begin_ - 1);
				switch (currentContext_->type) {
					case NetMessage::Status:
						currentContext_->message = NetMessage::createStatus(value);
						break;
					case NetMessage::Error:
						currentContext_->message = NetMessage::createError(value);
						break;
					case NetMessage::String:
						currentContext_->message = NetMessage::createString(value);
						break;
					case NetMessage::Number:
						currentContext_->message = NetMessage::createNumber(value.toInt());
						break;
					default:
						currentContext_->message = NetMessage::createNil();
						break;
				}
				setState(MESSAGE_END);
				nextChar();
				popContext();
				break;
			}
			case MESSAGE_NUM_ARGS: {
				switch (currentChar()) {
					case '0':
					case '1':
					case '2':
					case '3':
					case '4':
					case '5':
					case '6':
					case '7':
					case '8':
					case '9':
						currentContext_->number *= 10;
						currentContext_->number += currentChar() - '0';
						setState(MESSAGE_NUM_ARGS_OR_CR);
						nextChar();
						break;
					default:
						setState(SYNTAX_ERROR);
						return;
				}
				break;
			}
			case MESSAGE_NUM_ARGS_OR_CR:
				switch (currentChar()) {
					case '0':
					case '1':
					case '2':
					case '3':
					case '4':
					case '5':
					case '6':
					case '7':
					case '8':
					case '9':
						currentContext_->number *= 10;
						currentContext_->number += currentChar() - '0';
						nextChar();
						break;
					case '\r':
						setState(MESSAGE_LF);
						currentContext_->message = NetMessage::createArray(currentContext_->number);
						nextChar();
						break;
					default:
						setState(SYNTAX_ERROR);
						return;
				}
				break;
			case MESSAGE_LF:
				if (currentChar() != '\n') {
					setState(SYNTAX_ERROR);
					return;
				}

				nextChar();

				if (currentContext_->type == NetMessage::Array) {
					setState(BULK_BEGIN);
					pushContext();
				} else {
					setState(MESSAGE_END);
					popContext();
				}
				break;
			case BULK_BEGIN:
				if (currentChar() != '$') {
					setState(SYNTAX_ERROR);
					return;
				}
				setState(BULK_SIZE);
				nextChar();
				break;
			case BULK_SIZE:
				switch (currentChar()) {
					case '0':
					case '1':
					case '2':
					case '3':
					case '4':
					case '5':
					case '6':
					case '7':
					case '8':
					case '9':
						argSize_ *= 10;
						argSize_ += currentChar() - '0';
						setState(BULK_SIZE_OR_CR);
						nextChar();
						break;
					default:
						setState(SYNTAX_ERROR);
						return;
				}
				break;
			case BULK_SIZE_OR_CR:
				switch (currentChar()) {
					case '0':
					case '1':
					case '2':
					case '3':
					case '4':
					case '5':
					case '6':
					case '7':
					case '8':
					case '9':
						argSize_ *= 10;
						argSize_ += currentChar() - '0';
						nextChar();
						break;
					case '\r':
						setState(BULK_SIZE_LF);
						nextChar();
						break;
					default:
						setState(SYNTAX_ERROR);
						return;
				}
				break;
			case BULK_SIZE_LF:
				if (currentChar() != '\n') {
					setState(SYNTAX_ERROR);
					return;
				}
				nextChar();
				setState(BULK_BODY_OR_CR);
				begin_ = pos_;
				break;
			case BULK_BODY_OR_CR:
				if (argSize_ > 0) {
					argSize_ -= nextChar(argSize_);
				} else if (currentChar() == '\r') {
					BufferRef value = buffer_->ref(begin_, pos_ - begin_);
					currentContext_->message = NetMessage::createString(value);
					nextChar();
					setState(BULK_BODY_LF);
				} else {
					setState(SYNTAX_ERROR);
					return;
				}
				break;
			case BULK_BODY_LF:
				if (currentChar() != '\n') {
					setState(SYNTAX_ERROR);
					return;
				}
				nextChar();

				setState(MESSAGE_END);
				popContext();

				break;
			case MESSAGE_END:
				// if we reach here, then only because
				// there's garbage at the end of our message.
				break;
			case SYNTAX_ERROR:
				fprintf(stderr, "NetMessageSocket message syntax error at offset %zi\n", pos_);
				break;
			default:
				break;
		}
	}
}
Exemple #24
0
bool XLIFFHandler::endElement(const QString &namespaceURI, const QString& localName,
    const QString &qName)
{
    Q_UNUSED(qName);
    if (namespaceURI == m_URITT) {
        if (hasContext(XC_trans_unit) || hasContext(XC_restype_plurals))
            m_extra[localName] = accum;
        else
            m_translator.setExtra(localName, accum);
        return true;
    }
    if (namespaceURI != m_URI && namespaceURI != m_URI12)
        return false;
    //qDebug() << "URI:" <<  namespaceURI << "QNAME:" << qName;
    if (localName == QLatin1String("xliff")) {
        popContext(XC_xliff);
    } else if (localName == QLatin1String("source")) {
        if (hasContext(XC_alt_trans)) {
            if (m_isPlural && m_oldSources.isEmpty())
                m_oldSources.append(QString());
            m_oldSources.append(accum);
            m_hadAlt = true;
        } else {
            m_sources.append(accum);
        }
    } else if (localName == QLatin1String("target")) {
        if (popContext(XC_restype_translation)) {
            accum.replace(QChar(Translator::TextVariantSeparator),
                          QChar(Translator::BinaryVariantSeparator));
            m_translations.append(accum);
        }
    } else if (localName == QLatin1String("context-group")) {
        if (popContext(XC_context_group)) {
            m_refs.append(TranslatorMessage::Reference(
                m_extraFileName.isEmpty() ? m_fileName : m_extraFileName, m_lineNumber));
            m_extraFileName.clear();
            m_lineNumber = -1;
        } else {
            popContext(XC_context_group_any);
        }
    } else if (localName == QLatin1String("context")) {
        if (popContext(XC_context_linenumber)) {
            bool ok;
            m_lineNumber = accum.trimmed().toInt(&ok);
            if (!ok)
                m_lineNumber = -1;
        } else if (popContext(XC_context_filename)) {
            m_extraFileName = accum;
        } else if (popContext(XC_context_comment)) {
            m_comment = accum;
        } else if (popContext(XC_context_old_comment)) {
            m_oldComment = accum;
        }
    } else if (localName == QLatin1String("note")) {
        if (popContext(XC_extra_comment))
            m_extraComment = accum;
        else if (popContext(XC_translator_comment))
            m_translatorComment = accum;
    } else if (localName == QLatin1String("ph")) {
        m_ctype.clear();
        popContext(XC_ph);
    } else if (localName == QLatin1String("trans-unit")) {
        popContext(XC_trans_unit);
        if (!m_hadAlt)
            m_oldSources.append(QString());
        if (!hasContext(XC_restype_plurals)) {
            if (!finalizeMessage(false))
                return false;
        }
    } else if (localName == QLatin1String("alt-trans")) {
        popContext(XC_alt_trans);
    } else if (localName == QLatin1String("group")) {
        if (popContext(XC_restype_plurals)) {
            if (!finalizeMessage(true))
                return false;
        } else if (popContext(XC_restype_context)) {
            m_context.clear();
        } else {
            popContext(XC_group);
        }
    }
    return true;
}
static GstCaps *
gst_openal_helper_probe_caps (ALCcontext * ctx)
{
    static const struct
    {
        gint count;
        GstAudioChannelPosition pos[8];
    } chans[] = {
        {
            1, {
                GST_AUDIO_CHANNEL_POSITION_FRONT_MONO
            }
        }, {
            2, {
                GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
                GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT
            }
        }, {
            4, {
                GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
                GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
                GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
                GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT
            }
        }, {
            6, {
                GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
                GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
                GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
                GST_AUDIO_CHANNEL_POSITION_LFE,
                GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
                GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT
            }
        }, {
            7, {
                GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
                GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
                GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
                GST_AUDIO_CHANNEL_POSITION_LFE,
                GST_AUDIO_CHANNEL_POSITION_REAR_CENTER,
                GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
                GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT
            }
        }, {
            8, {
                GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
                GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
                GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
                GST_AUDIO_CHANNEL_POSITION_LFE,
                GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
                GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
                GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
                GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT
            }
        },
    };
    GstStructure *structure;
    ALCcontext *old;
    GstCaps *caps;

    old = pushContext (ctx);

    caps = gst_caps_new_empty ();
    if (alIsExtensionPresent ("AL_EXT_MCFORMATS")) {
        const char *fmt32[] = {
            "AL_FORMAT_MONO_FLOAT32", "AL_FORMAT_STEREO_FLOAT32",
            "AL_FORMAT_QUAD32", "AL_FORMAT_51CHN32", "AL_FORMAT_61CHN32",
            "AL_FORMAT_71CHN32", NULL
        }, *fmt16[] = {
            "AL_FORMAT_MONO16", "AL_FORMAT_STEREO16", "AL_FORMAT_QUAD16",
            "AL_FORMAT_51CHN16", "AL_FORMAT_61CHN16", "AL_FORMAT_71CHN16", NULL
        },
        *fmt8[] = {
            "AL_FORMAT_MONO8", "AL_FORMAT_STEREO8", "AL_FORMAT_QUAD8",
            "AL_FORMAT_51CHN8", "AL_FORMAT_61CHN8", "AL_FORMAT_71CHN8", NULL
        };
        int i;

        if (alIsExtensionPresent ("AL_EXT_FLOAT32")) {
            for (i = 0; fmt32[i]; i++) {
                ALenum val = alGetEnumValue (fmt32[i]);
                if (checkALError () != AL_NO_ERROR || val == 0 || val == -1)
                    continue;

                structure = gst_structure_new ("audio/x-raw-float",
                                               "endianness", G_TYPE_INT, G_BYTE_ORDER,
                                               "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE,
                                               OPENAL_MAX_RATE, "width", G_TYPE_INT, 32, NULL);
                gst_structure_set (structure, "channels", G_TYPE_INT,
                                   chans[i].count, NULL);
                if (chans[i].count > 2)
                    gst_audio_set_channel_positions (structure, chans[i].pos);
                gst_caps_append_structure (caps, structure);
            }
        }
        for (i = 0; fmt16[i]; i++) {
            ALenum val = alGetEnumValue (fmt16[i]);
            if (checkALError () != AL_NO_ERROR || val == 0 || val == -1)
                continue;

            structure = gst_structure_new ("audio/x-raw-int",
                                           "endianness", G_TYPE_INT, G_BYTE_ORDER,
                                           "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE, OPENAL_MAX_RATE,
                                           "width", G_TYPE_INT, 16,
                                           "depth", G_TYPE_INT, 16, "signed", G_TYPE_BOOLEAN, TRUE, NULL);
            gst_structure_set (structure, "channels", G_TYPE_INT,
                               chans[i].count, NULL);
            if (chans[i].count > 2)
                gst_audio_set_channel_positions (structure, chans[i].pos);
            gst_caps_append_structure (caps, structure);
        }
        for (i = 0; fmt8[i]; i++) {
            ALenum val = alGetEnumValue (fmt8[i]);
            if (checkALError () != AL_NO_ERROR || val == 0 || val == -1)
                continue;

            structure = gst_structure_new ("audio/x-raw-int",
                                           "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE, OPENAL_MAX_RATE,
                                           "width", G_TYPE_INT, 8,
                                           "depth", G_TYPE_INT, 8, "signed", G_TYPE_BOOLEAN, FALSE, NULL);
            gst_structure_set (structure, "channels", G_TYPE_INT,
                               chans[i].count, NULL);
            if (chans[i].count > 2)
                gst_audio_set_channel_positions (structure, chans[i].pos);
            gst_caps_append_structure (caps, structure);
        }
    } else {
        if (alIsExtensionPresent ("AL_EXT_FLOAT32")) {
            structure = gst_structure_new ("audio/x-raw-float",
                                           "endianness", G_TYPE_INT, G_BYTE_ORDER,
                                           "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE, OPENAL_MAX_RATE,
                                           "width", G_TYPE_INT, 32, "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
            gst_caps_append_structure (caps, structure);
        }

        structure = gst_structure_new ("audio/x-raw-int",
                                       "endianness", G_TYPE_INT, G_BYTE_ORDER,
                                       "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE, OPENAL_MAX_RATE,
                                       "width", G_TYPE_INT, 16,
                                       "depth", G_TYPE_INT, 16,
                                       "signed", G_TYPE_BOOLEAN, TRUE,
                                       "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
        gst_caps_append_structure (caps, structure);

        structure = gst_structure_new ("audio/x-raw-int",
                                       "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE, OPENAL_MAX_RATE,
                                       "width", G_TYPE_INT, 8,
                                       "depth", G_TYPE_INT, 8,
                                       "signed", G_TYPE_BOOLEAN, FALSE,
                                       "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
        gst_caps_append_structure (caps, structure);
    }

    if (alIsExtensionPresent ("AL_EXT_MULAW_MCFORMATS")) {
        const char *fmtmulaw[] = {
            "AL_FORMAT_MONO_MULAW", "AL_FORMAT_STEREO_MULAW",
            "AL_FORMAT_QUAD_MULAW", "AL_FORMAT_51CHN_MULAW",
            "AL_FORMAT_61CHN_MULAW", "AL_FORMAT_71CHN_MULAW", NULL
        };
        int i;

        for (i = 0; fmtmulaw[i]; i++) {
            ALenum val = alGetEnumValue (fmtmulaw[i]);
            if (checkALError () != AL_NO_ERROR || val == 0 || val == -1)
                continue;

            structure = gst_structure_new ("audio/x-mulaw",
                                           "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE, OPENAL_MAX_RATE, NULL);
            gst_structure_set (structure, "channels", G_TYPE_INT,
                               chans[i].count, NULL);
            if (chans[i].count > 2)
                gst_audio_set_channel_positions (structure, chans[i].pos);
            gst_caps_append_structure (caps, structure);
        }
    } else if (alIsExtensionPresent ("AL_EXT_MULAW")) {
        structure = gst_structure_new ("audio/x-mulaw",
                                       "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE, OPENAL_MAX_RATE,
                                       "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
        gst_caps_append_structure (caps, structure);
    }

    popContext (old, ctx);
    return caps;
}
Exemple #26
0
Control::~Control()
{
  popContext();

  Q_ASSERT(current_context == 0);
}