Ticket #17 (closed enhancement: fixed)

Opened 2 years ago

Last modified 6 months ago

Patch to expose device "handle" to applications

Reported by: leland_lucius Owned by: aknudsen
Priority: minor Milestone: V19-RC1
Component: host-api-alsa Version: 2.0
Keywords: Cc:

Description

Refer to mailing list discussion on PortMixer? and exposing devices for a full understanding of the changes:

diff -wruN orig/audacity/lib-src/portaudio-v19/include/pa_linux_alsa.h audacity/lib-src/portaudio-v19/include/pa_linux_alsa.h
--- orig/audacity/lib-src/portaudio-v19/include/pa_linux_alsa.h	2006-09-04 14:05:58.000000000 -0500
+++ audacity/lib-src/portaudio-v19/include/pa_linux_alsa.h	2006-09-04 05:30:19.000000000 -0500
@@ -63,6 +63,10 @@
 
 void PaAlsa_EnableWatchdog( PaStream *s, int enable );
 
+int PaAlsa_GetStreamInputCard( PaStream *s );
+
+int PaAlsa_GetStreamOutputCard( PaStream *s );
+
 #ifdef __cplusplus
 }
 #endif
diff -wruN orig/audacity/lib-src/portaudio-v19/src/hostapi/alsa/pa_linux_alsa.c audacity/lib-src/portaudio-v19/src/hostapi/alsa/pa_linux_alsa.c
--- orig/audacity/lib-src/portaudio-v19/src/hostapi/alsa/pa_linux_alsa.c	2006-09-04 14:05:58.000000000 -0500
+++ audacity/lib-src/portaudio-v19/src/hostapi/alsa/pa_linux_alsa.c	2006-09-04 05:30:19.000000000 -0500
@@ -3321,3 +3321,40 @@
     stream->threading.useWatchdog = enable;
 #endif
 }
+
+int PaAlsa_GetStreamInputCard( PaStream *s )
+{
+    PaAlsaStream *stream = (PaAlsaStream *) s;
+    snd_pcm_info_t *pcmInfo;
+    int card = -1;
+
+    if( stream->capture.pcm )
+    {
+        snd_pcm_info_alloca( &pcmInfo );
+        if( snd_pcm_info( stream->capture.pcm, pcmInfo ) >= 0 )
+        {
+            card = snd_pcm_info_get_card( pcmInfo );
+        }
+    }
+
+    return card;
+}
+
+int PaAlsa_GetStreamOutputCard( PaStream *s )
+{
+    PaAlsaStream *stream = (PaAlsaStream *) s;
+    snd_pcm_info_t *pcmInfo;
+    int card = -1;
+
+    if( stream->playback.pcm )
+    {
+        snd_pcm_info_alloca( &pcmInfo );
+        if( snd_pcm_info( stream->playback.pcm, pcmInfo ) >= 0 )
+        {
+            card = snd_pcm_info_get_card( pcmInfo );
+        }
+    }
+
+    return card;
+}
+

Leland

Attachments

alsa.diff (1.7 kB) - added by leland_lucius 2 years ago.

Change History

Changed 2 years ago by leland_lucius

Changed 21 months ago by aknudsen

  • status changed from new to closed
  • resolution set to fixed

I've accepted the patch in a somewhat modified form, so that errors can be returned.

Changed 21 months ago by rossb

  • status changed from closed to reopened
  • resolution fixed deleted

The committed code in r1145 casts a PaStream? to a PaAlsaStream? without checking that it is a PaAlsaStream?. See GetWinMMEStreamPointer in pa_win_wmme.c for example.

Changed 20 months ago by aknudsen

  • status changed from reopened to new

Changed 20 months ago by aknudsen

  • status changed from new to assigned

Changed 6 months ago by rossb

  • milestone set to V19-RC1

Changed 6 months ago by aknudsen

  • status changed from assigned to closed
  • resolution set to fixed

Changed 6 months ago by aknudsen

  • status changed from closed to reopened
  • resolution fixed deleted

Changed 6 months ago by aknudsen

  • status changed from reopened to closed
  • resolution set to fixed

I've followed your suggestion, Ross.

Note: See TracTickets for help on using tickets.