[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdemultimedia/kscd/libwm/audio
From: Alex Kern <alex.kern () gmx ! de>
Date: 2006-11-26 20:38:13
Message-ID: 1164573493.775678.29134.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 608126 by kernalex:
new backend phonon, now not working
M +7 -4 audio.c
M +10 -1 audio.h
M +36 -15 audio_alsa.c
M +3 -3 audio_arts.c
A audio_phonon.cpp [License: no copyright]
M +11 -11 audio_sun.c
--- trunk/KDE/kdemultimedia/kscd/libwm/audio/audio.c #608125:608126
@@ -4,16 +4,19 @@
#include <config-alsa.h>
#include <string.h>
-struct audio_oops* setup_arts(const char *dev, const char *ctl);
-struct audio_oops* setup_alsa(const char *dev, const char *ctl);
+struct audio_oops *setup_phonon(const char *dev, const char *ctl);
+struct audio_oops *setup_arts(const char *dev, const char *ctl);
+struct audio_oops *setup_alsa(const char *dev, const char *ctl);
-struct audio_oops* setup_soundsystem(const char* ss, const char* dev, const char* ctl)
+struct audio_oops *setup_soundsystem(const char *ss, const char *dev, const char *ctl)
{
if(!ss) {
ERRORLOG("audio: Internal error, trying to setup a NULL soundsystem.\n");
return NULL;
}
+ if(!strcmp(ss, "phonon"))
+ return setup_phonon(dev, ctl);
#ifdef USE_ARTS
if(!strcmp(ss, "arts"))
return setup_arts(dev, ctl);
@@ -22,7 +25,7 @@
if(!strcmp(ss, "alsa"))
return setup_alsa(dev, ctl);
#endif
-#ifdef USE_SUN_AUDIO
+#if defined(sun) || defined(__sun__)
if(!strcmp(ss, "sun"))
return setup_sun_audio(dev, ctl);
#endif
--- trunk/KDE/kdemultimedia/kscd/libwm/audio/audio.h #608125:608126
@@ -17,5 +17,14 @@
int (*wmaudio_volume)(int);
};
-extern struct audio_oops* setup_soundsystem(const char*, const char*, const char*);
+#ifdef __cplusplus
+ extern "C" {
+#endif
+struct audio_oops *setup_soundsystem(const char *, const char *, const char *);
+
+#ifdef __cplusplus
+ }
+#endif
+
+
--- trunk/KDE/kdemultimedia/kscd/libwm/audio/audio_alsa.c #608125:608126
@@ -6,9 +6,9 @@
* Cleanups by Jaroslav Kysela <perex@jcu.cz>
* Ville Syrjala <syrjala@sci.fi>
*
- * adopted for libworkman cdda audio backend from Alexander Kern alex.kern@gmx.de
+ * adopted for libworkman cdda audio backend from Alexander Kern alex.kern@gmx.de
*
- * Adapted to support both ALSA V0.x and V1.x APIs for PCM calls
+ * Adapted to support both ALSA V0.x and V1.x APIs for PCM calls
* (Philip Nelson <teamdba@scotdb.com> 2004-03-15)
*
* This file comes under GPL license.
@@ -32,14 +32,30 @@
snd_pcm_t *handle;
snd_pcm_format_t format = SND_PCM_FORMAT_S16; /* sample format */
+
+#if (SND_LIB_MAJOR < 1)
int rate = 44100; /* stream rate */
+int new_rate;
int channels = 2; /* count of channels */
int buffer_time = 2000000; /* ring buffer length in us */
int period_time = 100000; /* period time in us */
+#else
+unsigned int rate = 44100; /* stream rate */
+unsigned int new_rate;
+int channels = 2; /* count of channels */
+unsigned int buffer_time = 2000000; /* ring buffer length in us */
+unsigned int period_time = 100000; /* period time in us */
+#endif
+#if (SND_LIB_MAJOR < 1)
snd_pcm_sframes_t buffer_size;
snd_pcm_sframes_t period_size;
+#else
+snd_pcm_uframes_t buffer_size;
+snd_pcm_uframes_t period_size;
+#endif
+
int alsa_open(void);
int alsa_close(void);
int alsa_stop(void);
@@ -50,7 +66,7 @@
static int set_hwparams(snd_pcm_hw_params_t *params,
snd_pcm_access_t accesspar)
{
- int err, dir, new_rate;
+ int err, dir;
/* choose all parameters */
err = snd_pcm_hw_params_any(handle, params);
@@ -77,11 +93,11 @@
return err;
}
/* set the stream rate */
-#if (SND_LIB_MAJOR < 1)
+#if (SND_LIB_MAJOR < 1)
err = new_rate = snd_pcm_hw_params_set_rate_near(handle, params, rate, 0);
#else
new_rate = rate;
- err = snd_pcm_hw_params_set_rate_near(handle, params, &new_rate, 0);
+ err = snd_pcm_hw_params_set_rate_near(handle, params, &rate, 0);
#endif
if (err < 0) {
ERRORLOG("Rate %iHz not available for playback: %s\n", rate, snd_strerror(err));
@@ -104,7 +120,7 @@
#if (SND_LIB_MAJOR < 1)
buffer_size = snd_pcm_hw_params_get_buffer_size(params);
#else
- err = snd_pcm_hw_params_get_buffer_size(params, &buffer_size);
+ err = snd_pcm_hw_params_get_buffer_size(params, &buffer_size);
if (err < 0) {
ERRORLOG("Unable to get buffer size : %s\n", snd_strerror(err));
return err;
@@ -115,7 +131,7 @@
/* set the period time */
#if (SND_LIB_MAJOR < 1)
err = snd_pcm_hw_params_set_period_time_near(handle, params, period_time, &dir);
-#else
+#else
err = snd_pcm_hw_params_set_period_time_near(handle, params, &period_time, &dir);
#endif
if (err < 0) {
@@ -123,7 +139,7 @@
return err;
}
-#if (SND_LIB_MAJOR < 1)
+#if (SND_LIB_MAJOR < 1)
period_size = snd_pcm_hw_params_get_period_size(params, &dir);
#else
err = snd_pcm_hw_params_get_period_size(params, &period_size, &dir);
@@ -214,7 +230,7 @@
int err;
DEBUGLOG("alsa_close\n");
-
+
err = alsa_stop();
#if (SND_LIB_MAJOR < 1)
@@ -285,7 +301,7 @@
if (err < 0) {
ERRORLOG("Unable to drop pcm stream: %s\n", snd_strerror(err));
}
-
+
err = snd_pcm_prepare(handle);
if (err < 0) {
ERRORLOG("Unable to snd_pcm_prepare pcm stream: %s\n", snd_strerror(err));
@@ -300,6 +316,8 @@
int
alsa_state(struct cdda_block *blk)
{
+ DEBUGLOG("alsa_state\n");
+
return -1; /* not implemented yet for ALSA */
}
@@ -318,16 +336,19 @@
{
static int init_complete = 0;
+ DEBUGLOG("setup_alsa\n");
+
+ if(init_complete) {
+ alsa_close();
+ init_complete = 0;
+ }
+
if(dev && strlen(dev) > 0) {
device = strdup(dev);
} else {
device = strdup("plughw:0,0"); /* playback device */
}
- if(init_complete) {
- ERRORLOG("already initialized\n");
- return NULL;
- }
if(!alsa_open())
init_complete = 1;
else
@@ -336,4 +357,4 @@
return &alsa_oops;
}
-#endif /* ALSA */
+#endif /* HAVE_LIBASOUND2 */
--- trunk/KDE/kdemultimedia/kscd/libwm/audio/audio_arts.c #608125:608126
@@ -71,9 +71,9 @@
DEBUGLOG("arts_close\n");
arts_close_stream(arts_stream);
-
+
arts_free();
-
+
return 0;
}
@@ -135,7 +135,7 @@
}
arts_open();
-
+
return &arts_oops;
}
#endif
--- trunk/KDE/kdemultimedia/kscd/libwm/audio/audio_sun.c #608125:608126
@@ -5,7 +5,7 @@
* (c) 1991-1997 by Steven Grimm (original author)
* (c) by Dirk Försterling (current 'author' = maintainer)
* The maintainer can be contacted by his e-mail address:
- * milliByte@DeathsDoor.com
+ * milliByte@DeathsDoor.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -27,7 +27,7 @@
#include <config.h>
-#ifdef USE_SUN_AUDIO
+#if defined(sun) || defined(__sun__)
#include <stdio.h>
#include <malloc.h>
@@ -73,7 +73,7 @@
static int aufd, aucfd;
static int raw_audio = 1; /* Can /dev/audio take 44.1KHz stereo? */
-/*
+/*
* For fast linear-to-ulaw mapping, we use a lookup table that's generated
* at startup.
*/
@@ -101,8 +101,8 @@
int linval;
audiodev = getenv("AUDIODEV");
- if (audiodev == NULL ||
- strncmp("/dev/", audiodev, 5) ||
+ if (audiodev == NULL ||
+ strncmp("/dev/", audiodev, 5) ||
strstr(audiodev, "/../") )
audiodev = "/dev/audio";
@@ -418,7 +418,7 @@
#define ZEROTRAP /* turn on the trap as per the MIL-STD */
#define BIAS 0x84 /* define the add-in bias for 16 bit samples */
#define CLIP 32635
-
+
unsigned char
linear_to_ulaw( sample )
int sample;
@@ -441,12 +441,12 @@
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
int sign, exponent, mantissa;
unsigned char ulawbyte;
-
+
/* Get the sample into sign-magnitude. */
sign = (sample >> 8) & 0x80; /* set aside the sign */
if ( sign != 0 ) sample = -sample; /* get magnitude */
if ( sample > CLIP ) sample = CLIP; /* clip the magnitude */
-
+
/* Convert from 16 bit linear to ulaw. */
sample = sample + BIAS;
exponent = exp_lut[( sample >> 7 ) & 0xFF];
@@ -455,7 +455,7 @@
#ifdef ZEROTRAP
if ( ulawbyte == 0 ) ulawbyte = 0x02; /* optional CCITT trap */
#endif
-
+
return ulawbyte;
}
@@ -518,8 +518,8 @@
}
sun_audio_open();
-
+
return &sun_audio_oops;
}
-#endif /* USE_SUN_AUDIO */
+#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic