mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-05 21:55:24 +00:00
Added an option to WasapiOut
to enable its internal resampler.
This commit is contained in:
parent
9fb2c6412d
commit
25b2e07d3b
@ -47,6 +47,7 @@
|
|||||||
#define PREF_DEVICE_ID "device_id"
|
#define PREF_DEVICE_ID "device_id"
|
||||||
#define PREF_ENDPOINT_ROUTING "enable_audio_endpoint_routing"
|
#define PREF_ENDPOINT_ROUTING "enable_audio_endpoint_routing"
|
||||||
#define PREF_BUFFER_LENGTH_SECONDS "buffer_length_seconds"
|
#define PREF_BUFFER_LENGTH_SECONDS "buffer_length_seconds"
|
||||||
|
#define PREF_DISABLE_INTERNAL_RESAMPLER "disable_internal_resampler"
|
||||||
|
|
||||||
/* NOTE! device init and deinit logic was stolen and modified from
|
/* NOTE! device init and deinit logic was stolen and modified from
|
||||||
QMMP's WASAPI output plugin! http://qmmp.ylsoftware.com/ */
|
QMMP's WASAPI output plugin! http://qmmp.ylsoftware.com/ */
|
||||||
@ -106,6 +107,7 @@ extern "C" __declspec(dllexport) void SetPreferences(musik::core::sdk::IPreferen
|
|||||||
::prefs = prefs;
|
::prefs = prefs;
|
||||||
prefs->GetString(PREF_DEVICE_ID, nullptr, 0, "");
|
prefs->GetString(PREF_DEVICE_ID, nullptr, 0, "");
|
||||||
prefs->GetBool(PREF_ENDPOINT_ROUTING, false);
|
prefs->GetBool(PREF_ENDPOINT_ROUTING, false);
|
||||||
|
prefs->GetBool(PREF_DISABLE_INTERNAL_RESAMPLER, true);
|
||||||
prefs->Save();
|
prefs->Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,6 +115,7 @@ extern "C" __declspec(dllexport) musik::core::sdk::ISchema* GetSchema() {
|
|||||||
auto schema = new TSchema<>();
|
auto schema = new TSchema<>();
|
||||||
schema->AddBool(PREF_ENDPOINT_ROUTING, false);
|
schema->AddBool(PREF_ENDPOINT_ROUTING, false);
|
||||||
schema->AddDouble(PREF_BUFFER_LENGTH_SECONDS, 1.0, 2, 0.25, 5.0);
|
schema->AddDouble(PREF_BUFFER_LENGTH_SECONDS, 1.0, 2, 0.25, 5.0);
|
||||||
|
schema->AddBool(PREF_DISABLE_INTERNAL_RESAMPLER, true);
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,6 +123,10 @@ static bool audioRoutingEnabled() {
|
|||||||
return ::prefs && prefs->GetBool(PREF_ENDPOINT_ROUTING, false);
|
return ::prefs && prefs->GetBool(PREF_ENDPOINT_ROUTING, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool disableInternalResampler() {
|
||||||
|
return ::prefs && prefs->GetBool(PREF_DISABLE_INTERNAL_RESAMPLER, true);
|
||||||
|
}
|
||||||
|
|
||||||
class NotificationClient : public IMMNotificationClient {
|
class NotificationClient : public IMMNotificationClient {
|
||||||
public:
|
public:
|
||||||
NotificationClient(WasapiOut* owner)
|
NotificationClient(WasapiOut* owner)
|
||||||
@ -519,6 +526,12 @@ found_or_done:
|
|||||||
int WasapiOut::GetDefaultSampleRate() {
|
int WasapiOut::GetDefaultSampleRate() {
|
||||||
int result = -1;
|
int result = -1;
|
||||||
Lock lock(this->stateMutex);
|
Lock lock(this->stateMutex);
|
||||||
|
if (!disableInternalResampler()) {
|
||||||
|
/* if our internal sampler is not disabled, we'll let WASAPI take care of
|
||||||
|
resampling; return -1 here to have audio delivered in its native bitrate,
|
||||||
|
and don't allow decoders to resample. */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
this->InitializeAudioClient();
|
this->InitializeAudioClient();
|
||||||
if (this->audioClient) {
|
if (this->audioClient) {
|
||||||
WAVEFORMATEX* deviceFormat = nullptr;
|
WAVEFORMATEX* deviceFormat = nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user