int pa_scache_add_item( pa_core *c, const char *name, const pa_sample_spec *ss, const pa_channel_map *map, const pa_memchunk *chunk, pa_proplist *p, uint32_t *idx) { pa_scache_entry *e; char st[PA_SAMPLE_SPEC_SNPRINT_MAX]; pa_channel_map tmap; pa_assert(c); pa_assert(name); pa_assert(!ss || pa_sample_spec_valid(ss)); pa_assert(!map || (pa_channel_map_valid(map) && ss && pa_channel_map_compatible(map, ss))); if (ss && !map) { pa_channel_map_init_extend(&tmap, ss->channels, PA_CHANNEL_MAP_DEFAULT); map = &tmap; } if (chunk && chunk->length > PA_SCACHE_ENTRY_SIZE_MAX) return -1; if (!(e = scache_add_item(c, name))) return -1; pa_sample_spec_init(&e->sample_spec); pa_channel_map_init(&e->channel_map); pa_cvolume_init(&e->volume); e->volume_is_set = FALSE; if (ss) { e->sample_spec = *ss; pa_cvolume_reset(&e->volume, ss->channels); } if (map) e->channel_map = *map; if (chunk) { e->memchunk = *chunk; pa_memblock_ref(e->memchunk.memblock); } if (p) pa_proplist_update(e->proplist, PA_UPDATE_REPLACE, p); if (idx) *idx = e->index; pa_log_debug("Created sample \"%s\" (#%d), %lu bytes with sample spec %s", name, e->index, (unsigned long) e->memchunk.length, pa_sample_spec_snprint(st, sizeof(st), &e->sample_spec)); return 0; }
JNIEXPORT jlong JNICALL Java_org_jitsi_impl_neomedia_pulseaudio_PA_cvolume_1new (JNIEnv *env, jclass clazz) { pa_cvolume *cv = pa_xmalloc(sizeof(pa_cvolume)); if (cv) cv = pa_cvolume_init(cv); return (intptr_t) cv; }
PulseStream::PulseStream(QString streamUuid, QString role) : QObject() , mStreamUuid(streamUuid) , mIndex(PA_INVALID_INDEX) , mDevice(-1) , mMute(false) , mCachedVolume(-1) , mRole(role) { pa_cvolume_init(&mVolume); }
static int qpa_ctl_in (HWVoiceIn *hw, int cmd, ...) { PAVoiceIn *pa = (PAVoiceIn *) hw; pa_operation *op; pa_cvolume v; paaudio *g = pa->g; #ifdef PA_CHECK_VERSION pa_cvolume_init (&v); #endif switch (cmd) { case VOICE_VOLUME: { SWVoiceIn *sw; va_list ap; va_start (ap, cmd); sw = va_arg (ap, SWVoiceIn *); va_end (ap); v.channels = 2; v.values[0] = ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * sw->vol.l) / UINT32_MAX; v.values[1] = ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * sw->vol.r) / UINT32_MAX; pa_threaded_mainloop_lock (g->mainloop); op = pa_context_set_source_output_volume (g->context, pa_stream_get_index (pa->stream), &v, NULL, NULL); if (!op) { qpa_logerr (pa_context_errno (g->context), "set_source_output_volume() failed\n"); } else { pa_operation_unref(op); } op = pa_context_set_source_output_mute (g->context, pa_stream_get_index (pa->stream), sw->vol.mute, NULL, NULL); if (!op) { qpa_logerr (pa_context_errno (g->context), "set_source_output_mute() failed\n"); } else { pa_operation_unref (op); } pa_threaded_mainloop_unlock (g->mainloop); } } return 0; }
CAESinkPULSE::CAESinkPULSE() { m_IsAllocated = false; m_passthrough = false; m_MainLoop = NULL; m_BytesPerSecond = 0; m_BufferSize = 0; m_Channels = 0; m_Stream = NULL; m_Context = NULL; m_IsStreamPaused = false; m_volume_needs_update = false; m_periodSize = 0; pa_cvolume_init(&m_Volume); }
static pa_scache_entry* scache_add_item(pa_core *c, const char *name) { pa_scache_entry *e; pa_assert(c); pa_assert(name); if ((e = pa_namereg_get(c, name, PA_NAMEREG_SAMPLE))) { if (e->memchunk.memblock) pa_memblock_unref(e->memchunk.memblock); pa_xfree(e->filename); pa_proplist_clear(e->proplist); pa_assert(e->core == c); pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE|PA_SUBSCRIPTION_EVENT_CHANGE, e->index); } else { e = pa_xnew(pa_scache_entry, 1); if (!pa_namereg_register(c, name, PA_NAMEREG_SAMPLE, e, TRUE)) { pa_xfree(e); return NULL; } e->name = pa_xstrdup(name); e->core = c; e->proplist = pa_proplist_new(); pa_idxset_put(c->scache, e, &e->index); pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE|PA_SUBSCRIPTION_EVENT_NEW, e->index); } e->last_used_time = 0; pa_memchunk_reset(&e->memchunk); e->filename = NULL; e->lazy = FALSE; e->last_used_time = 0; pa_sample_spec_init(&e->sample_spec); pa_channel_map_init(&e->channel_map); pa_cvolume_init(&e->volume); e->volume_is_set = FALSE; pa_proplist_sets(e->proplist, PA_PROP_MEDIA_ROLE, "event"); return e; }
void PaObject::set_volume(float perc) { if (pa_set_volume != nullptr) { pa_threaded_mainloop_lock(pulse.pa_ml); int vol = (PA_VOLUME_NORM * perc); pa_cvolume cvol; pa_cvolume_init(&cvol); pa_cvolume_set(&cvol, channels, vol); pa_operation *o = pa_set_volume( pulse.pa_ctx, index, &cvol, NULL, NULL ); pa_operation_unref(o); pa_threaded_mainloop_unlock(pulse.pa_ml); } }