diff options
author | Sebastien Alaiwan <[email protected]> | 2014-10-14 21:16:16 +0200 |
---|---|---|
committer | Sebastien Alaiwan <[email protected]> | 2014-10-14 21:16:16 +0200 |
commit | 4c5618878f7e65096142c504d1eaa25038195ff8 (patch) | |
tree | e2a43e460e8ca4da3c5ce4af99d46c8fe92ed419 /src/cubeb_jack.cpp | |
parent | a0aa1de44886d0b788feb2695734b4612ad7eac0 (diff) | |
download | cubeb-4c5618878f7e65096142c504d1eaa25038195ff8.tar.gz cubeb-4c5618878f7e65096142c504d1eaa25038195ff8.zip |
jack backend: handle cubeb_stream_set_volume correctly. Add corresponding test to test_audio.
Diffstat (limited to 'src/cubeb_jack.cpp')
-rw-r--r-- | src/cubeb_jack.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cubeb_jack.cpp b/src/cubeb_jack.cpp index 7aa3218..9b562be 100644 --- a/src/cubeb_jack.cpp +++ b/src/cubeb_jack.cpp @@ -166,6 +166,7 @@ struct cubeb_stream { char stream_name[256]; jack_port_t *output_ports[MAX_CHANNELS]; jack_ringbuffer_t *ringbuffer[MAX_CHANNELS]; + float volume; }; struct cubeb { @@ -352,7 +353,7 @@ cbjack_stream_refill(cubeb_stream * stream) for(unsigned int c = 0; c < stream->params.channels; c++) { float* buffer = stream->context->buffer[c]; for (long f = 0; f < num_frames; f++) { - buffer[f] = interleaved_buffer[(f * stream->params.channels) + c]; + buffer[f] = interleaved_buffer[(f * stream->params.channels) + c] * stream->volume; } } @@ -607,6 +608,7 @@ cbjack_stream_init(cubeb * context, cubeb_stream ** stream, char const * stream_ stm->data_callback = data_callback; stm->state_callback = state_callback; stm->position = 0; + stm->volume = 1.0f; if (stm->params.rate != stm->context->jack_sample_rate) { int resampler_error; @@ -694,6 +696,8 @@ cbjack_stream_get_latency(cubeb_stream * stream, uint32_t * latency) static int cbjack_stream_set_volume(cubeb_stream * stm, float volume) { + AutoLock lock(stm->context->mutex); + stm->volume = volume; return CUBEB_OK; } |