Implement volume handling

- Remove obs_source::type because it became redundant now that the
   type is always stored in the obs_source::info variable.

 - Apply presentation volumes of 1.0 and 0.0 to sources when they
   activate/deactivate, respectively.  It also applies that presentation
   volume to all sub-sources, with exception of transition sources.
   Transition sources must apply presentation volume manually to their
   sub-sources with the new transition functions below.

 - Add a "transition_volume" variable to obs_source structure, and add
   three functions for handling volume for transitions:

   * obs_transition_begin_frame
   * obs_source_set_transition_vol
   * obs_transition_end_frame

   Because the to/from targets of a transition source might both contain
   some of the same sources, handling the transitioning of volumes for
   that specific situation becomes an issue.

   So for transitions, instead of modifying the presentation volumes
   directly for both sets of sources, we do this:

   - First, call obs_transition_begin_frame at the beginning of each
     transition frame, which will reset transition volumes for all
     sub-sources to 0.  Presentation volumes remain unchanged.

   - Call obs_source_set_transition_vol on each sub-source, which will
     then add the volume to the transition volume for each source in
     that source's tree.  Presentation volumes still remain unchanged.

   - Then you call obs_trandition_end_frame when complete, which will
     then finally set the presentation volumes to the transition
     volumes.

   For example, let's say that there's one source that's within both the
   "transitioning from" sources and "transition to" sources.  It would
   add both the fade in and fade out volumes to that source, and then
   when the frame is complete, it would set the presentation volume to
   the sum of those two values, rather than set the presentation volume
   for that same source twice which would cause weird volume jittering
   and also set the wrong values.
This commit is contained in:
jp9000
2014-02-21 19:41:38 -07:00
parent bdcabc6170
commit be81276f03
4 changed files with 94 additions and 6 deletions

View File

@@ -218,7 +218,6 @@ obs_scene_t obs_scene_create(const char *name)
}
source->name = bstrdup(name);
source->type = OBS_SOURCE_TYPE_SCENE;
scene->source = source;
obs_source_init(source, &scene_info);
@@ -245,7 +244,7 @@ obs_source_t obs_scene_getsource(obs_scene_t scene)
obs_scene_t obs_scene_fromsource(obs_source_t source)
{
if (source->type != OBS_SOURCE_TYPE_SCENE)
if (source->info.type != OBS_SOURCE_TYPE_SCENE)
return NULL;
return source->data;