parent
07d30cbff9
commit
18f97fb494
|
@ -73,6 +73,7 @@ struct obs_volmeter {
|
|||
DARRAY(struct meter_cb) callbacks;
|
||||
|
||||
enum obs_peak_meter_type peak_meter_type;
|
||||
unsigned int update_ms;
|
||||
float prev_samples[MAX_AUDIO_CHANNELS][4];
|
||||
|
||||
float magnitude[MAX_AUDIO_CHANNELS];
|
||||
|
@ -782,6 +783,8 @@ obs_volmeter_t *obs_volmeter_create(enum obs_fader_type type)
|
|||
|
||||
volmeter->type = type;
|
||||
|
||||
obs_volmeter_set_update_interval(volmeter, 50);
|
||||
|
||||
return volmeter;
|
||||
fail:
|
||||
obs_volmeter_destroy(volmeter);
|
||||
|
@ -863,6 +866,29 @@ void obs_volmeter_set_peak_meter_type(obs_volmeter_t *volmeter,
|
|||
pthread_mutex_unlock(&volmeter->mutex);
|
||||
}
|
||||
|
||||
void obs_volmeter_set_update_interval(obs_volmeter_t *volmeter,
|
||||
const unsigned int ms)
|
||||
{
|
||||
if (!volmeter || !ms)
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&volmeter->mutex);
|
||||
volmeter->update_ms = ms;
|
||||
pthread_mutex_unlock(&volmeter->mutex);
|
||||
}
|
||||
|
||||
unsigned int obs_volmeter_get_update_interval(obs_volmeter_t *volmeter)
|
||||
{
|
||||
if (!volmeter)
|
||||
return 0;
|
||||
|
||||
pthread_mutex_lock(&volmeter->mutex);
|
||||
const unsigned int interval = volmeter->update_ms;
|
||||
pthread_mutex_unlock(&volmeter->mutex);
|
||||
|
||||
return interval;
|
||||
}
|
||||
|
||||
int obs_volmeter_get_nr_channels(obs_volmeter_t *volmeter)
|
||||
{
|
||||
int source_nr_audio_channels;
|
||||
|
|
|
@ -231,6 +231,34 @@ EXPORT void
|
|||
obs_volmeter_set_peak_meter_type(obs_volmeter_t *volmeter,
|
||||
enum obs_peak_meter_type peak_meter_type);
|
||||
|
||||
/**
|
||||
* @brief Set the update interval for the volume meter
|
||||
* @param volmeter pointer to the volume meter object
|
||||
* @param ms update interval in ms
|
||||
*
|
||||
* This sets the update interval in milliseconds that should be processed before
|
||||
* the resulting values are emitted by the levels_updated signal. The resulting
|
||||
* number of audio samples is rounded to an integer.
|
||||
*
|
||||
* Please note that due to way obs does receive audio data from the sources
|
||||
* this is no hard guarantee for the timing of the signal itself. When the
|
||||
* volume meter receives a chunk of data that is multiple the size of the sample
|
||||
* interval, all data will be sampled and the values updated accordingly, but
|
||||
* only the signal for the last segment is actually emitted.
|
||||
* On the other hand data might be received in a way that will cause the signal
|
||||
* to be emitted in shorter intervals than specified here under some
|
||||
* circumstances.
|
||||
*/
|
||||
EXPORT void obs_volmeter_set_update_interval(obs_volmeter_t *volmeter,
|
||||
const unsigned int ms);
|
||||
|
||||
/**
|
||||
* @brief Get the update interval currently used for the volume meter
|
||||
* @param volmeter pointer to the volume meter object
|
||||
* @return update interval in ms
|
||||
*/
|
||||
EXPORT unsigned int obs_volmeter_get_update_interval(obs_volmeter_t *volmeter);
|
||||
|
||||
/**
|
||||
* @brief Get the number of channels which are configured for this source.
|
||||
* @param volmeter pointer to the volume meter object
|
||||
|
|
Loading…
Reference in New Issue