Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 63229 Details for
Bug 98769
media-sound/sidplay-2.0.9: ALSA driver and configure fix
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
sidplay-2.0.9 ALSA and configure patch
sidplay-2.0.9-alsa-fix.patch (text/plain), 8.08 KB, created by
Heikki Orsila
on 2005-07-12 05:58:07 UTC
(
hide
)
Description:
sidplay-2.0.9 ALSA and configure patch
Filename:
MIME Type:
Creator:
Heikki Orsila
Created:
2005-07-12 05:58:07 UTC
Size:
8.08 KB
patch
obsolete
>diff -u -r sidplay-2.0.9-org/configure.ac sidplay-2.0.9-mod/configure.ac >--- sidplay-2.0.9-org/configure.ac 2004-05-05 23:13:58.000000000 +0300 >+++ sidplay-2.0.9-mod/configure.ac 2005-07-12 15:23:45.000000000 +0300 >@@ -24,6 +24,8 @@ > soundcard.h sys/audio.h sun/audioio.h sun/dbriio.h sys/audioio.h \ > audio.h dmedia/audio.h) > >+AC_ARG_WITH(alsa,[ --with-alsa Use ALSA library for sound],[WANT_ALSA=$withval],[WANT_ALSA=no]) >+ > AH_TOP( > [/* Define supported audio driver */ > #undef HAVE_HARDSID >@@ -60,9 +62,17 @@ > AC_MSG_RESULT(irix) > AC_CHECK_LIB(audio, main, [AUDIO_LDADD=-laudio AC_SUBST(AUDIO_LDADD)]) > ;; >- *linux*) AC_DEFINE(HAVE_OSS) >- audiodrv_libadd="./audio/oss/liboss.a" >- AC_MSG_RESULT(oss) >+ *linux*) >+ if test "$WANT_ALSA" = "yes" ; then >+ AC_DEFINE(HAVE_ALSA) >+ audiodrv_libadd="./audio/alsa/libalsa.a" >+ AC_MSG_RESULT(alsa) >+ AC_CHECK_LIB(asound, main, [AUDIO_LDFLAGS=-lasound AC_SUBST(AUDIO_LDFLAGS)]) >+ else >+ AC_DEFINE(HAVE_OSS) >+ audiodrv_libadd="./audio/oss/liboss.a" >+ AC_MSG_RESULT(oss) >+ fi > ;; > *netbsd*) AC_DEFINE(HAVE_OSS) > audiodrv_libadd="./audio/oss/liboss.a" >diff -u -r sidplay-2.0.9-org/src/audio/alsa/audiodrv.cpp sidplay-2.0.9-mod/src/audio/alsa/audiodrv.cpp >--- sidplay-2.0.9-org/src/audio/alsa/audiodrv.cpp 2002-03-04 21:07:48.000000000 +0200 >+++ sidplay-2.0.9-mod/src/audio/alsa/audiodrv.cpp 2005-07-12 15:23:58.000000000 +0300 >@@ -2,6 +2,9 @@ > // Advanced Linux Sound Architecture (ALSA) specific audio driver interface. > // -------------------------------------------------------------------------- > /*************************************************************************** >+ * 2005-07-12: Heikki Orsila <heikki.orsila@iki.fi> >+ * Fixed use of obsolete parts of ALSA API >+ * > * $Log: audiodrv.cpp,v $ > * Revision 1.7 2002/03/04 19:07:48 s_a_white > * Fix C++ use of nothrow. >@@ -31,6 +34,7 @@ > #include "audiodrv.h" > #ifdef HAVE_ALSA > >+#include <iostream> > #include <stdio.h> > #ifdef HAVE_EXCEPTIONS > # include <new> >@@ -57,18 +61,15 @@ > void *Audio_ALSA::open (AudioConfig &cfg, const char *) > { > AudioConfig tmpCfg; >- int mask, wantedFormat, format; >- int rtn; >- int card = -1, dev = 0; >- >- if (_audioHandle != NULL) >- { >+ snd_pcm_uframes_t buffer_frames; >+ snd_pcm_hw_params_t *hw_params; >+ >+ if (_audioHandle != NULL) { > _errorString = "ERROR: Device already in use"; > return NULL; > } > >- if ((rtn = snd_pcm_open_preferred (&_audioHandle, &card, &dev, SND_PCM_OPEN_PLAYBACK))) >- { >+ if (snd_pcm_open (&_audioHandle, "default", SND_PCM_STREAM_PLAYBACK, 0)) { > _errorString = "ERROR: Could not open audio device."; > goto open_error; > } >@@ -77,68 +78,69 @@ > // May later be replaced with driver defaults. > tmpCfg = cfg; > >- snd_pcm_channel_params_t pp; >- snd_pcm_channel_setup_t setup; >- >- snd_pcm_channel_info_t pi; >- >- memset (&pi, 0, sizeof (pi)); >- pi.channel = SND_PCM_CHANNEL_PLAYBACK; >- if ((rtn = snd_pcm_plugin_info (_audioHandle, &pi))) >- { >- _errorString = "ALSA: snd_pcm_plugin_info failed."; >- goto open_error; >+ if (snd_pcm_hw_params_malloc(&hw_params)) { >+ _errorString = "ERROR: could not malloc hwparams."; >+ goto open_error; > } >- >- memset(&pp, 0, sizeof (pp)); >- >- pp.mode = SND_PCM_MODE_BLOCK; >- pp.channel = SND_PCM_CHANNEL_PLAYBACK; >- pp.start_mode = SND_PCM_START_FULL; >- pp.stop_mode = SND_PCM_STOP_STOP; >- >- pp.buf.block.frag_size = pi.max_fragment_size; >- >- pp.buf.block.frags_max = 1; >- pp.buf.block.frags_min = 1; >- >- pp.format.interleave = 1; >- pp.format.rate = tmpCfg.frequency; >- pp.format.voices = tmpCfg.channels; >- >- // Set sample precision and type of encoding. >- if ( tmpCfg.precision == 8 ) >- { >- tmpCfg.encoding = AUDIO_UNSIGNED_PCM; >- pp.format.format = SND_PCM_SFMT_U8; >+ >+ if (snd_pcm_hw_params_any (_audioHandle, hw_params)) { >+ _errorString = "ERROR: could not initialize hw params"; >+ goto open_error; > } >- if ( tmpCfg.precision == 16 ) >- { >- tmpCfg.encoding = AUDIO_SIGNED_PCM; >- pp.format.format = SND_PCM_SFMT_S16_LE; >+ >+ if (snd_pcm_hw_params_set_access (_audioHandle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) { >+ _errorString = "ERROR: could not set access type"; >+ goto open_error; > } > >- if ((rtn = snd_pcm_plugin_params (_audioHandle, &pp)) < 0) >- { >- _errorString = "ALSA: snd_pcm_plugin_params failed."; >- goto open_error; >+ snd_pcm_format_t alsamode; >+ switch (tmpCfg.precision) { >+ case 8: >+ tmpCfg.encoding = AUDIO_UNSIGNED_PCM; >+ alsamode = SND_PCM_FORMAT_U8; >+ break; >+ case 16: >+ tmpCfg.encoding = AUDIO_SIGNED_PCM; >+ alsamode = SND_PCM_FORMAT_S16; >+ break; >+ default: >+ _errorString = "ERROR: set desired number of bits for audio device."; >+ goto open_error; > } >- >- if ((rtn = snd_pcm_plugin_prepare (_audioHandle, SND_PCM_CHANNEL_PLAYBACK)) < 0) >- { >- _errorString = "ALSA: snd_pcm_plugin_prepare failed."; >- goto open_error; >+ >+ if (snd_pcm_hw_params_set_format (_audioHandle, hw_params, alsamode)) { >+ _errorString = "ERROR: could not set sample format"; >+ goto open_error; > } >- >- memset (&setup, 0, sizeof (setup)); >- setup.channel = SND_PCM_CHANNEL_PLAYBACK; >- if ((rtn = snd_pcm_plugin_setup (_audioHandle, &setup)) < 0) >- { >- _errorString = "ALSA: snd_pcm_plugin_setup failed."; >- goto open_error; >+ >+ if (snd_pcm_hw_params_set_channels (_audioHandle, hw_params, tmpCfg.channels)) { >+ _errorString = "ERROR: could not set channel count"; >+ goto open_error; > } > >- tmpCfg.bufSize = setup.buf.block.frag_size; >+ unsigned int rate = tmpCfg.frequency; >+ if (snd_pcm_hw_params_set_rate_near (_audioHandle, hw_params, &rate, 0)) { >+ _errorString = "ERROR: could not set sample rate"; >+ goto open_error; >+ } >+ >+ _alsa_to_frames_divisor = tmpCfg.channels * tmpCfg.precision / 8; >+ buffer_frames = 4096; >+ snd_pcm_hw_params_set_period_size_near(_audioHandle, hw_params, &buffer_frames, 0); >+ >+ if (snd_pcm_hw_params (_audioHandle, hw_params)) { >+ _errorString = "ERROR: could not set hw parameters"; >+ goto open_error; >+ } >+ >+ snd_pcm_hw_params_free (hw_params); >+ >+ if (snd_pcm_prepare (_audioHandle)) { >+ _errorString = "ERROR: could not prepare audio interface for use"; >+ goto open_error; >+ } >+ >+ tmpCfg.bufSize = buffer_frames * _alsa_to_frames_divisor; > #ifdef HAVE_EXCEPTIONS > _sampleBuffer = new(std::nothrow) int_least8_t[tmpCfg.bufSize]; > #else >@@ -158,13 +160,11 @@ > return _sampleBuffer; > > open_error: >+ std::cerr << "ALSA open error: " << _errorString << std::endl; > if (_audioHandle != NULL) >- { > close (); >- } >- > perror ("ALSA"); >-return NULL; >+ return NULL; > } > > // Close an opened audio device, free any allocated buffers and >@@ -174,7 +174,7 @@ > if (_audioHandle != NULL ) > { > snd_pcm_close(_audioHandle); >- delete [] _sampleBuffer; >+ delete [] ((int_least8_t *) _sampleBuffer); > outOfOrder (); > } > } >@@ -192,7 +192,7 @@ > return NULL; > } > >- snd_pcm_plugin_write (_audioHandle, _sampleBuffer, _settings.bufSize); >+ snd_pcm_writei (_audioHandle, _sampleBuffer, _settings.bufSize / _alsa_to_frames_divisor); > return (void *) _sampleBuffer; > } > >diff -u -r sidplay-2.0.9-org/src/audio/alsa/audiodrv.h sidplay-2.0.9-mod/src/audio/alsa/audiodrv.h >--- sidplay-2.0.9-org/src/audio/alsa/audiodrv.h 2002-01-10 21:04:00.000000000 +0200 >+++ sidplay-2.0.9-mod/src/audio/alsa/audiodrv.h 2005-07-12 15:24:03.000000000 +0300 >@@ -35,8 +35,7 @@ > #include <errno.h> > #include <fcntl.h> > #include <unistd.h> >-#include <sys/ioctl.h> >-#include <sys/asoundlib.h> >+#include <alsa/asoundlib.h> > #include "../AudioBase.h" > > >@@ -44,6 +43,7 @@ > { > private: // ------------------------------------------------------- private > snd_pcm_t * _audioHandle; >+ int _alsa_to_frames_divisor; > > void outOfOrder (); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 98769
:
63229
|
63230
|
67869
|
70811