From 8aecdcc938777864c7ab0d66ff6e05a99fe67b21 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 17 Mar 2015 21:31:09 +0100 Subject: Add VLC exit handler --- src/VLCInput.h | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'src/VLCInput.h') diff --git a/src/VLCInput.h b/src/VLCInput.h index 13b0695..e387044 100644 --- a/src/VLCInput.h +++ b/src/VLCInput.h @@ -48,39 +48,43 @@ class VLCInput m_rate(rate), m_vlc(NULL) { } - ~VLCInput() { - if (m_mp) { - /* Stop playing */ - libvlc_media_player_stop(m_mp); - - /* Free the media_player */ - libvlc_media_player_release(m_mp); - } - - if (m_vlc) { - libvlc_release(m_vlc); - m_vlc = NULL; - } - } + ~VLCInput() { cleanup(); } /* Prepare the audio input */ int prepare(); + /* Read exactly length bytes into buf. + * Blocks if not enough data is available, + * or returns zero if EOF reached. + * + * Returns the number of bytes written into + * the buffer. + */ ssize_t read(uint8_t* buf, size_t length); // Callbacks for VLC - void preRender( + + /* Notification of VLC exit */ + void exit_cb(void); + + /* Prepare a buffer for VLC */ + void preRender_cb( uint8_t** pp_pcm_buffer, size_t size); - void postRender( + /* Receive a buffer with audio samples + * from VLC + */ + void postRender_cb( uint8_t* p_pcm_buffer, size_t size); int getRate() { return m_rate; } protected: + void cleanup(void); + ssize_t m_read(uint8_t* buf, size_t length); std::vector m_current_buf; -- cgit v1.2.3