Пример #1
0
static void
gst_crossfeed_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
{
  GstCrossfeed *crossfeed = GST_CROSSFEED (object);

  switch (prop_id) {
    case ARG_ACTIVE:
      GST_CROSSFEED_LOCK (crossfeed);
      crossfeed->active = g_value_get_boolean (value);
      gst_crossfeed_update_passthrough (crossfeed);
      /* Clear the filter buffer if it gets set inactive, so we have
       * a fresh start when it gets activated again. */
      if (!crossfeed->active) {
        GST_CROSSFEED_UNLOCK (crossfeed);
        GST_CROSSFEED_BS2B_LOCK (crossfeed);
        bs2b_clear (crossfeed->bs2bdp);
        GST_CROSSFEED_BS2B_UNLOCK (crossfeed);
      } else {
        GST_CROSSFEED_UNLOCK (crossfeed);
      }
      break;
    case ARG_FCUT:
      GST_CROSSFEED_BS2B_LOCK (crossfeed);
      bs2b_set_level_fcut (crossfeed->bs2bdp, g_value_get_int (value));
      GST_CROSSFEED_BS2B_UNLOCK (crossfeed);
      break;
    case ARG_FEED:
      GST_CROSSFEED_BS2B_LOCK (crossfeed);
      bs2b_set_level_feed (crossfeed->bs2bdp, g_value_get_int (value));
      GST_CROSSFEED_BS2B_UNLOCK (crossfeed);
      break;
    case ARG_PRESET:
      switch (g_value_get_enum (value)) {
        case PRESET_DEFAULT:
          GST_CROSSFEED_BS2B_LOCK (crossfeed);
          bs2b_set_level (crossfeed->bs2bdp, BS2B_DEFAULT_CLEVEL);
          GST_CROSSFEED_BS2B_UNLOCK (crossfeed);
          break;
        case PRESET_CMOY:
          GST_CROSSFEED_BS2B_LOCK (crossfeed);
          bs2b_set_level (crossfeed->bs2bdp, BS2B_CMOY_CLEVEL);
          GST_CROSSFEED_BS2B_UNLOCK (crossfeed);
          break;
        case PRESET_JMEIER:
          GST_CROSSFEED_BS2B_LOCK (crossfeed);
          bs2b_set_level (crossfeed->bs2bdp, BS2B_JMEIER_CLEVEL);
          GST_CROSSFEED_BS2B_UNLOCK (crossfeed);
          break;
        default:
          G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
          break;
      }
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}
Пример #2
0
static gboolean gst_crossfeed_sink_eventfunc (GstBaseTransform * trans,
    GstEvent * event)
{
  GstCrossfeed *crossfeed = GST_CROSSFEED (trans);

  if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) {
    GST_CROSSFEED_BS2B_LOCK (crossfeed);
    bs2b_clear (crossfeed->bs2bdp);
    GST_CROSSFEED_BS2B_UNLOCK (crossfeed);
  }

  return GST_BASE_TRANSFORM_CLASS (parent_class)->event (trans, event);
}
Пример #3
0
/*
    alcCreateContext

    Create and attach a Context to a particular Device.
*/
ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint *attrList)
{
    ALuint attrIdx, reqStereoSources;
    ALCcontext *ALContext;
    void *temp;
    ALuint i;

    SuspendContext(NULL);

    if(!IsDevice(device) || device->IsCaptureDevice || !device->Connected)
    {
        alcSetError(ALC_INVALID_DEVICE);
        ProcessContext(NULL);
        return NULL;
    }

    // Reset Context Last Error code
    g_eLastContextError = ALC_NO_ERROR;

    // If a context is already running on the device, stop playback so the
    // device attributes can be updated
    if(device->NumContexts > 0)
    {
        ProcessContext(NULL);
        ALCdevice_StopPlayback(device);
        SuspendContext(NULL);
    }

    // Check for attributes
    if(attrList)
    {
        ALCint level = device->Bs2bLevel;
        ALCuint freq = device->Frequency;
        ALCint numMono = device->lNumMonoSources;
        ALCint numStereo = device->lNumStereoSources;
        ALCuint numSends = device->NumAuxSends;

        attrIdx = 0;
        while(attrList[attrIdx])
        {
            if(attrList[attrIdx] == ALC_FREQUENCY)
            {
                freq = attrList[attrIdx + 1];
                if(freq == 0)
                    freq = device->Frequency;
            }

            if(attrList[attrIdx] == ALC_STEREO_SOURCES)
            {
                reqStereoSources = attrList[attrIdx + 1];
                if(reqStereoSources > device->MaxNoOfSources)
                    reqStereoSources = device->MaxNoOfSources;

                numStereo = reqStereoSources;
                numMono = device->MaxNoOfSources - numStereo;
            }

            if(attrList[attrIdx] == ALC_MAX_AUXILIARY_SENDS)
            {
                numSends = attrList[attrIdx + 1];
                if(numSends > MAX_SENDS)
                    numSends = MAX_SENDS;
            }

            attrIdx += 2;
        }

        device->Bs2bLevel = GetConfigValueInt(NULL, "cf_level", level);
        device->Frequency = GetConfigValueInt(NULL, "frequency", freq);
        device->lNumMonoSources = numMono;
        device->lNumStereoSources = numStereo;
        device->NumAuxSends = GetConfigValueInt(NULL, "sends", numSends);
    }

    if(ALCdevice_ResetPlayback(device) == ALC_FALSE)
    {
        alcSetError(ALC_INVALID_DEVICE);
        aluHandleDisconnect(device);
        ProcessContext(NULL);
        return NULL;
    }

    for(i = 0;i < device->NumContexts;i++)
    {
        ALCcontext *context = device->Contexts[i];
        ALeffectslot *slot;
        ALsource *source;

        SuspendContext(context);
        for(slot = context->AuxiliaryEffectSlot;slot != NULL;slot = slot->next)
        {
            if(!slot->EffectState)
                continue;

            if(ALEffect_DeviceUpdate(slot->EffectState, device) == AL_FALSE)
            {
                alcSetError(ALC_INVALID_DEVICE);
                aluHandleDisconnect(device);
                ProcessContext(context);
                ProcessContext(NULL);
                ALCdevice_StopPlayback(device);
                return NULL;
            }
            ALEffect_Update(slot->EffectState, context, &slot->effect);
        }

        for(source = context->Source;source != NULL;source = source->next)
        {
            ALuint s = device->NumAuxSends;
            while(s < MAX_SENDS)
            {
                if(source->Send[s].Slot)
                    source->Send[s].Slot->refcount--;
                source->Send[s].Slot = NULL;
                source->Send[s].WetFilter.type = 0;
                source->Send[s].WetFilter.filter = 0;
                s++;
            }
        }
        ProcessContext(context);
    }

    if(device->Bs2bLevel > 0 && device->Bs2bLevel <= 6)
    {
        if(!device->Bs2b)
        {
            device->Bs2b = calloc(1, sizeof(*device->Bs2b));
            bs2b_clear(device->Bs2b);
        }
        bs2b_set_srate(device->Bs2b, device->Frequency);
        bs2b_set_level(device->Bs2b, device->Bs2bLevel);
    }
    else
    {
        free(device->Bs2b);
        device->Bs2b = NULL;
    }

    temp = realloc(device->Contexts, (device->NumContexts+1) * sizeof(*device->Contexts));
    if(!temp)
    {
        alcSetError(ALC_OUT_OF_MEMORY);
        ProcessContext(NULL);
        return NULL;
    }
    device->Contexts = temp;

    ALContext = calloc(1, sizeof(ALCcontext));
    if(!ALContext)
    {
        alcSetError(ALC_OUT_OF_MEMORY);
        ProcessContext(NULL);
        return NULL;
    }

    device->Contexts[device->NumContexts++] = ALContext;
    ALContext->Device = device;

    InitContext(ALContext);

    ALContext->next = g_pContextList;
    g_pContextList = ALContext;
    g_ulContextCount++;

    ProcessContext(NULL);

    return ALContext;
}