diff options
author | Alfred E. Heggestad <aeh@db.org> | 2014-11-09 11:15:28 +0100 |
---|---|---|
committer | Alfred E. Heggestad <aeh@db.org> | 2014-11-09 11:15:28 +0100 |
commit | 89deeb14cb876a37d9fd0b6e47d48a392bae1515 (patch) | |
tree | 3d182db78419f26e293077c8653de804ce71d99a /modules/winwave/play.c | |
parent | 9c6e8cfe1470b9382fab2b93c1cd2b9eea521c0d (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/play.c')
-rw-r--r-- | modules/winwave/play.c | 30 |
1 files changed, 26 insertions, 4 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; |