summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Grandin <grandinp@gmail.com>2017-05-08 13:29:46 -0700
committerPierre Grandin <grandinp@gmail.com>2017-05-08 13:29:46 -0700
commita1df401d5a04fd16a2404227b24d599caab00b4d (patch)
treea7820bac5d16dd784e1b61f4f89dddb8e5ac97a6
parent0bc599037d9160e184a41a301e5440ac38737010 (diff)
downloadnavit-a1df401d5a04fd16a2404227b24d599caab00b4d.tar.gz
Removed player-stub dependencies upon alsa
-rwxr-xr-xCMakeLists.txt3
-rw-r--r--navit/audio/player-stub/CMakeLists.txt3
-rw-r--r--navit/audio/player-stub/alsa-audio.c237
-rw-r--r--navit/audio/player-stub/audio.c59
-rw-r--r--navit/audio/player-stub/stub.c1
5 files changed, 2 insertions, 301 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fa4349947..99b748ac0 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -107,7 +107,7 @@ add_module(speech/dbus "dbus-glib-1 not found" FALSE)
add_module(speech/cmdline "neither system() nor CreateProcess() found" FALSE)
add_module(audio/output-alsa "alsalib not found" FALSE)
add_module(audio/player-mpd "mpd not found" FALSE)
-add_module(audio/player-stub "default" FALSE)
+add_module(audio/player-stub "default" TRUE)
add_module(audio/player-spotify "libspotify not found" FALSE)
add_module(vehicle/gpsd_dbus "dbus-glib-1 not found" FALSE)
add_module(vehicle/qt5 "Qt5 libraries not found" FALSE)
@@ -519,7 +519,6 @@ if (ALSA_FOUND)
set_with_reason(audio/player-mpd "mpd and mpc found" TRUE)
endif(MPC)
endif(MPD)
- set_with_reason(audio/player-stub "alsa found - the stub has no additional dependecies" TRUE)
set_with_reason(USE_AUDIO_FRAMEWORK "alsa found" TRUE)
endif(UNIX AND NOT ANDROID AND NOT APPLE)
endif (ALSA_FOUND)
diff --git a/navit/audio/player-stub/CMakeLists.txt b/navit/audio/player-stub/CMakeLists.txt
index 75622374e..f38fe1315 100644
--- a/navit/audio/player-stub/CMakeLists.txt
+++ b/navit/audio/player-stub/CMakeLists.txt
@@ -1,2 +1 @@
-module_add_library(audio_player-stub stub.c alsa-audio.c audio.c )
-target_link_libraries(audio_player-stub ${ALSA_LIBRARY})
+module_add_library(audio_player-stub stub.c )
diff --git a/navit/audio/player-stub/alsa-audio.c b/navit/audio/player-stub/alsa-audio.c
deleted file mode 100644
index 48d990682..000000000
--- a/navit/audio/player-stub/alsa-audio.c
+++ /dev/null
@@ -1,237 +0,0 @@
-//* vim: set tabstop=4 expandtab: */
-/*
- * Copyright (c) 2006-2009 Spotify Ltd
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- *
- * ALSA audio output driver.
- *
- * This file is part of the libspotify examples suite.
- */
-
-
-
-
-#include <alsa/asoundlib.h>
-#include <errno.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include "debug.h"
-
-#include "alsa.h"
-#include "stub.h"
-
-static snd_pcm_t *alsa_open(char *dev, int rate, int channels)
-{
- snd_pcm_hw_params_t *hwp;
- snd_pcm_sw_params_t *swp;
- snd_pcm_t *h;
- int r;
- int dir;
- snd_pcm_uframes_t period_size_min;
- snd_pcm_uframes_t period_size_max;
- snd_pcm_uframes_t buffer_size_min;
- snd_pcm_uframes_t buffer_size_max;
- snd_pcm_uframes_t period_size;
- snd_pcm_uframes_t buffer_size;
-
- if ((r = snd_pcm_open(&h, dev, SND_PCM_STREAM_PLAYBACK, 0) < 0)) {
- dbg(lvl_error, "Something went wrong with %s\n", dev);
- return NULL;
- }
-
- hwp = alloca(snd_pcm_hw_params_sizeof());
- memset(hwp, 0, snd_pcm_hw_params_sizeof());
- snd_pcm_hw_params_any(h, hwp);
-
- snd_pcm_hw_params_set_access(h, hwp, SND_PCM_ACCESS_RW_INTERLEAVED);
- snd_pcm_hw_params_set_format(h, hwp, SND_PCM_FORMAT_S16_LE);
- snd_pcm_hw_params_set_rate(h, hwp, rate, 0);
- snd_pcm_hw_params_set_channels(h, hwp, channels);
-
- /* Configurue period */
-
- dir = 0;
- snd_pcm_hw_params_get_period_size_min(hwp, &period_size_min, &dir);
- dir = 0;
- snd_pcm_hw_params_get_period_size_max(hwp, &period_size_max, &dir);
-
- period_size = 1024;
-
- dir = 0;
- r = snd_pcm_hw_params_set_period_size_near(h, hwp, &period_size, &dir);
-
- if (r < 0) {
- dbg(lvl_error, "audio: Unable to set period size %lu (%s)\n",
- period_size, snd_strerror(r));
- snd_pcm_close(h);
- return NULL;
- }
-
- dir = 0;
- r = snd_pcm_hw_params_get_period_size(hwp, &period_size, &dir);
-
- if (r < 0) {
- dbg(lvl_error, "audio: Unable to get period size (%s)\n",
- snd_strerror(r));
- snd_pcm_close(h);
- return NULL;
- }
-
- /* Configurue buffer size */
-
- snd_pcm_hw_params_get_buffer_size_min(hwp, &buffer_size_min);
- snd_pcm_hw_params_get_buffer_size_max(hwp, &buffer_size_max);
- buffer_size = period_size * 4;
-
- dir = 0;
- r = snd_pcm_hw_params_set_buffer_size_near(h, hwp, &buffer_size);
-
- if (r < 0) {
- dbg(lvl_error, "audio: Unable to set buffer size %lu (%s)\n",
- buffer_size, snd_strerror(r));
- snd_pcm_close(h);
- return NULL;
- }
-
- r = snd_pcm_hw_params_get_buffer_size(hwp, &buffer_size);
-
- if (r < 0) {
- dbg(lvl_error, "audio: Unable to get buffer size (%s)\n",
- snd_strerror(r));
- snd_pcm_close(h);
- return NULL;
- }
-
- /* write the hw params */
- r = snd_pcm_hw_params(h, hwp);
-
- if (r < 0) {
- dbg(lvl_error, "audio: Unable to configure hardware parameters (%s)\n",
- snd_strerror(r));
- snd_pcm_close(h);
- return NULL;
- }
-
- /*
- * Software parameters
- */
-
- swp = alloca(snd_pcm_sw_params_sizeof());
- memset(hwp, 0, snd_pcm_sw_params_sizeof());
- snd_pcm_sw_params_current(h, swp);
-
- r = snd_pcm_sw_params_set_avail_min(h, swp, period_size);
-
- if (r < 0) {
- dbg(lvl_error, "audio: Unable to configure wakeup threshold (%s)\n",
- snd_strerror(r));
- snd_pcm_close(h);
- return NULL;
- }
-
- snd_pcm_sw_params_set_start_threshold(h, swp, 0);
-
- if (r < 0) {
- dbg(lvl_error, "audio: Unable to configure start threshold (%s)\n",
- snd_strerror(r));
- snd_pcm_close(h);
- return NULL;
- }
-
- r = snd_pcm_sw_params(h, swp);
-
- if (r < 0) {
- dbg(lvl_error, "audio: Cannot set soft parameters (%s)\n",
- snd_strerror(r));
- snd_pcm_close(h);
- return NULL;
- }
-
- r = snd_pcm_prepare(h);
- if (r < 0) {
- dbg(lvl_error, "audio: Cannot prepare audio for playback (%s)\n",
- snd_strerror(r));
- snd_pcm_close(h);
- return NULL;
- }
-
- return h;
-}
-
-static void* alsa_audio_start(void *aux)
-{
- audio_fifo_t *af = aux;
- snd_pcm_t *h = NULL;
- int c;
- int cur_channels = 0;
- int cur_rate = 0;
-
- audio_fifo_data_t *afd;
-
- for (;;) {
- afd = audio_get(af);
-
- if (!h || cur_rate != afd->rate || cur_channels != afd->channels) {
- if (h) snd_pcm_close(h);
-
- cur_rate = afd->rate;
- cur_channels = afd->channels;
-
- // h = alsa_open("front:CARD=Set,DEV=0", cur_rate, cur_channels);
- h = alsa_open("dmixer", cur_rate, cur_channels);
-
- if (!h) {
- dbg(lvl_error, "Unable to open ALSA device (%d channels, %d Hz), can't continue\n", cur_channels, cur_rate);
- return;
- } else {
- dbg(lvl_info, "ALSA device (%d channels, %d Hz), ok\n", cur_channels, cur_rate);
- }
- }
-
- c = snd_pcm_wait(h, 1000);
-
- if (c >= 0)
- c = snd_pcm_avail_update(h);
-
- if (c == -EPIPE)
- snd_pcm_prepare(h);
-
- snd_pcm_writei(h, afd->samples, afd->nsamples);
- free(afd);
- }
-}
-
-void audio_init(audio_fifo_t *af)
-{
- pthread_t tid;
-
- TAILQ_INIT(&af->q);
- af->qlen = 0;
-
- pthread_mutex_init(&af->mutex, NULL);
- pthread_cond_init(&af->cond, NULL);
-
- pthread_create(&tid, NULL, alsa_audio_start, af);
-}
-
diff --git a/navit/audio/player-stub/audio.c b/navit/audio/player-stub/audio.c
deleted file mode 100644
index 13b54001c..000000000
--- a/navit/audio/player-stub/audio.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2010 Spotify Ltd
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- *
- * Audio helper functions.
- *
- * This file is part of the libspotify examples suite.
- */
-
-#include "stub.h"
-#include <stdlib.h>
-
-audio_fifo_data_t* audio_get(audio_fifo_t *af)
-{
- audio_fifo_data_t *afd;
- pthread_mutex_lock(&af->mutex);
-
- while (!(afd = TAILQ_FIRST(&af->q)))
- pthread_cond_wait(&af->cond, &af->mutex);
-
- TAILQ_REMOVE(&af->q, afd, link);
- af->qlen -= afd->nsamples;
-
- pthread_mutex_unlock(&af->mutex);
- return afd;
-}
-
-void audio_fifo_flush(audio_fifo_t *af)
-{
- audio_fifo_data_t *afd;
-
- pthread_mutex_lock(&af->mutex);
-
- while((afd = TAILQ_FIRST(&af->q))) {
- TAILQ_REMOVE(&af->q, afd, link);
- free(afd);
- }
-
- af->qlen = 0;
- pthread_mutex_unlock(&af->mutex);
-}
diff --git a/navit/audio/player-stub/stub.c b/navit/audio/player-stub/stub.c
index 477a60e0e..d31d291d3 100644
--- a/navit/audio/player-stub/stub.c
+++ b/navit/audio/player-stub/stub.c
@@ -1527,7 +1527,6 @@ player_stub_new(struct audio_methods *meth, struct callback_list * cbl, struct a
dbg (lvl_info, "found music directory: %s\n", stub->musicdir);
}
- audio_init (&g_audiofifo);
/**
* place init code for your player implementation here
*/