From f53f3338f8fedb2790966c3a879275f71004e7f5 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Wed, 3 Aug 2011 17:27:42 +0000 Subject: ixed pulseaudio and jack support, updated Russian translation git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2289 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/Output/jack/bio2jack.c | 16 ++++++++-------- src/plugins/Output/jack/outputjack.cpp | 13 ++++++++++++- src/plugins/Output/jack/outputjack.h | 4 ++-- src/plugins/Output/pulseaudio/outputpulseaudio.cpp | 1 - src/plugins/Ui/skinned/translations/skinned_plugin_ru.ts | 3 ++- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/plugins/Output/jack/bio2jack.c b/src/plugins/Output/jack/bio2jack.c index ddc45478a..2b9f04e70 100644 --- a/src/plugins/Output/jack/bio2jack.c +++ b/src/plugins/Output/jack/bio2jack.c @@ -261,7 +261,7 @@ TimeValDifference(struct timeval *start, struct timeval *end) trying to trace mutexes it's more important to know *who* called us than just that we were called. This uses from pre-processor trickery so that the fprintf is actually placed in the function making the getDriver call. Thus, the __FUNCTION__ and __LINE__ - macros will actually reference our caller, rather than getDriver. The reason the + macros will actually reference our caller, rather than getDriver. The reason the fprintf call is passes as a parameter is because this macro has to still return a jack_driver_t* and we want to log both before *and* after the getDriver call for easier detection of blocked calls. @@ -792,7 +792,7 @@ JACK_callback(nframes_t nframes, void *arg) /* the ringbuffer is designed such that only one thread should ever access each pointer. since calling read_advance here will be touching the read pointer which is also accessed by JACK_Read, we need to lock the mutex first for safety */ - jack_driver_t *d = tryGetDriver(drv->deviceID); + jack_driver_t *d = tryGetDriver(drv->deviceID); if( d ) { /* double check the write space after we've gained the lock, just @@ -803,7 +803,7 @@ JACK_callback(nframes_t nframes, void *arg) ERR("buffer overrun of %ld bytes\n", jack_bytes - write_space); jack_ringbuffer_read_advance(drv->pRecPtr, jack_bytes - write_space); } - releaseDriver(drv); + releaseDriver(drv); } } @@ -917,10 +917,10 @@ JACK_shutdown(void *arg) TRACE("trying to reconnect right now\n"); /* lets see if we can't reestablish the connection */ - if(JACK_OpenDevice(drv) != ERR_SUCCESS) + /*if(JACK_OpenDevice(drv) != ERR_SUCCESS) { ERR("unable to reconnect with jack\n"); - } + }*/ releaseDriver(drv); } @@ -1423,7 +1423,7 @@ JACK_Reset(int deviceID) * deviceID is set to the opened device * if client is non-zero and in_use is FALSE then just set in_use to TRUE * - * return value is zero upon success, non-zero upon failure + * return value is zero upon success, non-zero upon failure * * if ERR_RATE_MISMATCH (*rate) will be updated with the jack servers rate */ @@ -1521,7 +1521,7 @@ JACK_OpenEx(int *deviceID, unsigned int bits_per_channel, drv->jack_output_port_flags = jack_port_flags | JackPortIsInput; /* port must be input(ie we can put data into it), so mask this in */ drv->jack_input_port_flags = jack_port_flags | JackPortIsOutput; /* port must be output(ie we can get data from it), so mask this in */ - /* check that we have the correct number of port names + /* check that we have the correct number of port names FIXME?: not sure how we should handle output ports vs input ports.... */ if((jack_port_name_count > 1) @@ -1759,7 +1759,7 @@ JACK_Write(int deviceID, unsigned char *data, unsigned long bytes) TRACE("frames free == %ld, bytes = %lu\n", frames_free, bytes); TRACE("state = '%s'\n", DEBUGSTATE(drv->state)); - /* if we are currently STOPPED we should start playing now... + /* if we are currently STOPPED we should start playing now... do this before the check for bytes == 0 since some clients like to write 0 bytes the first time out */ if(drv->state == STOPPED) diff --git a/src/plugins/Output/jack/outputjack.cpp b/src/plugins/Output/jack/outputjack.cpp index 39548acd4..a08f5efbc 100644 --- a/src/plugins/Output/jack/outputjack.cpp +++ b/src/plugins/Output/jack/outputjack.cpp @@ -31,10 +31,13 @@ #include #include +#define JACK_TIMEOUT 500000L + OutputJACK::OutputJACK(QObject *parent) : Output(parent), m_inited(false), m_configure(false) { JACK_Init(); + m_wait_time = 0; } OutputJACK::~OutputJACK() @@ -89,8 +92,17 @@ qint64 OutputJACK::writeAudio(unsigned char *data, qint64 maxSize) if(!m_configure) return -1; m = JACK_Write(jack_device, (unsigned char*)data, maxSize); + if (!m) + { usleep(2000); + if(JACK_GetState(jack_device) != PLAYING) + m_wait_time += 2000; + if(m_wait_time > JACK_TIMEOUT) + return -1; + } + else + m_wait_time = 0; return m; } @@ -107,4 +119,3 @@ void OutputJACK::uninitialize() if (m_configure) JACK_Close(jack_device); } - diff --git a/src/plugins/Output/jack/outputjack.h b/src/plugins/Output/jack/outputjack.h index 5b4e79bcb..9f3b8750b 100644 --- a/src/plugins/Output/jack/outputjack.h +++ b/src/plugins/Output/jack/outputjack.h @@ -46,12 +46,12 @@ public: private: //output api qint64 writeAudio(unsigned char *data, qint64 maxSize); - void drain(){}; + void drain(){} void reset(); // helper functions void uninitialize(); - qint64 m; + qint64 m, m_wait_time; bool m_inited, m_configure; int jack_device; }; diff --git a/src/plugins/Output/pulseaudio/outputpulseaudio.cpp b/src/plugins/Output/pulseaudio/outputpulseaudio.cpp index c867ffbb9..5d3d00547 100644 --- a/src/plugins/Output/pulseaudio/outputpulseaudio.cpp +++ b/src/plugins/Output/pulseaudio/outputpulseaudio.cpp @@ -104,7 +104,6 @@ qint64 OutputPulseAudio::writeAudio(unsigned char *data, qint64 maxSize) int i = 0; if ((i = pa_simple_write(m_connection, data, maxSize, &error)) < 0) { - mutex()->unlock(); qWarning("OutputPulseAudio: pa_simple_write() failed: %s", pa_strerror(error)); return -1; } diff --git a/src/plugins/Ui/skinned/translations/skinned_plugin_ru.ts b/src/plugins/Ui/skinned/translations/skinned_plugin_ru.ts index 9309a91fa..fa316ab0f 100644 --- a/src/plugins/Ui/skinned/translations/skinned_plugin_ru.ts +++ b/src/plugins/Ui/skinned/translations/skinned_plugin_ru.ts @@ -1100,7 +1100,8 @@ Ilya Kotov <forkotov02@hotmail.ru> Artwork: Andrey Adreev <andreev00@gmail.com> - + Графика: +Андрей Андреев <andreev00@gmail.com> -- cgit v1.2.3-13-gbd6f