static void pulse_free(void *data) { pa_t *pa = (pa_t*)data; if (!pa) return; if (pa->mainloop) pa_threaded_mainloop_stop(pa->mainloop); if (pa->stream) { pa_stream_disconnect(pa->stream); pa_stream_unref(pa->stream); } if (pa->context) { pa_context_disconnect(pa->context); pa_context_unref(pa->context); } if (pa->mainloop) pa_threaded_mainloop_free(pa->mainloop); free(pa); }
/** Destroy libao driver */ static void uninit(int immed) { if (stream && !immed) { pa_threaded_mainloop_lock(mainloop); waitop(pa_stream_drain(stream, success_cb, NULL)); } if (mainloop) pa_threaded_mainloop_stop(mainloop); if (stream) { pa_stream_disconnect(stream); pa_stream_unref(stream); stream = NULL; } if (context) { pa_context_disconnect(context); pa_context_unref(context); context = NULL; } if (mainloop) { pa_threaded_mainloop_free(mainloop); mainloop = NULL; } }
static void pulse_close(void) { connected = 0; if (mainloop) pa_threaded_mainloop_stop(mainloop); if (stream) { pa_stream_disconnect(stream); pa_stream_unref(stream); stream = NULL; } if (context) { pa_context_disconnect(context); pa_context_unref(context); context = NULL; } if (mainloop) { pa_threaded_mainloop_free(mainloop); mainloop = NULL; } volume_time_event = NULL; volume_valid = 0; }
void QPulseAudioInput::close() { if (!m_opened) return; m_timer->stop(); QPulseAudioEngine *pulseEngine = QPulseAudioEngine::instance(); if (m_stream) { pulseEngine->lock(); pa_stream_set_state_callback(m_stream, 0, 0); pa_stream_set_read_callback(m_stream, 0, 0); pa_stream_set_underflow_callback(m_stream, 0, 0); pa_stream_set_overflow_callback(m_stream, 0, 0); pa_stream_disconnect(m_stream); pa_stream_unref(m_stream); m_stream = 0; pulseEngine->unlock(); } disconnect(pulseEngine, &QPulseAudioEngine::contextFailed, this, &QPulseAudioInput::onPulseContextFailed); if (!m_pullMode && m_audioSource) { delete m_audioSource; m_audioSource = 0; } m_opened = false; }
static void pulse_close(ALCdevice *device) { pulse_data *data = device->ExtraData; pa_threaded_mainloop_lock(data->loop); if(data->stream) { #if PA_CHECK_VERSION(0,9,15) if(pa_stream_set_buffer_attr_callback) pa_stream_set_buffer_attr_callback(data->stream, NULL, NULL); #endif pa_stream_disconnect(data->stream); pa_stream_unref(data->stream); } pa_context_disconnect(data->context); pa_context_unref(data->context); pa_threaded_mainloop_unlock(data->loop); pa_threaded_mainloop_stop(data->loop); pa_threaded_mainloop_free(data->loop); free(data->device_name); device->ExtraData = NULL; pa_xfree(data); }
static void uninit(struct ao *ao) { struct priv *priv = ao->priv; if (priv->mainloop) pa_threaded_mainloop_stop(priv->mainloop); if (priv->stream) { pa_stream_disconnect(priv->stream); pa_stream_unref(priv->stream); priv->stream = NULL; } if (priv->context) { pa_context_disconnect(priv->context); pa_context_unref(priv->context); priv->context = NULL; } if (priv->mainloop) { pa_threaded_mainloop_free(priv->mainloop); priv->mainloop = NULL; } pthread_cond_destroy(&priv->wakeup); pthread_mutex_destroy(&priv->wakeup_lock); }
static void uninit(struct ao *ao, bool cut_audio) { struct priv *priv = ao->priv; if (priv->stream && !cut_audio) { pa_threaded_mainloop_lock(priv->mainloop); waitop(priv, pa_stream_drain(priv->stream, success_cb, ao)); } if (priv->mainloop) pa_threaded_mainloop_stop(priv->mainloop); if (priv->stream) { pa_stream_disconnect(priv->stream); pa_stream_unref(priv->stream); priv->stream = NULL; } if (priv->context) { pa_context_disconnect(priv->context); pa_context_unref(priv->context); priv->context = NULL; } if (priv->mainloop) { pa_threaded_mainloop_free(priv->mainloop); priv->mainloop = NULL; } }
void CAESinkPULSE::Deinitialize() { CSingleLock lock(m_sec); m_IsAllocated = false; m_passthrough = false; m_periodSize = 0; if (m_Stream) Drain(); if (m_MainLoop) pa_threaded_mainloop_stop(m_MainLoop); if (m_Stream) { pa_stream_disconnect(m_Stream); pa_stream_unref(m_Stream); m_Stream = NULL; m_IsStreamPaused = false; } if (m_Context) { pa_context_disconnect(m_Context); pa_context_unref(m_Context); m_Context = NULL; } if (m_MainLoop) { pa_threaded_mainloop_free(m_MainLoop); m_MainLoop = NULL; } }
static void pulse_close(ALCdevice *device) //{{{ { pulse_data *data = device->ExtraData; pa_threaded_mainloop_lock(data->loop); if(data->stream) { pa_stream_disconnect(data->stream); pa_stream_unref(data->stream); } pa_context_disconnect(data->context); pa_context_unref(data->context); pa_threaded_mainloop_unlock(data->loop); pa_threaded_mainloop_stop(data->loop); pa_threaded_mainloop_free(data->loop); DestroyRingBuffer(data->ring); free(data->device_name); device->ExtraData = NULL; pa_xfree(data); } //}}}
/* * Disconnect from the pulse audio stream */ static void pulse_diconnect_stream(struct pulse_data *data) { if (data->stream) { pa_stream_disconnect(data->stream); pa_stream_unref(data->stream); } }
static void pulse_stop_playback(ALCdevice *device) //{{{ { pulse_data *data = device->ExtraData; if(!data->stream) return; data->killNow = AL_TRUE; if(data->thread) { pa_threaded_mainloop_signal(data->loop, 0); StopThread(data->thread); data->thread = NULL; } data->killNow = AL_FALSE; pa_threaded_mainloop_lock(data->loop); #if PA_CHECK_VERSION(0,9,15) if(pa_stream_set_buffer_attr_callback) pa_stream_set_buffer_attr_callback(data->stream, NULL, NULL); #endif pa_stream_set_moved_callback(data->stream, NULL, NULL); pa_stream_set_write_callback(data->stream, NULL, NULL); pa_stream_set_underflow_callback(data->stream, NULL, NULL); pa_stream_disconnect(data->stream); pa_stream_unref(data->stream); data->stream = NULL; pa_threaded_mainloop_unlock(data->loop); } //}}}
static void uninit(aout_instance_t *p_aout){ struct aout_sys_t * p_sys = p_aout->output.p_sys; if (p_sys->mainloop) pa_threaded_mainloop_stop(p_sys->mainloop); if (p_sys->stream) { pa_stream_disconnect(p_sys->stream); pa_stream_unref(p_sys->stream); p_sys->stream = NULL; } if (p_sys->context) { pa_context_disconnect(p_sys->context); pa_context_unref(p_sys->context); p_sys->context = NULL; } if (p_sys->mainloop) { pa_threaded_mainloop_free(p_sys->mainloop); p_sys->mainloop = NULL; } free(p_sys); p_aout->output.p_sys = NULL; }
// Close all streams/contexts/loops and return void quisk_close_sound_pulseaudio() { int i = 0; if (quisk_sound_state.verbose_pulse) printf("Closing Pulseaudio interfaces \n "); while (OpenPulseDevices[i]) { pa_stream_disconnect(OpenPulseDevices[i]); pa_stream_unref(OpenPulseDevices[i]); OpenPulseDevices[i] = '\0'; i++; } if (quisk_sound_state.verbose_pulse) printf("Waiting for %d streams to disconnect\n", streams_ready); while(streams_ready > 0); if (pa_IQ_ctx) { pa_context_disconnect(pa_IQ_ctx); pa_context_unref(pa_IQ_ctx); } if (pa_ctx) { pa_context_disconnect(pa_ctx); pa_context_unref(pa_ctx); } if (pa_ml) { pa_threaded_mainloop_stop(pa_ml); pa_threaded_mainloop_free(pa_ml); } }
void AudioOutputPulseAudio::CloseDevice() { if (mainloop) pa_threaded_mainloop_lock(mainloop); if (pstream) { FlushStream("CloseDevice"); pa_stream_disconnect(pstream); pa_stream_unref(pstream); pstream = NULL; } if (pcontext) { pa_context_drain(pcontext, NULL, NULL); pa_context_disconnect(pcontext); pa_context_unref(pcontext); pcontext = NULL; } if (mainloop) { pa_threaded_mainloop_unlock(mainloop); pa_threaded_mainloop_stop(mainloop); mainloop = NULL; } }
/* this method may be called inside the pulse main loop, so be VERY careful with locking */ void CPulseAEStream::Destroy() { if (!m_Initialized) return; if (m_Destroyed) return; m_fader.StopThread(true); pa_threaded_mainloop_lock(m_MainLoop); if (m_DrainOperation) { pa_operation_cancel(m_DrainOperation); pa_operation_unref(m_DrainOperation); m_DrainOperation = NULL; } if (m_Stream) { pa_stream_disconnect(m_Stream); pa_stream_unref(m_Stream); m_Stream = NULL; } /* signal CPulseAE to free us */ m_Destroyed = true; m_Initialized = false; pa_threaded_mainloop_unlock(m_MainLoop); }
void PulseOutput::close() { #ifdef DEBUG context->getReactor().debug(); #endif if (stream) { GM_DEBUG_PRINT("[pulse] disconnecting stream\n"); pa_stream_disconnect(stream); pa_stream_unref(stream); stream=nullptr; } if (pulse_context) { GM_DEBUG_PRINT("[pulse] disconnecting context\n"); pa_context_disconnect(pulse_context); pa_context_unref(pulse_context); pulse_context=nullptr; } #ifdef DEBUG context->getReactor().debug(); #endif delete pa_io_event::recycle; delete pa_time_event::recycle; delete pa_defer_event::recycle; pa_io_event::recycle = nullptr; pa_time_event::recycle = nullptr; pa_defer_event::recycle = nullptr; pulsevolume = PA_VOLUME_MUTED; af.reset(); }
int sa_stream_destroy(sa_stream_t *s) { if (s == NULL) { return SA_SUCCESS; } pthread_mutex_lock(&s->mutex); s->thread_id = 0; pthread_mutex_unlock(&s->mutex); pa_threaded_mainloop_lock(s->m); pa_stream_disconnect(s->stream); s->stream = NULL; pa_context_disconnect(s->context); pa_context_unref(s->context); s->context = NULL; pa_threaded_mainloop_unlock(s->m); pa_threaded_mainloop_stop(s->m); pa_threaded_mainloop_free(s->m); pthread_mutex_destroy(&s->mutex); while (s->bl_head != NULL) { sa_buf * next = s->bl_head->next; free(s->bl_head); s->bl_head = next; } free(s); return SA_SUCCESS; }
/** * This is called whenever the context status changes */ static void stream_destroy(pa_audio_mode_t *pam) { pa_stream_disconnect(pam->stream); pa_stream_unref(pam->stream); pam->stream = NULL; }
static void pulse_write_postprocess(MSFilter *f){ PulseWriteState *s=(PulseWriteState*)f->data; if (s->stream) { pa_threaded_mainloop_lock(pa_loop); pa_stream_disconnect(s->stream); pa_stream_unref(s->stream); pa_threaded_mainloop_unlock(pa_loop); } }
/* * stop recording */ static void pulse_stop_recording(struct pulse_data *data) { if (data->stream) { pulse_lock(); pa_stream_disconnect(data->stream); pa_stream_unref(data->stream); pulse_unlock(); } }
static void stream_drain_complete (pa_stream *pa, int success, void *data) { Stream *stream = data; pa_stream_disconnect (stream->pa); pa_stream_unref (stream->pa); g_object_unref (stream->audio); g_free (stream); }
static int m_pa_stream_connect(pa_context *pa_ctx) { if (pa_context_get_server_protocol_version (pa_ctx) < 13) { return -1; } printf("server version: %d\n", pa_context_get_server_protocol_version(pa_ctx)); if (s) { pa_stream_disconnect(s); pa_stream_unref(s); } pa_proplist *proplist; pa_buffer_attr attr; pa_sample_spec ss; int res; //char dev_name[40]; // pa_sample_spec ss.channels = 1; ss.format = PA_SAMPLE_FLOAT32; ss.rate = 25; // pa_buffer_attr memset(&attr, 0, sizeof(attr)); attr.fragsize = sizeof(float); attr.maxlength = (uint32_t) -1; // pa_proplist proplist = pa_proplist_new (); pa_proplist_sets (proplist, PA_PROP_APPLICATION_ID, "Deepin Sound Settings"); // create new stream if (!(s = pa_stream_new_with_proplist(pa_ctx, "Deepin Sound Settings", &ss, NULL, proplist))) { fprintf(stderr, "pa_stream_new error\n"); return -2; } pa_proplist_free(proplist); pa_stream_set_read_callback(s, on_monitor_read_callback, NULL); pa_stream_set_suspended_callback(s, on_monitor_suspended_callback, NULL); res = pa_stream_connect_record(s, NULL, &attr, (pa_stream_flags_t) (PA_STREAM_DONT_MOVE |PA_STREAM_PEAK_DETECT |PA_STREAM_ADJUST_LATENCY)); if (res < 0) { fprintf(stderr, "Failed to connect monitoring stream\n"); return -3; } return 0; }
static void gst_pulsesrc_destroy_stream (GstPulseSrc * pulsesrc) { if (pulsesrc->stream) { pa_stream_disconnect (pulsesrc->stream); pa_stream_unref (pulsesrc->stream); pulsesrc->stream = NULL; } g_free (pulsesrc->device_description); pulsesrc->device_description = NULL; }
void QPulseAudioThread::reconnect(SourceContainer::const_iterator pos = s_sourceList.end()) { if (s_sourceList.empty()) return; if (pos != s_sourceList.end()) { s_sourcePosition = pos; qDebug() << "reconnecting with" << *pos; } else s_sourcePosition = scanForPlaybackMonitor(); if (s_sourcePosition == s_sourceList.end()) { s_sourcePosition = s_sourceList.begin(); } if (stream && (pa_stream_get_state(stream) == PA_STREAM_READY)) { //qDebug() << "disconnect"; pa_stream_disconnect ( stream ); // pa_stream_unref(stream); //qDebug() << "* return *"; } if ( ! ( stream = pa_stream_new ( context, stream_name, &sample_spec, channel_map_set ? &channel_map : NULL ) ) ) { fprintf ( stderr, "pa_stream_new() failed: %s\n", pa_strerror ( pa_context_errno ( context ) ) ); return; } pa_stream_set_state_callback ( stream, stream_state_callback, &s_sourceList ); pa_stream_set_read_callback ( stream, stream_read_callback, &s_sourceList ); pa_stream_set_moved_callback(stream, stream_moved_callback, &s_sourceList ); switch (pa_stream_get_state(stream)) { case PA_STREAM_UNCONNECTED:// The stream is not yet connected to any sink or source. qDebug() << "unconnected: connecting..."; connectHelper(s_sourcePosition); break; case PA_STREAM_CREATING ://The stream is being created. break; case PA_STREAM_READY :// The stream is established, you may pass audio data to it now. qDebug() << "stream is still ready, waiting for callback..."; break; case PA_STREAM_FAILED :// An error occured that made the stream invalid. qDebug() << "stream is now invalid. great."; break; case PA_STREAM_TERMINATED:// The stream has been terminated cleanly. qDebug() << "terminated..."; break; } }
JNIEXPORT void JNICALL Java_com_harrcharr_pulse_Stream_disconnect( JNIEnv *jenv, jobject jstream) { pa_stream *stream = get_stream_ptr(jenv, jstream); if (pa_stream_disconnect(stream) < 0) { LOGE("Failed to disconnect from stream"); // Throw an exception to java } pa_stream_unref(stream); }
static void rdpsnd_pulse_set_format(rdpsndDevicePlugin* device, rdpsndFormat* format, int latency) { rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)device; if (pulse->stream) { pa_threaded_mainloop_lock(pulse->mainloop); pa_stream_disconnect(pulse->stream); pa_stream_unref(pulse->stream); pulse->stream = NULL; pa_threaded_mainloop_unlock(pulse->mainloop); } rdpsnd_pulse_open(device, format, latency); }
void xmms_pulse_backend_close_stream (xmms_pulse *p) { assert (p); pa_threaded_mainloop_lock (p->mainloop); /* We're killing it anyway, sod errors. */ xmms_pulse_backend_drain (p, NULL); pa_stream_disconnect (p->stream); pa_stream_unref (p->stream); p->stream = NULL; pa_threaded_mainloop_unlock (p->mainloop); }
static void rdpsnd_pulse_close(rdpsndDevicePlugin* device) { rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)device; if (!pulse->context || !pulse->stream) return; pa_threaded_mainloop_lock(pulse->mainloop); rdpsnd_pulse_wait_for_operation(pulse, pa_stream_drain(pulse->stream, rdpsnd_pulse_stream_success_callback, pulse)); pa_stream_disconnect(pulse->stream); pa_stream_unref(pulse->stream); pulse->stream = NULL; pa_threaded_mainloop_unlock(pulse->mainloop); }
static void streamRequestCallback(pa_stream *p, size_t nbytes, FileReader *h) { switch (h->writeToStream(p, nbytes)) { case FileReader::StatusOk: break; case FileReader::StatusEof: pa_stream_set_write_callback(p, NULL, NULL); pa_stream_finish_upload(p); break; case FileReader::StatusError: pa_stream_set_write_callback(p, NULL, NULL); pa_stream_disconnect(p); break; } }
static BOOL tsmf_pulse_close_stream(TSMFPulseAudioDevice *pulse) { if(!pulse->context || !pulse->stream) return FALSE; DEBUG_TSMF(""); pa_threaded_mainloop_lock(pulse->mainloop); pa_stream_set_write_callback(pulse->stream, NULL, NULL); tsmf_pulse_wait_for_operation(pulse, pa_stream_drain(pulse->stream, tsmf_pulse_stream_success_callback, pulse)); pa_stream_disconnect(pulse->stream); pa_stream_unref(pulse->stream); pulse->stream = NULL; pa_threaded_mainloop_unlock(pulse->mainloop); return TRUE; }