summaryrefslogtreecommitdiff
path: root/modules/winwave
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2014-11-09 11:15:28 +0100
committerAlfred E. Heggestad <aeh@db.org>2014-11-09 11:15:28 +0100
commit89deeb14cb876a37d9fd0b6e47d48a392bae1515 (patch)
tree3d182db78419f26e293077c8653de804ce71d99a /modules/winwave
parent9c6e8cfe1470b9382fab2b93c1cd2b9eea521c0d (diff)
winwave: added mapping of device-name to device
contributed by Tomasz Ostrowski from the "VoIP/SIP client (softphone) for Windows" project: http://tomeko.net/software/SIPclient/ Review: alfredh
Diffstat (limited to 'modules/winwave')
-rw-r--r--modules/winwave/play.c30
-rw-r--r--modules/winwave/src.c30
2 files changed, 52 insertions, 8 deletions
diff --git a/modules/winwave/play.c b/modules/winwave/play.c
index 77e7501..e258561 100644
--- a/modules/winwave/play.c
+++ b/modules/winwave/play.c
@@ -128,8 +128,31 @@ static void CALLBACK waveOutCallback(HWAVEOUT hwo,
}
+static unsigned int find_dev(const char *name)
+{
+ WAVEOUTCAPS wic;
+ unsigned int i, nInDevices = waveOutGetNumDevs();
+
+ if (!str_isset(name))
+ return WAVE_MAPPER;
+
+ for (i=0; i<nInDevices; i++) {
+ if (waveOutGetDevCaps(i, &wic,
+ sizeof(WAVEOUTCAPS))==MMSYSERR_NOERROR) {
+
+ if (0 == str_cmp(name, wic.szPname)) {
+ return i;
+ }
+ }
+ }
+
+ return WAVE_MAPPER;
+}
+
+
static int write_stream_open(struct auplay_st *st,
- const struct auplay_prm *prm)
+ const struct auplay_prm *prm,
+ unsigned int dev)
{
WAVEFORMATEX wfmt;
MMRESULT res;
@@ -156,7 +179,7 @@ static int write_stream_open(struct auplay_st *st,
wfmt.nAvgBytesPerSec = wfmt.nSamplesPerSec * wfmt.nBlockAlign;
wfmt.cbSize = 0;
- res = waveOutOpen(&st->waveout, WAVE_MAPPER, &wfmt,
+ res = waveOutOpen(&st->waveout, dev, &wfmt,
(DWORD_PTR) waveOutCallback,
(DWORD_PTR) st,
CALLBACK_FUNCTION | WAVE_FORMAT_DIRECT);
@@ -175,7 +198,6 @@ int winwave_play_alloc(struct auplay_st **stp, struct auplay *ap,
{
struct auplay_st *st;
int i, err;
- (void)device;
if (!stp || !ap || !prm)
return EINVAL;
@@ -188,7 +210,7 @@ int winwave_play_alloc(struct auplay_st **stp, struct auplay *ap,
st->wh = wh;
st->arg = arg;
- err = write_stream_open(st, prm);
+ err = write_stream_open(st, prm, find_dev(device));
if (err)
goto out;
diff --git a/modules/winwave/src.c b/modules/winwave/src.c
index 39abfed..c671176 100644
--- a/modules/winwave/src.c
+++ b/modules/winwave/src.c
@@ -117,7 +117,30 @@ static void CALLBACK waveInCallback(HWAVEOUT hwo,
}
-static int read_stream_open(struct ausrc_st *st, const struct ausrc_prm *prm)
+static unsigned int find_dev(const char *name)
+{
+ WAVEINCAPS wic;
+ unsigned int i, nInDevices = waveInGetNumDevs();
+
+ if (!str_isset(name))
+ return WAVE_MAPPER;
+
+ for (i=0; i<nInDevices; i++) {
+ if (waveInGetDevCaps(i, &wic,
+ sizeof(WAVEINCAPS))==MMSYSERR_NOERROR) {
+
+ if (0 == str_casecmp(name, wic.szPname)) {
+ return i;
+ }
+ }
+ }
+
+ return WAVE_MAPPER;
+}
+
+
+static int read_stream_open(struct ausrc_st *st, const struct ausrc_prm *prm,
+ unsigned int dev)
{
WAVEFORMATEX wfmt;
MMRESULT res;
@@ -146,7 +169,7 @@ static int read_stream_open(struct ausrc_st *st, const struct ausrc_prm *prm)
wfmt.nAvgBytesPerSec = wfmt.nSamplesPerSec * wfmt.nBlockAlign;
wfmt.cbSize = 0;
- res = waveInOpen(&st->wavein, WAVE_MAPPER, &wfmt,
+ res = waveInOpen(&st->wavein, dev, &wfmt,
(DWORD_PTR) waveInCallback,
(DWORD_PTR) st,
CALLBACK_FUNCTION | WAVE_FORMAT_DIRECT);
@@ -174,7 +197,6 @@ int winwave_src_alloc(struct ausrc_st **stp, struct ausrc *as,
int err;
(void)ctx;
- (void)device;
(void)errh;
if (!stp || !as || !prm)
@@ -188,7 +210,7 @@ int winwave_src_alloc(struct ausrc_st **stp, struct ausrc *as,
st->rh = rh;
st->arg = arg;
- err = read_stream_open(st, prm);
+ err = read_stream_open(st, prm, find_dev(device));
if (err)
mem_deref(st);