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
00eec752
Commit
00eec752
authored
Mar 03, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pulse: Correctly set the device name.
parent
bf781ee2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
16 deletions
+54
-16
mini_al.h
mini_al.h
+54
-16
No files found.
mini_al.h
View file @
00eec752
...
@@ -7081,6 +7081,21 @@ static mal_result mal_context_init__pulse(mal_context* pContext)
...
@@ -7081,6 +7081,21 @@ static mal_result mal_context_init__pulse(mal_context* pContext)
}
}
static
mal_result
mal_device__wait_for_operation__pulse
(
mal_device
*
pDevice
,
pa_operation
*
pOP
)
{
mal_assert
(
pDevice
!=
NULL
);
mal_assert
(
pOP
!=
NULL
);
while
(
pa_operation_get_state
(
pOP
)
!=
PA_OPERATION_DONE
)
{
int
error
=
pa_mainloop_iterate
((
pa_mainloop
*
)
pDevice
->
pulse
.
pMainLoop
,
1
,
NULL
);
if
(
error
<
0
)
{
return
mal_result_from_pulse
(
error
);
}
}
return
MAL_SUCCESS
;
}
static
void
mal_pulse_device_enum_state_callback
(
pa_context
*
pPulseContext
,
void
*
pUserData
)
static
void
mal_pulse_device_enum_state_callback
(
pa_context
*
pPulseContext
,
void
*
pUserData
)
{
{
pa_context_state_t
*
pPulseContextState
=
(
pa_context_state_t
*
)
pUserData
;
pa_context_state_t
*
pPulseContextState
=
(
pa_context_state_t
*
)
pUserData
;
...
@@ -7319,6 +7334,30 @@ static void mal_pulse_device_read_callback(pa_stream* pStream, size_t sizeInByte
...
@@ -7319,6 +7334,30 @@ static void mal_pulse_device_read_callback(pa_stream* pStream, size_t sizeInByte
}
}
}
}
static
void
mal_device_sink_name_callback
(
pa_context
*
pPulseContext
,
const
pa_sink_info
*
pInfo
,
int
endOfList
,
void
*
pUserData
)
{
if
(
endOfList
>
0
)
{
return
;
}
mal_device
*
pDevice
=
(
mal_device
*
)
pUserData
;
mal_assert
(
pDevice
!=
NULL
);
mal_strcpy_s
(
pDevice
->
name
,
sizeof
(
pDevice
->
name
),
pInfo
->
description
);
}
static
void
mal_device_source_name_callback
(
pa_context
*
pPulseContext
,
const
pa_source_info
*
pInfo
,
int
endOfList
,
void
*
pUserData
)
{
if
(
endOfList
>
0
)
{
return
;
}
mal_device
*
pDevice
=
(
mal_device
*
)
pUserData
;
mal_assert
(
pDevice
!=
NULL
);
mal_strcpy_s
(
pDevice
->
name
,
sizeof
(
pDevice
->
name
),
pInfo
->
description
);
}
static
void
mal_device_uninit__pulse
(
mal_device
*
pDevice
)
static
void
mal_device_uninit__pulse
(
mal_device
*
pDevice
)
{
{
mal_assert
(
pDevice
!=
NULL
);
mal_assert
(
pDevice
!=
NULL
);
...
@@ -7486,7 +7525,21 @@ static mal_result mal_device_init__pulse(mal_context* pContext, mal_device_type
...
@@ -7486,7 +7525,21 @@ static mal_result mal_device_init__pulse(mal_context* pContext, mal_device_type
pDevice
->
periods
=
attr
.
maxlength
/
attr
.
tlength
;
pDevice
->
periods
=
attr
.
maxlength
/
attr
.
tlength
;
// TODO: Get the name of the device.
// Grab the name of the device if we can.
dev
=
pa_stream_get_device_name
((
pa_stream
*
)
pDevice
->
pulse
.
pStream
);
if
(
dev
!=
NULL
)
{
pa_operation
*
pOP
=
NULL
;
if
(
type
==
mal_device_type_playback
)
{
pOP
=
pa_context_get_sink_info_by_name
((
pa_context
*
)
pDevice
->
pulse
.
pPulseContext
,
dev
,
mal_device_sink_name_callback
,
pDevice
);
}
else
{
pOP
=
pa_context_get_source_info_by_name
((
pa_context
*
)
pDevice
->
pulse
.
pPulseContext
,
dev
,
mal_device_source_name_callback
,
pDevice
);
}
if
(
pOP
!=
NULL
)
{
mal_device__wait_for_operation__pulse
(
pDevice
,
pOP
);
pa_operation_unref
(
pOP
);
}
}
// Set callbacks for reading and writing data to/from the PulseAudio stream.
// Set callbacks for reading and writing data to/from the PulseAudio stream.
...
@@ -7520,21 +7573,6 @@ static void mal_pulse_operation_complete_callback(pa_stream* pStream, int succes
...
@@ -7520,21 +7573,6 @@ static void mal_pulse_operation_complete_callback(pa_stream* pStream, int succes
*
pIsSuccessful
=
(
mal_bool32
)
success
;
*
pIsSuccessful
=
(
mal_bool32
)
success
;
}
}
static
mal_result
mal_device__wait_for_operation__pulse
(
mal_device
*
pDevice
,
pa_operation
*
pOP
)
{
mal_assert
(
pDevice
!=
NULL
);
mal_assert
(
pOP
!=
NULL
);
while
(
pa_operation_get_state
(
pOP
)
!=
PA_OPERATION_DONE
)
{
int
error
=
pa_mainloop_iterate
((
pa_mainloop
*
)
pDevice
->
pulse
.
pMainLoop
,
1
,
NULL
);
if
(
error
<
0
)
{
return
mal_result_from_pulse
(
error
);
}
}
return
MAL_SUCCESS
;
}
static
mal_result
mal_device__cork_stream__pulse
(
mal_device
*
pDevice
,
int
cork
)
static
mal_result
mal_device__cork_stream__pulse
(
mal_device
*
pDevice
,
int
cork
)
{
{
mal_bool32
wasSuccessful
=
MAL_FALSE
;
mal_bool32
wasSuccessful
=
MAL_FALSE
;
...
...
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