FreeRDP
Loading...
Searching...
No Matches
tsmf_audio.c
1
20#include <freerdp/config.h>
21
22#include <stdio.h>
23#include <stdlib.h>
24#include <string.h>
25
26#include "tsmf_audio.h"
27
28static ITSMFAudioDevice* tsmf_load_audio_device_by_name(const char* name, const char* device)
29{
30 ITSMFAudioDevice* audio = NULL;
31 union
32 {
33 PVIRTUALCHANNELENTRY pvce;
34 TSMF_AUDIO_DEVICE_ENTRY entry;
35 } cnv;
36 cnv.pvce = freerdp_load_channel_addin_entry("tsmf", name, "audio", 0);
37
38 if (!cnv.entry)
39 return NULL;
40
41 const UINT rc = cnv.entry(&audio);
42
43 if ((rc != CHANNEL_RC_OK) || !audio)
44 {
45 WLog_ERR(TAG, "failed to call export function in %s", name);
46 return NULL;
47 }
48
49 if (!audio->Open(audio, device))
50 {
51 audio->Free(audio);
52 audio = NULL;
53 WLog_ERR(TAG, "failed to open, name: %s, device: %s", name, device);
54 }
55 else
56 {
57 WLog_DBG(TAG, "name: %s, device: %s", name, device);
58 }
59
60 return audio;
61}
62
63ITSMFAudioDevice* tsmf_load_audio_device(const char* name, const char* device)
64{
65 ITSMFAudioDevice* audio = NULL;
66
67 if (name)
68 {
69 audio = tsmf_load_audio_device_by_name(name, device);
70 }
71 else
72 {
73#if defined(WITH_PULSE)
74 if (!audio)
75 audio = tsmf_load_audio_device_by_name("pulse", device);
76#endif
77
78#if defined(WITH_OSS)
79 if (!audio)
80 audio = tsmf_load_audio_device_by_name("oss", device);
81#endif
82
83#if defined(WITH_ALSA)
84 if (!audio)
85 audio = tsmf_load_audio_device_by_name("alsa", device);
86#endif
87 }
88
89 if (audio == NULL)
90 {
91 WLog_ERR(TAG, "no sound device.");
92 }
93 else
94 {
95 WLog_DBG(TAG, "name: %s, device: %s", name, device);
96 }
97
98 return audio;
99}