Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
d248f329
Commit
d248f329
authored
Mar 18, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't modify pDeviceInfo in mal_context_get_device_info() on error.
parent
65cb6133
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
11 deletions
+19
-11
mini_al.h
mini_al.h
+19
-11
No files found.
mini_al.h
View file @
d248f329
...
@@ -1439,6 +1439,8 @@ mal_result mal_context_get_devices(mal_context* pContext, mal_device_info** ppPl
...
@@ -1439,6 +1439,8 @@ mal_result mal_context_get_devices(mal_context* pContext, mal_device_info** ppPl
// backends and devices support shared or exclusive mode, in which case this function will fail
// backends and devices support shared or exclusive mode, in which case this function will fail
// if the requested share mode is unsupported.
// if the requested share mode is unsupported.
//
//
// This leaves pDeviceInfo unmodified in the result of an error.
//
// Return Value:
// Return Value:
// MAL_SUCCESS if successful; any other error code otherwise.
// MAL_SUCCESS if successful; any other error code otherwise.
//
//
...
@@ -5406,19 +5408,21 @@ BOOL CALLBACK mal_context_get_device_info_callback__dsound(LPGUID lpGuid, LPCSTR
...
@@ -5406,19 +5408,21 @@ BOOL CALLBACK mal_context_get_device_info_callback__dsound(LPGUID lpGuid, LPCSTR
mal_assert
(
pData
!=
NULL
);
mal_assert
(
pData
!=
NULL
);
if
((
pData
->
pDeviceID
==
NULL
||
mal_is_guid_equal
(
pData
->
pDeviceID
->
dsound
,
&
MAL_GUID_NULL
))
&&
(
lpGuid
==
NULL
||
mal_is_guid_equal
(
lpGuid
,
&
MAL_GUID_NULL
)))
{
if
((
pData
->
pDeviceID
==
NULL
||
mal_is_guid_equal
(
pData
->
pDeviceID
->
dsound
,
&
MAL_GUID_NULL
))
&&
(
lpGuid
==
NULL
||
mal_is_guid_equal
(
lpGuid
,
&
MAL_GUID_NULL
)))
{
// Default device.
mal_strncpy_s
(
pData
->
pDeviceInfo
->
name
,
sizeof
(
pData
->
pDeviceInfo
->
name
),
lpcstrDescription
,
(
size_t
)
-
1
);
mal_strncpy_s
(
pData
->
pDeviceInfo
->
name
,
sizeof
(
pData
->
pDeviceInfo
->
name
),
lpcstrDescription
,
(
size_t
)
-
1
);
pData
->
found
=
MAL_TRUE
;
pData
->
found
=
MAL_TRUE
;
return
FALSE
;
// Stop enumeration.
return
FALSE
;
// Stop enumeration.
}
else
{
}
else
{
if
(
memcmp
(
pData
->
pDeviceID
->
dsound
,
lpGuid
,
sizeof
(
pData
->
pDeviceID
->
dsound
))
==
0
)
{
// Not the default device.
mal_strncpy_s
(
pData
->
pDeviceInfo
->
name
,
sizeof
(
pData
->
pDeviceInfo
->
name
),
lpcstrDescription
,
(
size_t
)
-
1
);
if
(
lpGuid
!=
NULL
)
{
pData
->
found
=
MAL_TRUE
;
if
(
memcmp
(
pData
->
pDeviceID
->
dsound
,
lpGuid
,
sizeof
(
pData
->
pDeviceID
->
dsound
))
==
0
)
{
return
FALSE
;
// Stop enumeration.
mal_strncpy_s
(
pData
->
pDeviceInfo
->
name
,
sizeof
(
pData
->
pDeviceInfo
->
name
),
lpcstrDescription
,
(
size_t
)
-
1
);
pData
->
found
=
MAL_TRUE
;
return
FALSE
;
// Stop enumeration.
}
}
}
}
}
return
TRUE
;
return
TRUE
;
}
}
...
@@ -14097,14 +14101,17 @@ mal_result mal_context_get_devices(mal_context* pContext, mal_device_info** ppPl
...
@@ -14097,14 +14101,17 @@ mal_result mal_context_get_devices(mal_context* pContext, mal_device_info** ppPl
mal_result
mal_context_get_device_info
(
mal_context
*
pContext
,
mal_device_type
type
,
const
mal_device_id
*
pDeviceID
,
mal_share_mode
shareMode
,
mal_device_info
*
pDeviceInfo
)
mal_result
mal_context_get_device_info
(
mal_context
*
pContext
,
mal_device_type
type
,
const
mal_device_id
*
pDeviceID
,
mal_share_mode
shareMode
,
mal_device_info
*
pDeviceInfo
)
{
{
if
(
pDeviceInfo
==
NULL
)
return
MAL_INVALID_ARGS
;
// NOTE: Do not clear pDeviceInfo on entry. The reason is the pDeviceID may actually point to pDeviceInfo->id which will break things.
mal_zero_object
(
pDeviceInfo
);
if
(
pContext
==
NULL
||
pDeviceInfo
==
NULL
)
{
return
MAL_INVALID_ARGS
;
}
if
(
pContext
==
NULL
)
return
MAL_INVALID_ARGS
;
mal_device_info
deviceInfo
;
mal_zero_object
(
&
deviceInfo
);
// Help the backend out by copying over the device ID if we have one.
// Help the backend out by copying over the device ID if we have one.
if
(
pDeviceID
!=
NULL
)
{
if
(
pDeviceID
!=
NULL
)
{
m
emcpy
(
&
pDeviceInfo
->
id
,
pDeviceID
,
sizeof
(
*
pDeviceID
));
m
al_copy_memory
(
&
deviceInfo
.
id
,
pDeviceID
,
sizeof
(
*
pDeviceID
));
}
}
// The backend may have an optimized device info retrieval function. If so, try that first.
// The backend may have an optimized device info retrieval function. If so, try that first.
...
@@ -14112,10 +14119,11 @@ mal_result mal_context_get_device_info(mal_context* pContext, mal_device_type ty
...
@@ -14112,10 +14119,11 @@ mal_result mal_context_get_device_info(mal_context* pContext, mal_device_type ty
mal_result
result
;
mal_result
result
;
mal_mutex_lock
(
&
pContext
->
deviceInfoLock
);
mal_mutex_lock
(
&
pContext
->
deviceInfoLock
);
{
{
result
=
pContext
->
onGetDeviceInfo
(
pContext
,
type
,
pDeviceID
,
shareMode
,
pD
eviceInfo
);
result
=
pContext
->
onGetDeviceInfo
(
pContext
,
type
,
pDeviceID
,
shareMode
,
&
d
eviceInfo
);
}
}
mal_mutex_unlock
(
&
pContext
->
deviceInfoLock
);
mal_mutex_unlock
(
&
pContext
->
deviceInfoLock
);
*
pDeviceInfo
=
deviceInfo
;
return
result
;
return
result
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment